| 101 | |
| 102 | |
| 103 | void OGRWriter::prepared(PointTableRef table) |
| 104 | { |
| 105 | if (m_measureDimName.size()) |
| 106 | { |
| 107 | m_measureDim = table.layout()->findDim(m_measureDimName); |
| 108 | if (m_measureDim == Dimension::Id::Unknown) |
| 109 | throwError("Dimension '" + m_measureDimName + "' (measure_dim) not " |
| 110 | "found."); |
| 111 | } |
| 112 | |
| 113 | if (m_driverName.empty()) |
| 114 | { |
| 115 | if (FileUtils::extension(filename()) == ".geojson") |
| 116 | m_driverName = "GeoJSON"; |
| 117 | else |
| 118 | m_driverName = "ESRI Shapefile"; |
| 119 | } |
| 120 | |
| 121 | // Build the attr dims list, replacing special keywords with the proper |
| 122 | // field names. |
| 123 | for (auto& name : m_attrDimNames) |
| 124 | { |
| 125 | if (name == "all") |
| 126 | { |
| 127 | m_attrDimNames.clear(); |
| 128 | for (auto& dim : table.layout()->dims()) |
| 129 | { |
| 130 | switch(dim) |
| 131 | { |
| 132 | // we don't need geometry attributes repeated as fields |
| 133 | case Dimension::Id::X: |
| 134 | case Dimension::Id::Y: |
| 135 | case Dimension::Id::Z: |
| 136 | break; |
| 137 | |
| 138 | default: |
| 139 | if (dim != m_measureDim) { |
| 140 | m_attrDimNames.push_back(table.layout()->dimName(dim)); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | break; |
| 145 | } |
| 146 | else |
| 147 | { |
| 148 | auto dim = table.layout()->findDim(name); |
| 149 | if (dim == Dimension::Id::Unknown) |
| 150 | throwError("Dimension '" + name + "' (attr_dims) not found."); |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | |
| 156 | void OGRWriter::readyTable(PointTableRef table) |