Debian Codegraph @

ogr/ogrsf_frmts/gmlas/ogrgmlasconf.cpp

raw symbols SCIP
1 /******************************************************************************
2 * Project: OGR
3 * Purpose: OGRGMLASDriver implementation
4 * Author: Even Rouault, <even dot rouault at spatialys dot com>
5 *
6 * Initial development funded by the European Earth observation programme
7 * Copernicus
8 *
9 ******************************************************************************
10 * Copyright (c) 2016, Even Rouault, <even dot rouault at spatialys dot com>
11 *
12 * SPDX-License-Identifier: MIT
13 ****************************************************************************/
14
15 #include "ogr_gmlas.h"cxx . . $ `<file>/ogr/ogrsf_frmts/gmlas/ogr_gmlas.h`/
16
17 #include "cpl_minixml.h"cxx . . $ `<file>/port/cpl_minixml.h`/
18
19 #include <algorithm>
20
21 #ifdef EMBED_RESOURCE_FILES
22 #include "embedded_resources.h"
23 #endif
24
25 /************************************************************************/
26 /* Finalize() */
27 /************************************************************************/
28
29 void GMLASConfigurationcxx . . $ GMLASConfiguration#::Finalizecxx . . $ GMLASConfiguration#Finalize(49f6e7a06ebc5aa8).()
30 {
31 if (m_bAllowXSDCachecxx . . $ GMLASConfiguration#m_bAllowXSDCache. && m_osXSDCacheDirectorycxx . . $ GMLASConfiguration#m_osXSDCacheDirectory..empty())
32 {
33 m_osXSDCacheDirectorycxx . . $ GMLASConfiguration#m_osXSDCacheDirectory. = GDALGetCacheDirectorycxx . . $ GDALGetCacheDirectory(efd28698952f529a).();
34 if (m_osXSDCacheDirectorycxx . . $ GMLASConfiguration#m_osXSDCacheDirectory..empty())
35 {
36 CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
37 "Could not determine a directory for GMLAS XSD cache");
38 }
39 else
40 {
41 m_osXSDCacheDirectorycxx . . $ GMLASConfiguration#m_osXSDCacheDirectory. = CPLFormFilenameSafe(
42 m_osXSDCacheDirectorycxx . . $ GMLASConfiguration#m_osXSDCacheDirectory., "gmlas_xsd_cache", nullptr);
43 CPLDebug("GMLAS", "XSD cache directory: %s",
44 m_osXSDCacheDirectorycxx . . $ GMLASConfiguration#m_osXSDCacheDirectory..c_str());
45 }
46 }
47 }
48
49 /************************************************************************/
50 /* CPLGetXMLBoolValue() */
51 /************************************************************************/
52
53 static bool CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(CPLXMLNodecxx . . $ CPLXMLNode# *psNode, const char *pszKey,
54 bool bDefault)
55 {
56 const char *pszVal = CPLGetXMLValue(psNode, pszKey, nullptr);
57 if (pszVal)
58 return CPLTestBool(pszVal);
59 else
60 return bDefault;
61 }
62
63 /************************************************************************/
64 /* IsValidXPath() */
65 /************************************************************************/
66
67 static bool IsValidXPathcxx . . $ IsValidXPath(86da8d82cde12b2b).(const CPLString &osXPath)
68 {
69 // Check that the XPath syntax belongs to the subset we
70 // understand
71 bool bOK = !osXPath.empty();
72 for (size_t i = 0; i < osXPath.size(); ++i)
73 {
74 const char chCur = osXPath[i];
75 if (chCur == '/')
76 {
77 // OK
78 }
79 else if (chCur == '@' && (i == 0 || osXPath[i - 1] == '/') &&
80 i < osXPath.size() - 1 &&
81 isalpha(static_cast<unsigned char>(osXPath[i + 1])))
82 {
83 // OK
84 }
85 else if (chCur == '_' || isalpha(static_cast<unsigned char>(chCur)))
86 {
87 // OK
88 }
89 else if (isdigit(static_cast<unsigned char>(chCur)) && i > 0 &&
90 (isalnum(static_cast<unsigned char>(osXPath[i - 1])) ||
91 osXPath[i - 1] == '_'))
92 {
93 // OK
94 }
95 else if (chCur == ':' && i > 0 &&
96 (isalnum(static_cast<unsigned char>(osXPath[i - 1])) ||
97 osXPath[i - 1] == '_') &&
98 i < osXPath.size() - 1 &&
99 isalpha(static_cast<unsigned char>(osXPath[i + 1])))
100 {
101 // OK
102 }
103 else
104 {
105 bOK = false;
106 break;
107 }
108 }
109 return bOK;
110 }
111
112 /************************************************************************/
113 /* GMLASConfigurationErrorHandler() */
114 /************************************************************************/
115
116 static void CPL_STDCALLcxx . . $ `port/cpl_port.h:325:9`! GMLASConfigurationErrorHandlercxx . . $ GMLASConfigurationErrorHandler(99778bdeeaba47a2).(CPLErr /*eErr*/,
117 CPLErrorNum /*nType*/,
118 const char *pszMsg)
119 {
120 stdcxx . . $ std/::vector<CPLString> *paosErrors =
121 static_cast<stdcxx . . $ std/::vector<CPLString> *>(CPLGetErrorHandlerUserData());
122 paosErrors->push_back(pszMsg);
123 }
124
125 /************************************************************************/
126 /* ParseNamespaces() */
127 /************************************************************************/
128
129 static void ParseNamespacescxx . . $ ParseNamespaces(3a389bb98f8cc48a).(CPLXMLNodecxx . . $ CPLXMLNode# *psContainerNode,
130 stdcxx . . $ std/::mapcxx . . $ std/map#<CPLString, CPLString> &oMap)
131 {
132 CPLXMLNodecxx . . $ CPLXMLNode# *psNamespaces = CPLGetXMLNode(psContainerNode, "Namespaces");
133 if (psNamespaces != nullptr)
134 {
135 for (CPLXMLNodecxx . . $ CPLXMLNode# *psIter = psNamespaces->psChildcxx . . $ CPLXMLNode#psChild.; psIter != nullptr;
136 psIter = psIter->psNextcxx . . $ CPLXMLNode#psNext.)
137 {
138 if (psIter->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element &&
139 EQUALcxx . . $ `port/cpl_port.h:532:9`!(psIter->pszValue, "Namespace"))
140 {
141 const stdcxx . . $ std/::string osPrefix =
142 CPLGetXMLValue(psIter, "prefix", "");
143 const stdcxx . . $ std/::string osURI = CPLGetXMLValue(psIter, "uri", "");
144 if (!osPrefix.empty() && !osURI.empty())
145 {
146 if (oMap.findcxx . . $ std/map#find(36f8d56706583706).(osPrefix) ==cxx . . $ std/`operator==`(be6a71a859368080). oMap.endcxx . . $ std/map#end(7e4de33083b6e738).())
147 {
148 oMap[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).osPrefix] = osURI;
149 }
150 else
151 {
152 CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
153 "Prefix %s was already mapped to %s. "
154 "Attempt to map it to %s ignored",
155 osPrefix.c_str(), oMap[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).osPrefix].c_str(),
156 osURI.c_str());
157 }
158 }
159 }
160 }
161 }
162 }
163
164 /************************************************************************/
165 /* GetDefaultConfFile() */
166 /************************************************************************/
167
168 /* static */
169 stdcxx . . $ std/::string GMLASConfigurationcxx . . $ GMLASConfiguration#::GetDefaultConfFilecxx . . $ GMLASConfiguration#GetDefaultConfFile(33f5e2c12af2e764).(bool &bUnlinkAfterUse)
170 {
171 bUnlinkAfterUse = false;
172 #if !defined(USE_ONLY_EMBEDDED_RESOURCE_FILES)
173 const char *pszConfigFile = CPLFindFile("gdal", szDEFAULT_CONF_FILENAMEcxx . . $ GMLASConstants/szDEFAULT_CONF_FILENAME.);
174 if (pszConfigFile)
175 return pszConfigFile;
176 #endif
177 #ifdef EMBED_RESOURCE_FILES
178 static const bool bOnce [[maybe_unused]] = []()
179 {
180 CPLDebug("GMLAS", "Using embedded %s", szDEFAULT_CONF_FILENAME);
181 return true;
182 }();
183 bUnlinkAfterUse = true;
184 const std::string osTmpFilename =
185 VSIMemGenerateHiddenFilename(szDEFAULT_CONF_FILENAME);
186 VSIFCloseL(VSIFileFromMemBuffer(
187 osTmpFilename.c_str(),
188 const_cast<GByte *>(
189 reinterpret_cast<const GByte *>(GMLASConfXMLGetFileContent())),
190 static_cast<int>(strlen(GMLASConfXMLGetFileContent())),
191 /* bTakeOwnership = */ false));
192 return osTmpFilename;
193 #else
194 return stdcxx . . $ std/::string();
195 #endif
196 }
197
198 /************************************************************************/
199 /* Load() */
200 /************************************************************************/
201
202 bool GMLASConfigurationcxx . . $ GMLASConfiguration#::Loadcxx . . $ GMLASConfiguration#Load(c5f7da30cbc0f4e9).(const char *pszFilename)
203 {
204 // Allow configuration to be inlined
205 CPLXMLNodecxx . . $ CPLXMLNode# *psRoot = STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszFilename, "<Configuration")
206 ? CPLParseXMLString(pszFilename)
207 : CPLParseXMLFile(pszFilename);
208 if (psRoot == nullptr)
209 {
210 Finalizecxx . . $ GMLASConfiguration#Finalize(49f6e7a06ebc5aa8).();
211 return false;
212 }
213 CPLXMLTreeCloser oCloser(psRoot);
214 CPL_IGNORE_RET_VAL(oCloser);
215
216 // Validate the configuration file
217 if (CPLTestBool(CPLGetConfigOption("GDAL_XML_VALIDATION", "YES")))
218 {
219 #ifdef EMBED_RESOURCE_FILES
220 std::string osTmpFilename;
221 CPLErrorStateBackuper oErrorStateBackuper(CPLQuietErrorHandler);
222 #endif
223 #ifdef USE_ONLY_EMBEDDED_RESOURCE_FILES
224 const char *pszXSD = nullptr;
225 #else
226 const char *pszXSD = CPLFindFile("gdal", "gmlasconf.xsd");
227 #endif
228 #ifdef EMBED_RESOURCE_FILES
229 if (!pszXSD)
230 {
231 static const bool bOnce [[maybe_unused]] = []()
232 {
233 CPLDebug("GMLAS", "Using embedded gmlasconf.xsd");
234 return true;
235 }();
236 osTmpFilename = VSIMemGenerateHiddenFilename("gmlasconf.xsd");
237 pszXSD = osTmpFilename.c_str();
238 VSIFCloseL(VSIFileFromMemBuffer(
239 osTmpFilename.c_str(),
240 const_cast<GByte *>(reinterpret_cast<const GByte *>(
241 GMLASConfXSDGetFileContent())),
242 static_cast<int>(strlen(GMLASConfXSDGetFileContent())),
243 /* bTakeOwnership = */ false));
244 }
245 #else
246 if (pszXSD)
247 #endif
248 {
249 stdcxx . . $ std/::vector<CPLString> aosErrors;
250 const CPLErr eErrClass = CPLGetLastErrorType();
251 const CPLErrorNum nErrNum = CPLGetLastErrorNo();
252 const CPLString osErrMsg = CPLGetLastErrorMsg();
253 CPLPushErrorHandlerEx(GMLASConfigurationErrorHandlercxx . . $ GMLASConfigurationErrorHandler(99778bdeeaba47a2)., &aosErrors);
254 int bRet = CPLValidateXML(pszFilename, pszXSD, nullptr);
255 CPLPopErrorHandler();
256 if (!bRet && !aosErrors.empty() &&
257 strstr(aosErrors[0].c_str(), "missing libxml2 support") ==
258 nullptr)
259 {
260 for (size_t i = 0; i < aosErrors.size(); i++)
261 {
262 CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, "%s",
263 aosErrors[i].c_str());
264 }
265 }
266 else
267 {
268 CPLErrorSetState(eErrClass, nErrNum, osErrMsg);
269 }
270 }
271
272 #ifdef EMBED_RESOURCE_FILES
273 if (!osTmpFilename.empty())
274 VSIUnlink(osTmpFilename.c_str());
275 #endif
276 }
277
278 m_bAllowRemoteSchemaDownloadcxx . . $ GMLASConfiguration#m_bAllowRemoteSchemaDownload. =
279 CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(psRoot, "=Configuration.AllowRemoteSchemaDownload",
280 ALLOW_REMOTE_SCHEMA_DOWNLOAD_DEFAULTcxx . . $ GMLASConstants/ALLOW_REMOTE_SCHEMA_DOWNLOAD_DEFAULT.);
281
282 m_bAllowXSDCachecxx . . $ GMLASConfiguration#m_bAllowXSDCache. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
283 psRoot, "=Configuration.SchemaCache.enabled", ALLOW_XSD_CACHE_DEFAULTcxx . . $ GMLASConstants/ALLOW_XSD_CACHE_DEFAULT.);
284 if (m_bAllowXSDCachecxx . . $ GMLASConfiguration#m_bAllowXSDCache.)
285 {
286 m_osXSDCacheDirectorycxx . . $ GMLASConfiguration#m_osXSDCacheDirectory. =
287 CPLGetXMLValue(psRoot, "=Configuration.SchemaCache.Directory", "");
288 }
289
290 m_bSchemaFullCheckingcxx . . $ GMLASConfiguration#m_bSchemaFullChecking. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
291 psRoot, "=Configuration.SchemaAnalysisOptions.SchemaFullChecking",
292 SCHEMA_FULL_CHECKING_DEFAULTcxx . . $ GMLASConstants/SCHEMA_FULL_CHECKING_DEFAULT.);
293
294 m_bHandleMultipleImportscxx . . $ GMLASConfiguration#m_bHandleMultipleImports. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
295 psRoot, "=Configuration.SchemaAnalysisOptions.HandleMultipleImports",
296 HANDLE_MULTIPLE_IMPORTS_DEFAULTcxx . . $ GMLASConstants/HANDLE_MULTIPLE_IMPORTS_DEFAULT.);
297
298 m_bValidatecxx . . $ GMLASConfiguration#m_bValidate. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
299 psRoot, "=Configuration.Validation.enabled", VALIDATE_DEFAULTcxx . . $ GMLASConstants/VALIDATE_DEFAULT.);
300
301 if (m_bValidatecxx . . $ GMLASConfiguration#m_bValidate.)
302 {
303 m_bFailIfValidationErrorcxx . . $ GMLASConfiguration#m_bFailIfValidationError. =
304 CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(psRoot, "=Configuration.Validation.FailIfError",
305 FAIL_IF_VALIDATION_ERROR_DEFAULTcxx . . $ GMLASConstants/FAIL_IF_VALIDATION_ERROR_DEFAULT.);
306 }
307
308 m_bExposeMetadataLayerscxx . . $ GMLASConfiguration#m_bExposeMetadataLayers. =
309 CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(psRoot, "=Configuration.ExposeMetadataLayers",
310 EXPOSE_METADATA_LAYERS_DEFAULTcxx . . $ GMLASConstants/EXPOSE_METADATA_LAYERS_DEFAULT.);
311
312 m_bAlwaysGenerateOGRIdcxx . . $ GMLASConfiguration#m_bAlwaysGenerateOGRId. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
313 psRoot, "=Configuration.LayerBuildingRules.AlwaysGenerateOGRId",
314 ALWAYS_GENERATE_OGR_ID_DEFAULTcxx . . $ GMLASConstants/ALWAYS_GENERATE_OGR_ID_DEFAULT.);
315
316 m_bRemoveUnusedLayerscxx . . $ GMLASConfiguration#m_bRemoveUnusedLayers. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
317 psRoot, "=Configuration.LayerBuildingRules.RemoveUnusedLayers",
318 REMOVE_UNUSED_LAYERS_DEFAULTcxx . . $ GMLASConstants/REMOVE_UNUSED_LAYERS_DEFAULT.);
319
320 m_bRemoveUnusedFieldscxx . . $ GMLASConfiguration#m_bRemoveUnusedFields. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
321 psRoot, "=Configuration.LayerBuildingRules.RemoveUnusedFields",
322 REMOVE_UNUSED_FIELDS_DEFAULTcxx . . $ GMLASConstants/REMOVE_UNUSED_FIELDS_DEFAULT.);
323
324 m_bUseArrayscxx . . $ GMLASConfiguration#m_bUseArrays. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
325 psRoot, "=Configuration.LayerBuildingRules.UseArrays",
326 USE_ARRAYS_DEFAULTcxx . . $ GMLASConstants/USE_ARRAYS_DEFAULT.);
327 m_bUseNullStatecxx . . $ GMLASConfiguration#m_bUseNullState. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
328 psRoot, "=Configuration.LayerBuildingRules.UseNullState",
329 USE_NULL_STATE_DEFAULTcxx . . $ GMLASConstants/USE_NULL_STATE_DEFAULT.);
330 m_bIncludeGeometryXMLcxx . . $ GMLASConfiguration#m_bIncludeGeometryXML. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
331 psRoot, "=Configuration.LayerBuildingRules.GML.IncludeGeometryXML",
332 INCLUDE_GEOMETRY_XML_DEFAULTcxx . . $ GMLASConstants/INCLUDE_GEOMETRY_XML_DEFAULT.);
333 m_bInstantiateGMLFeaturesOnlycxx . . $ GMLASConfiguration#m_bInstantiateGMLFeaturesOnly. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
334 psRoot,
335 "=Configuration.LayerBuildingRules.GML.InstantiateGMLFeaturesOnly",
336 INSTANTIATE_GML_FEATURES_ONLY_DEFAULTcxx . . $ GMLASConstants/INSTANTIATE_GML_FEATURES_ONLY_DEFAULT.);
337 m_nIdentifierMaxLengthcxx . . $ GMLASConfiguration#m_nIdentifierMaxLength. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetXMLValue(
338 psRoot, "=Configuration.LayerBuildingRules.IdentifierMaxLength", "0"));
339 m_bCaseInsensitiveIdentifiercxx . . $ GMLASConfiguration#m_bCaseInsensitiveIdentifier. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
340 psRoot, "=Configuration.LayerBuildingRules.CaseInsensitiveIdentifier",
341 CASE_INSENSITIVE_IDENTIFIER_DEFAULTcxx . . $ GMLASConstants/CASE_INSENSITIVE_IDENTIFIER_DEFAULT.);
342 m_bPGIdentifierLaunderingcxx . . $ GMLASConfiguration#m_bPGIdentifierLaundering. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
343 psRoot,
344 "=Configuration.LayerBuildingRules.PostgreSQLIdentifierLaundering",
345 PG_IDENTIFIER_LAUNDERING_DEFAULTcxx . . $ GMLASConstants/PG_IDENTIFIER_LAUNDERING_DEFAULT.);
346
347 CPLXMLNodecxx . . $ CPLXMLNode# *psFlatteningRules = CPLGetXMLNode(
348 psRoot, "=Configuration.LayerBuildingRules.FlatteningRules");
349 if (psFlatteningRules)
350 {
351 m_nMaximumFieldsForFlatteningcxx . . $ GMLASConfiguration#m_nMaximumFieldsForFlattening. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetXMLValue(
352 psFlatteningRules, "MaximumNumberOfFields",
353 CPLSPrintf("%d", MAXIMUM_FIELDS_FLATTENING_DEFAULTcxx . . $ GMLASConstants/MAXIMUM_FIELDS_FLATTENING_DEFAULT.)));
354
355 ParseNamespacescxx . . $ ParseNamespaces(3a389bb98f8cc48a).(psFlatteningRules, m_oMapPrefixToURIFlatteningRulescxx . . $ GMLASConfiguration#m_oMapPrefixToURIFlatteningRules.);
356
357 for (CPLXMLNodecxx . . $ CPLXMLNode# *psIter = psFlatteningRules->psChildcxx . . $ CPLXMLNode#psChild.; psIter != nullptr;
358 psIter = psIter->psNextcxx . . $ CPLXMLNode#psNext.)
359 {
360 if (psIter->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element &&
361 EQUALcxx . . $ `port/cpl_port.h:532:9`!(psIter->pszValue, "ForceFlatteningXPath"))
362 {
363 m_osForcedFlattenedXPathcxx . . $ GMLASConfiguration#m_osForcedFlattenedXPath..push_back(
364 CPLGetXMLValue(psIter, "", ""));
365 }
366 else if (psIter->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element &&
367 EQUALcxx . . $ `port/cpl_port.h:532:9`!(psIter->pszValue, "DisableFlatteningXPath"))
368 {
369 m_osDisabledFlattenedXPathcxx . . $ GMLASConfiguration#m_osDisabledFlattenedXPath..push_back(
370 CPLGetXMLValue(psIter, "", ""));
371 }
372 }
373 }
374
375 const char *pszSWEProcessingActivation = CPLGetXMLValue(
376 psRoot, "=Configuration.LayerBuildingRules.SWEProcessing.Activation",
377 "ifSWENamespaceFoundInTopElement");
378 if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSWEProcessingActivation, "ifSWENamespaceFoundInTopElement"))
379 m_eSWEActivationModecxx . . $ GMLASConfiguration#m_eSWEActivationMode. = SWE_ACTIVATE_IF_NAMESPACE_FOUNDcxx . . $ GMLASConfiguration#SWE_ACTIVATE_IF_NAMESPACE_FOUND.;
380 else if (CPLTestBool(pszSWEProcessingActivation))
381 m_eSWEActivationModecxx . . $ GMLASConfiguration#m_eSWEActivationMode. = SWE_ACTIVATE_TRUEcxx . . $ GMLASConfiguration#SWE_ACTIVATE_TRUE.;
382 else
383 m_eSWEActivationModecxx . . $ GMLASConfiguration#m_eSWEActivationMode. = SWE_ACTIVATE_FALSEcxx . . $ GMLASConfiguration#SWE_ACTIVATE_FALSE.;
384 m_bSWEProcessDataRecordcxx . . $ GMLASConfiguration#m_bSWEProcessDataRecord. = CPLTestBool(CPLGetXMLValue(
385 psRoot,
386 "=Configuration.LayerBuildingRules.SWEProcessing.ProcessDataRecord",
387 "true"));
388 m_bSWEProcessDataArraycxx . . $ GMLASConfiguration#m_bSWEProcessDataArray. = CPLTestBool(CPLGetXMLValue(
389 psRoot,
390 "=Configuration.LayerBuildingRules.SWEProcessing.ProcessDataArray",
391 "true"));
392
393 CPLXMLNodecxx . . $ CPLXMLNode# *psTypingConstraints =
394 CPLGetXMLNode(psRoot, "=Configuration.TypingConstraints");
395 if (psTypingConstraints)
396 {
397 ParseNamespacescxx . . $ ParseNamespaces(3a389bb98f8cc48a).(psTypingConstraints, m_oMapPrefixToURITypeConstraintscxx . . $ GMLASConfiguration#m_oMapPrefixToURITypeConstraints.);
398
399 for (CPLXMLNodecxx . . $ CPLXMLNode# *psIter = psTypingConstraints->psChildcxx . . $ CPLXMLNode#psChild.;
400 psIter != nullptr; psIter = psIter->psNextcxx . . $ CPLXMLNode#psNext.)
401 {
402 if (psIter->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element &&
403 EQUALcxx . . $ `port/cpl_port.h:532:9`!(psIter->pszValue, "ChildConstraint"))
404 {
405 const CPLString &osXPath(
406 CPLGetXMLValue(psIter, "ContainerXPath", ""));
407 CPLXMLNodecxx . . $ CPLXMLNode# *psChildrenTypes =
408 CPLGetXMLNode(psIter, "ChildrenElements");
409 if (IsValidXPathcxx . . $ IsValidXPath(86da8d82cde12b2b).(osXPath))
410 {
411 for (CPLXMLNodecxx . . $ CPLXMLNode# *psIter2 = psChildrenTypes
412 ? psChildrenTypes->psChildcxx . . $ CPLXMLNode#psChild.
413 : nullptr;
414 psIter2 != nullptr; psIter2 = psIter2->psNextcxx . . $ CPLXMLNode#psNext.)
415 {
416 if (psIter2->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element &&
417 EQUALcxx . . $ `port/cpl_port.h:532:9`!(psIter2->pszValue, "Element"))
418 {
419 m_oMapChildrenElementsConstraintscxx . . $ GMLASConfiguration#m_oMapChildrenElementsConstraints.[cxx . . $ std/map#`operator[]`(bbd415b616967878).osXPath]
420 .push_back(CPLGetXMLValue(psIter2, "", ""));
421 }
422 }
423 }
424 else
425 {
426 CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
427 "XPath syntax %s not supported", osXPath.c_str());
428 }
429 }
430 }
431 }
432
433 CPLXMLNodecxx . . $ CPLXMLNode# *psIgnoredXPaths =
434 CPLGetXMLNode(psRoot, "=Configuration.IgnoredXPaths");
435 if (psIgnoredXPaths)
436 {
437 const bool bGlobalWarnIfIgnoredXPathFound = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
438 psIgnoredXPaths, "WarnIfIgnoredXPathFoundInDocInstance",
439 WARN_IF_EXCLUDED_XPATH_FOUND_DEFAULTcxx . . $ GMLASConstants/WARN_IF_EXCLUDED_XPATH_FOUND_DEFAULT.);
440
441 ParseNamespacescxx . . $ ParseNamespaces(3a389bb98f8cc48a).(psIgnoredXPaths, m_oMapPrefixToURIIgnoredXPathscxx . . $ GMLASConfiguration#m_oMapPrefixToURIIgnoredXPaths.);
442
443 for (CPLXMLNodecxx . . $ CPLXMLNode# *psIter = psIgnoredXPaths->psChildcxx . . $ CPLXMLNode#psChild.; psIter != nullptr;
444 psIter = psIter->psNextcxx . . $ CPLXMLNode#psNext.)
445 {
446 if (psIter->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element &&
447 EQUALcxx . . $ `port/cpl_port.h:532:9`!(psIter->pszValue, "XPath"))
448 {
449 const CPLString &osXPath(CPLGetXMLValue(psIter, "", ""));
450 if (IsValidXPathcxx . . $ IsValidXPath(86da8d82cde12b2b).(osXPath))
451 {
452 m_aosIgnoredXPathscxx . . $ GMLASConfiguration#m_aosIgnoredXPaths..push_back(osXPath);
453
454 const bool bWarnIfIgnoredXPathFound = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
455 psIter, "warnIfIgnoredXPathFoundInDocInstance",
456 bGlobalWarnIfIgnoredXPathFound);
457 m_oMapIgnoredXPathToWarncxx . . $ GMLASConfiguration#m_oMapIgnoredXPathToWarn.[cxx . . $ std/map#`operator[]`(bbd415b616967878).osXPath] =
458 bWarnIfIgnoredXPathFound;
459 }
460 else
461 {
462 CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
463 "XPath syntax %s not supported", osXPath.c_str());
464 }
465 }
466 }
467 }
468
469 CPLXMLNodecxx . . $ CPLXMLNode# *psXLinkResolutionNode =
470 CPLGetXMLNode(psRoot, "=Configuration.XLinkResolution");
471 if (psXLinkResolutionNode != nullptr)
472 m_oXLinkResolutioncxx . . $ GMLASConfiguration#m_oXLinkResolution..LoadFromXMLcxx . . $ GMLASXLinkResolutionConf#LoadFromXML(c07029e002bb4716).(psXLinkResolutionNode);
473
474 // Parse WriterConfig
475 CPLXMLNodecxx . . $ CPLXMLNode# *psWriterConfig =
476 CPLGetXMLNode(psRoot, "=Configuration.WriterConfig");
477 if (psWriterConfig != nullptr)
478 {
479 m_nIndentSizecxx . . $ GMLASConfiguration#m_nIndentSize. =
480 atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetXMLValue(psWriterConfig, "IndentationSize",
481 CPLSPrintf("%d", INDENT_SIZE_DEFAULTcxx . . $ GMLASConstants/INDENT_SIZE_DEFAULT.)));
482 m_nIndentSizecxx . . $ GMLASConfiguration#m_nIndentSize. =
483 stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(INDENT_SIZE_MAXcxx . . $ GMLASConstants/INDENT_SIZE_MAX., stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(INDENT_SIZE_MINcxx . . $ GMLASConstants/INDENT_SIZE_MIN., m_nIndentSizecxx . . $ GMLASConfiguration#m_nIndentSize.));
484
485 m_osCommentcxx . . $ GMLASConfiguration#m_osComment. = CPLGetXMLValue(psWriterConfig, "Comment", "");
486
487 m_osLineFormatcxx . . $ GMLASConfiguration#m_osLineFormat. = CPLGetXMLValue(psWriterConfig, "LineFormat", "");
488
489 m_osSRSNameFormatcxx . . $ GMLASConfiguration#m_osSRSNameFormat. = CPLGetXMLValue(psWriterConfig, "SRSNameFormat", "");
490
491 m_osWrappingcxx . . $ GMLASConfiguration#m_osWrapping. = CPLGetXMLValue(psWriterConfig, "Wrapping",
492 szWFS2_FEATURECOLLECTIONcxx . . $ GMLASConstants/szWFS2_FEATURECOLLECTION.);
493
494 m_osTimestampcxx . . $ GMLASConfiguration#m_osTimestamp. = CPLGetXMLValue(psWriterConfig, "Timestamp", "");
495
496 m_osWFS20SchemaLocationcxx . . $ GMLASConfiguration#m_osWFS20SchemaLocation. = CPLGetXMLValue(
497 psWriterConfig, "WFS20SchemaLocation", szWFS20_SCHEMALOCATIONcxx . . $ GMLASConstants/szWFS20_SCHEMALOCATION.);
498 }
499
500 Finalizecxx . . $ GMLASConfiguration#Finalize(49f6e7a06ebc5aa8).();
501
502 return true;
503 }
504
505 /************************************************************************/
506 /* LoadFromXML() */
507 /************************************************************************/
508
509 bool GMLASXLinkResolutionConfcxx . . $ GMLASXLinkResolutionConf#::LoadFromXMLcxx . . $ GMLASXLinkResolutionConf#LoadFromXML(c07029e002bb4716).(CPLXMLNodecxx . . $ CPLXMLNode# *psRoot)
510 {
511 m_nTimeOutcxx . . $ GMLASXLinkResolutionConf#m_nTimeOut. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetXMLValue(psRoot, "Timeout", "0"));
512
513 m_nMaxFileSizecxx . . $ GMLASXLinkResolutionConf#m_nMaxFileSize. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetXMLValue(
514 psRoot, "MaxFileSize", CPLSPrintf("%d", MAX_FILE_SIZE_DEFAULTcxx . . $ GMLASConstants/MAX_FILE_SIZE_DEFAULT.)));
515
516 m_nMaxGlobalResolutionTimecxx . . $ GMLASXLinkResolutionConf#m_nMaxGlobalResolutionTime. =
517 atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetXMLValue(psRoot, "MaxGlobalResolutionTime", "0"));
518
519 m_osProxyServerPortcxx . . $ GMLASXLinkResolutionConf#m_osProxyServerPort. = CPLGetXMLValue(psRoot, "ProxyServerPort", "");
520 m_osProxyUserPasswordcxx . . $ GMLASXLinkResolutionConf#m_osProxyUserPassword. = CPLGetXMLValue(psRoot, "ProxyUserPassword", "");
521 m_osProxyAuthcxx . . $ GMLASXLinkResolutionConf#m_osProxyAuth. = CPLGetXMLValue(psRoot, "ProxyAuth", "");
522
523 m_osCacheDirectorycxx . . $ GMLASXLinkResolutionConf#m_osCacheDirectory. = CPLGetXMLValue(psRoot, "CacheDirectory", "");
524 if (m_osCacheDirectorycxx . . $ GMLASXLinkResolutionConf#m_osCacheDirectory..empty())
525 {
526 m_osCacheDirectorycxx . . $ GMLASXLinkResolutionConf#m_osCacheDirectory. = GDALGetCacheDirectorycxx . . $ GDALGetCacheDirectory(efd28698952f529a).();
527 if (!m_osCacheDirectorycxx . . $ GMLASXLinkResolutionConf#m_osCacheDirectory..empty())
528 {
529 m_osCacheDirectorycxx . . $ GMLASXLinkResolutionConf#m_osCacheDirectory. = CPLFormFilenameSafe(
530 m_osCacheDirectorycxx . . $ GMLASXLinkResolutionConf#m_osCacheDirectory., "xlink_resolved_cache", nullptr);
531 }
532 }
533
534 m_bDefaultResolutionEnabledcxx . . $ GMLASXLinkResolutionConf#m_bDefaultResolutionEnabled. =
535 CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(psRoot, "DefaultResolution.enabled",
536 DEFAULT_RESOLUTION_ENABLED_DEFAULTcxx . . $ GMLASConstants/DEFAULT_RESOLUTION_ENABLED_DEFAULT.);
537
538 m_bDefaultAllowRemoteDownloadcxx . . $ GMLASXLinkResolutionConf#m_bDefaultAllowRemoteDownload. =
539 CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(psRoot, "DefaultResolution.AllowRemoteDownload",
540 ALLOW_REMOTE_DOWNLOAD_DEFAULTcxx . . $ GMLASConstants/ALLOW_REMOTE_DOWNLOAD_DEFAULT.);
541
542 // TODO when we support other modes
543 // m_eDefaultResolutionMode =
544
545 m_nDefaultResolutionDepthcxx . . $ GMLASXLinkResolutionConf#m_nDefaultResolutionDepth. =
546 atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetXMLValue(psRoot, "DefaultResolution.ResolutionDepth", "1"));
547
548 m_bDefaultCacheResultscxx . . $ GMLASXLinkResolutionConf#m_bDefaultCacheResults. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
549 psRoot, "DefaultResolution.CacheResults", CACHE_RESULTS_DEFAULTcxx . . $ GMLASConstants/CACHE_RESULTS_DEFAULT.);
550
551 CPLXMLNodecxx . . $ CPLXMLNode# *psIterURL = psRoot->psChildcxx . . $ CPLXMLNode#psChild.;
552 for (; psIterURL != nullptr; psIterURL = psIterURL->psNextcxx . . $ CPLXMLNode#psNext.)
553 {
554 if (psIterURL->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element &&
555 strcmp(psIterURL->pszValuecxx . . $ CPLXMLNode#pszValue., "URLSpecificResolution") == 0)
556 {
557 GMLASXLinkResolutionConfcxx . . $ GMLASXLinkResolutionConf#::URLSpecificResolutioncxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution# oItem;
558 oItem.m_osURLPrefixcxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#m_osURLPrefix. = CPLGetXMLValue(psIterURL, "URLPrefix", "");
559
560 oItem.m_bAllowRemoteDownloadcxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#m_bAllowRemoteDownload. =
561 CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(psIterURL, "AllowRemoteDownload",
562 ALLOW_REMOTE_DOWNLOAD_DEFAULTcxx . . $ GMLASConstants/ALLOW_REMOTE_DOWNLOAD_DEFAULT.);
563
564 const char *pszResolutionModel =
565 CPLGetXMLValue(psIterURL, "ResolutionMode", "RawContent");
566 if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszResolutionModel, "RawContent"))
567 oItem.m_eResolutionModecxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#m_eResolutionMode. = RawContentcxx . . $ GMLASXLinkResolutionConf#RawContent.;
568 else
569 oItem.m_eResolutionModecxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#m_eResolutionMode. = FieldsFromXPathcxx . . $ GMLASXLinkResolutionConf#FieldsFromXPath.;
570
571 oItem.m_nResolutionDepthcxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#m_nResolutionDepth. =
572 atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetXMLValue(psIterURL, "ResolutionDepth", "1"));
573
574 oItem.m_bCacheResultscxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#m_bCacheResults. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
575 psIterURL, "CacheResults", CACHE_RESULTS_DEFAULTcxx . . $ GMLASConstants/CACHE_RESULTS_DEFAULT.);
576
577 CPLXMLNodecxx . . $ CPLXMLNode# *psIter = psIterURL->psChildcxx . . $ CPLXMLNode#psChild.;
578 for (; psIter != nullptr; psIter = psIter->psNextcxx . . $ CPLXMLNode#psNext.)
579 {
580 if (psIter->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element &&
581 strcmp(psIter->pszValuecxx . . $ CPLXMLNode#pszValue., "HTTPHeader") == 0)
582 {
583 CPLString osName(CPLGetXMLValue(psIter, "Name", ""));
584 CPLString osValue(CPLGetXMLValue(psIter, "Value", ""));
585 oItem.m_aosNameValueHTTPHeaderscxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#m_aosNameValueHTTPHeaders..push_back(
586 stdcxx . . $ std/::pair<CPLString, CPLString>(osName, osValue));
587 }
588 else if (psIter->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element &&
589 strcmp(psIter->pszValuecxx . . $ CPLXMLNode#pszValue., "Field") == 0)
590 {
591 URLSpecificResolutioncxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#::XPathDerivedFieldcxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#XPathDerivedField# oField;
592 oField.m_osNamecxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#XPathDerivedField#m_osName. = CPLGetXMLValue(psIter, "Name", "");
593 oField.m_osTypecxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#XPathDerivedField#m_osType. = CPLGetXMLValue(psIter, "Type", "");
594 oField.m_osXPathcxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#XPathDerivedField#m_osXPath. = CPLGetXMLValue(psIter, "XPath", "");
595 oItem.m_aoFieldscxx . . $ GMLASXLinkResolutionConf#URLSpecificResolution#m_aoFields..push_back(stdcxx . . $ std/::move(oField));
596 }
597 }
598
599 m_aoURLSpecificRulescxx . . $ GMLASXLinkResolutionConf#m_aoURLSpecificRules..push_back(stdcxx . . $ std/::move(oItem));
600 }
601 }
602
603 m_bResolveInternalXLinkscxx . . $ GMLASXLinkResolutionConf#m_bResolveInternalXLinks. = CPLGetXMLBoolValuecxx . . $ CPLGetXMLBoolValue(25aa7ac1e7ece827).(
604 psRoot, "ResolveInternalXLinks", INTERNAL_XLINK_RESOLUTION_DEFAULTcxx . . $ GMLASConstants/INTERNAL_XLINK_RESOLUTION_DEFAULT.);
605
606 return true;
607 }