| 326 | /************************************************************************/ |
| 327 | |
| 328 | void GDALJP2AbstractDataset::LoadVectorLayers(int bOpenRemoteResources) |
| 329 | { |
| 330 | CSLConstList papszGMLJP2 = GetMetadata("xml:gml.root-instance"); |
| 331 | if (papszGMLJP2 == nullptr) |
| 332 | return; |
| 333 | |
| 334 | CPLErr eLastErr = CPLGetLastErrorType(); |
| 335 | int nLastErrNo = CPLGetLastErrorNo(); |
| 336 | CPLString osLastErrorMsg = CPLGetLastErrorMsg(); |
| 337 | CPLXMLNode *const psRoot = CPLParseXMLString(papszGMLJP2[0]); |
| 338 | if (CPLGetLastErrorType() == CE_None && eLastErr != CE_None) |
| 339 | CPLErrorSetState(eLastErr, nLastErrNo, osLastErrorMsg.c_str()); |
| 340 | |
| 341 | if (psRoot == nullptr) |
| 342 | return; |
| 343 | CPLXMLNode *const psCC = |
| 344 | CPLGetXMLNode(psRoot, "=gmljp2:GMLJP2CoverageCollection"); |
| 345 | if (psCC == nullptr) |
| 346 | { |
| 347 | CPLDestroyXMLNode(psRoot); |
| 348 | return; |
| 349 | } |
| 350 | |
| 351 | const std::string osTmpDir = VSIMemGenerateHiddenFilename("gmljp2"); |
| 352 | |
| 353 | // Find feature collections. |
| 354 | int nLayersAtCC = 0; |
| 355 | int nLayersAtGC = 0; |
| 356 | // CPLXMLNode* psCCChildIter = psCC->psChild; |
| 357 | for (CPLXMLNode *psCCChildIter = psCC->psChild; psCCChildIter != nullptr; |
| 358 | psCCChildIter = psCCChildIter->psNext) |
| 359 | { |
| 360 | if (psCCChildIter->eType != CXT_Element || |
| 361 | strcmp(psCCChildIter->pszValue, "gmljp2:featureMember") != 0 || |
| 362 | psCCChildIter->psChild == nullptr || |
| 363 | psCCChildIter->psChild->eType != CXT_Element) |
| 364 | continue; |
| 365 | |
| 366 | CPLXMLNode *const psGCorGMLJP2Features = psCCChildIter->psChild; |
| 367 | bool bIsGC = |
| 368 | strstr(psGCorGMLJP2Features->pszValue, "GridCoverage") != nullptr; |
| 369 | |
| 370 | for (CPLXMLNode *psGCorGMLJP2FeaturesChildIter = |
| 371 | psGCorGMLJP2Features->psChild; |
| 372 | psGCorGMLJP2FeaturesChildIter != nullptr; |
| 373 | psGCorGMLJP2FeaturesChildIter = |
| 374 | psGCorGMLJP2FeaturesChildIter->psNext) |
| 375 | { |
| 376 | if (psGCorGMLJP2FeaturesChildIter->eType != CXT_Element || |
| 377 | strcmp(psGCorGMLJP2FeaturesChildIter->pszValue, |
| 378 | "gmljp2:feature") != 0 || |
| 379 | psGCorGMLJP2FeaturesChildIter->psChild == nullptr) |
| 380 | continue; |
| 381 | |
| 382 | CPLXMLNode *psFC = nullptr; |
| 383 | bool bFreeFC = false; |
| 384 | |
| 385 | CPLXMLNode *const psChild = psGCorGMLJP2FeaturesChildIter->psChild; |
no test coverage detected