| 154 | |
| 155 | |
| 156 | void OGRWriter::readyTable(PointTableRef table) |
| 157 | { |
| 158 | m_driver = GetGDALDriverManager()->GetDriverByName(m_driverName.data()); |
| 159 | m_geomType = (m_multiCount == 1) ? wkbPointZM : wkbMultiPointZM; |
| 160 | |
| 161 | const auto& layout = table.layout(); |
| 162 | for(auto& name : m_attrDimNames) |
| 163 | { |
| 164 | auto dim = layout->findDim(name); |
| 165 | auto dimType = layout->dimType(dim); |
| 166 | OGRFieldType ogrType; |
| 167 | |
| 168 | switch(dimType) |
| 169 | { |
| 170 | case Dimension::Type::Signed8: |
| 171 | case Dimension::Type::Unsigned8: |
| 172 | case Dimension::Type::Signed16: |
| 173 | case Dimension::Type::Unsigned16: |
| 174 | case Dimension::Type::Signed32: |
| 175 | ogrType = OFTInteger; |
| 176 | break; |
| 177 | case Dimension::Type::Unsigned32: |
| 178 | case Dimension::Type::Signed64: |
| 179 | case Dimension::Type::Unsigned64: // error here? |
| 180 | ogrType = OFTInteger64; |
| 181 | break; |
| 182 | case Dimension::Type::Float: |
| 183 | case Dimension::Type::Double: |
| 184 | ogrType = OFTReal; |
| 185 | break; |
| 186 | case Dimension::Type::None: |
| 187 | default: |
| 188 | throwError("Unknown type for dimension '" + name + "' (attr_dims)."); |
| 189 | continue; |
| 190 | } |
| 191 | |
| 192 | // This is strange code. The attributes stored in m_attrs are a tuple and the |
| 193 | // third element is an OGRFieldDefn, NOT an OGRFieldDefn*. However, there is a |
| 194 | // constructor for an OGRFieldDefn that takes OGRFieldDefn* and that's |
| 195 | // what's invoked in emplace_back() below. |
| 196 | // Despite the existince of this copying via a pointer, older versions of GDAL |
| 197 | // disallowed the normal copy constructor for OGRFieldDefn. This changed with |
| 198 | // GDAL version 3.10.2, where regular copy ctors were enabled. So if PDAL |
| 199 | // requries GDAL of at least that version, this dynamic allocation can |
| 200 | // be replaced with a stack-based construction. |
| 201 | std::unique_ptr<OGRFieldDefn> fieldDef(new OGRFieldDefn(name.c_str(), ogrType)); |
| 202 | m_attrs.emplace_back(dim, dimType, fieldDef.get()); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | void OGRWriter::readyFile(const std::string& filename, const SpatialReference& srs) |
| 207 | { |