| 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Project: GML Reader |
| 4 | * Purpose: Implementation of GMLParseXSD() |
| 5 | * Author: Frank Warmerdam, [email protected] |
| 6 | * |
| 7 | ****************************************************************************** |
| 8 | * Copyright (c) 2005, Frank Warmerdam |
| 9 | * Copyright (c) 2010-2014, Even Rouault <even dot rouault at spatialys.com> |
| 10 | * |
| 11 | * SPDX-License-Identifier: MIT |
| 12 | ****************************************************************************/ |
| 13 | |
| 14 | #include "cpl_port.h"cxx . . $ `<file>/port/cpl_port.h`/ |
| 15 | #include "parsexsd.h"cxx . . $ `<file>/ogr/ogrsf_frmts/gmlutils/parsexsd.h`/ |
| 16 | |
| 17 | #include <cmath> |
| 18 | #include <cstdlib> |
| 19 | #include <cstring> |
| 20 | #include <set> |
| 21 | #include <string> |
| 22 | #include <utility> |
| 23 | |
| 24 | #include "cpl_conv.h"cxx . . $ `<file>/port/cpl_conv.h`/ |
| 25 | #include "cpl_error.h"cxx . . $ `<file>/port/cpl_error.h`/ |
| 26 | #include "cpl_http.h"cxx . . $ `<file>/port/cpl_http.h`/ |
| 27 | #include "cpl_minixml.h"cxx . . $ `<file>/port/cpl_minixml.h`/ |
| 28 | #include "cpl_string.h"cxx . . $ `<file>/port/cpl_string.h`/ |
| 29 | #include "ogr_core.h"cxx . . $ `<file>/ogr/ogr_core.h`/ |
| 30 | |
| 31 | /************************************************************************/ |
| 32 | /* StripNS() */ |
| 33 | /* */ |
| 34 | /* Return potentially shortened form of string with namespace */ |
| 35 | /* stripped off if there is one. Returns pointer into */ |
| 36 | /* original string. */ |
| 37 | /************************************************************************/ |
| 38 | static const char *StripNScxx . . $ StripNS(fb58d2e09a2a1ce6).(const char *pszFullValue) |
| 39 | |
| 40 | { |
| 41 | const char *pszColon = strstr(pszFullValue, ":"); |
| 42 | if (pszColon == nullptr) |
| 43 | return pszFullValue; |
| 44 | else |
| 45 | return pszColon + 1; |
| 46 | } |
| 47 | |
| 48 | /************************************************************************/ |
| 49 | /* GetSimpleTypeProperties() */ |
| 50 | /************************************************************************/ |
| 51 | |
| 52 | static bool GetSimpleTypePropertiescxx . . $ GetSimpleTypeProperties(1154cd4f761f8782).(CPLXMLNode *psTypeNode, |
| 53 | GMLPropertyTypecxx . . $ GMLPropertyType# *pGMLType, int *pnWidth, |
| 54 | int *pnPrecision) |
| 55 | { |
| 56 | const char *pszBase = |
| 57 | StripNScxx . . $ StripNS(fb58d2e09a2a1ce6).(CPLGetXMLValue(psTypeNode, "restriction.base", "")); |
| 58 | |
| 59 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "decimal")) |
| 60 | { |
| 61 | *pGMLType = GMLPT_Realcxx . . $ GMLPT_Real.; |
| 62 | const char *pszWidth = |
| 63 | CPLGetXMLValue(psTypeNode, "restriction.totalDigits.value", "0"); |
| 64 | const char *pszPrecision = |
| 65 | CPLGetXMLValue(psTypeNode, "restriction.fractionDigits.value", "0"); |
| 66 | *pnWidth = atoicxx . . $ atoi(f5ecf3191ed0cd93).(pszWidth); |
| 67 | *pnPrecision = atoicxx . . $ atoi(f5ecf3191ed0cd93).(pszPrecision); |
| 68 | return true; |
| 69 | } |
| 70 | |
| 71 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "float")) |
| 72 | { |
| 73 | *pGMLType = GMLPT_Floatcxx . . $ GMLPT_Float.; |
| 74 | return true; |
| 75 | } |
| 76 | |
| 77 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "double")) |
| 78 | { |
| 79 | *pGMLType = GMLPT_Realcxx . . $ GMLPT_Real.; |
| 80 | return true; |
| 81 | } |
| 82 | |
| 83 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "integer")) |
| 84 | { |
| 85 | *pGMLType = GMLPT_Integercxx . . $ GMLPT_Integer.; |
| 86 | const char *pszWidth = |
| 87 | CPLGetXMLValue(psTypeNode, "restriction.totalDigits.value", "0"); |
| 88 | *pnWidth = atoicxx . . $ atoi(f5ecf3191ed0cd93).(pszWidth); |
| 89 | return true; |
| 90 | } |
| 91 | |
| 92 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "long")) |
| 93 | { |
| 94 | *pGMLType = GMLPT_Integer64cxx . . $ GMLPT_Integer64.; |
| 95 | const char *pszWidth = |
| 96 | CPLGetXMLValue(psTypeNode, "restriction.totalDigits.value", "0"); |
| 97 | *pnWidth = atoicxx . . $ atoi(f5ecf3191ed0cd93).(pszWidth); |
| 98 | return true; |
| 99 | } |
| 100 | |
| 101 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "unsignedLong")) |
| 102 | { |
| 103 | // Optimistically map to signed integer... |
| 104 | *pGMLType = GMLPT_Integer64cxx . . $ GMLPT_Integer64.; |
| 105 | const char *pszWidth = |
| 106 | CPLGetXMLValue(psTypeNode, "restriction.totalDigits.value", "0"); |
| 107 | *pnWidth = atoicxx . . $ atoi(f5ecf3191ed0cd93).(pszWidth); |
| 108 | return true; |
| 109 | } |
| 110 | |
| 111 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "string")) |
| 112 | { |
| 113 | *pGMLType = GMLPT_Stringcxx . . $ GMLPT_String.; |
| 114 | const char *pszWidth = |
| 115 | CPLGetXMLValue(psTypeNode, "restriction.maxLength.value", "0"); |
| 116 | *pnWidth = atoicxx . . $ atoi(f5ecf3191ed0cd93).(pszWidth); |
| 117 | return true; |
| 118 | } |
| 119 | |
| 120 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "date")) |
| 121 | { |
| 122 | *pGMLType = GMLPT_Datecxx . . $ GMLPT_Date.; |
| 123 | return true; |
| 124 | } |
| 125 | |
| 126 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "time")) |
| 127 | { |
| 128 | *pGMLType = GMLPT_Timecxx . . $ GMLPT_Time.; |
| 129 | return true; |
| 130 | } |
| 131 | |
| 132 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "dateTime") || EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "TimeInstantType")) |
| 133 | { |
| 134 | *pGMLType = GMLPT_DateTimecxx . . $ GMLPT_DateTime.; |
| 135 | return true; |
| 136 | } |
| 137 | |
| 138 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "boolean")) |
| 139 | { |
| 140 | *pGMLType = GMLPT_Booleancxx . . $ GMLPT_Boolean.; |
| 141 | return true; |
| 142 | } |
| 143 | |
| 144 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszBase, "short")) |
| 145 | { |
| 146 | *pGMLType = GMLPT_Shortcxx . . $ GMLPT_Short.; |
| 147 | return true; |
| 148 | } |
| 149 | |
| 150 | return false; |
| 151 | } |
| 152 | |
| 153 | /************************************************************************/ |
| 154 | /* LookForSimpleType() */ |
| 155 | /************************************************************************/ |
| 156 | |
| 157 | static bool LookForSimpleTypecxx . . $ LookForSimpleType(763c2334171ecd7a).(CPLXMLNode *psSchemaNode, |
| 158 | const char *pszStrippedNSType, |
| 159 | GMLPropertyTypecxx . . $ GMLPropertyType# *pGMLType, int *pnWidth, |
| 160 | int *pnPrecision) |
| 161 | { |
| 162 | CPLXMLNode *psThis = psSchemaNode->psChildcxx . . $ CPLXMLNode#psChild.; |
| 163 | for (; psThis != nullptr; psThis = psThis->psNextcxx . . $ CPLXMLNode#psNext.) |
| 164 | { |
| 165 | if (psThis->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element && |
| 166 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(psThis->pszValue, "simpleType") && |
| 167 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(CPLGetXMLValue(psThis, "name", ""), pszStrippedNSType)) |
| 168 | { |
| 169 | break; |
| 170 | } |
| 171 | } |
| 172 | if (psThis == nullptr) |
| 173 | return false; |
| 174 | |
| 175 | return GetSimpleTypePropertiescxx . . $ GetSimpleTypeProperties(1154cd4f761f8782).(psThis, pGMLType, pnWidth, pnPrecision); |
| 176 | } |
| 177 | |
| 178 | /************************************************************************/ |
| 179 | /* GetSingleChildElement() */ |
| 180 | /************************************************************************/ |
| 181 | |
| 182 | /* Returns the child element whose name is pszExpectedValue only if */ |
| 183 | /* there is only one child that is an element. */ |
| 184 | static CPLXMLNode *GetSingleChildElementcxx . . $ GetSingleChildElement(218ed43f37d9d8e5).(CPLXMLNode *psNode, |
| 185 | const char *pszExpectedValue) |
| 186 | { |
| 187 | if (psNode == nullptr) |
| 188 | return nullptr; |
| 189 | |
| 190 | CPLXMLNode *psIter = psNode->psChildcxx . . $ CPLXMLNode#psChild.; |
| 191 | if (psIter == nullptr) |
| 192 | return nullptr; |
| 193 | |
| 194 | CPLXMLNode *psChild = nullptr; |
| 195 | while (psIter != nullptr) |
| 196 | { |
| 197 | if (psIter->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element) |
| 198 | { |
| 199 | if (psChild != nullptr) |
| 200 | return nullptr; |
| 201 | if (pszExpectedValue != nullptr && |
| 202 | strcmp(psIter->pszValuecxx . . $ CPLXMLNode#pszValue., pszExpectedValue) != 0) |
| 203 | return nullptr; |
| 204 | psChild = psIter; |
| 205 | } |
| 206 | psIter = psIter->psNextcxx . . $ CPLXMLNode#psNext.; |
| 207 | } |
| 208 | return psChild; |
| 209 | } |
| 210 | |
| 211 | /************************************************************************/ |
| 212 | /* CheckMinMaxOccursCardinality() */ |
| 213 | /************************************************************************/ |
| 214 | |
| 215 | static int CheckMinMaxOccursCardinalitycxx . . $ CheckMinMaxOccursCardinality(70d354c6ab72d4fa).(CPLXMLNode *psNode) |
| 216 | { |
| 217 | const char *pszMinOccurs = CPLGetXMLValue(psNode, "minOccurs", nullptr); |
| 218 | const char *pszMaxOccurs = CPLGetXMLValue(psNode, "maxOccurs", nullptr); |
| 219 | return (pszMinOccurs == nullptr || EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszMinOccurs, "0") || |
| 220 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszMinOccurs, "1")) && |
| 221 | (pszMaxOccurs == nullptr || EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszMaxOccurs, "1")); |
| 222 | } |
| 223 | |
| 224 | /************************************************************************/ |
| 225 | /* GetListTypeFromSingleType() */ |
| 226 | /************************************************************************/ |
| 227 | |
| 228 | static GMLPropertyTypecxx . . $ GMLPropertyType# GetListTypeFromSingleTypecxx . . $ GetListTypeFromSingleType(daafc12b670b4038).(GMLPropertyTypecxx . . $ GMLPropertyType# eType) |
| 229 | { |
| 230 | if (eType == GMLPT_Stringcxx . . $ GMLPT_String.) |
| 231 | return GMLPT_StringListcxx . . $ GMLPT_StringList.; |
| 232 | if (eType == GMLPT_Integercxx . . $ GMLPT_Integer. || eType == GMLPT_Shortcxx . . $ GMLPT_Short.) |
| 233 | return GMLPT_IntegerListcxx . . $ GMLPT_IntegerList.; |
| 234 | if (eType == GMLPT_Integer64cxx . . $ GMLPT_Integer64.) |
| 235 | return GMLPT_Integer64Listcxx . . $ GMLPT_Integer64List.; |
| 236 | if (eType == GMLPT_Realcxx . . $ GMLPT_Real. || eType == GMLPT_Floatcxx . . $ GMLPT_Float.) |
| 237 | return GMLPT_RealListcxx . . $ GMLPT_RealList.; |
| 238 | if (eType == GMLPT_Booleancxx . . $ GMLPT_Boolean.) |
| 239 | return GMLPT_BooleanListcxx . . $ GMLPT_BooleanList.; |
| 240 | if (eType == GMLPT_FeaturePropertycxx . . $ GMLPT_FeatureProperty.) |
| 241 | return GMLPT_FeaturePropertyListcxx . . $ GMLPT_FeaturePropertyList.; |
| 242 | return eType; |
| 243 | } |
| 244 | |
| 245 | /************************************************************************/ |
| 246 | /* ParseFeatureType() */ |
| 247 | /************************************************************************/ |
| 248 | |
| 249 | typedef structcxx . . $ $anonymous_type_926c7b0045985326_0# |
| 250 | { |
| 251 | const char *pszNamecxx . . $ $anonymous_type_926c7b0045985326_0#pszName.; |
| 252 | OGRwkbGeometryType eTypecxx . . $ $anonymous_type_926c7b0045985326_0#eType.; |
| 253 | } AssocNameTypecxx . . $ AssocNameType#; |
| 254 | |
| 255 | static const AssocNameTypecxx . . $ AssocNameType# apsPropertyTypescxx . . $ apsPropertyTypes.[] = { |
| 256 | {"GeometryPropertyType", wkbUnknown}, |
| 257 | {"PointPropertyType", wkbPoint}, |
| 258 | {"LineStringPropertyType", wkbLineString}, |
| 259 | {"CurvePropertyType", wkbCompoundCurve}, |
| 260 | {"PolygonPropertyType", wkbPolygon}, |
| 261 | {"SurfacePropertyType", wkbCurvePolygon}, |
| 262 | {"MultiPointPropertyType", wkbMultiPoint}, |
| 263 | {"MultiLineStringPropertyType", wkbMultiLineString}, |
| 264 | {"MultiCurvePropertyType", wkbMultiCurve}, |
| 265 | {"MultiPolygonPropertyType", wkbMultiPolygon}, |
| 266 | {"MultiSurfacePropertyType", wkbMultiSurface}, |
| 267 | {"MultiGeometryPropertyType", wkbGeometryCollection}, |
| 268 | {"GeometryAssociationType", wkbUnknown}, |
| 269 | {nullptr, wkbUnknown}, |
| 270 | }; |
| 271 | |
| 272 | /* Found in FME .xsd (e.g. <element ref="gml:curveProperty" minOccurs="0"/>) */ |
| 273 | static const AssocNameTypecxx . . $ AssocNameType# apsRefTypescxx . . $ apsRefTypes.[] = { |
| 274 | {"pointProperty", wkbPoint}, |
| 275 | {"curveProperty", wkbLineString}, // Should we promote to wkbCompoundCurve? |
| 276 | {"surfaceProperty", wkbPolygon}, // Should we promote to wkbCurvePolygon? |
| 277 | {"multiPointProperty", wkbMultiPoint}, |
| 278 | {"multiCurveProperty", wkbMultiLineString}, |
| 279 | // Should we promote to wkbMultiSurface? |
| 280 | {"multiSurfaceProperty", wkbMultiPolygon}, |
| 281 | {nullptr, wkbUnknown}, |
| 282 | }; |
| 283 | |
| 284 | static GMLFeatureClasscxx . . $ GMLFeatureClass# *GMLParseFeatureTypecxx . . $ GMLParseFeatureType(f4036cd29ef8551).(CPLXMLNode *psSchemaNode, |
| 285 | const char *pszName, |
| 286 | CPLXMLNode *psThis); |
| 287 | |
| 288 | static GMLFeatureClasscxx . . $ GMLFeatureClass# *GMLParseFeatureTypecxx . . $ GMLParseFeatureType(539475793efd80c1).(CPLXMLNode *psSchemaNode, |
| 289 | const char *pszName, |
| 290 | const char *pszType) |
| 291 | { |
| 292 | CPLXMLNode *psThis = psSchemaNode->psChildcxx . . $ CPLXMLNode#psChild.; |
| 293 | for (; psThis != nullptr; psThis = psThis->psNextcxx . . $ CPLXMLNode#psNext.) |
| 294 | { |
| 295 | if (psThis->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element && |
| 296 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(psThis->pszValue, "complexType") && |
| 297 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(CPLGetXMLValue(psThis, "name", ""), pszType)) |
| 298 | { |
| 299 | break; |
| 300 | } |
| 301 | } |
| 302 | if (psThis == nullptr) |
| 303 | return nullptr; |
| 304 | |
| 305 | return GMLParseFeatureTypecxx . . $ GMLParseFeatureType(f4036cd29ef8551).(psSchemaNode, pszName, psThis); |
| 306 | } |
| 307 | |
| 308 | static GMLFeatureClasscxx . . $ GMLFeatureClass# *GMLParseFeatureTypecxx . . $ GMLParseFeatureType(f4036cd29ef8551).(CPLXMLNode *psSchemaNode, |
| 309 | const char *pszName, |
| 310 | CPLXMLNode *psComplexType) |
| 311 | { |
| 312 | |
| 313 | /* -------------------------------------------------------------------- */ |
| 314 | /* Grab the sequence of extensions greatgrandchild. */ |
| 315 | /* -------------------------------------------------------------------- */ |
| 316 | CPLXMLNode *psAttrSeq = |
| 317 | CPLGetXMLNode(psComplexType, "complexContent.extension.sequence"); |
| 318 | |
| 319 | if (psAttrSeq == nullptr) |
| 320 | { |
| 321 | return nullptr; |
| 322 | } |
| 323 | |
| 324 | /* -------------------------------------------------------------------- */ |
| 325 | /* We are pretty sure this going to be a valid Feature class */ |
| 326 | /* now, so create it. */ |
| 327 | /* -------------------------------------------------------------------- */ |
| 328 | GMLFeatureClasscxx . . $ GMLFeatureClass# *poClass = new GMLFeatureClasscxx . . $ GMLFeatureClass#(pszName); |
| 329 | |
| 330 | /* -------------------------------------------------------------------- */ |
| 331 | /* Loop over each of the attribute elements being defined for */ |
| 332 | /* this feature class. */ |
| 333 | /* -------------------------------------------------------------------- */ |
| 334 | int nAttributeIndex = 0; |
| 335 | |
| 336 | bool bGotUnrecognizedType = false; |
| 337 | |
| 338 | CPLXMLNode *psAttrDef = psAttrSeq->psChildcxx . . $ CPLXMLNode#psChild.; |
| 339 | for (; psAttrDef != nullptr; psAttrDef = psAttrDef->psNextcxx . . $ CPLXMLNode#psNext.) |
| 340 | { |
| 341 | if (strcmp(psAttrDef->pszValuecxx . . $ CPLXMLNode#pszValue., "group") == 0) |
| 342 | { |
| 343 | /* Too complex schema for us. Aborts parsing */ |
| 344 | delete poClass; |
| 345 | return nullptr; |
| 346 | } |
| 347 | |
| 348 | /* Parse stuff like: |
| 349 | <xs:choice> |
| 350 | <xs:element ref="gml:polygonProperty"/> |
| 351 | <xs:element ref="gml:multiPolygonProperty"/> |
| 352 | </xs:choice> |
| 353 | as found in |
| 354 | https://downloadagiv.blob.core.windows.net/overstromingsgebieden-en-oeverzones/2014_01/Overstromingsgebieden_en_oeverzones_2014_01_GML.zip |
| 355 | */ |
| 356 | if (strcmp(psAttrDef->pszValuecxx . . $ CPLXMLNode#pszValue., "choice") == 0) |
| 357 | { |
| 358 | CPLXMLNode *psChild = psAttrDef->psChildcxx . . $ CPLXMLNode#psChild.; |
| 359 | bool bPolygon = false; |
| 360 | bool bMultiPolygon = false; |
| 361 | for (; psChild; psChild = psChild->psNextcxx . . $ CPLXMLNode#psNext.) |
| 362 | { |
| 363 | if (psChild->eTypecxx . . $ CPLXMLNode#eType. != CXT_Element) |
| 364 | continue; |
| 365 | if (strcmp(psChild->pszValuecxx . . $ CPLXMLNode#pszValue., "element") == 0) |
| 366 | { |
| 367 | const char *pszRef = |
| 368 | CPLGetXMLValue(psChild, "ref", nullptr); |
| 369 | if (pszRef != nullptr) |
| 370 | { |
| 371 | if (strcmp(pszRef, "gml:polygonProperty") == 0) |
| 372 | { |
| 373 | bPolygon = true; |
| 374 | } |
| 375 | else if (strcmp(pszRef, "gml:multiPolygonProperty") == |
| 376 | 0) |
| 377 | { |
| 378 | bMultiPolygon = true; |
| 379 | } |
| 380 | else |
| 381 | { |
| 382 | delete poClass; |
| 383 | return nullptr; |
| 384 | } |
| 385 | } |
| 386 | else |
| 387 | { |
| 388 | delete poClass; |
| 389 | return nullptr; |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | if (bPolygon && bMultiPolygon) |
| 394 | { |
| 395 | poClass->AddGeometryPropertycxx . . $ GMLFeatureClass#AddGeometryProperty(492bdec084017061).(new GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn#( |
| 396 | "", "", wkbMultiPolygon, nAttributeIndex, true)); |
| 397 | |
| 398 | nAttributeIndex++; |
| 399 | } |
| 400 | continue; |
| 401 | } |
| 402 | |
| 403 | if (!EQUALcxx . . $ `port/cpl_port.h:532:9`!(psAttrDef->pszValue, "element")) |
| 404 | continue; |
| 405 | |
| 406 | // MapServer WFS writes element type as an attribute of element |
| 407 | // not as a simpleType definition. |
| 408 | const char *pszType = CPLGetXMLValue(psAttrDef, "type", nullptr); |
| 409 | const char *pszElementName = CPLGetXMLValue(psAttrDef, "name", nullptr); |
| 410 | bool bNullable = |
| 411 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(CPLGetXMLValue(psAttrDef, "minOccurs", "1"), "0"); |
| 412 | const char *pszMaxOccurs = |
| 413 | CPLGetXMLValue(psAttrDef, "maxOccurs", nullptr); |
| 414 | if (pszType != nullptr) |
| 415 | { |
| 416 | const char *pszStrippedNSType = StripNScxx . . $ StripNS(fb58d2e09a2a1ce6).(pszType); |
| 417 | int nWidth = 0; |
| 418 | int nPrecision = 0; |
| 419 | |
| 420 | GMLPropertyTypecxx . . $ GMLPropertyType# gmlType = GMLPT_Untypedcxx . . $ GMLPT_Untyped.; |
| 421 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "string") || |
| 422 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "Character")) |
| 423 | gmlType = GMLPT_Stringcxx . . $ GMLPT_String.; |
| 424 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "date")) |
| 425 | gmlType = GMLPT_Datecxx . . $ GMLPT_Date.; |
| 426 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "time")) |
| 427 | gmlType = GMLPT_Timecxx . . $ GMLPT_Time.; |
| 428 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "dateTime") || |
| 429 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "TimeInstantType")) |
| 430 | gmlType = GMLPT_DateTimecxx . . $ GMLPT_DateTime.; |
| 431 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "real") || |
| 432 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "double") || |
| 433 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "decimal")) |
| 434 | gmlType = GMLPT_Realcxx . . $ GMLPT_Real.; |
| 435 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "float")) |
| 436 | gmlType = GMLPT_Floatcxx . . $ GMLPT_Float.; |
| 437 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "int") || |
| 438 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "integer")) |
| 439 | gmlType = GMLPT_Integercxx . . $ GMLPT_Integer.; |
| 440 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "long")) |
| 441 | gmlType = GMLPT_Integer64cxx . . $ GMLPT_Integer64.; |
| 442 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "unsignedLong")) |
| 443 | { |
| 444 | // Optimistically map to signed integer |
| 445 | gmlType = GMLPT_Integer64cxx . . $ GMLPT_Integer64.; |
| 446 | } |
| 447 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "short")) |
| 448 | gmlType = GMLPT_Shortcxx . . $ GMLPT_Short.; |
| 449 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "boolean")) |
| 450 | gmlType = GMLPT_Booleancxx . . $ GMLPT_Boolean.; |
| 451 | // TODO: Would be nice to have a binary type. |
| 452 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStrippedNSType, "hexBinary")) |
| 453 | gmlType = GMLPT_Stringcxx . . $ GMLPT_String.; |
| 454 | else if (strcmp(pszType, "gml:FeaturePropertyType") == 0) |
| 455 | { |
| 456 | gmlType = GMLPT_FeaturePropertycxx . . $ GMLPT_FeatureProperty.; |
| 457 | } |
| 458 | else if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszType, "gml:")) |
| 459 | { |
| 460 | const AssocNameTypecxx . . $ AssocNameType# *psIter = apsPropertyTypescxx . . $ apsPropertyTypes.; |
| 461 | while (psIter->pszNamecxx . . $ $anonymous_type_926c7b0045985326_0#pszName.) |
| 462 | { |
| 463 | if (strncmp(pszType + 4, psIter->pszNamecxx . . $ $anonymous_type_926c7b0045985326_0#pszName., |
| 464 | strlen(psIter->pszNamecxx . . $ $anonymous_type_926c7b0045985326_0#pszName.)) == 0) |
| 465 | { |
| 466 | OGRwkbGeometryType eType = psIter->eTypecxx . . $ $anonymous_type_926c7b0045985326_0#eType.; |
| 467 | stdcxx . . $ std/::string osSRSNamecxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 468 | |
| 469 | // Look if there's a comment restricting to subclasses. |
| 470 | for (const CPLXMLNode *psIter2 = psAttrDef->psNextcxx . . $ CPLXMLNode#psNext.; |
| 471 | psIter2 != nullptr; psIter2 = psIter2->psNextcxx . . $ CPLXMLNode#psNext.) |
| 472 | { |
| 473 | if (psIter2->eTypecxx . . $ CPLXMLNode#eType. == CXT_Comment) |
| 474 | { |
| 475 | if (strstr(psIter2->pszValuecxx . . $ CPLXMLNode#pszValue., |
| 476 | "restricted to Polygon")) |
| 477 | eType = wkbPolygon; |
| 478 | else if (strstr(psIter2->pszValuecxx . . $ CPLXMLNode#pszValue., |
| 479 | "restricted to LineString")) |
| 480 | eType = wkbLineString; |
| 481 | else if (strstr(psIter2->pszValuecxx . . $ CPLXMLNode#pszValue., |
| 482 | "restricted to MultiPolygon")) |
| 483 | eType = wkbMultiPolygon; |
| 484 | else if (strstr( |
| 485 | psIter2->pszValuecxx . . $ CPLXMLNode#pszValue., |
| 486 | "restricted to MultiLineString")) |
| 487 | eType = wkbMultiLineString; |
| 488 | else |
| 489 | { |
| 490 | const char *pszSRSName = |
| 491 | strstr(psIter2->pszValuecxx . . $ CPLXMLNode#pszValue., "srsName=\""); |
| 492 | if (pszSRSName) |
| 493 | { |
| 494 | osSRSName =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). |
| 495 | pszSRSName + strlen("srsName=\""); |
| 496 | const auto nPos = osSRSName.findcxx . . $ std/__cxx11/basic_string#find(2dda2fc6b78abe68).('"'); |
| 497 | if (nPos != stdcxx . . $ std/::string::nposcxx . . $ std/__cxx11/basic_string#npos.) |
| 498 | osSRSName.resizecxx . . $ std/__cxx11/basic_string#resize(9dac5f4bebd06212).(nPos); |
| 499 | else |
| 500 | osSRSName.clearcxx . . $ std/__cxx11/basic_string#clear(ced63f7c635d850d).(); |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | // Try to get coordinate precision from a construct like: |
| 507 | /* |
| 508 | <xs:element name="wkb_geometry" type="gml:SurfacePropertyType" nillable="true" minOccurs="0" maxOccurs="1"> |
| 509 | <xs:annotation> |
| 510 | <xs:appinfo source="http://ogr.maptools.org/"> |
| 511 | <ogr:xy_coordinate_resolution>8.9e-9</ogr:xy_coordinate_resolution> |
| 512 | <ogr:z_coordinate_resolution>1e-3</ogr:z_coordinate_resolution> |
| 513 | <ogr:m_coordinate_resolution>1e-3</ogr:m_coordinate_resolution> |
| 514 | </xs:appinfo> |
| 515 | </xs:annotation> |
| 516 | </xs:element> |
| 517 | */ |
| 518 | OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision# oGeomCoordPrec; |
| 519 | const auto psAnnotation = |
| 520 | CPLGetXMLNode(psAttrDef, "annotation"); |
| 521 | if (psAnnotation) |
| 522 | { |
| 523 | for (const CPLXMLNode *psIterAppinfo = |
| 524 | psAnnotation->psChildcxx . . $ CPLXMLNode#psChild.; |
| 525 | psIterAppinfo; |
| 526 | psIterAppinfo = psIterAppinfo->psNextcxx . . $ CPLXMLNode#psNext.) |
| 527 | { |
| 528 | if (psIterAppinfo->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element && |
| 529 | strcmp(psIterAppinfo->pszValuecxx . . $ CPLXMLNode#pszValue., |
| 530 | "appinfo") == 0 && |
| 531 | strcmp(CPLGetXMLValue(psIterAppinfo, |
| 532 | "source", ""), |
| 533 | "http://ogr.maptools.org/") == 0) |
| 534 | { |
| 535 | if (const char *pszXYRes = CPLGetXMLValue( |
| 536 | psIterAppinfo, |
| 537 | "xy_coordinate_resolution", |
| 538 | nullptr)) |
| 539 | { |
| 540 | const double dfVal = CPLAtof(pszXYRes); |
| 541 | if (dfVal > 0 && stdcxx . . $ std/::isfinite(dfVal)) |
| 542 | oGeomCoordPrec.dfXYResolutioncxx . . $ OGRGeomCoordinatePrecision#dfXYResolution. = |
| 543 | dfVal; |
| 544 | } |
| 545 | if (const char *pszZRes = CPLGetXMLValue( |
| 546 | psIterAppinfo, |
| 547 | "z_coordinate_resolution", nullptr)) |
| 548 | { |
| 549 | const double dfVal = CPLAtof(pszZRes); |
| 550 | if (dfVal > 0 && stdcxx . . $ std/::isfinite(dfVal)) |
| 551 | oGeomCoordPrec.dfZResolutioncxx . . $ OGRGeomCoordinatePrecision#dfZResolution. = |
| 552 | dfVal; |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *poDefn = |
| 559 | new GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn#( |
| 560 | pszElementName, pszElementName, eType, |
| 561 | nAttributeIndex, bNullable, oGeomCoordPrec); |
| 562 | poDefn->SetSRSNamecxx . . $ GMLGeometryPropertyDefn#SetSRSName(9c546c94e5fcce4e).(osSRSName); |
| 563 | |
| 564 | if (poClass->AddGeometryPropertycxx . . $ GMLFeatureClass#AddGeometryProperty(492bdec084017061).(poDefn) < 0) |
| 565 | delete poDefn; |
| 566 | else |
| 567 | nAttributeIndex++; |
| 568 | |
| 569 | break; |
| 570 | } |
| 571 | |
| 572 | psIter++; |
| 573 | } |
| 574 | |
| 575 | if (psIter->pszNamecxx . . $ $anonymous_type_926c7b0045985326_0#pszName. == nullptr) |
| 576 | { |
| 577 | // Can be a non geometry gml type. |
| 578 | // Too complex schema for us. Aborts parsing. |
| 579 | delete poClass; |
| 580 | return nullptr; |
| 581 | } |
| 582 | |
| 583 | if (poClass->GetGeometryPropertyCountcxx . . $ GMLFeatureClass#GetGeometryPropertyCount(455f465bc33b4cdf).() == 0) |
| 584 | bGotUnrecognizedType = true; |
| 585 | |
| 586 | continue; |
| 587 | } |
| 588 | |
| 589 | /* Integraph stuff */ |
| 590 | else if (strcmp(pszType, "G:Point_MultiPointPropertyType") == 0 || |
| 591 | strcmp(pszType, "gmgml:Point_MultiPointPropertyType") == 0) |
| 592 | { |
| 593 | GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *poDefn = new GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn#( |
| 594 | pszElementName, pszElementName, wkbMultiPoint, |
| 595 | nAttributeIndex, bNullable); |
| 596 | |
| 597 | if (poClass->AddGeometryPropertycxx . . $ GMLFeatureClass#AddGeometryProperty(492bdec084017061).(poDefn) < 0) |
| 598 | delete poDefn; |
| 599 | else |
| 600 | nAttributeIndex++; |
| 601 | |
| 602 | continue; |
| 603 | } |
| 604 | else if (strcmp(pszType, |
| 605 | "G:LineString_MultiLineStringPropertyType") == 0 || |
| 606 | strcmp(pszType, |
| 607 | "gmgml:LineString_MultiLineStringPropertyType") == |
| 608 | 0) |
| 609 | { |
| 610 | GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *poDefn = new GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn#( |
| 611 | pszElementName, pszElementName, wkbMultiLineString, |
| 612 | nAttributeIndex, bNullable); |
| 613 | |
| 614 | if (poClass->AddGeometryPropertycxx . . $ GMLFeatureClass#AddGeometryProperty(492bdec084017061).(poDefn) < 0) |
| 615 | delete poDefn; |
| 616 | else |
| 617 | nAttributeIndex++; |
| 618 | |
| 619 | continue; |
| 620 | } |
| 621 | else if (strcmp(pszType, "G:Polygon_MultiPolygonPropertyType") == |
| 622 | 0 || |
| 623 | strcmp(pszType, |
| 624 | "gmgml:Polygon_MultiPolygonPropertyType") == 0 || |
| 625 | strcmp(pszType, "gmgml:Polygon_Surface_MultiSurface_" |
| 626 | "CompositeSurfacePropertyType") == 0) |
| 627 | { |
| 628 | GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *poDefn = new GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn#( |
| 629 | pszElementName, pszElementName, wkbMultiPolygon, |
| 630 | nAttributeIndex, bNullable); |
| 631 | |
| 632 | if (poClass->AddGeometryPropertycxx . . $ GMLFeatureClass#AddGeometryProperty(492bdec084017061).(poDefn) < 0) |
| 633 | delete poDefn; |
| 634 | else |
| 635 | nAttributeIndex++; |
| 636 | |
| 637 | continue; |
| 638 | } |
| 639 | |
| 640 | // ERDAS Apollo stufflike in |
| 641 | // http://apollo.erdas.com/erdas-apollo/vector/WORLDWIDE?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=wfs:cntry98) |
| 642 | else if (strcmp(pszType, "wfs:MixedPolygonPropertyType") == 0) |
| 643 | { |
| 644 | GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *poDefn = new GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn#( |
| 645 | pszElementName, pszElementName, wkbMultiPolygon, |
| 646 | nAttributeIndex, bNullable); |
| 647 | |
| 648 | if (poClass->AddGeometryPropertycxx . . $ GMLFeatureClass#AddGeometryProperty(492bdec084017061).(poDefn) < 0) |
| 649 | delete poDefn; |
| 650 | else |
| 651 | nAttributeIndex++; |
| 652 | |
| 653 | continue; |
| 654 | } |
| 655 | |
| 656 | else |
| 657 | { |
| 658 | gmlType = GMLPT_Untypedcxx . . $ GMLPT_Untyped.; |
| 659 | if (!LookForSimpleTypecxx . . $ LookForSimpleType(763c2334171ecd7a).(psSchemaNode, pszStrippedNSType, |
| 660 | &gmlType, &nWidth, &nPrecision)) |
| 661 | { |
| 662 | // Too complex schema for us. Aborts parsing. |
| 663 | delete poClass; |
| 664 | return nullptr; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | if (pszElementName == nullptr) |
| 669 | pszElementName = "unnamed"; |
| 670 | const char *pszPropertyName = pszElementName; |
| 671 | if (gmlType == GMLPT_FeaturePropertycxx . . $ GMLPT_FeatureProperty.) |
| 672 | { |
| 673 | pszPropertyName = CPLSPrintf("%s_href", pszElementName); |
| 674 | } |
| 675 | GMLPropertyDefncxx . . $ GMLPropertyDefn# *poProp = |
| 676 | new GMLPropertyDefncxx . . $ GMLPropertyDefn#(pszPropertyName, pszElementName); |
| 677 | |
| 678 | if (pszMaxOccurs != nullptr && strcmp(pszMaxOccurs, "1") != 0) |
| 679 | gmlType = GetListTypeFromSingleTypecxx . . $ GetListTypeFromSingleType(daafc12b670b4038).(gmlType); |
| 680 | |
| 681 | poProp->SetTypecxx . . $ GMLPropertyDefn#SetType(e56f951e2e23bc45).(gmlType); |
| 682 | poProp->SetWidthcxx . . $ GMLPropertyDefn#SetWidth(d4f767463ce0a6b3).(nWidth); |
| 683 | poProp->SetPrecisioncxx . . $ GMLPropertyDefn#SetPrecision(d4f767463ce0a6b3).(nPrecision); |
| 684 | poProp->SetNullablecxx . . $ GMLPropertyDefn#SetNullable(b45ddcbc8423892c).(bNullable); |
| 685 | |
| 686 | const CPLXMLNode *psAnnotation = |
| 687 | CPLGetXMLNode(psAttrDef, "annotation"); |
| 688 | if (psAnnotation) |
| 689 | { |
| 690 | const char *pszDocumentation = |
| 691 | CPLGetXMLValue(psAnnotation, "documentation", nullptr); |
| 692 | if (pszDocumentation) |
| 693 | poProp->SetDocumentationcxx . . $ GMLPropertyDefn#SetDocumentation(9c546c94e5fcce4e).(pszDocumentationcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 694 | } |
| 695 | |
| 696 | if (poClass->AddPropertycxx . . $ GMLFeatureClass#AddProperty(b7cb0caa1392178c).(poProp) < 0) |
| 697 | delete poProp; |
| 698 | else |
| 699 | nAttributeIndex++; |
| 700 | |
| 701 | continue; |
| 702 | } |
| 703 | |
| 704 | // For now we skip geometries. Fixup later. |
| 705 | CPLXMLNode *psSimpleType = CPLGetXMLNode(psAttrDef, "simpleType"); |
| 706 | if (psSimpleType == nullptr) |
| 707 | { |
| 708 | const char *pszRef = CPLGetXMLValue(psAttrDef, "ref", nullptr); |
| 709 | |
| 710 | // FME .xsd |
| 711 | if (pszRef != nullptr && STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszRef, "gml:")) |
| 712 | { |
| 713 | const AssocNameTypecxx . . $ AssocNameType# *psIter = apsRefTypescxx . . $ apsRefTypes.; |
| 714 | while (psIter->pszNamecxx . . $ $anonymous_type_926c7b0045985326_0#pszName.) |
| 715 | { |
| 716 | if (strncmp(pszRef + 4, psIter->pszNamecxx . . $ $anonymous_type_926c7b0045985326_0#pszName., |
| 717 | strlen(psIter->pszNamecxx . . $ $anonymous_type_926c7b0045985326_0#pszName.)) == 0) |
| 718 | { |
| 719 | if (poClass->GetGeometryPropertyCountcxx . . $ GMLFeatureClass#GetGeometryPropertyCount(455f465bc33b4cdf).() > 0) |
| 720 | { |
| 721 | OGRwkbGeometryType eNewType = psIter->eTypecxx . . $ $anonymous_type_926c7b0045985326_0#eType.; |
| 722 | OGRwkbGeometryType eOldType = |
| 723 | static_cast<OGRwkbGeometryType>( |
| 724 | poClass->GetGeometryPropertycxx . . $ GMLFeatureClass#GetGeometryProperty(d57792ed8f30a1b4).(0)->GetTypecxx . . $ GMLGeometryPropertyDefn#GetType(5a40c54c5ff210ce).()); |
| 725 | |
| 726 | if ((eNewType == wkbMultiPoint && |
| 727 | eOldType == wkbPoint) || |
| 728 | (eNewType == wkbMultiLineString && |
| 729 | eOldType == wkbLineString) || |
| 730 | (eNewType == wkbMultiPolygon && |
| 731 | eOldType == wkbPolygon)) |
| 732 | { |
| 733 | poClass->GetGeometryPropertycxx . . $ GMLFeatureClass#GetGeometryProperty(d57792ed8f30a1b4).(0)->SetTypecxx . . $ GMLGeometryPropertyDefn#SetType(f47ce3f1fe923726).( |
| 734 | eNewType); |
| 735 | } |
| 736 | else |
| 737 | { |
| 738 | CPLDebug("GML", |
| 739 | "Geometry field already found ! " |
| 740 | "Ignoring the following ones"); |
| 741 | } |
| 742 | } |
| 743 | else |
| 744 | { |
| 745 | GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *poDefn = |
| 746 | new GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn#( |
| 747 | pszElementName, pszElementName, |
| 748 | psIter->eTypecxx . . $ $anonymous_type_926c7b0045985326_0#eType., nAttributeIndex, true); |
| 749 | |
| 750 | if (poClass->AddGeometryPropertycxx . . $ GMLFeatureClass#AddGeometryProperty(492bdec084017061).(poDefn) < 0) |
| 751 | delete poDefn; |
| 752 | else |
| 753 | nAttributeIndex++; |
| 754 | } |
| 755 | |
| 756 | break; |
| 757 | } |
| 758 | |
| 759 | psIter++; |
| 760 | } |
| 761 | |
| 762 | if (psIter->pszNamecxx . . $ $anonymous_type_926c7b0045985326_0#pszName. == nullptr) |
| 763 | { |
| 764 | // Can be a non geometry gml type . |
| 765 | // Too complex schema for us. Aborts parsing. |
| 766 | delete poClass; |
| 767 | return nullptr; |
| 768 | } |
| 769 | |
| 770 | if (poClass->GetGeometryPropertyCountcxx . . $ GMLFeatureClass#GetGeometryPropertyCount(455f465bc33b4cdf).() == 0) |
| 771 | bGotUnrecognizedType = true; |
| 772 | |
| 773 | continue; |
| 774 | } |
| 775 | |
| 776 | /* Parse stuff like the following found in |
| 777 | http://199.29.1.81:8181/miwfs/GetFeature.ashx?REQUEST=GetFeature&MAXFEATURES=1&SERVICE=WFS&VERSION=1.0.0&TYPENAME=miwfs:World |
| 778 | : <xs:element name="Obj" minOccurs="0" maxOccurs="1"> |
| 779 | <xs:complexType> |
| 780 | <xs:sequence> |
| 781 | <xs:element ref="gml:_Geometry"/> |
| 782 | </xs:sequence> |
| 783 | </xs:complexType> |
| 784 | </xs:element> |
| 785 | */ |
| 786 | CPLXMLNode *l_psComplexType = |
| 787 | GetSingleChildElementcxx . . $ GetSingleChildElement(218ed43f37d9d8e5).(psAttrDef, "complexType"); |
| 788 | CPLXMLNode *psComplexTypeSequence = |
| 789 | GetSingleChildElementcxx . . $ GetSingleChildElement(218ed43f37d9d8e5).(l_psComplexType, "sequence"); |
| 790 | CPLXMLNode *psComplexTypeSequenceElement = |
| 791 | GetSingleChildElementcxx . . $ GetSingleChildElement(218ed43f37d9d8e5).(psComplexTypeSequence, "element"); |
| 792 | |
| 793 | if (pszElementName != nullptr && |
| 794 | CheckMinMaxOccursCardinalitycxx . . $ CheckMinMaxOccursCardinality(70d354c6ab72d4fa).(psAttrDef) && |
| 795 | psComplexTypeSequenceElement != nullptr && |
| 796 | CheckMinMaxOccursCardinalitycxx . . $ CheckMinMaxOccursCardinality(70d354c6ab72d4fa).(psComplexTypeSequence) && |
| 797 | strcmp(CPLGetXMLValue(psComplexTypeSequenceElement, "ref", ""), |
| 798 | "gml:_Geometry") == 0) |
| 799 | { |
| 800 | GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *poDefn = new GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn#( |
| 801 | pszElementName, pszElementName, wkbUnknown, nAttributeIndex, |
| 802 | bNullable); |
| 803 | |
| 804 | if (poClass->AddGeometryPropertycxx . . $ GMLFeatureClass#AddGeometryProperty(492bdec084017061).(poDefn) < 0) |
| 805 | delete poDefn; |
| 806 | else |
| 807 | nAttributeIndex++; |
| 808 | |
| 809 | continue; |
| 810 | } |
| 811 | else |
| 812 | { |
| 813 | // Too complex schema for us. Aborts parsing. |
| 814 | delete poClass; |
| 815 | return nullptr; |
| 816 | } |
| 817 | } |
| 818 | |
| 819 | if (pszElementName == nullptr) |
| 820 | pszElementName = "unnamed"; |
| 821 | GMLPropertyDefncxx . . $ GMLPropertyDefn# *poProp = |
| 822 | new GMLPropertyDefncxx . . $ GMLPropertyDefn#(pszElementName, pszElementName); |
| 823 | |
| 824 | GMLPropertyTypecxx . . $ GMLPropertyType# eType = GMLPT_Untypedcxx . . $ GMLPT_Untyped.; |
| 825 | int nWidth = 0; |
| 826 | int nPrecision = 0; |
| 827 | GetSimpleTypePropertiescxx . . $ GetSimpleTypeProperties(1154cd4f761f8782).(psSimpleType, &eType, &nWidth, &nPrecision); |
| 828 | |
| 829 | if (pszMaxOccurs != nullptr && strcmp(pszMaxOccurs, "1") != 0) |
| 830 | eType = GetListTypeFromSingleTypecxx . . $ GetListTypeFromSingleType(daafc12b670b4038).(eType); |
| 831 | |
| 832 | poProp->SetTypecxx . . $ GMLPropertyDefn#SetType(e56f951e2e23bc45).(eType); |
| 833 | poProp->SetWidthcxx . . $ GMLPropertyDefn#SetWidth(d4f767463ce0a6b3).(nWidth); |
| 834 | poProp->SetPrecisioncxx . . $ GMLPropertyDefn#SetPrecision(d4f767463ce0a6b3).(nPrecision); |
| 835 | poProp->SetNullablecxx . . $ GMLPropertyDefn#SetNullable(b45ddcbc8423892c).(bNullable); |
| 836 | |
| 837 | const CPLXMLNode *psAnnotation = CPLGetXMLNode(psAttrDef, "annotation"); |
| 838 | if (psAnnotation) |
| 839 | { |
| 840 | const char *pszDocumentation = |
| 841 | CPLGetXMLValue(psAnnotation, "documentation", nullptr); |
| 842 | if (pszDocumentation) |
| 843 | poProp->SetDocumentationcxx . . $ GMLPropertyDefn#SetDocumentation(9c546c94e5fcce4e).(pszDocumentationcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 844 | } |
| 845 | |
| 846 | if (poClass->AddPropertycxx . . $ GMLFeatureClass#AddProperty(b7cb0caa1392178c).(poProp) < 0) |
| 847 | delete poProp; |
| 848 | else |
| 849 | nAttributeIndex++; |
| 850 | } |
| 851 | |
| 852 | // If we have found an unknown types, let's be on the side of caution and |
| 853 | // create a geometry field. |
| 854 | if (poClass->GetGeometryPropertyCountcxx . . $ GMLFeatureClass#GetGeometryPropertyCount(455f465bc33b4cdf).() == 0 && bGotUnrecognizedType) |
| 855 | { |
| 856 | poClass->AddGeometryPropertycxx . . $ GMLFeatureClass#AddGeometryProperty(492bdec084017061).( |
| 857 | new GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn#("", "", wkbUnknown, -1, true)); |
| 858 | } |
| 859 | |
| 860 | /* -------------------------------------------------------------------- */ |
| 861 | /* Class complete, add to reader class list. */ |
| 862 | /* -------------------------------------------------------------------- */ |
| 863 | poClass->SetSchemaLockedcxx . . $ GMLFeatureClass#SetSchemaLocked(b45ddcbc8423892c).(true); |
| 864 | |
| 865 | return poClass; |
| 866 | } |
| 867 | |
| 868 | /************************************************************************/ |
| 869 | /* ExcludeBaseGMLSchemas() */ |
| 870 | /************************************************************************/ |
| 871 | |
| 872 | static bool ExcludeBaseGMLSchemascxx . . $ ExcludeBaseGMLSchemas(7c222eea44a24d43).(const stdcxx . . $ std/::string &osFilename) |
| 873 | { |
| 874 | // List of substrings to exclude |
| 875 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::string> excludedBaseGMLReferencedSchemasList = {cxx . . $ std/vector#vector(9619226211e5a241). |
| 876 | "/gml/3.2.1/", "gml/3.1.1/", "/gml/2.1.2/", "/gmlsfProfile/"}; |
| 877 | for (const auto &pattern : excludedBaseGMLReferencedSchemasList) |
| 878 | { |
| 879 | if (osFilename.findcxx . . $ std/__cxx11/basic_string#find(cabbe8683ddb9d2a).(pattern) != stdcxx . . $ std/::string::nposcxx . . $ std/__cxx11/basic_string#npos.) |
| 880 | { |
| 881 | return false; // Found one of the excluded base GML referenced schema |
| 882 | } |
| 883 | } |
| 884 | return true; // None of the base GML referenced schemas were found |
| 885 | } |
| 886 | |
| 887 | /************************************************************************/ |
| 888 | /* GMLParseXMLFile() */ |
| 889 | /************************************************************************/ |
| 890 | |
| 891 | static CPLXMLNode *GMLParseXMLFilecxx . . $ GMLParseXMLFile(52b0c77518b0fb33).(const char *pszFilename) |
| 892 | { |
| 893 | if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszFilename, "http://") || |
| 894 | STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszFilename, "https://")) |
| 895 | { |
| 896 | CPLXMLNode *psRet = nullptr; |
| 897 | CPLHTTPResult *psResult = CPLHTTPFetch(pszFilename, nullptr); |
| 898 | if (psResult != nullptr) |
| 899 | { |
| 900 | if (psResult->pabyData != nullptr) |
| 901 | { |
| 902 | psRet = CPLParseXMLString( |
| 903 | reinterpret_cast<const char *>(psResult->pabyData)); |
| 904 | } |
| 905 | CPLHTTPDestroyResult(psResult); |
| 906 | } |
| 907 | return psRet; |
| 908 | } |
| 909 | else |
| 910 | { |
| 911 | return CPLParseXMLFile(pszFilename); |
| 912 | } |
| 913 | } |
| 914 | |
| 915 | /************************************************************************/ |
| 916 | /* CPLGetFirstChildNode() */ |
| 917 | /************************************************************************/ |
| 918 | |
| 919 | static CPLXMLNode *CPLGetFirstChildNodecxx . . $ CPLGetFirstChildNode(9be79785b15eb63c).(CPLXMLNode *psNode) |
| 920 | { |
| 921 | if (psNode == nullptr) |
| 922 | return nullptr; |
| 923 | CPLXMLNode *psIter = psNode->psChildcxx . . $ CPLXMLNode#psChild.; |
| 924 | while (psIter != nullptr) |
| 925 | { |
| 926 | if (psIter->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element) |
| 927 | return psIter; |
| 928 | psIter = psIter->psNextcxx . . $ CPLXMLNode#psNext.; |
| 929 | } |
| 930 | return nullptr; |
| 931 | } |
| 932 | |
| 933 | /************************************************************************/ |
| 934 | /* CPLGetLastNode() */ |
| 935 | /************************************************************************/ |
| 936 | |
| 937 | static CPLXMLNode *CPLGetLastNodecxx . . $ CPLGetLastNode(9be79785b15eb63c).(CPLXMLNode *psNode) |
| 938 | { |
| 939 | CPLXMLNode *psIter = psNode; |
| 940 | while (psIter->psNextcxx . . $ CPLXMLNode#psNext. != nullptr) |
| 941 | psIter = psIter->psNextcxx . . $ CPLXMLNode#psNext.; |
| 942 | return psIter; |
| 943 | } |
| 944 | |
| 945 | /************************************************************************/ |
| 946 | /* CPLXMLSchemaResolveInclude() */ |
| 947 | /************************************************************************/ |
| 948 | |
| 949 | static void CPLXMLSchemaResolveIncludecxx . . $ CPLXMLSchemaResolveInclude(b016552be8db6080).(const char *pszMainSchemaLocation, |
| 950 | CPLXMLNode *psSchemaNode, |
| 951 | bool bUseSchemaImports) |
| 952 | { |
| 953 | stdcxx . . $ std/::setcxx . . $ std/set#<CPLString> osAlreadyIncludedcxx . . $ std/set#set(49f6e7a06ebc5aa8).; |
| 954 | |
| 955 | bool bTryAgain; |
| 956 | do |
| 957 | { |
| 958 | CPLXMLNode *psLast = nullptr; |
| 959 | bTryAgain = false; |
| 960 | |
| 961 | CPLXMLNode *psThis = psSchemaNode->psChildcxx . . $ CPLXMLNode#psChild.; |
| 962 | for (; psThis != nullptr; psThis = psThis->psNextcxx . . $ CPLXMLNode#psNext.) |
| 963 | { |
| 964 | stdcxx . . $ std/::string osSchemaLocation = |
| 965 | CPLGetXMLValuecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(psThis, "schemaLocation", ""); |
| 966 | |
| 967 | if (psThis->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element && |
| 968 | (EQUALcxx . . $ `port/cpl_port.h:532:9`!(psThis->pszValue, "include") || |
| 969 | (bUseSchemaImports == TRUEcxx . . $ `port/cpl_port.h:1184:9`! && |
| 970 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(psThis->pszValue, "import") && |
| 971 | ExcludeBaseGMLSchemascxx . . $ ExcludeBaseGMLSchemas(7c222eea44a24d43).(osSchemaLocation)))) |
| 972 | { |
| 973 | |
| 974 | if (!osSchemaLocation.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).() && |
| 975 | osAlreadyIncluded.countcxx . . $ std/set#count(a9c5b6ffd713dfa6).(osSchemaLocation) == 0) |
| 976 | { |
| 977 | osAlreadyIncluded.insertcxx . . $ std/set#insert(10916b2dbd511ba8).(osSchemaLocation); |
| 978 | |
| 979 | if (!STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(osSchemaLocation.c_str(), "http://") && |
| 980 | !STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(osSchemaLocation.c_str(), "https://") && |
| 981 | CPLIsFilenameRelative(osSchemaLocation.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).())) |
| 982 | { |
| 983 | osSchemaLocation =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). CPLFormFilenameSafe( |
| 984 | CPLGetPathSafe(pszMainSchemaLocation).c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), |
| 985 | osSchemaLocation.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), nullptr); |
| 986 | } |
| 987 | |
| 988 | CPLXMLNode *psIncludedXSDTree = |
| 989 | GMLParseXMLFilecxx . . $ GMLParseXMLFile(52b0c77518b0fb33).(osSchemaLocation.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 990 | if (psIncludedXSDTree != nullptr) |
| 991 | { |
| 992 | CPLStripXMLNamespace(psIncludedXSDTree, nullptr, TRUEcxx . . $ `port/cpl_port.h:1184:9`!); |
| 993 | CPLXMLNode *psIncludedSchemaNode = |
| 994 | CPLGetXMLNode(psIncludedXSDTree, "=schema"); |
| 995 | if (psIncludedSchemaNode != nullptr) |
| 996 | { |
| 997 | // Substitute de <include> node by its content. |
| 998 | CPLXMLNode *psFirstChildElement = |
| 999 | CPLGetFirstChildNodecxx . . $ CPLGetFirstChildNode(9be79785b15eb63c).(psIncludedSchemaNode); |
| 1000 | if (psFirstChildElement != nullptr) |
| 1001 | { |
| 1002 | CPLXMLNode *psCopy = |
| 1003 | CPLCloneXMLTree(psFirstChildElement); |
| 1004 | if (psLast != nullptr) |
| 1005 | psLast->psNextcxx . . $ CPLXMLNode#psNext. = psCopy; |
| 1006 | else |
| 1007 | psSchemaNode->psChildcxx . . $ CPLXMLNode#psChild. = psCopy; |
| 1008 | CPLXMLNode *psNext = psThis->psNextcxx . . $ CPLXMLNode#psNext.; |
| 1009 | psThis->psNextcxx . . $ CPLXMLNode#psNext. = nullptr; |
| 1010 | CPLDestroyXMLNode(psThis); |
| 1011 | psThis = CPLGetLastNodecxx . . $ CPLGetLastNode(9be79785b15eb63c).(psCopy); |
| 1012 | psThis->psNextcxx . . $ CPLXMLNode#psNext. = psNext; |
| 1013 | |
| 1014 | // In case the included schema also contains |
| 1015 | // includes. |
| 1016 | bTryAgain = true; |
| 1017 | } |
| 1018 | } |
| 1019 | CPLDestroyXMLNode(psIncludedXSDTree); |
| 1020 | } |
| 1021 | } |
| 1022 | } |
| 1023 | |
| 1024 | psLast = psThis; |
| 1025 | } |
| 1026 | } while (bTryAgain); |
| 1027 | |
| 1028 | const char *pszSchemaOutputName = |
| 1029 | CPLGetConfigOption("GML_SCHEMA_OUTPUT_NAME", nullptr); |
| 1030 | if (pszSchemaOutputName != nullptr) |
| 1031 | { |
| 1032 | CPLSerializeXMLTreeToFile(psSchemaNode, pszSchemaOutputName); |
| 1033 | } |
| 1034 | } |
| 1035 | |
| 1036 | /************************************************************************/ |
| 1037 | /* GetUniqueConstraints() */ |
| 1038 | /************************************************************************/ |
| 1039 | |
| 1040 | static stdcxx . . $ std/::setcxx . . $ std/set#<stdcxx . . $ std/::pair<stdcxx . . $ std/::string, stdcxx . . $ std/::string>> |
| 1041 | GetUniqueConstraintscxx . . $ GetUniqueConstraints(90564fb3f22481b6).(const CPLXMLNode *psNode) |
| 1042 | { |
| 1043 | /* Parse |
| 1044 | <xs:unique name="uniqueConstraintpolyeas_id"> |
| 1045 | <xs:selector xpath="ogr:featureMember/ogr:poly"/> |
| 1046 | <xs:field xpath="ogr:eas_id"/> |
| 1047 | </xs:unique> |
| 1048 | */ |
| 1049 | stdcxx . . $ std/::setcxx . . $ std/set#<stdcxx . . $ std/::pair<stdcxx . . $ std/::string, stdcxx . . $ std/::string>> oSetcxx . . $ std/set#set(49f6e7a06ebc5aa8).; |
| 1050 | for (const auto *psIter = psNode->psChildcxx . . $ CPLXMLNode#psChild.; psIter != nullptr; |
| 1051 | psIter = psIter->psNextcxx . . $ CPLXMLNode#psNext.) |
| 1052 | { |
| 1053 | if (psIter->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element && EQUALcxx . . $ `port/cpl_port.h:532:9`!(psIter->pszValue, "unique")) |
| 1054 | { |
| 1055 | const char *pszSelector = |
| 1056 | CPLGetXMLValue(psIter, "selector.xpath", nullptr); |
| 1057 | const char *pszField = |
| 1058 | CPLGetXMLValue(psIter, "field.xpath", nullptr); |
| 1059 | if (pszSelector && pszField && pszField[0] != '@') |
| 1060 | { |
| 1061 | const char *pszSlash = strchr(pszSelector, '/'); |
| 1062 | if (pszSlash) |
| 1063 | { |
| 1064 | oSet.insertcxx . . $ std/set#insert(10916b2dbd511ba8).( |
| 1065 | stdcxx . . $ std/::pair(StripNScxx . . $ StripNS(fb58d2e09a2a1ce6).(pszSlash + 1), StripNScxx . . $ StripNS(fb58d2e09a2a1ce6).(pszField))); |
| 1066 | } |
| 1067 | } |
| 1068 | } |
| 1069 | } |
| 1070 | return oSetcxx . . $ std/set#set(f3bfeaebad815056).; |
| 1071 | } |
| 1072 | |
| 1073 | /************************************************************************/ |
| 1074 | /* GMLParseXSD() */ |
| 1075 | /************************************************************************/ |
| 1076 | |
| 1077 | bool GMLParseXSDcxx . . $ GMLParseXSD(48e53934138cfdb4).(const char *pszFile, bool bUseSchemaImports, |
| 1078 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<GMLFeatureClasscxx . . $ GMLFeatureClass# *> &aosClasses, |
| 1079 | bool &bFullyUnderstood) |
| 1080 | |
| 1081 | { |
| 1082 | bFullyUnderstood = false; |
| 1083 | |
| 1084 | if (pszFile == nullptr) |
| 1085 | return false; |
| 1086 | |
| 1087 | /* -------------------------------------------------------------------- */ |
| 1088 | /* Load the raw XML file. */ |
| 1089 | /* -------------------------------------------------------------------- */ |
| 1090 | CPLXMLNode *psXSDTree = GMLParseXMLFilecxx . . $ GMLParseXMLFile(52b0c77518b0fb33).(pszFile); |
| 1091 | |
| 1092 | if (psXSDTree == nullptr) |
| 1093 | return false; |
| 1094 | |
| 1095 | /* -------------------------------------------------------------------- */ |
| 1096 | /* Strip off any namespace qualifiers. */ |
| 1097 | /* -------------------------------------------------------------------- */ |
| 1098 | CPLStripXMLNamespace(psXSDTree, nullptr, TRUEcxx . . $ `port/cpl_port.h:1184:9`!); |
| 1099 | |
| 1100 | /* -------------------------------------------------------------------- */ |
| 1101 | /* Find <schema> root element. */ |
| 1102 | /* -------------------------------------------------------------------- */ |
| 1103 | CPLXMLNode *psSchemaNode = CPLGetXMLNode(psXSDTree, "=schema"); |
| 1104 | if (psSchemaNode == nullptr) |
| 1105 | { |
| 1106 | CPLDestroyXMLNode(psXSDTree); |
| 1107 | return false; |
| 1108 | } |
| 1109 | |
| 1110 | /* ==================================================================== */ |
| 1111 | /* Process each include directive. */ |
| 1112 | /* ==================================================================== */ |
| 1113 | CPLXMLSchemaResolveIncludecxx . . $ CPLXMLSchemaResolveInclude(b016552be8db6080).(pszFile, psSchemaNode, bUseSchemaImports); |
| 1114 | |
| 1115 | // CPLSerializeXMLTreeToFile(psSchemaNode, "/vsistdout/"); |
| 1116 | |
| 1117 | bFullyUnderstood = true; |
| 1118 | |
| 1119 | /* ==================================================================== */ |
| 1120 | /* Process each feature class definition. */ |
| 1121 | /* ==================================================================== */ |
| 1122 | CPLXMLNode *psThis = psSchemaNode->psChildcxx . . $ CPLXMLNode#psChild.; |
| 1123 | |
| 1124 | stdcxx . . $ std/::setcxx . . $ std/set#<stdcxx . . $ std/::pair<stdcxx . . $ std/::string, stdcxx . . $ std/::string>> oSetUniqueConstraintscxx . . $ std/set#set(49f6e7a06ebc5aa8).; |
| 1125 | |
| 1126 | for (; psThis != nullptr; psThis = psThis->psNextcxx . . $ CPLXMLNode#psNext.) |
| 1127 | { |
| 1128 | /* -------------------------------------------------------------------- |
| 1129 | */ |
| 1130 | /* Check for <xs:element> node. */ |
| 1131 | /* -------------------------------------------------------------------- |
| 1132 | */ |
| 1133 | if (psThis->eTypecxx . . $ CPLXMLNode#eType. != CXT_Element || !EQUALcxx . . $ `port/cpl_port.h:532:9`!(psThis->pszValue, "element")) |
| 1134 | continue; |
| 1135 | |
| 1136 | /* -------------------------------------------------------------------- |
| 1137 | */ |
| 1138 | /* Get name */ |
| 1139 | /* -------------------------------------------------------------------- |
| 1140 | */ |
| 1141 | const char *pszName = CPLGetXMLValue(psThis, "name", nullptr); |
| 1142 | if (pszName == nullptr) |
| 1143 | { |
| 1144 | continue; |
| 1145 | } |
| 1146 | |
| 1147 | /* -------------------------------------------------------------------- |
| 1148 | */ |
| 1149 | /* Check the substitution group. */ |
| 1150 | /* -------------------------------------------------------------------- |
| 1151 | */ |
| 1152 | const char *pszSubGroup = |
| 1153 | StripNScxx . . $ StripNS(fb58d2e09a2a1ce6).(CPLGetXMLValue(psThis, "substitutionGroup", "")); |
| 1154 | |
| 1155 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszName, "FeatureCollection") && |
| 1156 | (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSubGroup, "_FeatureCollection") || |
| 1157 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSubGroup, "_GML") || |
| 1158 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSubGroup, "AbstractFeature"))) |
| 1159 | { |
| 1160 | oSetUniqueConstraints =cxx . . $ std/set#`operator=`(3c964fc90d3047d2). GetUniqueConstraintscxx . . $ GetUniqueConstraints(90564fb3f22481b6).(psThis); |
| 1161 | continue; |
| 1162 | } |
| 1163 | |
| 1164 | // AbstractFeature used by GML 3.2. |
| 1165 | if (!EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSubGroup, "_Feature") && |
| 1166 | !EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSubGroup, "AbstractFeature")) |
| 1167 | { |
| 1168 | continue; |
| 1169 | } |
| 1170 | |
| 1171 | /* -------------------------------------------------------------------- |
| 1172 | */ |
| 1173 | /* Get type and verify relationship with name. */ |
| 1174 | /* -------------------------------------------------------------------- |
| 1175 | */ |
| 1176 | const char *pszType = CPLGetXMLValue(psThis, "type", nullptr); |
| 1177 | if (pszType == nullptr) |
| 1178 | { |
| 1179 | CPLXMLNode *psComplexType = CPLGetXMLNode(psThis, "complexType"); |
| 1180 | if (psComplexType) |
| 1181 | { |
| 1182 | GMLFeatureClasscxx . . $ GMLFeatureClass# *poClass = |
| 1183 | GMLParseFeatureTypecxx . . $ GMLParseFeatureType(f4036cd29ef8551).(psSchemaNode, pszName, psComplexType); |
| 1184 | if (poClass) |
| 1185 | aosClasses.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(poClass); |
| 1186 | else |
| 1187 | bFullyUnderstood = false; |
| 1188 | } |
| 1189 | continue; |
| 1190 | } |
| 1191 | if (strstr(pszType, ":") != nullptr) |
| 1192 | pszType = strstr(pszType, ":") + 1; |
| 1193 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszType, pszName)) |
| 1194 | { |
| 1195 | // A few WFS servers return a type name which is the element name |
| 1196 | // without any _Type or Type suffix |
| 1197 | // e.g.: |
| 1198 | // http://apollo.erdas.com/erdas-apollo/vector/Cherokee?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=iwfs:Air |
| 1199 | // */ |
| 1200 | |
| 1201 | // TODO(schwehr): What was supposed to go here? |
| 1202 | } |
| 1203 | |
| 1204 | // <element name="RekisteriyksikonPalstanTietoja" |
| 1205 | // type="ktjkiiwfs:PalstanTietojaType" substitutionGroup="gml:_Feature" |
| 1206 | // /> |
| 1207 | else if (strlen(pszType) > 4 && |
| 1208 | strcmp(pszType + strlen(pszType) - 4, "Type") == 0 && |
| 1209 | strlen(pszName) > strlen(pszType) - 4 && |
| 1210 | strncmp(pszName + strlen(pszName) - (strlen(pszType) - 4), |
| 1211 | pszType, strlen(pszType) - 4) == 0) |
| 1212 | { |
| 1213 | } |
| 1214 | |
| 1215 | else if (!EQUALNcxx . . $ `port/cpl_port.h:530:9`!(pszType, pszName, strlen(pszName)) || |
| 1216 | !(EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszType + strlen(pszName), "_Type") || |
| 1217 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszType + strlen(pszName), "Type") || |
| 1218 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszType + strlen(pszName), "FeatureType"))) |
| 1219 | { |
| 1220 | continue; |
| 1221 | } |
| 1222 | |
| 1223 | // CanVec .xsd contains weird types that are not used in the related |
| 1224 | // GML. |
| 1225 | if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszName, "XyZz") || STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszName, "XyZ1") || |
| 1226 | STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszName, "XyZ2")) |
| 1227 | continue; |
| 1228 | |
| 1229 | GMLFeatureClasscxx . . $ GMLFeatureClass# *poClass = |
| 1230 | GMLParseFeatureTypecxx . . $ GMLParseFeatureType(539475793efd80c1).(psSchemaNode, pszName, pszType); |
| 1231 | if (poClass) |
| 1232 | aosClasses.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(poClass); |
| 1233 | else |
| 1234 | bFullyUnderstood = false; |
| 1235 | } |
| 1236 | |
| 1237 | CPLDestroyXMLNode(psXSDTree); |
| 1238 | |
| 1239 | // Attach unique constraints to fields |
| 1240 | for (const auto &typeFieldPair : oSetUniqueConstraints) |
| 1241 | { |
| 1242 | for (const auto *poClass : aosClasses) |
| 1243 | { |
| 1244 | if (poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).() ==cxx . . $ std/`operator==`(3a786e8ce7e53c2c). typeFieldPair.first) |
| 1245 | { |
| 1246 | auto poProperty = |
| 1247 | poClass->GetPropertycxx . . $ GMLFeatureClass#GetProperty(acdde07287789be5).(typeFieldPair.second.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 1248 | if (poProperty) |
| 1249 | { |
| 1250 | poProperty->SetUniquecxx . . $ GMLPropertyDefn#SetUnique(b45ddcbc8423892c).(true); |
| 1251 | } |
| 1252 | break; |
| 1253 | } |
| 1254 | } |
| 1255 | } |
| 1256 | |
| 1257 | return !aosClasses.emptycxx . . $ std/vector#empty(3482b152b9333168).(); |
| 1258 | } |