| 1 | /********************************************************************** |
| 2 | * |
| 3 | * Name: mitab_imapinfo |
| 4 | * Project: MapInfo mid/mif Tab Read/Write library |
| 5 | * Language: C++ |
| 6 | * Purpose: Implementation of the IMapInfoFile class, super class of |
| 7 | * of MIFFile and TABFile |
| 8 | * Author: Daniel Morissette, [email protected] |
| 9 | * |
| 10 | ********************************************************************** |
| 11 | * Copyright (c) 1999-2008, Daniel Morissette |
| 12 | * Copyright (c) 2014, Even Rouault <even.rouault at spatialys.com> |
| 13 | * |
| 14 | * SPDX-License-Identifier: MIT |
| 15 | **********************************************************************/ |
| 16 | |
| 17 | #include "cpl_port.h"cxx . . $ `<file>/port/cpl_port.h`/ |
| 18 | #include "mitab.h"cxx . . $ `<file>/ogr/ogrsf_frmts/mitab/mitab.h`/ |
| 19 | |
| 20 | #include <cassert> |
| 21 | #include <cctype> |
| 22 | #include <cstring> |
| 23 | #include <algorithm> |
| 24 | |
| 25 | #include "cpl_conv.h"cxx . . $ `<file>/port/cpl_conv.h`/ |
| 26 | #include "cpl_error.h"cxx . . $ `<file>/port/cpl_error.h`/ |
| 27 | #include "cpl_vsi.h"cxx . . $ `<file>/port/cpl_vsi.h`/ |
| 28 | #include "mitab_priv.h"cxx . . $ `<file>/ogr/ogrsf_frmts/mitab/mitab_priv.h`/ |
| 29 | #include "mitab_utils.h"cxx . . $ `<file>/ogr/ogrsf_frmts/mitab/mitab_utils.h`/ |
| 30 | #include "ogr_core.h"cxx . . $ `<file>/ogr/ogr_core.h`/ |
| 31 | #include "ogr_feature.h"cxx . . $ `<file>/ogr/ogr_feature.h`/ |
| 32 | #include "ogr_geometry.h"cxx . . $ `<file>/ogr/ogr_geometry.h`/ |
| 33 | |
| 34 | #ifdef __HP_aCC |
| 35 | #include <wchar.h> /* iswspace() */ |
| 36 | #else |
| 37 | #include <wctype.h> /* iswspace() */ |
| 38 | #endif |
| 39 | |
| 40 | /********************************************************************** |
| 41 | * IMapInfoFile::IMapInfoFile() |
| 42 | * |
| 43 | * Constructor. |
| 44 | **********************************************************************/ |
| 45 | IMapInfoFilecxx . . $ IMapInfoFile#::IMapInfoFilecxx . . $ IMapInfoFile#IMapInfoFile(e01695728c6d811).(GDALDatasetcxx . . $ GDALDataset# *poDS) |
| 46 | : m_poDScxx . . $ IMapInfoFile#m_poDS.(poDS), m_nCurFeatureIdcxx . . $ IMapInfoFile#m_nCurFeatureId.(0), m_poCurFeaturecxx . . $ IMapInfoFile#m_poCurFeature.(nullptr), |
| 47 | m_bBoundsSetcxx . . $ IMapInfoFile#m_bBoundsSet.(FALSEcxx . . $ `port/cpl_port.h:1180:9`!), m_pszCharsetcxx . . $ IMapInfoFile#m_pszCharset.(nullptr) |
| 48 | { |
| 49 | } |
| 50 | |
| 51 | /********************************************************************** |
| 52 | * IMapInfoFile::~IMapInfoFile() |
| 53 | * |
| 54 | * Destructor. |
| 55 | **********************************************************************/ |
| 56 | IMapInfoFilecxx . . $ IMapInfoFile#::~cxx . . $ IMapInfoFile#`~IMapInfoFile`(ced63f7c635d850d).IMapInfoFilecxx . . $ IMapInfoFile#() |
| 57 | { |
| 58 | if (m_poCurFeaturecxx . . $ IMapInfoFile#m_poCurFeature.) |
| 59 | { |
| 60 | delete m_poCurFeaturecxx . . $ IMapInfoFile#m_poCurFeature.; |
| 61 | m_poCurFeaturecxx . . $ IMapInfoFile#m_poCurFeature. = nullptr; |
| 62 | } |
| 63 | |
| 64 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_pszCharsetcxx . . $ IMapInfoFile#m_pszCharset.); |
| 65 | m_pszCharsetcxx . . $ IMapInfoFile#m_pszCharset. = nullptr; |
| 66 | } |
| 67 | |
| 68 | /********************************************************************** |
| 69 | * IMapInfoFile::Open() |
| 70 | * |
| 71 | * Compatibility layer with new interface. |
| 72 | * Return 0 on success, -1 in case of failure. |
| 73 | **********************************************************************/ |
| 74 | |
| 75 | int IMapInfoFilecxx . . $ IMapInfoFile#::Opencxx . . $ IMapInfoFile#Open(bbc7bb074ff2fd85).(const char *pszFname, const char *pszAccess, |
| 76 | GBoolcxx . . $ GBool# bTestOpenNoError, const char *pszCharset) |
| 77 | { |
| 78 | // cppcheck-suppress nullPointer |
| 79 | if (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszAccess, "r")) |
| 80 | return Opencxx . . $ IMapInfoFile#Open(5d3da58accdfcf15).(pszFname, TABReadcxx . . $ TABRead., bTestOpenNoError, pszCharset); |
| 81 | else if (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszAccess, "w")) |
| 82 | return Opencxx . . $ IMapInfoFile#Open(5d3da58accdfcf15).(pszFname, TABWritecxx . . $ TABWrite., bTestOpenNoError, pszCharset); |
| 83 | else |
| 84 | { |
| 85 | CPLError(CE_Failure, CPLE_FileIOcxx . . $ `port/cpl_error.h:112:9`!, |
| 86 | "Open() failed: access mode \"%s\" not supported", pszAccess); |
| 87 | return -1; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /********************************************************************** |
| 92 | * IMapInfoFile::SmartOpen() |
| 93 | * |
| 94 | * Use this static method to automatically open any flavor of MapInfo |
| 95 | * dataset. This method will detect the file type, create an object |
| 96 | * of the right type, and open the file. |
| 97 | * |
| 98 | * Call GetFileClass() on the returned object if you need to find out |
| 99 | * its exact type. (To access format-specific methods for instance) |
| 100 | * |
| 101 | * Returns the new object ptr. , or NULL if the open failed. |
| 102 | **********************************************************************/ |
| 103 | IMapInfoFilecxx . . $ IMapInfoFile# *IMapInfoFilecxx . . $ IMapInfoFile#::SmartOpencxx . . $ IMapInfoFile#SmartOpen(f42f583494f0add4).(GDALDatasetcxx . . $ GDALDataset# *poDS, const char *pszFname, |
| 104 | GBoolcxx . . $ GBool# bUpdate, |
| 105 | GBoolcxx . . $ GBool# bTestOpenNoError /*=FALSE*/) |
| 106 | { |
| 107 | IMapInfoFilecxx . . $ IMapInfoFile# *poFile = nullptr; |
| 108 | int nLen = 0; |
| 109 | |
| 110 | if (pszFname) |
| 111 | nLen = static_cast<int>(strlen(pszFname)); |
| 112 | |
| 113 | if (nLen > 4 && (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszFname + nLen - 4, ".MIF") || |
| 114 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszFname + nLen - 4, ".MID"))) |
| 115 | { |
| 116 | /*------------------------------------------------------------- |
| 117 | * MIF/MID file |
| 118 | *------------------------------------------------------------*/ |
| 119 | poFile = new MIFFilecxx . . $ MIFFile#(poDS); |
| 120 | } |
| 121 | else if (nLen > 4 && EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszFname + nLen - 4, ".TAB")) |
| 122 | { |
| 123 | /*------------------------------------------------------------- |
| 124 | * .TAB file ... is it a TABFileView or a TABFile? |
| 125 | * We have to read the .tab header to find out. |
| 126 | *------------------------------------------------------------*/ |
| 127 | char *pszAdjFname = CPLStrdup(pszFname); |
| 128 | GBoolcxx . . $ GBool# bFoundFields = FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 129 | GBoolcxx . . $ GBool# bFoundView = FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 130 | GBoolcxx . . $ GBool# bFoundSeamless = FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 131 | |
| 132 | TABAdjustFilenameExtensioncxx . . $ TABAdjustFilenameExtension(1ef8e6ec083aabb9).(pszAdjFname); |
| 133 | VSILFILE *fp = VSIFOpenL(pszAdjFname, "r"); |
| 134 | const char *pszLine = nullptr; |
| 135 | while (fp && (pszLine = CPLReadLineL(fp)) != nullptr) |
| 136 | { |
| 137 | while (isspace(static_cast<unsigned char>(*pszLine))) |
| 138 | pszLine++; |
| 139 | if (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszLine, "Fields")) |
| 140 | bFoundFields = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 141 | else if (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszLine, "create view")) |
| 142 | bFoundView = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 143 | else if (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszLine, "\"\\IsSeamless\" = \"TRUE\"")) |
| 144 | bFoundSeamless = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 145 | } |
| 146 | |
| 147 | if (bFoundView) |
| 148 | poFile = new TABViewcxx . . $ TABView#(poDS); |
| 149 | else if (bFoundFields && bFoundSeamless) |
| 150 | poFile = new TABSeamlesscxx . . $ TABSeamless#(poDS); |
| 151 | else if (bFoundFields) |
| 152 | poFile = new TABFilecxx . . $ TABFile#TABFile(e01695728c6d811).(poDS); |
| 153 | |
| 154 | if (fp) |
| 155 | VSIFCloseL(fp); |
| 156 | |
| 157 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszAdjFname); |
| 158 | } |
| 159 | |
| 160 | /*----------------------------------------------------------------- |
| 161 | * Perform the open() call |
| 162 | *----------------------------------------------------------------*/ |
| 163 | if (poFile && poFile->Opencxx . . $ IMapInfoFile#Open(5d3da58accdfcf15).(pszFname, bUpdate ? TABReadWritecxx . . $ TABReadWrite. : TABReadcxx . . $ TABRead., |
| 164 | bTestOpenNoError) != 0) |
| 165 | { |
| 166 | delete poFile; |
| 167 | poFile = nullptr; |
| 168 | } |
| 169 | |
| 170 | if (!bTestOpenNoError && poFile == nullptr) |
| 171 | { |
| 172 | CPLError(CE_Failure, CPLE_FileIOcxx . . $ `port/cpl_error.h:112:9`!, |
| 173 | "%s could not be opened as a MapInfo dataset.", pszFname); |
| 174 | } |
| 175 | |
| 176 | return poFile; |
| 177 | } |
| 178 | |
| 179 | /********************************************************************** |
| 180 | * IMapInfoFile::GetNextFeature() |
| 181 | * |
| 182 | * Standard OGR GetNextFeature implementation. This method is used |
| 183 | * to retrieve the next OGRFeature. |
| 184 | **********************************************************************/ |
| 185 | OGRFeaturecxx . . $ OGRFeature# *IMapInfoFilecxx . . $ IMapInfoFile#::GetNextFeaturecxx . . $ IMapInfoFile#GetNextFeature(ec9eceddec1d9563).() |
| 186 | { |
| 187 | GIntBigcxx . . $ GIntBig# nFeatureId = 0; |
| 188 | |
| 189 | while ((nFeatureId = GetNextFeatureIdcxx . . $ IMapInfoFile#GetNextFeatureId(f5ca13db6eeb70f1).(m_nCurFeatureIdcxx . . $ IMapInfoFile#m_nCurFeatureId.)) != -1) |
| 190 | { |
| 191 | OGRGeometrycxx . . $ OGRGeometry# *poGeom = nullptr; |
| 192 | OGRFeaturecxx . . $ OGRFeature# *poFeatureRef = GetFeatureRefcxx . . $ IMapInfoFile#GetFeatureRef(6bb7592087f43672).(nFeatureId); |
| 193 | if (poFeatureRef == nullptr) |
| 194 | return nullptr; |
| 195 | else if ((m_poFilterGeomcxx . . $ OGRLayer#m_poFilterGeom. == nullptr || |
| 196 | ((poGeom = poFeatureRef->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).()) != nullptr && |
| 197 | FilterGeometrycxx . . $ OGRLayer#FilterGeometry(fed901b2566802ff).(poGeom))) && |
| 198 | (m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery. == nullptr || |
| 199 | m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery.->Evaluatecxx . . $ OGRFeatureQuery#Evaluate(2048609adab03aab).(poFeatureRef))) |
| 200 | { |
| 201 | // Avoid cloning feature... return the copy owned by the class |
| 202 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poFeatureRef == m_poCurFeature); |
| 203 | m_poCurFeaturecxx . . $ IMapInfoFile#m_poCurFeature. = nullptr; |
| 204 | if (poFeatureRef->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).() != nullptr) |
| 205 | poFeatureRef->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).()->assignSpatialReferencecxx . . $ OGRGeometry#assignSpatialReference(9ff39b79387a6086).( |
| 206 | GetSpatialRefcxx . . $ IMapInfoFile#GetSpatialRef(8a5496c2eeefaeaf).()); |
| 207 | return poFeatureRef; |
| 208 | } |
| 209 | } |
| 210 | return nullptr; |
| 211 | } |
| 212 | |
| 213 | /********************************************************************** |
| 214 | * IMapInfoFile::CreateTABFeature() |
| 215 | * |
| 216 | * Instantiate a TABFeature* from a OGRFeature* (or NULL on error) |
| 217 | **********************************************************************/ |
| 218 | |
| 219 | TABFeaturecxx . . $ TABFeature# *IMapInfoFilecxx . . $ IMapInfoFile#::CreateTABFeaturecxx . . $ IMapInfoFile#CreateTABFeature(6c26eacf86b0d4bc).(OGRFeaturecxx . . $ OGRFeature# *poFeature) |
| 220 | { |
| 221 | TABFeaturecxx . . $ TABFeature# *poTABFeature = nullptr; |
| 222 | OGRwkbGeometryType eGType; |
| 223 | TABPointcxx . . $ TABPoint# *poTABPointFeature = nullptr; |
| 224 | TABRegioncxx . . $ TABRegion# *poTABRegionFeature = nullptr; |
| 225 | TABPolylinecxx . . $ TABPolyline# *poTABPolylineFeature = nullptr; |
| 226 | |
| 227 | /*----------------------------------------------------------------- |
| 228 | * MITAB won't accept new features unless they are in a type derived |
| 229 | * from TABFeature... so we have to do our best to map to the right |
| 230 | * feature type based on the geometry type. |
| 231 | *----------------------------------------------------------------*/ |
| 232 | OGRGeometrycxx . . $ OGRGeometry# *poGeom = poFeature->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).(); |
| 233 | if (poGeom != nullptr) |
| 234 | eGType = poGeom->getGeometryTypecxx . . $ OGRGeometry#getGeometryType(5a40c54c5ff210ce).(); |
| 235 | else |
| 236 | eGType = wkbNone; |
| 237 | |
| 238 | switch (wkbFlattencxx . . $ `ogr/ogr_core.h:576:9`!(eGType)) |
| 239 | { |
| 240 | /*------------------------------------------------------------- |
| 241 | * POINT |
| 242 | *------------------------------------------------------------*/ |
| 243 | case wkbPoint: |
| 244 | { |
| 245 | const char *pszStyleString = poFeature->GetStyleStringcxx . . $ OGRFeature#GetStyleString(a9f41ea0e82d88cf).(); |
| 246 | if (pszStyleString) |
| 247 | { |
| 248 | if (strstr(pszStyleString, "LABEL(")) |
| 249 | { |
| 250 | auto poText = new TABTextcxx . . $ TABText#(poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()); |
| 251 | poText->SetLabelFromStyleStringcxx . . $ TABText#SetLabelFromStyleString(85c52e162fed56f9).(pszStyleString); |
| 252 | poTABFeature = poText; |
| 253 | |
| 254 | if (strstr(pszStyleString, "SYMBOL(")) |
| 255 | { |
| 256 | CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 257 | "OGR style string contains both " |
| 258 | "Label and Symbol parts. " |
| 259 | "Only Label taken into account due to " |
| 260 | "MapInfo TAB/MIF format limitations."); |
| 261 | } |
| 262 | } |
| 263 | else |
| 264 | { |
| 265 | TABFeatureClasscxx . . $ TABFeatureClass# featureClass = |
| 266 | ITABFeatureSymbolcxx . . $ ITABFeatureSymbol#::GetSymbolFeatureClasscxx . . $ ITABFeatureSymbol#GetSymbolFeatureClass(69dc7106111a5304).( |
| 267 | pszStyleString); |
| 268 | if (featureClass == TABFCFontPointcxx . . $ TABFCFontPoint.) |
| 269 | { |
| 270 | poTABFeature = |
| 271 | new TABFontPointcxx . . $ TABFontPoint#(poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()); |
| 272 | } |
| 273 | else if (featureClass == TABFCCustomPointcxx . . $ TABFCCustomPoint.) |
| 274 | { |
| 275 | poTABFeature = |
| 276 | new TABCustomPointcxx . . $ TABCustomPoint#(poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()); |
| 277 | } |
| 278 | else |
| 279 | { |
| 280 | poTABFeature = new TABPointcxx . . $ TABPoint#(poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()); |
| 281 | } |
| 282 | poTABPointFeature = |
| 283 | cpl::down_cast<TABPointcxx . . $ TABPoint# *>(poTABFeature); |
| 284 | poTABPointFeature->SetSymbolFromStyleStringcxx . . $ ITABFeatureSymbol#SetSymbolFromStyleString(85c52e162fed56f9).( |
| 285 | poFeature->GetStyleStringcxx . . $ OGRFeature#GetStyleString(a9f41ea0e82d88cf).()); |
| 286 | } |
| 287 | } |
| 288 | else |
| 289 | { |
| 290 | poTABFeature = new TABPointcxx . . $ TABPoint#(poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()); |
| 291 | } |
| 292 | break; |
| 293 | } |
| 294 | |
| 295 | /*------------------------------------------------------------- |
| 296 | * REGION |
| 297 | *------------------------------------------------------------*/ |
| 298 | case wkbPolygon: |
| 299 | case wkbMultiPolygon: |
| 300 | { |
| 301 | poTABFeature = new TABRegioncxx . . $ TABRegion#(poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()); |
| 302 | if (poFeature->GetStyleStringcxx . . $ OGRFeature#GetStyleString(a9f41ea0e82d88cf).()) |
| 303 | { |
| 304 | poTABRegionFeature = cpl::down_cast<TABRegioncxx . . $ TABRegion# *>(poTABFeature); |
| 305 | poTABRegionFeature->SetPenFromStyleStringcxx . . $ ITABFeaturePen#SetPenFromStyleString(85c52e162fed56f9).( |
| 306 | poFeature->GetStyleStringcxx . . $ OGRFeature#GetStyleString(a9f41ea0e82d88cf).()); |
| 307 | |
| 308 | poTABRegionFeature->SetBrushFromStyleStringcxx . . $ ITABFeatureBrush#SetBrushFromStyleString(85c52e162fed56f9).( |
| 309 | poFeature->GetStyleStringcxx . . $ OGRFeature#GetStyleString(a9f41ea0e82d88cf).()); |
| 310 | } |
| 311 | break; |
| 312 | } |
| 313 | /*------------------------------------------------------------- |
| 314 | * LINE/PLINE/MULTIPLINE |
| 315 | *------------------------------------------------------------*/ |
| 316 | case wkbLineString: |
| 317 | case wkbMultiLineString: |
| 318 | { |
| 319 | poTABFeature = new TABPolylinecxx . . $ TABPolyline#(poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()); |
| 320 | if (poFeature->GetStyleStringcxx . . $ OGRFeature#GetStyleString(a9f41ea0e82d88cf).()) |
| 321 | { |
| 322 | poTABPolylineFeature = |
| 323 | cpl::down_cast<TABPolylinecxx . . $ TABPolyline# *>(poTABFeature); |
| 324 | poTABPolylineFeature->SetPenFromStyleStringcxx . . $ ITABFeaturePen#SetPenFromStyleString(85c52e162fed56f9).( |
| 325 | poFeature->GetStyleStringcxx . . $ OGRFeature#GetStyleString(a9f41ea0e82d88cf).()); |
| 326 | } |
| 327 | break; |
| 328 | } |
| 329 | /*------------------------------------------------------------- |
| 330 | * Collection types that are not directly supported... convert |
| 331 | * to multiple features in output file through recursive calls. |
| 332 | *------------------------------------------------------------*/ |
| 333 | case wkbGeometryCollection: |
| 334 | case wkbMultiPoint: |
| 335 | { |
| 336 | OGRErr eStatus = OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 337 | assertcxx . . $ `<external>/4398592474888995393/assert.h:137:11`!(poGeom); // for clang static analyzer |
| 338 | OGRGeometryCollectioncxx . . $ OGRGeometryCollection# *poColl = poGeom->toGeometryCollectioncxx . . $ OGRGeometry#toGeometryCollection(2dc35bba37476a41).(); |
| 339 | auto poTmpFeature = std::unique_ptr<OGRFeaturecxx . . $ OGRFeature#>(poFeature->Clonecxx . . $ OGRFeature#Clone(bcd776315d3947b8).()); |
| 340 | |
| 341 | for (int i = 0; eStatus == OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`! && poColl != nullptr && |
| 342 | i < poColl->getNumGeometriescxx . . $ OGRGeometryCollection#getNumGeometries(455f465bc33b4cdf).(); |
| 343 | i++) |
| 344 | { |
| 345 | poTmpFeature->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(OGRNullFIDcxx . . $ `ogr/ogr_core.h:848:9`!); |
| 346 | poTmpFeature->SetGeometrycxx . . $ OGRFeature#SetGeometry(fed901b2566802ff).(poColl->getGeometryRefcxx . . $ OGRGeometryCollection#getGeometryRef(ea443ccec24c6360).(i)); |
| 347 | eStatus = ICreateFeaturecxx . . $ IMapInfoFile#ICreateFeature(2048609adab03aab).(poTmpFeature.get()); |
| 348 | } |
| 349 | break; |
| 350 | } |
| 351 | |
| 352 | /*------------------------------------------------------------- |
| 353 | * Unsupported type.... convert to MapInfo geometry NONE |
| 354 | *------------------------------------------------------------*/ |
| 355 | default: |
| 356 | { |
| 357 | poTABFeature = new TABFeaturecxx . . $ TABFeature#TABFeature(dc2636911e7adfe).(poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()); |
| 358 | break; |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | if (poTABFeature) |
| 363 | { |
| 364 | if (poGeom != nullptr) |
| 365 | poTABFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poGeom->clonecxx . . $ OGRGeometry#clone(bac917acb50a3c43).()); |
| 366 | |
| 367 | for (int i = 0; i < poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).(); i++) |
| 368 | { |
| 369 | poTABFeature->SetFieldcxx . . $ OGRFeature#SetField(7180b68df1666ab2).(i, poFeature->GetRawFieldRefcxx . . $ OGRFeature#GetRawFieldRef(4f12117e0ec8b5e4).(i)); |
| 370 | } |
| 371 | |
| 372 | poTABFeature->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(poFeature->GetFIDcxx . . $ OGRFeature#GetFID(98833e9ab7de59a4).()); |
| 373 | } |
| 374 | |
| 375 | return poTABFeature; |
| 376 | } |
| 377 | |
| 378 | /********************************************************************** |
| 379 | * IMapInfoFile::ICreateFeature() |
| 380 | * |
| 381 | * Standard OGR CreateFeature implementation. This method is used |
| 382 | * to create a new feature in current dataset |
| 383 | **********************************************************************/ |
| 384 | OGRErr IMapInfoFilecxx . . $ IMapInfoFile#::ICreateFeaturecxx . . $ IMapInfoFile#ICreateFeature(2048609adab03aab).(OGRFeaturecxx . . $ OGRFeature# *poFeature) |
| 385 | { |
| 386 | TABFeaturecxx . . $ TABFeature# *poTABFeature = CreateTABFeaturecxx . . $ IMapInfoFile#CreateTABFeature(6c26eacf86b0d4bc).(poFeature); |
| 387 | if (poTABFeature == nullptr) /* MultiGeometry */ |
| 388 | return OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 389 | |
| 390 | OGRErr eErr = CreateFeaturecxx . . $ IMapInfoFile#CreateFeature(a15eb74980f60b5d).(poTABFeature); |
| 391 | if (eErr == OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!) |
| 392 | poFeature->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(poTABFeature->GetFIDcxx . . $ OGRFeature#GetFID(98833e9ab7de59a4).()); |
| 393 | |
| 394 | delete poTABFeature; |
| 395 | |
| 396 | return eErr; |
| 397 | } |
| 398 | |
| 399 | /********************************************************************** |
| 400 | * IMapInfoFile::GetFeature() |
| 401 | * |
| 402 | * Standard OGR GetFeature implementation. This method is used |
| 403 | * to get the wanted (nFeatureId) feature, a NULL value will be |
| 404 | * returned on error. |
| 405 | **********************************************************************/ |
| 406 | OGRFeaturecxx . . $ OGRFeature# *IMapInfoFilecxx . . $ IMapInfoFile#::GetFeaturecxx . . $ IMapInfoFile#GetFeature(86ac52c37891ada7).(GIntBigcxx . . $ GIntBig# nFeatureId) |
| 407 | { |
| 408 | /*fprintf(stderr, "GetFeature(%ld)\n", nFeatureId);*/ |
| 409 | |
| 410 | OGRFeaturecxx . . $ OGRFeature# *poFeatureRef = GetFeatureRefcxx . . $ IMapInfoFile#GetFeatureRef(6bb7592087f43672).(nFeatureId); |
| 411 | if (poFeatureRef) |
| 412 | { |
| 413 | // Avoid cloning feature... return the copy owned by the class |
| 414 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poFeatureRef == m_poCurFeature); |
| 415 | m_poCurFeaturecxx . . $ IMapInfoFile#m_poCurFeature. = nullptr; |
| 416 | |
| 417 | return poFeatureRef; |
| 418 | } |
| 419 | else |
| 420 | return nullptr; |
| 421 | } |
| 422 | |
| 423 | /************************************************************************/ |
| 424 | /* GetTABType() */ |
| 425 | /* */ |
| 426 | /* Create a native field based on a generic OGR definition. */ |
| 427 | /************************************************************************/ |
| 428 | |
| 429 | int IMapInfoFilecxx . . $ IMapInfoFile#::GetTABTypecxx . . $ IMapInfoFile#GetTABType(109b42fe25c47970).(const OGRFieldDefncxx . . $ OGRFieldDefn# *poField, |
| 430 | TABFieldTypecxx . . $ TABFieldType# *peTABType, int *pnWidth, |
| 431 | int *pnPrecision) |
| 432 | { |
| 433 | TABFieldTypecxx . . $ TABFieldType# eTABType; |
| 434 | int nWidth = poField->GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).(); |
| 435 | int nPrecision = |
| 436 | poField->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTReal ? poField->GetPrecisioncxx . . $ OGRFieldDefn#GetPrecision(455f465bc33b4cdf).() : 0; |
| 437 | |
| 438 | if (poField->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTInteger) |
| 439 | { |
| 440 | if (poField->GetSubTypecxx . . $ OGRFieldDefn#GetSubType(4db5e065ad90bc77).() == OFSTBoolean) |
| 441 | { |
| 442 | eTABType = TABFLogicalcxx . . $ TABFLogical.; |
| 443 | nWidth = 1; |
| 444 | } |
| 445 | else |
| 446 | { |
| 447 | eTABType = TABFIntegercxx . . $ TABFInteger.; |
| 448 | if (nWidth == 0) |
| 449 | nWidth = 12; |
| 450 | } |
| 451 | } |
| 452 | else if (poField->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTInteger64) |
| 453 | { |
| 454 | eTABType = TABFLargeIntcxx . . $ TABFLargeInt.; |
| 455 | if (nWidth == 0) |
| 456 | nWidth = 20; |
| 457 | } |
| 458 | else if (poField->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTReal) |
| 459 | { |
| 460 | if (nWidth == 0 && poField->GetPrecisioncxx . . $ OGRFieldDefn#GetPrecision(455f465bc33b4cdf).() == 0) |
| 461 | { |
| 462 | eTABType = TABFFloatcxx . . $ TABFFloat.; |
| 463 | nWidth = 32; |
| 464 | } |
| 465 | else |
| 466 | { |
| 467 | eTABType = TABFDecimalcxx . . $ TABFDecimal.; |
| 468 | // Enforce Mapinfo limits, otherwise MapInfo will crash (#6392) |
| 469 | if (nWidth > 20 || nWidth - nPrecision < 2 || nPrecision > 16) |
| 470 | { |
| 471 | if (nWidth > 20) |
| 472 | nWidth = 20; |
| 473 | if (nWidth - nPrecision < 2) |
| 474 | nPrecision = nWidth - 2; |
| 475 | if (nPrecision > 16) |
| 476 | nPrecision = 16; |
| 477 | CPLDebug("MITAB", |
| 478 | "Adjusting initial width,precision of %s from %d,%d " |
| 479 | "to %d,%d", |
| 480 | poField->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), poField->GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).(), |
| 481 | poField->GetPrecisioncxx . . $ OGRFieldDefn#GetPrecision(455f465bc33b4cdf).(), nWidth, nPrecision); |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | else if (poField->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTDate) |
| 486 | { |
| 487 | eTABType = TABFDatecxx . . $ TABFDate.; |
| 488 | if (nWidth == 0) |
| 489 | nWidth = 10; |
| 490 | } |
| 491 | else if (poField->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTTime) |
| 492 | { |
| 493 | eTABType = TABFTimecxx . . $ TABFTime.; |
| 494 | if (nWidth == 0) |
| 495 | nWidth = 9; |
| 496 | } |
| 497 | else if (poField->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTDateTime) |
| 498 | { |
| 499 | eTABType = TABFDateTimecxx . . $ TABFDateTime.; |
| 500 | if (nWidth == 0) |
| 501 | nWidth = 19; |
| 502 | } |
| 503 | else if (poField->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTString) |
| 504 | { |
| 505 | eTABType = TABFCharcxx . . $ TABFChar.; |
| 506 | if (nWidth == 0) |
| 507 | nWidth = 254; |
| 508 | else |
| 509 | nWidth = std::mincxx . . $ std/min(2a338fce5842aa6a).(254, nWidth); |
| 510 | } |
| 511 | else |
| 512 | { |
| 513 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 514 | "IMapInfoFile::CreateField() called with unsupported field" |
| 515 | " type %d.\n" |
| 516 | "Note that Mapinfo files don't support list field types.\n", |
| 517 | poField->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).()); |
| 518 | |
| 519 | return -1; |
| 520 | } |
| 521 | |
| 522 | if (peTABType) |
| 523 | *peTABType = eTABType; |
| 524 | if (pnWidth) |
| 525 | *pnWidth = nWidth; |
| 526 | if (pnPrecision) |
| 527 | *pnPrecision = nPrecision; |
| 528 | |
| 529 | return 0; |
| 530 | } |
| 531 | |
| 532 | /************************************************************************/ |
| 533 | /* CreateField() */ |
| 534 | /* */ |
| 535 | /* Create a native field based on a generic OGR definition. */ |
| 536 | /************************************************************************/ |
| 537 | |
| 538 | OGRErr IMapInfoFilecxx . . $ IMapInfoFile#::CreateFieldcxx . . $ IMapInfoFile#CreateField(2cf5282e6e90de1e).(const OGRFieldDefncxx . . $ OGRFieldDefn# *poField, int bApproxOK) |
| 539 | |
| 540 | { |
| 541 | TABFieldTypecxx . . $ TABFieldType# eTABType; |
| 542 | int nWidth = 0; |
| 543 | int nPrecision = 0; |
| 544 | |
| 545 | if (GetTABTypecxx . . $ IMapInfoFile#GetTABType(109b42fe25c47970).(poField, &eTABType, &nWidth, &nPrecision) < 0) |
| 546 | return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 547 | |
| 548 | if (AddFieldNativecxx . . $ IMapInfoFile#AddFieldNative(8959b4d343699afa).(poField->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), eTABType, nWidth, nPrecision, |
| 549 | FALSEcxx . . $ `port/cpl_port.h:1180:9`!, FALSEcxx . . $ `port/cpl_port.h:1180:9`!, bApproxOK) > -1) |
| 550 | return OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 551 | |
| 552 | return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 553 | } |
| 554 | |
| 555 | /********************************************************************** |
| 556 | * IMapInfoFile::SetCharset() |
| 557 | * |
| 558 | * Set the charset for the tab header. |
| 559 | * |
| 560 | * |
| 561 | * Returns 0 on success, -1 on error. |
| 562 | **********************************************************************/ |
| 563 | int IMapInfoFilecxx . . $ IMapInfoFile#::SetCharsetcxx . . $ IMapInfoFile#SetCharset(5c4306d8553b3696).(const char *pszCharset) |
| 564 | { |
| 565 | if (pszCharset && strlen(pszCharset) > 0) |
| 566 | { |
| 567 | if (pszCharset == m_pszCharsetcxx . . $ IMapInfoFile#m_pszCharset.) |
| 568 | { |
| 569 | return 0; |
| 570 | } |
| 571 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_pszCharsetcxx . . $ IMapInfoFile#m_pszCharset.); |
| 572 | m_pszCharsetcxx . . $ IMapInfoFile#m_pszCharset. = CPLStrdup(pszCharset); |
| 573 | return 0; |
| 574 | } |
| 575 | return -1; |
| 576 | } |
| 577 | |
| 578 | const char *IMapInfoFilecxx . . $ IMapInfoFile#::GetCharsetcxx . . $ IMapInfoFile#GetCharset(a9f41ea0e82d88cf).() const |
| 579 | { |
| 580 | return m_pszCharsetcxx . . $ IMapInfoFile#m_pszCharset.; |
| 581 | } |
| 582 | |
| 583 | // Table is adopted from |
| 584 | // http://www.i-signum.com/Formation/download/MB_ReferenceGuide.pdf pp. 127-128 |
| 585 | // NOTE: if modifying this table, please keep doc/source/drivers/vector/mapinfo_encodings.csv in sync |
| 586 | static const char *const apszCharsetscxx . . $ apszCharsets.[][2] = { |
| 587 | {"Neutral", ""}, // No character conversions performed. |
| 588 | {"ISO8859_1", "ISO-8859-1"}, // ISO 8859-1 (UNIX) |
| 589 | {"ISO8859_2", "ISO-8859-2"}, // ISO 8859-2 (UNIX) |
| 590 | {"ISO8859_3", "ISO-8859-3"}, // ISO 8859-3 (UNIX) |
| 591 | {"ISO8859_4", "ISO-8859-4"}, // ISO 8859-4 (UNIX) |
| 592 | {"ISO8859_5", "ISO-8859-5"}, // ISO 8859-5 (UNIX) |
| 593 | {"ISO8859_6", "ISO-8859-6"}, // ISO 8859-6 (UNIX) |
| 594 | {"ISO8859_7", "ISO-8859-7"}, // ISO 8859-7 (UNIX) |
| 595 | {"ISO8859_8", "ISO-8859-8"}, // ISO 8859-8 (UNIX) |
| 596 | {"ISO8859_9", "ISO-8859-9"}, // ISO 8859-9 (UNIX) |
| 597 | {"PackedEUCJapaese", "EUC-JP"}, // UNIX, standard Japanese implementation. |
| 598 | {"WindowsLatin1", "CP1252"}, |
| 599 | {"WindowsLatin2", "CP1250"}, |
| 600 | {"WindowsArabic", "CP1256"}, |
| 601 | {"WindowsCyrillic", "CP1251"}, |
| 602 | {"WindowsBalticRim", "CP1257"}, |
| 603 | {"WindowsGreek", "CP1253"}, |
| 604 | {"WindowsHebrew", "CP1255"}, |
| 605 | {"WindowsTurkish", "CP1254"}, // Windows Eastern Europe |
| 606 | {"WindowsTradChinese", "CP950"}, // Windows Traditional Chinese |
| 607 | {"WindowsSimpChinese", "CP936"}, // Windows Simplified Chinese |
| 608 | {"WindowsJapanese", "CP932"}, |
| 609 | {"WindowsKorean", "CP949"}, |
| 610 | {"CodePage437", "CP437"}, // DOS Code Page 437 = IBM Extended ASCII |
| 611 | {"CodePage850", "CP850"}, // DOS Code Page 850 = Multilingual |
| 612 | {"CodePage852", "CP852"}, // DOS Code Page 852 = Eastern Europe |
| 613 | {"CodePage855", "CP855"}, // DOS Code Page 855 = Cyrillic |
| 614 | {"CodePage857", "CP857"}, |
| 615 | {"CodePage860", "CP860"}, // DOS Code Page 860 = Portuguese |
| 616 | {"CodePage861", "CP861"}, // DOS Code Page 861 = Icelandic |
| 617 | {"CodePage863", "CP863"}, // DOS Code Page 863 = French Canadian |
| 618 | {"CodePage864", "CP864"}, // DOS Code Page 864 = Arabic |
| 619 | {"CodePage865", "CP865"}, // DOS Code Page 865 = Nordic |
| 620 | {"CodePage869", "CP869"}, // DOS Code Page 869 = Modern Greek |
| 621 | {"LICS", ""}, // Lotus worksheet release 1,2 character set |
| 622 | {"LMBCS", ""}, // Lotus worksheet release 3,4 character set |
| 623 | {"UTF-8", "UTF-8"}, |
| 624 | {nullptr, nullptr}}; |
| 625 | |
| 626 | const char *IMapInfoFilecxx . . $ IMapInfoFile#::CharsetToEncodingcxx . . $ IMapInfoFile#CharsetToEncoding(fb58d2e09a2a1ce6).(const char *pszCharset) |
| 627 | { |
| 628 | if (pszCharset == nullptr) |
| 629 | { |
| 630 | return apszCharsetscxx . . $ apszCharsets.[0][1]; |
| 631 | } |
| 632 | |
| 633 | for (size_t i = 0; apszCharsetscxx . . $ apszCharsets.[i][0] != nullptr; ++i) |
| 634 | { |
| 635 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCharset, apszCharsets[i][0])) |
| 636 | { |
| 637 | return apszCharsetscxx . . $ apszCharsets.[i][1]; |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | CPLError(CE_Warning, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!, |
| 642 | "Cannot find iconv encoding corresponding to MapInfo %s charset", |
| 643 | pszCharset); |
| 644 | return apszCharsetscxx . . $ apszCharsets.[0][1]; |
| 645 | } |
| 646 | |
| 647 | const char *IMapInfoFilecxx . . $ IMapInfoFile#::EncodingToCharsetcxx . . $ IMapInfoFile#EncodingToCharset(fb58d2e09a2a1ce6).(const char *pszEncoding) |
| 648 | { |
| 649 | if (pszEncoding == nullptr) |
| 650 | { |
| 651 | return apszCharsetscxx . . $ apszCharsets.[0][0]; |
| 652 | } |
| 653 | |
| 654 | for (size_t i = 0; apszCharsetscxx . . $ apszCharsets.[i][1] != nullptr; ++i) |
| 655 | { |
| 656 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszEncoding, apszCharsets[i][1])) |
| 657 | { |
| 658 | return apszCharsetscxx . . $ apszCharsets.[i][0]; |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | CPLError(CE_Warning, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!, |
| 663 | "Cannot find MapInfo charset corresponding to iconv %s encoding", |
| 664 | pszEncoding); |
| 665 | return apszCharsetscxx . . $ apszCharsets.[0][0]; |
| 666 | } |
| 667 | |
| 668 | const char *IMapInfoFilecxx . . $ IMapInfoFile#::GetEncodingcxx . . $ IMapInfoFile#GetEncoding(a9f41ea0e82d88cf).() const |
| 669 | { |
| 670 | return CharsetToEncodingcxx . . $ IMapInfoFile#CharsetToEncoding(fb58d2e09a2a1ce6).(GetCharsetcxx . . $ IMapInfoFile#GetCharset(a9f41ea0e82d88cf).()); |
| 671 | } |
| 672 | |
| 673 | void IMapInfoFilecxx . . $ IMapInfoFile#::SetEncodingcxx . . $ IMapInfoFile#SetEncoding(85c52e162fed56f9).(const char *pszEncoding) |
| 674 | { |
| 675 | SetCharsetcxx . . $ IMapInfoFile#SetCharset(5c4306d8553b3696).(EncodingToCharsetcxx . . $ IMapInfoFile#EncodingToCharset(fb58d2e09a2a1ce6).(pszEncoding)); |
| 676 | } |
| 677 | |
| 678 | void IMapInfoFilecxx . . $ IMapInfoFile#::SetStrictLaunderingcxx . . $ IMapInfoFile#SetStrictLaundering(b45ddcbc8423892c).(bool bStrictLaundering) |
| 679 | { |
| 680 | m_bStrictLaunderingcxx . . $ IMapInfoFile#m_bStrictLaundering. = bStrictLaundering; |
| 681 | } |
| 682 | |
| 683 | int IMapInfoFilecxx . . $ IMapInfoFile#::TestUtf8Capabilitycxx . . $ IMapInfoFile#TestUtf8Capability(455f465bc33b4cdf).() const |
| 684 | { |
| 685 | const char *pszEncoding(GetEncodingcxx . . $ IMapInfoFile#GetEncoding(a9f41ea0e82d88cf).()); |
| 686 | if (strlen(pszEncoding) == 0) |
| 687 | { |
| 688 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 689 | } |
| 690 | |
| 691 | return CPLCanRecode("test", GetEncodingcxx . . $ IMapInfoFile#GetEncoding(a9f41ea0e82d88cf).(), CPL_ENC_UTF8cxx . . $ `port/cpl_string.h:251:9`!); |
| 692 | } |
| 693 | |
| 694 | CPLString IMapInfoFilecxx . . $ IMapInfoFile#::NormalizeFieldNamecxx . . $ IMapInfoFile#NormalizeFieldName(ad496a74a8bf8e68).(const char *pszName) const |
| 695 | { |
| 696 | CPLString osName(pszName); |
| 697 | if (strlen(GetEncodingcxx . . $ IMapInfoFile#GetEncoding(a9f41ea0e82d88cf).()) > 0) |
| 698 | osName.Recode(CPL_ENC_UTF8cxx . . $ `port/cpl_string.h:251:9`!, GetEncodingcxx . . $ IMapInfoFile#GetEncoding(a9f41ea0e82d88cf).()); |
| 699 | |
| 700 | char szNewFieldName[31 + 1]; /* 31 is the max characters for a field name*/ |
| 701 | unsigned int nRenameNum = 1; |
| 702 | |
| 703 | strncpy(szNewFieldName, osName.c_str(), sizeof(szNewFieldName) - 1); |
| 704 | szNewFieldName[sizeof(szNewFieldName) - 1] = '\0'; |
| 705 | |
| 706 | while (m_oSetFieldscxx . . $ IMapInfoFile#m_oSetFields..findcxx . . $ std/set#find(5d7b472851d10a0f).(CPLString(szNewFieldName).toupper()) !=cxx . . $ std/`operator!=`(a84eb84a7a5e8237). |
| 707 | m_oSetFieldscxx . . $ IMapInfoFile#m_oSetFields..endcxx . . $ std/set#end(3220b82c0db6d2a1).() && |
| 708 | nRenameNum < 10) |
| 709 | { |
| 710 | CPLsnprintf(szNewFieldName, sizeof(szNewFieldName), "%.29s_%.1u", |
| 711 | osName.c_str(), nRenameNum); |
| 712 | nRenameNum++; |
| 713 | } |
| 714 | |
| 715 | while (m_oSetFieldscxx . . $ IMapInfoFile#m_oSetFields..findcxx . . $ std/set#find(5d7b472851d10a0f).(CPLString(szNewFieldName).toupper()) !=cxx . . $ std/`operator!=`(a84eb84a7a5e8237). |
| 716 | m_oSetFieldscxx . . $ IMapInfoFile#m_oSetFields..endcxx . . $ std/set#end(3220b82c0db6d2a1).() && |
| 717 | nRenameNum < 100) |
| 718 | { |
| 719 | CPLsnprintf(szNewFieldName, sizeof(szNewFieldName), "%.29s%.2u", |
| 720 | osName.c_str(), nRenameNum); |
| 721 | nRenameNum++; |
| 722 | } |
| 723 | |
| 724 | if (m_oSetFieldscxx . . $ IMapInfoFile#m_oSetFields..findcxx . . $ std/set#find(5d7b472851d10a0f).(CPLString(szNewFieldName).toupper()) !=cxx . . $ std/`operator!=`(a84eb84a7a5e8237). |
| 725 | m_oSetFieldscxx . . $ IMapInfoFile#m_oSetFields..endcxx . . $ std/set#end(3220b82c0db6d2a1).()) |
| 726 | { |
| 727 | CPLError(CE_Failure, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!, |
| 728 | "Too many field names like '%s' when truncated to 31 letters " |
| 729 | "for MapInfo format.", |
| 730 | pszName); |
| 731 | } |
| 732 | |
| 733 | CPLString osNewFieldName(szNewFieldName); |
| 734 | if (strlen(GetEncodingcxx . . $ IMapInfoFile#GetEncoding(a9f41ea0e82d88cf).()) > 0) |
| 735 | osNewFieldName.Recode(GetEncodingcxx . . $ IMapInfoFile#GetEncoding(a9f41ea0e82d88cf).(), CPL_ENC_UTF8cxx . . $ `port/cpl_string.h:251:9`!); |
| 736 | |
| 737 | if (!EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszName, osNewFieldName.c_str())) |
| 738 | { |
| 739 | CPLError(CE_Warning, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!, |
| 740 | "Normalized/laundered field name: '%s' to '%s'", pszName, |
| 741 | osNewFieldName.c_str()); |
| 742 | } |
| 743 | |
| 744 | return osNewFieldName; |
| 745 | } |