Debian Codegraph @

ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp

raw symbols SCIP
1 /******************************************************************************
2 *
3 * Project: OGR
4 * Purpose: Implements OGRGMLDataSource class.
5 * Author: Frank Warmerdam, [email protected]
6 *
7 ******************************************************************************
8 * Copyright (c) 2002, Frank Warmerdam <[email protected]>
9 * Copyright (c) 2007-2013, Even Rouault <even dot rouault at spatialys.com>
10 *
11 * SPDX-License-Identifier: MIT
12 *
13 ******************************************************************************
14 * Contributor: Alessandro Furieri, [email protected]
15 * Portions of this module implementing GML_SKIP_RESOLVE_ELEMS HUGE
16 * Developed for Faunalia ( http://www.faunalia.it) with funding from
17 * Regione Toscana - Settore SISTEMA INFORMATIVO TERRITORIALE ED AMBIENTALE
18 *
19 ****************************************************************************/
20
21 #include "cpl_port.h"cxx . . $ `<file>/port/cpl_port.h`/
22 #include "ogr_gml.h"cxx . . $ `<file>/ogr/ogrsf_frmts/gml/ogr_gml.h`/
23
24 #include <algorithm>
25 #include <vector>
26
27 #include "cpl_conv.h"cxx . . $ `<file>/port/cpl_conv.h`/
28 #include "cpl_error.h"cxx . . $ `<file>/port/cpl_error.h`/
29 #include "cpl_http.h"cxx . . $ `<file>/port/cpl_http.h`/
30 #include "cpl_string.h"cxx . . $ `<file>/port/cpl_string.h`/
31 #include "cpl_vsi_error.h"cxx . . $ `<file>/port/cpl_vsi_error.h`/
32 #include "gmlreaderp.h"cxx . . $ `<file>/ogr/ogrsf_frmts/gml/gmlreaderp.h`/
33 #include "gmlregistry.h"cxx . . $ `<file>/ogr/ogrsf_frmts/gml/gmlregistry.h`/
34 #include "gmlutils.h"cxx . . $ `<file>/ogr/ogrsf_frmts/gmlutils/gmlutils.h`/
35 #include "ogr_p.h"cxx . . $ `<file>/ogr/ogr_p.h`/
36 #include "ogr_schema_override.h"cxx . . $ `<file>/ogr/ogr_schema_override.h`/
37 #include "parsexsd.h"cxx . . $ `<file>/ogr/ogrsf_frmts/gmlutils/parsexsd.h`/
38 #include "memdataset.h"cxx . . $ `<file>/frmts/mem/memdataset.h`/
39
40 /************************************************************************/
41 /* ReplaceSpaceByPct20IfNeeded() */
42 /************************************************************************/
43
44 static CPLString ReplaceSpaceByPct20IfNeededcxx . . $ ReplaceSpaceByPct20IfNeeded(a9d72c988d85d6d8).(const char *pszURL)
45 {
46 // Replace ' ' by '%20'.
47 CPLString osRet = pszURL;
48 const char *pszNeedle = strstr(pszURL, "; ");
49 if (pszNeedle)
50 {
51 char *pszTmp = static_cast<char *>(CPLMalloc(strlen(pszURL) + 2 + 1));
52 const int nBeforeNeedle = static_cast<int>(pszNeedle - pszURL);
53 memcpy(pszTmp, pszURL, nBeforeNeedle);
54 strcpy(pszTmp + nBeforeNeedle, ";%20");
55 strcpy(pszTmp + nBeforeNeedle + strlen(";%20"),
56 pszNeedle + strlen("; "));
57 osRet = pszTmp;
58 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszTmp);
59 }
60
61 return osRet;
62 }
63
64 /************************************************************************/
65 /* OGRGMLDataSource() */
66 /************************************************************************/
67
68 OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::OGRGMLDataSourcecxx . . $ OGRGMLDataSource#OGRGMLDataSource(49f6e7a06ebc5aa8).()
69 : papoLayerscxx . . $ OGRGMLDataSource#papoLayers.(nullptr), nLayerscxx . . $ OGRGMLDataSource#nLayers.(0), papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions.(nullptr),
70 fpOutputcxx . . $ OGRGMLDataSource#fpOutput.(nullptr), bFpOutputIsNonSeekablecxx . . $ OGRGMLDataSource#bFpOutputIsNonSeekable.(false),
71 bFpOutputSingleFilecxx . . $ OGRGMLDataSource#bFpOutputSingleFile.(false), bBBOX3Dcxx . . $ OGRGMLDataSource#bBBOX3D.(false), nBoundedByLocationcxx . . $ OGRGMLDataSource#nBoundedByLocation.(-1),
72 nSchemaInsertLocationcxx . . $ OGRGMLDataSource#nSchemaInsertLocation.(-1), bIsOutputGML3cxx . . $ OGRGMLDataSource#bIsOutputGML3.(false),
73 bIsOutputGML3Deegreecxx . . $ OGRGMLDataSource#bIsOutputGML3Deegree.(false), bIsOutputGML32cxx . . $ OGRGMLDataSource#bIsOutputGML32.(false),
74 eSRSNameFormatcxx . . $ OGRGMLDataSource#eSRSNameFormat.(SRSNAME_SHORTcxx . . $ SRSNAME_SHORT.), bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.(true),
75 poReadercxx . . $ OGRGMLDataSource#poReader.(nullptr), bOutIsTempFilecxx . . $ OGRGMLDataSource#bOutIsTempFile.(false), bExposeGMLIdcxx . . $ OGRGMLDataSource#bExposeGMLId.(false),
76 bExposeFidcxx . . $ OGRGMLDataSource#bExposeFid.(false), bIsWFScxx . . $ OGRGMLDataSource#bIsWFS.(false), bUseGlobalSRSNamecxx . . $ OGRGMLDataSource#bUseGlobalSRSName.(false),
77 m_bInvertAxisOrderIfLatLongcxx . . $ OGRGMLDataSource#m_bInvertAxisOrderIfLatLong.(false), m_bConsiderEPSGAsURNcxx . . $ OGRGMLDataSource#m_bConsiderEPSGAsURN.(false),
78 m_eSwapCoordinatescxx . . $ OGRGMLDataSource#m_eSwapCoordinates.(GML_SWAP_AUTOcxx . . $ GML_SWAP_AUTO.), m_bGetSecondaryGeometryOptioncxx . . $ OGRGMLDataSource#m_bGetSecondaryGeometryOption.(false),
79 eReadModecxx . . $ OGRGMLDataSource#eReadMode.(STANDARDcxx . . $ STANDARD.), poStoredGMLFeaturecxx . . $ OGRGMLDataSource#poStoredGMLFeature.(nullptr),
80 poLastReadLayercxx . . $ OGRGMLDataSource#poLastReadLayer.(nullptr), bEmptyAsNullcxx . . $ OGRGMLDataSource#bEmptyAsNull.(true)
81 {
82 }
83
84 /************************************************************************/
85 /* ~OGRGMLDataSource() */
86 /************************************************************************/
87
88 OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::~cxx . . $ OGRGMLDataSource#`~OGRGMLDataSource`(ced63f7c635d850d).OGRGMLDataSourcecxx . . $ OGRGMLDataSource#()
89 {
90 OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::Closecxx . . $ OGRGMLDataSource#Close(6418138aff7e2b45).();
91 }
92
93 /************************************************************************/
94 /* Close() */
95 /************************************************************************/
96
97 CPLErr OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::Closecxx . . $ OGRGMLDataSource#Close(6418138aff7e2b45).(GDALProgressFunc, void *)
98 {
99 CPLErr eErr = CE_None;
100 if (nOpenFlagscxx . . $ GDALDataset#nOpenFlags. != OPEN_FLAGS_CLOSEDcxx . . $ GDALDataset#OPEN_FLAGS_CLOSED.)
101 {
102 if (fpOutputcxx . . $ OGRGMLDataSource#fpOutput. && !m_bWriteErrorcxx . . $ OGRGMLDataSource#m_bWriteError.)
103 {
104 if (nLayerscxx . . $ OGRGMLDataSource#nLayers. == 0)
105 WriteTopElementscxx . . $ OGRGMLDataSource#WriteTopElements(49f6e7a06ebc5aa8).();
106
107 const char *pszPrefix = GetAppPrefixcxx . . $ OGRGMLDataSource#GetAppPrefix(a9f41ea0e82d88cf).();
108 if (GMLFeatureCollectioncxx . . $ OGRGMLDataSource#GMLFeatureCollection(50ce9a9e25b4a850).())
109 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "</gml:FeatureCollection>");
110 else if (RemoveAppPrefixcxx . . $ OGRGMLDataSource#RemoveAppPrefix(50ce9a9e25b4a850).())
111 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "</FeatureCollection>");
112 else
113 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "</%s:FeatureCollection>", pszPrefix);
114
115 if (bFpOutputIsNonSeekablecxx . . $ OGRGMLDataSource#bFpOutputIsNonSeekable.)
116 {
117 VSIFCloseL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput.);
118 fpOutputcxx . . $ OGRGMLDataSource#fpOutput. = nullptr;
119 }
120
121 InsertHeadercxx . . $ OGRGMLDataSource#InsertHeader(49f6e7a06ebc5aa8).();
122
123 if (!bFpOutputIsNonSeekablecxx . . $ OGRGMLDataSource#bFpOutputIsNonSeekable. && nBoundedByLocationcxx . . $ OGRGMLDataSource#nBoundedByLocation. != -1 &&
124 VSIFSeekL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput.,
125 static_cast<vsi_l_offset>(nBoundedByLocationcxx . . $ OGRGMLDataSource#nBoundedByLocation.),
126 SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!) == 0)
127 {
128 if (m_bWriteGlobalSRScxx . . $ OGRGMLDataSource#m_bWriteGlobalSRS. && sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..IsInit() &&
129 IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).())
130 {
131 bool bCoordSwap = false;
132 char *pszSRSName =
133 m_poWriteGlobalSRScxx . . $ OGRGMLDataSource#m_poWriteGlobalSRS.
134 ? GML_GetSRSNamecxx . . $ GML_GetSRSName(30d61418dc65e8e3).(m_poWriteGlobalSRScxx . . $ OGRGMLDataSource#m_poWriteGlobalSRS..getcxx . . $ OGRRefCountedPtrBase#get(5a2a78a048fb49a8).(),
135 eSRSNameFormatcxx . . $ OGRGMLDataSource#eSRSNameFormat., &bCoordSwap)
136 : CPLStrdup("");
137 char szLowerCorner[75] = {};
138 char szUpperCorner[75] = {};
139
140 OGRWktOptionscxx . . $ OGRWktOptions# coordOptscxx . . $ OGRWktOptions#OGRWktOptions(49f6e7a06ebc5aa8).;
141
142 if (OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::GetLayerCountcxx . . $ OGRGMLDataSource#GetLayerCount(455f465bc33b4cdf).() == 1)
143 {
144 OGRLayercxx . . $ OGRLayer# *poLayer = OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::GetLayercxx . . $ GDALDataset#GetLayer(7a9909270c12ab7d).(0);
145 if (poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).() == 1)
146 {
147 const auto &oCoordPrec =
148 poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()
149 ->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)
150 ->GetCoordinatePrecisioncxx . . $ OGRGeomFieldDefn#GetCoordinatePrecision(4cbff8bea018030e).();
151 if (oCoordPrec.dfXYResolutioncxx . . $ OGRGeomCoordinatePrecision#dfXYResolution. !=
152 OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN.)
153 {
154 coordOpts.formatcxx . . $ OGRWktOptions#format. = OGRWktFormatcxx . . $ OGRWktFormat#::Fcxx . . $ OGRWktFormat#F.;
155 coordOpts.xyPrecisioncxx . . $ OGRWktOptions#xyPrecision. =
156 OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::
157 ResolutionToPrecisioncxx . . $ OGRGeomCoordinatePrecision#ResolutionToPrecision(620b9ac44d2573a6).(
158 oCoordPrec.dfXYResolutioncxx . . $ OGRGeomCoordinatePrecision#dfXYResolution.);
159 }
160 if (oCoordPrec.dfZResolutioncxx . . $ OGRGeomCoordinatePrecision#dfZResolution. !=
161 OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN.)
162 {
163 coordOpts.formatcxx . . $ OGRWktOptions#format. = OGRWktFormatcxx . . $ OGRWktFormat#::Fcxx . . $ OGRWktFormat#F.;
164 coordOpts.zPrecisioncxx . . $ OGRWktOptions#zPrecision. =
165 OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::
166 ResolutionToPrecisioncxx . . $ OGRGeomCoordinatePrecision#ResolutionToPrecision(620b9ac44d2573a6).(
167 oCoordPrec.dfZResolutioncxx . . $ OGRGeomCoordinatePrecision#dfZResolution.);
168 }
169 }
170 }
171
172 stdcxx . . $ std/::string wkt;
173 if (bCoordSwap)
174 {
175 wkt = OGRMakeWktCoordinatecxx . . $ OGRMakeWktCoordinate(a84276fb309939f2).(
176 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinY, sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinX,
177 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinZ, bBBOX3Dcxx . . $ OGRGMLDataSource#bBBOX3D. ? 3 : 2, coordOpts);
178 memcpy(szLowerCorner, wkt.data(), wkt.size() + 1);
179
180 wkt = OGRMakeWktCoordinatecxx . . $ OGRMakeWktCoordinate(a84276fb309939f2).(
181 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxY, sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxX,
182 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxZ, bBBOX3Dcxx . . $ OGRGMLDataSource#bBBOX3D. ? 3 : 2, coordOpts);
183 memcpy(szUpperCorner, wkt.data(), wkt.size() + 1);
184 }
185 else
186 {
187 wkt = OGRMakeWktCoordinatecxx . . $ OGRMakeWktCoordinate(a84276fb309939f2).(
188 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinX, sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinY,
189 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinZ, bBBOX3Dcxx . . $ OGRGMLDataSource#bBBOX3D. ? 3 : 2, coordOpts);
190 memcpy(szLowerCorner, wkt.data(), wkt.size() + 1);
191
192 wkt = OGRMakeWktCoordinatecxx . . $ OGRMakeWktCoordinate(a84276fb309939f2).(
193 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxX, sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxY,
194 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxZ, (bBBOX3Dcxx . . $ OGRGMLDataSource#bBBOX3D.) ? 3 : 2, coordOpts);
195 memcpy(szUpperCorner, wkt.data(), wkt.size() + 1);
196 }
197 if (bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.)
198 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " ");
199 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
200 fpOutputcxx . . $ OGRGMLDataSource#fpOutput.,
201 "<gml:boundedBy><gml:Envelope%s%s><gml:lowerCorner>%s"
202 "</gml:lowerCorner><gml:upperCorner>%s</"
203 "gml:upperCorner>"
204 "</gml:Envelope></gml:boundedBy>",
205 bBBOX3Dcxx . . $ OGRGMLDataSource#bBBOX3D. ? " srsDimension=\"3\"" : "", pszSRSName,
206 szLowerCorner, szUpperCorner);
207 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszSRSName);
208 }
209 else if (m_bWriteGlobalSRScxx . . $ OGRGMLDataSource#m_bWriteGlobalSRS. && sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..IsInit())
210 {
211 if (bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.)
212 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " ");
213 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "<gml:boundedBy>");
214 if (bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.)
215 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " ");
216 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "<gml:Box>");
217 if (bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.)
218 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " ");
219 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput.,
220 "<gml:coord><gml:X>%.16g</gml:X>"
221 "<gml:Y>%.16g</gml:Y>",
222 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinX, sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinY);
223 if (bBBOX3Dcxx . . $ OGRGMLDataSource#bBBOX3D.)
224 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "<gml:Z>%.16g</gml:Z>",
225 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinZ);
226 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "</gml:coord>");
227 if (bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.)
228 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " ");
229 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput.,
230 "<gml:coord><gml:X>%.16g</gml:X>"
231 "<gml:Y>%.16g</gml:Y>",
232 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxX, sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxY);
233 if (bBBOX3Dcxx . . $ OGRGMLDataSource#bBBOX3D.)
234 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "<gml:Z>%.16g</gml:Z>",
235 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxZ);
236 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "</gml:coord>");
237 if (bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.)
238 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " ");
239 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "</gml:Box>");
240 if (bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.)
241 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " ");
242 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "</gml:boundedBy>");
243 }
244 else
245 {
246 if (bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.)
247 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " ");
248 if (IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).())
249 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
250 fpOutputcxx . . $ OGRGMLDataSource#fpOutput.,
251 "<gml:boundedBy><gml:Null /></gml:boundedBy>");
252 else
253 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "<gml:boundedBy><gml:null>missing"
254 "</gml:null></gml:boundedBy>");
255 }
256 }
257 }
258
259 if (fpOutputcxx . . $ OGRGMLDataSource#fpOutput.)
260 VSIFCloseL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput.);
261 fpOutputcxx . . $ OGRGMLDataSource#fpOutput. = nullptr;
262
263 CSLDestroy(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions.);
264 papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions. = nullptr;
265
266 for (int i = 0; i < nLayerscxx . . $ OGRGMLDataSource#nLayers.; i++)
267 delete papoLayerscxx . . $ OGRGMLDataSource#papoLayers.[i];
268 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(papoLayerscxx . . $ OGRGMLDataSource#papoLayers.);
269 papoLayerscxx . . $ OGRGMLDataSource#papoLayers. = nullptr;
270 nLayerscxx . . $ OGRGMLDataSource#nLayers. = 0;
271
272 if (poReadercxx . . $ OGRGMLDataSource#poReader.)
273 {
274 if (bOutIsTempFilecxx . . $ OGRGMLDataSource#bOutIsTempFile.)
275 VSIUnlink(poReadercxx . . $ OGRGMLDataSource#poReader.->GetSourceFileNamecxx . . $ IGMLReader#GetSourceFileName(33a1f659e94feb42).());
276 delete poReadercxx . . $ OGRGMLDataSource#poReader.;
277 poReadercxx . . $ OGRGMLDataSource#poReader. = nullptr;
278 }
279
280 poStoredGMLFeaturecxx . . $ OGRGMLDataSource#poStoredGMLFeature..reset();
281
282 if (m_bUnlinkXSDFilenamecxx . . $ OGRGMLDataSource#m_bUnlinkXSDFilename.)
283 {
284 VSIUnlink(osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename.);
285 m_bUnlinkXSDFilenamecxx . . $ OGRGMLDataSource#m_bUnlinkXSDFilename. = false;
286 }
287
288 if (m_bWriteErrorcxx . . $ OGRGMLDataSource#m_bWriteError.)
289 eErr = CE_Failure;
290 }
291 return eErr;
292 }
293
294 /************************************************************************/
295 /* CheckHeader() */
296 /************************************************************************/
297
298 bool OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::CheckHeadercxx . . $ OGRGMLDataSource#CheckHeader(c5f7da30cbc0f4e9).(const char *pszStr)
299 {
300 if (strstr(pszStr, "<wfs:FeatureCollection ") != nullptr)
301 return true;
302
303 if (strstr(pszStr, "opengis.net/gml") == nullptr &&
304 strstr(pszStr, "<csw:GetRecordsResponse") == nullptr)
305 {
306 return false;
307 }
308
309 // Ignore kml files
310 if (strstr(pszStr, "<kml") != nullptr)
311 {
312 return false;
313 }
314
315 // Ignore .xsd schemas.
316 if (strstr(pszStr, "<schema") != nullptr ||
317 strstr(pszStr, "<xs:schema") != nullptr ||
318 strstr(pszStr, "<xsd:schema") != nullptr)
319 {
320 return false;
321 }
322
323 // Ignore GeoRSS documents. They will be recognized by the GeoRSS driver.
324 if (strstr(pszStr, "<rss") != nullptr &&
325 strstr(pszStr, "xmlns:georss") != nullptr)
326 {
327 return false;
328 }
329
330 // Ignore OpenJUMP .jml documents.
331 // They will be recognized by the OpenJUMP driver.
332 if (strstr(pszStr, "<JCSDataFile") != nullptr)
333 {
334 return false;
335 }
336
337 // Ignore OGR WFS xml description files, or WFS Capabilities results.
338 if (strstr(pszStr, "<OGRWFSDataSource>") != nullptr ||
339 strstr(pszStr, "<wfs:WFS_Capabilities") != nullptr)
340 {
341 return false;
342 }
343
344 // Ignore WMTS capabilities results.
345 if (strstr(pszStr, "http://www.opengis.net/wmts/1.0") != nullptr)
346 {
347 return false;
348 }
349
350 return true;
351 }
352
353 /************************************************************************/
354 /* ExtractSRSName() */
355 /************************************************************************/
356
357 static bool ExtractSRSNamecxx . . $ ExtractSRSName(64fcc95e299940b4).(const char *pszXML, char *szSRSName,
358 size_t sizeof_szSRSName)
359 {
360 szSRSName[0] = '\0';
361
362 const char *pszSRSName = strstr(pszXML, "srsName=\"");
363 if (pszSRSName != nullptr)
364 {
365 pszSRSName += 9;
366 const char *pszEndQuote = strchr(pszSRSName, '"');
367 if (pszEndQuote != nullptr &&
368 static_cast<size_t>(pszEndQuote - pszSRSName) < sizeof_szSRSName)
369 {
370 memcpy(szSRSName, pszSRSName, pszEndQuote - pszSRSName);
371 szSRSName[pszEndQuote - pszSRSName] = '\0';
372 return true;
373 }
374 }
375 return false;
376 }
377
378 /************************************************************************/
379 /* Open() */
380 /************************************************************************/
381
382 bool OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::Opencxx . . $ OGRGMLDataSource#Open(8e59e7504f0850f4).(GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo)
383
384 {
385 // Extract XSD filename from connection string if present.
386 osFilenamecxx . . $ OGRGMLDataSource#osFilename. = poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.;
387 const char *pszXSDFilenameTmp = strstr(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename., ",xsd=");
388 if (pszXSDFilenameTmp != nullptr)
389 {
390 osFilenamecxx . . $ OGRGMLDataSource#osFilename..resize(pszXSDFilenameTmp - poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.);
391 osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename. = pszXSDFilenameTmp + strlen(",xsd=");
392 }
393 else
394 {
395 osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename. =
396 CSLFetchNameValueDef(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "XSD", "");
397 }
398
399 const char *pszFilename = osFilenamecxx . . $ OGRGMLDataSource#osFilename..c_str();
400
401 // Open the source file.
402 VSILFILE *fpToClose = nullptr;
403 VSILFILE *fp = nullptr;
404 if (poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL. != nullptr)
405 {
406 fp = poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL.;
407 VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fp, 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!);
408 }
409 else
410 {
411 fp = VSIFOpenL(pszFilename, "r");
412 if (fp == nullptr)
413 return false;
414 fpToClose = fp;
415 }
416
417 // Load a header chunk and check for signs it is GML.
418 char szHeader[4096] = {};
419 size_t nRead = VSIFReadL(szHeader, 1, sizeof(szHeader) - 1, fp);
420 if (nRead == 0)
421 {
422 if (fpToClose)
423 VSIFCloseL(fpToClose);
424 return false;
425 }
426 szHeader[nRead] = '\0';
427
428 CPLString osWithVsiGzip;
429
430 // Might be a OS-Mastermap gzipped GML, so let be nice and try to open
431 // it transparently with /vsigzip/.
432 if (static_cast<GBytecxx . . $ GByte#>(szHeader[0]) == 0x1f &&
433 static_cast<GBytecxx . . $ GByte#>(szHeader[1]) == 0x8b &&
434 EQUALcxx . . $ `port/cpl_port.h:532:9`!(CPLGetExtensionSafe(pszFilename).c_str(), "gz") &&
435 !STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszFilename, "/vsigzip/"))
436 {
437 if (fpToClose)
438 VSIFCloseL(fpToClose);
439 fpToClose = nullptr;
440 osWithVsiGzip = "/vsigzip/";
441 osWithVsiGzip += pszFilename;
442
443 pszFilename = osWithVsiGzip;
444
445 fp = fpToClose = VSIFOpenL(pszFilename, "r");
446 if (fp == nullptr)
447 return false;
448
449 nRead = VSIFReadL(szHeader, 1, sizeof(szHeader) - 1, fp);
450 if (nRead == 0)
451 {
452 VSIFCloseL(fpToClose);
453 return false;
454 }
455 szHeader[nRead] = '\0';
456 }
457
458 // Check for a UTF-8 BOM and skip if found.
459
460 // TODO: BOM is variable-length parameter and depends on encoding. */
461 // Add BOM detection for other encodings.
462
463 // Used to skip to actual beginning of XML data
464 char *szPtr = szHeader;
465
466 if ((static_cast<unsigned char>(szHeader[0]) == 0xEF) &&
467 (static_cast<unsigned char>(szHeader[1]) == 0xBB) &&
468 (static_cast<unsigned char>(szHeader[2]) == 0xBF))
469 {
470 szPtr += 3;
471 }
472
473 bool bExpatCompatibleEncoding = false;
474
475 const char *pszEncoding = strstr(szPtr, "encoding=");
476 if (pszEncoding)
477 bExpatCompatibleEncoding =
478 (pszEncoding[9] == '\'' || pszEncoding[9] == '"') &&
479 (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszEncoding + 10, "UTF-8") ||
480 STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszEncoding + 10, "ISO-8859-15") ||
481 (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszEncoding + 10, "ISO-8859-1") &&
482 pszEncoding[20] == pszEncoding[9]));
483 else
484 bExpatCompatibleEncoding = true; // utf-8 is the default.
485
486 const bool bHas3D = strstr(szPtr, "srsDimension=\"3\"") != nullptr ||
487 strstr(szPtr, "<gml:Z>") != nullptr;
488
489 // Here, we expect the opening chevrons of GML tree root element.
490 if (szPtr[0] != '<' || !CheckHeadercxx . . $ OGRGMLDataSource#CheckHeader(c5f7da30cbc0f4e9).(szPtr))
491 {
492 if (fpToClose)
493 VSIFCloseL(fpToClose);
494 return false;
495 }
496
497 // Now we definitely own the file descriptor.
498 if (fp == poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL.)
499 poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL. = nullptr;
500
501 // Small optimization: if we parse a <wfs:FeatureCollection> and
502 // that numberOfFeatures is set, we can use it to set the FeatureCount
503 // but *ONLY* if there's just one class.
504 const char *pszFeatureCollection = strstr(szPtr, "wfs:FeatureCollection");
505 if (pszFeatureCollection == nullptr)
506 // GML 3.2.1 output.
507 pszFeatureCollection = strstr(szPtr, "gml:FeatureCollection");
508 if (pszFeatureCollection == nullptr)
509 {
510 // Deegree WFS 1.0.0 output.
511 pszFeatureCollection = strstr(szPtr, "<FeatureCollection");
512 if (pszFeatureCollection &&
513 strstr(szPtr, "xmlns:wfs=\"http://www.opengis.net/wfs\"") ==
514 nullptr)
515 pszFeatureCollection = nullptr;
516 }
517
518 GIntBigcxx . . $ GIntBig# nNumberOfFeatures = 0;
519 if (pszFeatureCollection)
520 {
521 bExposeGMLIdcxx . . $ OGRGMLDataSource#bExposeGMLId. = true;
522 bIsWFScxx . . $ OGRGMLDataSource#bIsWFS. = true;
523 const char *pszNumberOfFeatures = strstr(szPtr, "numberOfFeatures=");
524 if (pszNumberOfFeatures)
525 {
526 pszNumberOfFeatures += 17;
527 char ch = pszNumberOfFeatures[0];
528 if ((ch == '\'' || ch == '"') &&
529 strchr(pszNumberOfFeatures + 1, ch) != nullptr)
530 {
531 nNumberOfFeatures = CPLAtoGIntBig(pszNumberOfFeatures + 1);
532 }
533 }
534 else if ((pszNumberOfFeatures = strstr(szPtr, "numberReturned=")) !=
535 nullptr)
536 {
537 // WFS 2.0.0
538 pszNumberOfFeatures += 15;
539 char ch = pszNumberOfFeatures[0];
540 if ((ch == '\'' || ch == '"') &&
541 strchr(pszNumberOfFeatures + 1, ch) != nullptr)
542 {
543 // 'unknown' might be a valid value in a corrected version of
544 // WFS 2.0 but it will also evaluate to 0, that is considered as
545 // unknown, so nothing particular to do.
546 nNumberOfFeatures = CPLAtoGIntBig(pszNumberOfFeatures + 1);
547 }
548 }
549 }
550 else if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszFilename, "/vsimem/") &&
551 strstr(pszFilename, "_ogr_wfs_"))
552 {
553 // http://regis.intergraph.com/wfs/dcmetro/request.asp? returns a
554 // <G:FeatureCollection> Who knows what servers can return? When
555 // in the context of the WFS driver always expose the gml:id to avoid
556 // later crashes.
557 bExposeGMLIdcxx . . $ OGRGMLDataSource#bExposeGMLId. = true;
558 bIsWFScxx . . $ OGRGMLDataSource#bIsWFS. = true;
559 }
560 else
561 {
562 bExposeGMLIdcxx . . $ OGRGMLDataSource#bExposeGMLId. = strstr(szPtr, " gml:id=\"") != nullptr ||
563 strstr(szPtr, " gml:id='") != nullptr;
564 bExposeFidcxx . . $ OGRGMLDataSource#bExposeFid. = strstr(szPtr, " fid=\"") != nullptr ||
565 strstr(szPtr, " fid='") != nullptr;
566 }
567
568 const char *pszExposeGMLId =
569 CSLFetchNameValueDef(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "EXPOSE_GML_ID",
570 CPLGetConfigOption("GML_EXPOSE_GML_ID", nullptr));
571 if (pszExposeGMLId)
572 bExposeGMLIdcxx . . $ OGRGMLDataSource#bExposeGMLId. = CPLTestBool(pszExposeGMLId);
573
574 const char *pszExposeFid =
575 CSLFetchNameValueDef(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "EXPOSE_FID",
576 CPLGetConfigOption("GML_EXPOSE_FID", nullptr));
577
578 if (pszExposeFid)
579 bExposeFidcxx . . $ OGRGMLDataSource#bExposeFid. = CPLTestBool(pszExposeFid);
580
581 const bool bHintConsiderEPSGAsURN =
582 strstr(szPtr, "xmlns:fme=\"http://www.safe.com/gml/fme\"") != nullptr;
583
584 char szSRSName[128] = {};
585
586 // MTKGML.
587 if (strstr(szPtr, "<Maastotiedot") != nullptr)
588 {
589 if (strstr(szPtr,
590 "http://xml.nls.fi/XML/Namespace/"
591 "Maastotietojarjestelma/SiirtotiedostonMalli/2011-02") ==
592 nullptr)
593 CPLDebug("GML", "Warning: a MTKGML file was detected, "
594 "but its namespace is unknown");
595 bUseGlobalSRSNamecxx . . $ OGRGMLDataSource#bUseGlobalSRSName. = true;
596 if (!ExtractSRSNamecxx . . $ ExtractSRSName(64fcc95e299940b4).(szPtr, szSRSName, sizeof(szSRSName)))
597 strcpy(szSRSName, "EPSG:3067");
598 }
599
600 const char *pszSchemaLocation = strstr(szPtr, "schemaLocation=");
601 if (pszSchemaLocation)
602 pszSchemaLocation += strlen("schemaLocation=");
603
604 bool bCheckAuxFile = true;
605 if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszFilename, "/vsicurl_streaming/"))
606 bCheckAuxFile = false;
607 else if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszFilename, "/vsicurl/") &&
608 (strstr(pszFilename, "?SERVICE=") ||
609 strstr(pszFilename, "&SERVICE=")))
610 bCheckAuxFile = false;
611
612 bool bIsWFSJointLayer = bIsWFScxx . . $ OGRGMLDataSource#bIsWFS. && strstr(szPtr, "<wfs:Tuple>");
613 if (bIsWFSJointLayer)
614 bExposeGMLIdcxx . . $ OGRGMLDataSource#bExposeGMLId. = false;
615
616 // We assume now that it is GML. Instantiate a GMLReader on it.
617 const char *pszReadMode =
618 CSLFetchNameValueDef(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "READ_MODE",
619 CPLGetConfigOption("GML_READ_MODE", "AUTO"));
620 if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszReadMode, "AUTO"))
621 pszReadMode = nullptr;
622 if (pszReadMode == nullptr || EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszReadMode, "STANDARD"))
623 eReadModecxx . . $ OGRGMLDataSource#eReadMode. = STANDARDcxx . . $ STANDARD.;
624 else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszReadMode, "SEQUENTIAL_LAYERS"))
625 eReadModecxx . . $ OGRGMLDataSource#eReadMode. = SEQUENTIAL_LAYERScxx . . $ SEQUENTIAL_LAYERS.;
626 else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszReadMode, "INTERLEAVED_LAYERS"))
627 eReadModecxx . . $ OGRGMLDataSource#eReadMode. = INTERLEAVED_LAYERScxx . . $ INTERLEAVED_LAYERS.;
628 else
629 {
630 CPLDebug("GML",
631 "Unrecognized value for GML_READ_MODE configuration option.");
632 }
633
634 m_bInvertAxisOrderIfLatLongcxx . . $ OGRGMLDataSource#m_bInvertAxisOrderIfLatLong. = CPLTestBool(CSLFetchNameValueDef(
635 poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "INVERT_AXIS_ORDER_IF_LAT_LONG",
636 CPLGetConfigOption("GML_INVERT_AXIS_ORDER_IF_LAT_LONG", "YES")));
637
638 const char *pszConsiderEPSGAsURN = CSLFetchNameValueDef(
639 poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "CONSIDER_EPSG_AS_URN",
640 CPLGetConfigOption("GML_CONSIDER_EPSG_AS_URN", "AUTO"));
641 if (!EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszConsiderEPSGAsURN, "AUTO"))
642 m_bConsiderEPSGAsURNcxx . . $ OGRGMLDataSource#m_bConsiderEPSGAsURN. = CPLTestBool(pszConsiderEPSGAsURN);
643 else if (bHintConsiderEPSGAsURN)
644 {
645 // GML produced by FME (at least CanVec GML) seem to honour EPSG axis
646 // ordering.
647 CPLDebug("GML", "FME-produced GML --> "
648 "consider that GML_CONSIDER_EPSG_AS_URN is set to YES");
649 m_bConsiderEPSGAsURNcxx . . $ OGRGMLDataSource#m_bConsiderEPSGAsURN. = true;
650 }
651 else
652 {
653 m_bConsiderEPSGAsURNcxx . . $ OGRGMLDataSource#m_bConsiderEPSGAsURN. = false;
654 }
655
656 const char *pszSwapCoordinates = CSLFetchNameValueDef(
657 poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "SWAP_COORDINATES",
658 CPLGetConfigOption("GML_SWAP_COORDINATES", "AUTO"));
659 m_eSwapCoordinatescxx . . $ OGRGMLDataSource#m_eSwapCoordinates. = EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSwapCoordinates, "AUTO") ? GML_SWAP_AUTOcxx . . $ GML_SWAP_AUTO.
660 : CPLTestBool(pszSwapCoordinates) ? GML_SWAP_YEScxx . . $ GML_SWAP_YES.
661 : GML_SWAP_NOcxx . . $ GML_SWAP_NO.;
662
663 m_bGetSecondaryGeometryOptioncxx . . $ OGRGMLDataSource#m_bGetSecondaryGeometryOption. =
664 CPLTestBool(CPLGetConfigOption("GML_GET_SECONDARY_GEOM", "NO"));
665
666 // EXPAT is faster than Xerces, so when it is safe to use it, use it!
667 // The only interest of Xerces is for rare encodings that Expat doesn't
668 // handle, but UTF-8 is well handled by Expat.
669 bool bUseExpatParserPreferably = bExpatCompatibleEncoding;
670
671 // Override default choice.
672 const char *pszGMLParser = CPLGetConfigOption("GML_PARSER", nullptr);
673 if (pszGMLParser)
674 {
675 if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszGMLParser, "EXPAT"))
676 bUseExpatParserPreferably = true;
677 else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszGMLParser, "XERCES"))
678 bUseExpatParserPreferably = false;
679 }
680
681 poReadercxx . . $ OGRGMLDataSource#poReader. =
682 CreateGMLReadercxx . . $ CreateGMLReader(bf5b963d5935fa41).(bUseExpatParserPreferably, m_bInvertAxisOrderIfLatLongcxx . . $ OGRGMLDataSource#m_bInvertAxisOrderIfLatLong.,
683 m_bConsiderEPSGAsURNcxx . . $ OGRGMLDataSource#m_bConsiderEPSGAsURN., m_eSwapCoordinatescxx . . $ OGRGMLDataSource#m_eSwapCoordinates.,
684 m_bGetSecondaryGeometryOptioncxx . . $ OGRGMLDataSource#m_bGetSecondaryGeometryOption.);
685 if (poReadercxx . . $ OGRGMLDataSource#poReader. == nullptr)
686 {
687 CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
688 "File %s appears to be GML but the GML reader can't\n"
689 "be instantiated, likely because Xerces or Expat support was\n"
690 "not configured in.",
691 pszFilename);
692 VSIFCloseL(fp);
693 return false;
694 }
695
696 poReadercxx . . $ OGRGMLDataSource#poReader.->SetSourceFilecxx . . $ IGMLReader#SetSourceFile(85c52e162fed56f9).(pszFilename);
697 auto poGMLReader = cpl::down_cast<GMLReadercxx . . $ GMLReader# *>(poReadercxx . . $ OGRGMLDataSource#poReader.);
698 poGMLReader->SetIsWFSJointLayercxx . . $ GMLReader#SetIsWFSJointLayer(b45ddcbc8423892c).(bIsWFSJointLayer);
699 bEmptyAsNullcxx . . $ OGRGMLDataSource#bEmptyAsNull. =
700 CPLFetchBool(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "EMPTY_AS_NULL", true);
701 poGMLReader->SetEmptyAsNullcxx . . $ GMLReader#SetEmptyAsNull(b45ddcbc8423892c).(bEmptyAsNullcxx . . $ OGRGMLDataSource#bEmptyAsNull.);
702 poGMLReader->SetReportAllAttributescxx . . $ GMLReader#SetReportAllAttributes(b45ddcbc8423892c).(CPLFetchBool(
703 poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "GML_ATTRIBUTES_TO_OGR_FIELDS",
704 CPLTestBool(CPLGetConfigOption("GML_ATTRIBUTES_TO_OGR_FIELDS", "NO"))));
705 poGMLReader->SetUseBBOXcxx . . $ GMLReader#SetUseBBOX(b45ddcbc8423892c).(
706 CPLFetchBool(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "USE_BBOX", false));
707
708 // Find <gml:description>, <gml:name> and <gml:boundedBy> and if it is
709 // a standalone geometry
710 // Also look for <gml:description>, <gml:identifier> and <gml:name> inside
711 // a feature
712 FindAndParseTopElementscxx . . $ OGRGMLDataSource#FindAndParseTopElements(c6d3c1ec18bf8a4a).(fp);
713
714 if (m_poStandaloneGeomcxx . . $ OGRGMLDataSource#m_poStandaloneGeom.)
715 {
716 papoLayerscxx . . $ OGRGMLDataSource#papoLayers. = static_cast<OGRLayercxx . . $ OGRLayer# **>(CPLMalloc(sizeof(OGRLayercxx . . $ OGRLayer# *)));
717 nLayerscxx . . $ OGRGMLDataSource#nLayers. = 1;
718 auto poLayer = new OGRMemLayercxx . . $ OGRMemLayer#OGRMemLayer(d19689c4c43be45a).(
719 "geometry",
720 m_oStandaloneGeomSRScxx . . $ OGRGMLDataSource#m_oStandaloneGeomSRS..IsEmptycxx . . $ OGRSpatialReference#IsEmpty(50ce9a9e25b4a850).() ? nullptr : &m_oStandaloneGeomSRScxx . . $ OGRGMLDataSource#m_oStandaloneGeomSRS.,
721 m_poStandaloneGeomcxx . . $ OGRGMLDataSource#m_poStandaloneGeom.->getGeometryTypecxx . . $ OGRGeometry#getGeometryType(5a40c54c5ff210ce).());
722 papoLayerscxx . . $ OGRGMLDataSource#papoLayers.[0] = poLayer;
723 auto poFeature = stdcxx . . $ std/::make_unique<OGRFeaturecxx . . $ OGRFeature#>(poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).());
724 poFeature->SetGeometrycxx . . $ OGRFeature#SetGeometry(409c5ef120a740b2).(stdcxx . . $ std/::move(m_poStandaloneGeomcxx . . $ OGRGMLDataSource#m_poStandaloneGeom.));
725 CPL_IGNORE_RET_VAL(poLayer->CreateFeaturecxx . . $ OGRLayer#CreateFeature(976bf09313a7fd5).(stdcxx . . $ std/::move(poFeature)));
726 poLayer->SetUpdatablecxx . . $ OGRMemLayer#SetUpdatable(b45ddcbc8423892c).(false);
727 VSIFCloseL(fp);
728 return true;
729 }
730
731 if (szSRSName[0] != '\0')
732 poReadercxx . . $ OGRGMLDataSource#poReader.->SetGlobalSRSNamecxx . . $ IGMLReader#SetGlobalSRSName(85c52e162fed56f9).(szSRSName);
733
734 const bool bIsWFSFromServer =
735 CPLString(pszFilename).ifind("SERVICE=WFS") != stdcxx . . $ std/::string::npos;
736
737 // Resolve the xlinks in the source file and save it with the
738 // extension ".resolved.gml". The source file will to set to that.
739 char *pszXlinkResolvedFilename = nullptr;
740 const char *pszOption = CPLGetConfigOption("GML_SAVE_RESOLVED_TO", nullptr);
741 bool bResolve = true;
742 bool bHugeFile = false;
743 if (bIsWFSFromServer ||
744 (pszOption != nullptr && STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszOption, "SAME")))
745 {
746 // "SAME" will overwrite the existing gml file.
747 pszXlinkResolvedFilename = CPLStrdup(pszFilename);
748 }
749 else if (pszOption != nullptr && CPLStrnlen(pszOption, 5) >= 5 &&
750 STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszOption - 4 + strlen(pszOption), ".gml"))
751 {
752 // Any string ending with ".gml" will try and write to it.
753 pszXlinkResolvedFilename = CPLStrdup(pszOption);
754 }
755 else
756 {
757 // When no option is given or is not recognised,
758 // use the same file name with the extension changed to .resolved.gml
759 pszXlinkResolvedFilename = CPLStrdup(
760 CPLResetExtensionSafe(pszFilename, "resolved.gml").c_str());
761
762 // Check if the file already exists.
763 VSIStatBufL sResStatBuf, sGMLStatBuf;
764 if (bCheckAuxFile &&
765 VSIStatL(pszXlinkResolvedFilename, &sResStatBuf) == 0)
766 {
767 if (VSIStatL(pszFilename, &sGMLStatBuf) == 0 &&
768 sGMLStatBuf.st_mtimecxx . . $ `<external>/16045971866008360577/struct_stat.h:78:11`! > sResStatBuf.st_mtimecxx . . $ `<external>/16045971866008360577/struct_stat.h:78:11`!)
769 {
770 CPLDebug("GML",
771 "Found %s but ignoring because it appears\n"
772 "be older than the associated GML file.",
773 pszXlinkResolvedFilename);
774 }
775 else
776 {
777 poReadercxx . . $ OGRGMLDataSource#poReader.->SetSourceFilecxx . . $ IGMLReader#SetSourceFile(85c52e162fed56f9).(pszXlinkResolvedFilename);
778 bResolve = false;
779 }
780 }
781 }
782
783 const char *pszSkipOption = CSLFetchNameValueDef(
784 poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "SKIP_RESOLVE_ELEMS",
785 CPLGetConfigOption("GML_SKIP_RESOLVE_ELEMS", "ALL"));
786
787 char **papszSkip = nullptr;
788 if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSkipOption, "ALL"))
789 bResolve = false;
790 else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSkipOption, "HUGE"))
791 // Exactly as NONE, but intended for HUGE files
792 bHugeFile = true;
793 else if (!EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSkipOption, "NONE")) // Use this to resolve everything.
794 papszSkip = CSLTokenizeString2(
795 pszSkipOption, ",", CSLT_STRIPLEADSPACEScxx . . $ `port/cpl_string.h:78:9`! | CSLT_STRIPENDSPACEScxx . . $ `port/cpl_string.h:80:9`!);
796 bool bHaveSchema = false;
797 bool bSchemaDone = false;
798
799 // Is some GML Feature Schema (.gfs) TEMPLATE required?
800 const char *pszGFSTemplateName =
801 CSLFetchNameValueDef(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "GFS_TEMPLATE",
802 CPLGetConfigOption("GML_GFS_TEMPLATE", nullptr));
803 if (pszGFSTemplateName != nullptr)
804 {
805 // Attempt to load the GFS TEMPLATE.
806 bHaveSchema = poReadercxx . . $ OGRGMLDataSource#poReader.->LoadClassescxx . . $ IGMLReader#LoadClasses(c5f7da30cbc0f4e9).(pszGFSTemplateName);
807 }
808
809 if (bResolve)
810 {
811 if (bHugeFile)
812 {
813 bSchemaDone = true;
814 bool bSqliteIsTempFile =
815 CPLTestBool(CPLGetConfigOption("GML_HUGE_TEMPFILE", "YES"));
816 int iSqliteCacheMB =
817 atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetConfigOption("OGR_SQLITE_CACHE", "0"));
818 if (poReadercxx . . $ OGRGMLDataSource#poReader.->HugeFileResolvercxx . . $ IGMLReader#HugeFileResolver(c06f6bb4ec832fa).(pszXlinkResolvedFilename,
819 bSqliteIsTempFile,
820 iSqliteCacheMB) == false)
821 {
822 // Assume an error has been reported.
823 VSIFCloseL(fp);
824 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszXlinkResolvedFilename);
825 return false;
826 }
827 }
828 else
829 {
830 poReadercxx . . $ OGRGMLDataSource#poReader.->ResolveXlinkscxx . . $ IGMLReader#ResolveXlinks(4a04dd83e4aa235f).(pszXlinkResolvedFilename, &bOutIsTempFilecxx . . $ OGRGMLDataSource#bOutIsTempFile.,
831 papszSkip);
832 }
833 }
834
835 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszXlinkResolvedFilename);
836 pszXlinkResolvedFilename = nullptr;
837 CSLDestroy(papszSkip);
838 papszSkip = nullptr;
839
840 // If the source filename for the reader is still the GML filename, then
841 // we can directly provide the file pointer. Otherwise close it.
842 if (strcmp(poReadercxx . . $ OGRGMLDataSource#poReader.->GetSourceFileNamecxx . . $ IGMLReader#GetSourceFileName(33a1f659e94feb42).(), pszFilename) == 0)
843 poReadercxx . . $ OGRGMLDataSource#poReader.->SetFPcxx . . $ IGMLReader#SetFP(c6d3c1ec18bf8a4a).(fp);
844 else
845 VSIFCloseL(fp);
846 fp = nullptr;
847
848 // Is a prescan required?
849 if (bHaveSchema && !bSchemaDone)
850 {
851 // We must detect which layers are actually present in the .gml
852 // and how many features they have.
853 if (!poReadercxx . . $ OGRGMLDataSource#poReader.->PrescanForTemplatecxx . . $ IGMLReader#PrescanForTemplate(c9857a73d68e59ba).())
854 {
855 // Assume an error has been reported.
856 return false;
857 }
858 }
859
860 CPLString osGFSFilename;
861 if (!bIsWFSFromServer)
862 {
863 osGFSFilename = CPLResetExtensionSafe(pszFilename, "gfs");
864 if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(osGFSFilename, "/vsigzip/"))
865 osGFSFilename = osGFSFilename.substr(strlen("/vsigzip/"));
866 }
867
868 // Can we find a GML Feature Schema (.gfs) for the input file?
869 if (!osGFSFilename.empty() && !bHaveSchema && !bSchemaDone &&
870 osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename..empty())
871 {
872 VSIStatBufL sGFSStatBuf;
873 if (bCheckAuxFile && VSIStatL(osGFSFilename, &sGFSStatBuf) == 0)
874 {
875 VSIStatBufL sGMLStatBuf;
876 if (VSIStatL(pszFilename, &sGMLStatBuf) == 0 &&
877 sGMLStatBuf.st_mtimecxx . . $ `<external>/16045971866008360577/struct_stat.h:78:11`! > sGFSStatBuf.st_mtimecxx . . $ `<external>/16045971866008360577/struct_stat.h:78:11`!)
878 {
879 CPLDebug("GML",
880 "Found %s but ignoring because it appears\n"
881 "be older than the associated GML file.",
882 osGFSFilename.c_str());
883 }
884 else
885 {
886 bHaveSchema = poReadercxx . . $ OGRGMLDataSource#poReader.->LoadClassescxx . . $ IGMLReader#LoadClasses(c5f7da30cbc0f4e9).(osGFSFilename);
887 if (bHaveSchema)
888 {
889 const stdcxx . . $ std/::string osXSDFilenameTmp =
890 CPLResetExtensionSafe(pszFilename, "xsd");
891 if (VSIStatExL(osXSDFilenameTmp.c_str(), &sGMLStatBuf,
892 VSI_STAT_EXISTS_FLAGcxx . . $ `port/cpl_vsi.h:238:9`!) == 0)
893 {
894 CPLDebug("GML", "Using %s file, ignoring %s",
895 osGFSFilename.c_str(),
896 osXSDFilenameTmp.c_str());
897 }
898 }
899 }
900 }
901 }
902
903 // Can we find an xsd which might conform to the GML3 Level 0
904 // profile? We really ought to look for it based on the rules
905 // schemaLocation in the GML feature collection but for now we
906 // just hopes it is in the same director with the same name.
907
908 bool bHasFoundXSD = false;
909
910 if (!bHaveSchema)
911 {
912 char **papszTypeNames = nullptr;
913
914 VSIStatBufL sXSDStatBuf;
915 if (osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename..empty())
916 {
917 osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename. = CPLResetExtensionSafe(pszFilename, "xsd");
918 if (bCheckAuxFile && VSIStatExL(osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename., &sXSDStatBuf,
919 VSI_STAT_EXISTS_FLAGcxx . . $ `port/cpl_vsi.h:238:9`!) == 0)
920 {
921 bHasFoundXSD = true;
922 }
923 }
924 else
925 {
926 if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(osXSDFilename, "http://") ||
927 STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(osXSDFilename, "https://") ||
928 VSIStatExL(osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename., &sXSDStatBuf, VSI_STAT_EXISTS_FLAGcxx . . $ `port/cpl_vsi.h:238:9`!) ==
929 0)
930 {
931 bHasFoundXSD = true;
932 }
933 }
934
935 // If not found, try if there is a schema in the gml_registry.xml
936 // that might match a declared namespace and featuretype.
937 if (!bHasFoundXSD)
938 {
939 GMLRegistrycxx . . $ GMLRegistry# oRegistrycxx . . $ GMLRegistry#GMLRegistry(42786403379ca8d8).(
940 CSLFetchNameValueDef(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "REGISTRY",
941 CPLGetConfigOption("GML_REGISTRY", "")));
942 if (oRegistry.Parsecxx . . $ GMLRegistry#Parse(c9857a73d68e59ba).())
943 {
944 CPLString osHeader(szHeader);
945 for (size_t iNS = 0; iNS < oRegistry.aoNamespacescxx . . $ GMLRegistry#aoNamespaces..size(); iNS++)
946 {
947 GMLRegistryNamespacecxx . . $ GMLRegistryNamespace# &oNamespace =
948 oRegistry.aoNamespacescxx . . $ GMLRegistry#aoNamespaces.[iNS];
949 // When namespace is omitted or fit with case sensitive
950 // match for name space prefix, then go next to find feature
951 // match.
952 //
953 // Case sensitive comparison since below test that also
954 // uses the namespace prefix is case sensitive.
955 if (!oNamespace.osPrefixcxx . . $ GMLRegistryNamespace#osPrefix..empty() &&
956 osHeader.find(CPLSPrintf(
957 "xmlns:%s", oNamespace.osPrefixcxx . . $ GMLRegistryNamespace#osPrefix..c_str())) ==
958 stdcxx . . $ std/::string::npos)
959 {
960 // namespace does not match with one of registry
961 // definition. go to next entry.
962 continue;
963 }
964
965 const char *pszURIToFind =
966 CPLSPrintf("\"%s\"", oNamespace.osURIcxx . . $ GMLRegistryNamespace#osURI..c_str());
967 if (strstr(szHeader, pszURIToFind) != nullptr)
968 {
969 if (oNamespace.bUseGlobalSRSNamecxx . . $ GMLRegistryNamespace#bUseGlobalSRSName.)
970 bUseGlobalSRSNamecxx . . $ OGRGMLDataSource#bUseGlobalSRSName. = true;
971
972 for (size_t iTypename = 0;
973 iTypename < oNamespace.aoFeatureTypescxx . . $ GMLRegistryNamespace#aoFeatureTypes..size();
974 iTypename++)
975 {
976 const char *pszElementToFind = nullptr;
977
978 GMLRegistryFeatureTypecxx . . $ GMLRegistryFeatureType# &oFeatureType =
979 oNamespace.aoFeatureTypescxx . . $ GMLRegistryNamespace#aoFeatureTypes.[iTypename];
980
981 if (!oNamespace.osPrefixcxx . . $ GMLRegistryNamespace#osPrefix..empty())
982 {
983 if (!oFeatureType.osElementValuecxx . . $ GMLRegistryFeatureType#osElementValue..empty())
984 pszElementToFind = CPLSPrintf(
985 "%s:%s>%s", oNamespace.osPrefixcxx . . $ GMLRegistryNamespace#osPrefix..c_str(),
986 oFeatureType.osElementNamecxx . . $ GMLRegistryFeatureType#osElementName..c_str(),
987 oFeatureType.osElementValuecxx . . $ GMLRegistryFeatureType#osElementValue..c_str());
988 else
989 pszElementToFind = CPLSPrintf(
990 "%s:%s", oNamespace.osPrefixcxx . . $ GMLRegistryNamespace#osPrefix..c_str(),
991 oFeatureType.osElementNamecxx . . $ GMLRegistryFeatureType#osElementName..c_str());
992 }
993 else
994 {
995 if (!oFeatureType.osElementValuecxx . . $ GMLRegistryFeatureType#osElementValue..empty())
996 pszElementToFind = CPLSPrintf(
997 "%s>%s",
998 oFeatureType.osElementNamecxx . . $ GMLRegistryFeatureType#osElementName..c_str(),
999 oFeatureType.osElementValuecxx . . $ GMLRegistryFeatureType#osElementValue..c_str());
1000 else
1001 pszElementToFind = CPLSPrintf(
1002 "<%s",
1003 oFeatureType.osElementNamecxx . . $ GMLRegistryFeatureType#osElementName..c_str());
1004 }
1005
1006 // Case sensitive test since in a CadastralParcel
1007 // feature there is a property basicPropertyUnit
1008 // xlink, not to be confused with a top-level
1009 // BasicPropertyUnit feature.
1010 if (osHeader.find(pszElementToFind) !=
1011 stdcxx . . $ std/::string::npos)
1012 {
1013 if (!oFeatureType.osSchemaLocationcxx . . $ GMLRegistryFeatureType#osSchemaLocation..empty())
1014 {
1015 osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename. =
1016 oFeatureType.osSchemaLocationcxx . . $ GMLRegistryFeatureType#osSchemaLocation.;
1017 if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(osXSDFilename, "http://") ||
1018 STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(osXSDFilename,
1019 "https://") ||
1020 VSIStatExL(osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename., &sXSDStatBuf,
1021 VSI_STAT_EXISTS_FLAGcxx . . $ `port/cpl_vsi.h:238:9`!) == 0)
1022 {
1023 bHasFoundXSD = true;
1024 bHaveSchema = true;
1025 CPLDebug(
1026 "GML",
1027 "Found %s for %s:%s in registry",
1028 osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename..c_str(),
1029 oNamespace.osPrefixcxx . . $ GMLRegistryNamespace#osPrefix..c_str(),
1030 oFeatureType.osElementNamecxx . . $ GMLRegistryFeatureType#osElementName..c_str());
1031 }
1032 else
1033 {
1034 CPLDebug("GML", "Cannot open %s",
1035 osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename..c_str());
1036 }
1037 }
1038 else
1039 {
1040 bHaveSchema = poReadercxx . . $ OGRGMLDataSource#poReader.->LoadClassescxx . . $ IGMLReader#LoadClasses(c5f7da30cbc0f4e9).(
1041 oFeatureType.osGFSSchemaLocationcxx . . $ GMLRegistryFeatureType#osGFSSchemaLocation.);
1042 if (bHaveSchema)
1043 {
1044 CPLDebug(
1045 "GML",
1046 "Found %s for %s:%s in registry",
1047 oFeatureType.osGFSSchemaLocationcxx . . $ GMLRegistryFeatureType#osGFSSchemaLocation.
1048 .c_str(),
1049 oNamespace.osPrefixcxx . . $ GMLRegistryNamespace#osPrefix..c_str(),
1050 oFeatureType.osElementNamecxx . . $ GMLRegistryFeatureType#osElementName..c_str());
1051 }
1052 }
1053 break;
1054 }
1055 }
1056 break;
1057 }
1058 }
1059 }
1060 }
1061
1062 /* For WFS, try to fetch the application schema */
1063 if (bIsWFScxx . . $ OGRGMLDataSource#bIsWFS. && !bHaveSchema && pszSchemaLocation != nullptr &&
1064 (pszSchemaLocation[0] == '\'' || pszSchemaLocation[0] == '"') &&
1065 strchr(pszSchemaLocation + 1, pszSchemaLocation[0]) != nullptr)
1066 {
1067 char *pszSchemaLocationTmp1 = CPLStrdup(pszSchemaLocation + 1);
1068 int nTruncLen = static_cast<int>(
1069 strchr(pszSchemaLocation + 1, pszSchemaLocation[0]) -
1070 (pszSchemaLocation + 1));
1071 pszSchemaLocationTmp1[nTruncLen] = '\0';
1072 char *pszSchemaLocationTmp2 =
1073 CPLUnescapeString(pszSchemaLocationTmp1, nullptr, CPLES_XMLcxx . . $ `port/cpl_string.h:155:9`!);
1074 CPLString osEscaped =
1075 ReplaceSpaceByPct20IfNeededcxx . . $ ReplaceSpaceByPct20IfNeeded(a9d72c988d85d6d8).(pszSchemaLocationTmp2);
1076 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszSchemaLocationTmp2);
1077 pszSchemaLocationTmp2 = CPLStrdup(osEscaped);
1078 if (pszSchemaLocationTmp2)
1079 {
1080 // pszSchemaLocationTmp2 is of the form:
1081 // http://namespace1 http://namespace1_schema_location
1082 // http://namespace2 http://namespace1_schema_location2 So we
1083 // try to find http://namespace1_schema_location that contains
1084 // hints that it is the WFS application */ schema, i.e. if it
1085 // contains typename= and request=DescribeFeatureType.
1086 char **papszTokens =
1087 CSLTokenizeString2(pszSchemaLocationTmp2, " \r\n", 0);
1088 int nTokens = CSLCount(papszTokens);
1089 if ((nTokens % 2) == 0)
1090 {
1091 for (int i = 0; i < nTokens; i += 2)
1092 {
1093 const char *pszEscapedURL = papszTokens[i + 1];
1094 char *pszLocation = CPLUnescapeString(
1095 pszEscapedURL, nullptr, CPLES_URLcxx . . $ `port/cpl_string.h:157:9`!);
1096 const CPLString osLocation(pszLocation);
1097 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszLocation);
1098 if (osLocation.ifind("typename=") !=
1099 stdcxx . . $ std/::string::npos &&
1100 osLocation.ifind("request=DescribeFeatureType") !=
1101 stdcxx . . $ std/::string::npos)
1102 {
1103 CPLString osTypeName =
1104 CPLURLGetValue(osLocation, "typename");
1105 papszTypeNames =
1106 CSLTokenizeString2(osTypeName, ",", 0);
1107
1108 // Old non-documented way
1109 const char *pszGML_DOWNLOAD_WFS_SCHEMA =
1110 CPLGetConfigOption("GML_DOWNLOAD_WFS_SCHEMA",
1111 nullptr);
1112 if (pszGML_DOWNLOAD_WFS_SCHEMA)
1113 {
1114 CPLError(
1115 CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
1116 "Configuration option "
1117 "GML_DOWNLOAD_WFS_SCHEMA is deprecated. "
1118 "Please use GML_DOWNLOAD_SCHEMA instead of "
1119 "the DOWNLOAD_SCHEMA open option");
1120 }
1121 else
1122 {
1123 pszGML_DOWNLOAD_WFS_SCHEMA = "YES";
1124 }
1125 if (!bHasFoundXSD && CPLHTTPEnabled() &&
1126 CPLFetchBool(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions.,
1127 "DOWNLOAD_SCHEMA",
1128 CPLTestBool(CPLGetConfigOption(
1129 "GML_DOWNLOAD_SCHEMA",
1130 pszGML_DOWNLOAD_WFS_SCHEMA))))
1131 {
1132 CPLHTTPResult *psResult =
1133 CPLHTTPFetch(pszEscapedURL, nullptr);
1134 if (psResult)
1135 {
1136 if (psResult->nStatus == 0 &&
1137 psResult->pabyData != nullptr)
1138 {
1139 bHasFoundXSD = true;
1140 m_bUnlinkXSDFilenamecxx . . $ OGRGMLDataSource#m_bUnlinkXSDFilename. = true;
1141 osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename. =
1142 VSIMemGenerateHiddenFilename(
1143 "tmp_ogr_gml.xsd");
1144 VSILFILE *fpMem = VSIFileFromMemBuffer(
1145 osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename., psResult->pabyData,
1146 psResult->nDataLen, TRUEcxx . . $ `port/cpl_port.h:1184:9`!);
1147 VSIFCloseL(fpMem);
1148 psResult->pabyData = nullptr;
1149 }
1150 CPLHTTPDestroyResult(psResult);
1151 }
1152 }
1153 break;
1154 }
1155 }
1156 }
1157 CSLDestroy(papszTokens);
1158 }
1159 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszSchemaLocationTmp2);
1160 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszSchemaLocationTmp1);
1161 }
1162
1163 bool bHasFeatureProperties = false;
1164 if (bHasFoundXSD)
1165 {
1166 stdcxx . . $ std/::vector<GMLFeatureClasscxx . . $ GMLFeatureClass# *> aosClasses;
1167 bool bUseSchemaImports = CPLFetchBool(
1168 poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "USE_SCHEMA_IMPORT",
1169 CPLTestBool(CPLGetConfigOption("GML_USE_SCHEMA_IMPORT", "NO")));
1170 bool bFullyUnderstood = false;
1171 bHaveSchema = GMLParseXSDcxx . . $ GMLParseXSD(48e53934138cfdb4).(osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename., bUseSchemaImports,
1172 aosClasses, bFullyUnderstood);
1173
1174 if (bHaveSchema && !bFullyUnderstood && bIsWFSJointLayer)
1175 {
1176 CPLDebug("GML", "Schema found, but only partially understood. "
1177 "Cannot be used in a WFS join context");
1178
1179 stdcxx . . $ std/::vector<GMLFeatureClass *>::const_iterator oIter =
1180 aosClasses.begin();
1181 stdcxx . . $ std/::vector<GMLFeatureClass *>::const_iterator oEndIter =
1182 aosClasses.end();
1183 while (oIter != oEndIter)
1184 {
1185 GMLFeatureClasscxx . . $ GMLFeatureClass# *poClass = *oIter;
1186
1187 delete poClass;
1188 ++oIter;
1189 }
1190 aosClasses.resize(0);
1191 bHaveSchema = false;
1192 }
1193
1194 if (bHaveSchema)
1195 {
1196 CPLDebug("GML", "Using %s", osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename..c_str());
1197 stdcxx . . $ std/::vector<GMLFeatureClass *>::const_iterator oIter =
1198 aosClasses.begin();
1199 stdcxx . . $ std/::vector<GMLFeatureClass *>::const_iterator oEndIter =
1200 aosClasses.end();
1201 while (oIter != oEndIter)
1202 {
1203 GMLFeatureClasscxx . . $ GMLFeatureClass# *poClass = *oIter;
1204
1205 if (poClass->HasFeaturePropertiescxx . . $ GMLFeatureClass#HasFeatureProperties(c9857a73d68e59ba).())
1206 {
1207 bHasFeatureProperties = true;
1208 break;
1209 }
1210 ++oIter;
1211 }
1212
1213 oIter = aosClasses.begin();
1214 while (oIter != oEndIter)
1215 {
1216 GMLFeatureClasscxx . . $ GMLFeatureClass# *poClass = *oIter;
1217 ++oIter;
1218
1219 // We have no way of knowing if the geometry type is 25D
1220 // when examining the xsd only, so if there was a hint
1221 // it is, we force to 25D.
1222 if (bHas3D && poClass->GetGeometryPropertyCountcxx . . $ GMLFeatureClass#GetGeometryPropertyCount(455f465bc33b4cdf).() == 1)
1223 {
1224 poClass->GetGeometryPropertycxx . . $ GMLFeatureClass#GetGeometryProperty(d57792ed8f30a1b4).(0)->SetTypecxx . . $ GMLGeometryPropertyDefn#SetType(f47ce3f1fe923726).(
1225 wkbSetZcxx . . $ `ogr/ogr_core.h:585:9`!(static_cast<OGRwkbGeometryType>(
1226 poClass->GetGeometryProperty(0)->GetType())));
1227 }
1228
1229 bool bAddClass = true;
1230 // If typenames are declared, only register the matching
1231 // classes, in case the XSD contains more layers, but not if
1232 // feature classes contain feature properties, in which case
1233 // we will have embedded features that will be reported as
1234 // top-level features.
1235 if (papszTypeNames != nullptr && !bHasFeatureProperties)
1236 {
1237 bAddClass = false;
1238 char **papszIter = papszTypeNames;
1239 while (*papszIter && !bAddClass)
1240 {
1241 const char *pszTypeName = *papszIter;
1242 if (strcmp(pszTypeName, poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).()) == 0)
1243 bAddClass = true;
1244 papszIter++;
1245 }
1246
1247 // Retry by removing prefixes.
1248 if (!bAddClass)
1249 {
1250 papszIter = papszTypeNames;
1251 while (*papszIter && !bAddClass)
1252 {
1253 const char *pszTypeName = *papszIter;
1254 const char *pszColon = strchr(pszTypeName, ':');
1255 if (pszColon)
1256 {
1257 pszTypeName = pszColon + 1;
1258 if (strcmp(pszTypeName,
1259 poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).()) == 0)
1260 {
1261 poClass->SetNamecxx . . $ GMLFeatureClass#SetName(85c52e162fed56f9).(pszTypeName);
1262 bAddClass = true;
1263 }
1264 }
1265 papszIter++;
1266 }
1267 }
1268 }
1269
1270 if (bAddClass &&
1271 poReadercxx . . $ OGRGMLDataSource#poReader.->GetClasscxx . . $ IGMLReader#GetClass(aef30861fca1f104).(poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).()) == nullptr)
1272 {
1273 poReadercxx . . $ OGRGMLDataSource#poReader.->AddClasscxx . . $ IGMLReader#AddClass(53ba4273d06d20f8).(poClass);
1274 }
1275 else
1276 delete poClass;
1277 }
1278
1279 poReadercxx . . $ OGRGMLDataSource#poReader.->SetClassListLockedcxx . . $ IGMLReader#SetClassListLocked(b45ddcbc8423892c).(true);
1280 }
1281 }
1282
1283 if (bHaveSchema && bIsWFScxx . . $ OGRGMLDataSource#bIsWFS.)
1284 {
1285 if (bIsWFSJointLayer)
1286 {
1287 BuildJointClassFromXSDcxx . . $ OGRGMLDataSource#BuildJointClassFromXSD(49f6e7a06ebc5aa8).();
1288 }
1289
1290 // For WFS, we can assume sequential layers.
1291 if (poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).() > 1 && pszReadMode == nullptr &&
1292 !bHasFeatureProperties)
1293 {
1294 CPLDebug("GML",
1295 "WFS output. Using SEQUENTIAL_LAYERS read mode");
1296 eReadModecxx . . $ OGRGMLDataSource#eReadMode. = SEQUENTIAL_LAYERScxx . . $ SEQUENTIAL_LAYERS.;
1297 }
1298 // Sometimes the returned schema contains only <xs:include> that we
1299 // don't resolve so ignore it.
1300 else if (poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).() == 0)
1301 bHaveSchema = false;
1302 }
1303
1304 CSLDestroy(papszTypeNames);
1305 }
1306
1307 // Japan Fundamental Geospatial Data (FGD)
1308 if (strstr(szPtr, "http://fgd.gsi.go.jp/spec/2008/FGD_GMLSchema"))
1309 {
1310 if (ExtractSRSNamecxx . . $ ExtractSRSName(64fcc95e299940b4).(szPtr, szSRSName, sizeof(szSRSName)))
1311 {
1312 CPLErrorStateBackuper oBackuper(CPLQuietErrorHandler);
1313 OGRSpatialReferencecxx . . $ OGRSpatialReference# oSRScxx . . $ OGRSpatialReference#OGRSpatialReference(85c52e162fed56f9).;
1314 if (oSRS.SetFromUserInputcxx . . $ OGRSpatialReference#SetFromUserInput(5a7b06e3ce74da13).(
1315 szSRSName,
1316 OGRSpatialReferencecxx . . $ OGRSpatialReference#::
1317 SET_FROM_USER_INPUT_LIMITATIONS_getcxx . . $ OGRSpatialReference#SET_FROM_USER_INPUT_LIMITATIONS_get(93405d8a1d31001f).()) == OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!)
1318 {
1319 bUseGlobalSRSNamecxx . . $ OGRGMLDataSource#bUseGlobalSRSName. = true;
1320 for (int i = 0; i < poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).(); ++i)
1321 {
1322 poReadercxx . . $ OGRGMLDataSource#poReader.->GetClasscxx . . $ IGMLReader#GetClass(472756784324af7f).(i)->SetSRSNamecxx . . $ GMLFeatureClass#SetSRSName(85c52e162fed56f9).(szSRSName);
1323 }
1324 }
1325 }
1326 }
1327
1328 // Force a first pass to establish the schema. Eventually we will have
1329 // mechanisms for remembering the schema and related information.
1330 const char *pszForceSRSDetection =
1331 CSLFetchNameValue(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "FORCE_SRS_DETECTION");
1332 if (!bHaveSchema ||
1333 (pszForceSRSDetection && CPLTestBool(pszForceSRSDetection)))
1334 {
1335 bool bOnlyDetectSRS = bHaveSchema;
1336 if (!poReadercxx . . $ OGRGMLDataSource#poReader.->PrescanForSchemacxx . . $ IGMLReader#PrescanForSchema(f2cb034b043a1ce9).(true, bOnlyDetectSRS))
1337 {
1338 // Assume an error was reported.
1339 return false;
1340 }
1341 if (!bHaveSchema)
1342 {
1343 if (bIsWFSJointLayer && poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).() == 1)
1344 {
1345 BuildJointClassFromScannedSchemacxx . . $ OGRGMLDataSource#BuildJointClassFromScannedSchema(49f6e7a06ebc5aa8).();
1346 }
1347
1348 if (bHasFoundXSD)
1349 {
1350 CPLDebug("GML", "Generating %s file, ignoring %s",
1351 osGFSFilename.c_str(), osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename..c_str());
1352 }
1353 }
1354 }
1355
1356 if (poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).() > 1 && poReadercxx . . $ OGRGMLDataSource#poReader.->IsSequentialLayerscxx . . $ IGMLReader#IsSequentialLayers(50ce9a9e25b4a850).() &&
1357 pszReadMode == nullptr)
1358 {
1359 CPLDebug("GML",
1360 "Layers are monoblock. Using SEQUENTIAL_LAYERS read mode");
1361 eReadModecxx . . $ OGRGMLDataSource#eReadMode. = SEQUENTIAL_LAYERScxx . . $ SEQUENTIAL_LAYERS.;
1362 }
1363
1364 if (!DealWithOgrSchemaOpenOptioncxx . . $ OGRGMLDataSource#DealWithOgrSchemaOpenOption(425044c81b8374a5).(poOpenInfo))
1365 {
1366 return false;
1367 }
1368
1369 // Save the schema file if possible. Don't make a fuss if we
1370 // can't. It could be read-only directory or something.
1371 const char *pszWriteGFS =
1372 CSLFetchNameValueDef(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "WRITE_GFS", "AUTO");
1373 bool bWriteGFS = false;
1374 if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszWriteGFS, "AUTO"))
1375 {
1376 if (!bHaveSchema && !poReadercxx . . $ OGRGMLDataSource#poReader.->HasStoppedParsingcxx . . $ IGMLReader#HasStoppedParsing(c9857a73d68e59ba).() &&
1377 VSIIsLocal(pszFilename) &&
1378 VSISupportsSequentialWrite(pszFilename, false))
1379 {
1380 VSIStatBufL sGFSStatBuf;
1381 if (VSIStatExL(osGFSFilename, &sGFSStatBuf, VSI_STAT_EXISTS_FLAGcxx . . $ `port/cpl_vsi.h:238:9`!) !=
1382 0)
1383 {
1384 bWriteGFS = true;
1385 }
1386 else
1387 {
1388 CPLDebug("GML", "Not saving %s file: already exists.",
1389 osGFSFilename.c_str());
1390 }
1391 }
1392 }
1393 else if (CPLTestBool(pszWriteGFS))
1394 {
1395 if (bHaveSchema || !poReadercxx . . $ OGRGMLDataSource#poReader.->HasStoppedParsingcxx . . $ IGMLReader#HasStoppedParsing(c9857a73d68e59ba).())
1396 {
1397 bWriteGFS = true;
1398 }
1399 else
1400 {
1401 CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
1402 "GFS file saving asked, but cannot be done");
1403 }
1404 }
1405
1406 if (bWriteGFS)
1407 {
1408 if (!poReadercxx . . $ OGRGMLDataSource#poReader.->SaveClassescxx . . $ IGMLReader#SaveClasses(c5f7da30cbc0f4e9).(osGFSFilename))
1409 {
1410 if (CPLTestBool(pszWriteGFS))
1411 {
1412 CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
1413 "GFS file saving asked, but failed");
1414 }
1415 else
1416 {
1417 CPLDebug("GML", "Not saving %s file: can't be created.",
1418 osGFSFilename.c_str());
1419 }
1420 }
1421 }
1422
1423 // Translate the GMLFeatureClasses into layers.
1424 papoLayerscxx . . $ OGRGMLDataSource#papoLayers. = static_cast<OGRLayercxx . . $ OGRLayer# **>(
1425 CPLCalloc(sizeof(OGRLayercxx . . $ OGRLayer# *), poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).()));
1426 nLayerscxx . . $ OGRGMLDataSource#nLayers. = 0;
1427
1428 if (poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).() == 1 && nNumberOfFeatures != 0)
1429 {
1430 GMLFeatureClasscxx . . $ GMLFeatureClass# *poClass = poReadercxx . . $ OGRGMLDataSource#poReader.->GetClasscxx . . $ IGMLReader#GetClass(472756784324af7f).(0);
1431 GIntBigcxx . . $ GIntBig# nFeatureCount = poClass->GetFeatureCountcxx . . $ GMLFeatureClass#GetFeatureCount(a5d9f2bf8849668d).();
1432 if (nFeatureCount < 0)
1433 {
1434 poClass->SetFeatureCountcxx . . $ GMLFeatureClass#SetFeatureCount(35cb52607f6af42f).(nNumberOfFeatures);
1435 }
1436 else if (nFeatureCount != nNumberOfFeatures)
1437 {
1438 CPLDebug("GML", "Feature count in header, "
1439 "and actual feature count don't match");
1440 }
1441 }
1442
1443 if (bIsWFScxx . . $ OGRGMLDataSource#bIsWFS. && poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).() == 1)
1444 bUseGlobalSRSNamecxx . . $ OGRGMLDataSource#bUseGlobalSRSName. = true;
1445
1446 while (nLayerscxx . . $ OGRGMLDataSource#nLayers. < poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).())
1447 {
1448 papoLayerscxx . . $ OGRGMLDataSource#papoLayers.[nLayerscxx . . $ OGRGMLDataSource#nLayers.] = TranslateGMLSchemacxx . . $ OGRGMLDataSource#TranslateGMLSchema(9a73fff96f3e603f).(poReadercxx . . $ OGRGMLDataSource#poReader.->GetClasscxx . . $ IGMLReader#GetClass(472756784324af7f).(nLayerscxx . . $ OGRGMLDataSource#nLayers.));
1449 nLayerscxx . . $ OGRGMLDataSource#nLayers.++;
1450 }
1451
1452 // Warn if we have geometry columns without known CRS due to only using
1453 // the .xsd
1454 if (bHaveSchema && pszForceSRSDetection == nullptr)
1455 {
1456 bool bExitLoop = false;
1457 for (int i = 0; !bExitLoop && i < nLayerscxx . . $ OGRGMLDataSource#nLayers.; ++i)
1458 {
1459 const auto poLayer = papoLayerscxx . . $ OGRGMLDataSource#papoLayers.[i];
1460 const auto poLayerDefn = poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).();
1461 const auto nGeomFieldCount = poLayerDefn->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).();
1462 for (int j = 0; j < nGeomFieldCount; ++j)
1463 {
1464 if (poLayerDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(j)->GetSpatialRefcxx . . $ OGRGeomFieldDefn#GetSpatialRef(8a5496c2eeefaeaf).() ==
1465 nullptr)
1466 {
1467 bExitLoop = true;
1468 break;
1469 }
1470 }
1471 }
1472 if (bExitLoop)
1473 {
1474 CPLDebug("GML",
1475 "Geometry fields without known CRS have been detected. "
1476 "You may want to specify the FORCE_SRS_DETECTION open "
1477 "option to YES.");
1478 }
1479 }
1480
1481 return true;
1482 }
1483
1484 /************************************************************************/
1485 /* BuildJointClassFromXSD() */
1486 /************************************************************************/
1487
1488 void OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::BuildJointClassFromXSDcxx . . $ OGRGMLDataSource#BuildJointClassFromXSD(49f6e7a06ebc5aa8).()
1489 {
1490 CPLString osJointClassName = "join";
1491 for (int i = 0; i < poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).(); i++)
1492 {
1493 osJointClassName += "_";
1494 osJointClassName += poReadercxx . . $ OGRGMLDataSource#poReader.->GetClasscxx . . $ IGMLReader#GetClass(472756784324af7f).(i)->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).();
1495 }
1496 GMLFeatureClasscxx . . $ GMLFeatureClass# *poJointClass = new GMLFeatureClasscxx . . $ GMLFeatureClass#(osJointClassName);
1497 poJointClass->SetElementNamecxx . . $ GMLFeatureClass#SetElementName(85c52e162fed56f9).("Tuple");
1498 for (int i = 0; i < poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).(); i++)
1499 {
1500 GMLFeatureClasscxx . . $ GMLFeatureClass# *poClass = poReadercxx . . $ OGRGMLDataSource#poReader.->GetClasscxx . . $ IGMLReader#GetClass(472756784324af7f).(i);
1501
1502 {
1503 CPLString osPropertyName;
1504 osPropertyName.Printf("%s.%s", poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).(), "gml_id");
1505 GMLPropertyDefncxx . . $ GMLPropertyDefn# *poNewProperty =
1506 new GMLPropertyDefncxx . . $ GMLPropertyDefn#(osPropertyName);
1507 CPLString osSrcElement;
1508 osSrcElement.Printf("member|%s@id", poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).());
1509 poNewProperty->SetSrcElementcxx . . $ GMLPropertyDefn#SetSrcElement(85c52e162fed56f9).(osSrcElement);
1510 poNewProperty->SetTypecxx . . $ GMLPropertyDefn#SetType(e56f951e2e23bc45).(GMLPT_Stringcxx . . $ GMLPT_String.);
1511 poJointClass->AddPropertycxx . . $ GMLFeatureClass#AddProperty(b7cb0caa1392178c).(poNewProperty);
1512 }
1513
1514 for (int iField = 0; iField < poClass->GetPropertyCountcxx . . $ GMLFeatureClass#GetPropertyCount(455f465bc33b4cdf).(); iField++)
1515 {
1516 GMLPropertyDefncxx . . $ GMLPropertyDefn# *poProperty = poClass->GetPropertycxx . . $ GMLFeatureClass#GetProperty(b950e76b5d86c48f).(iField);
1517 CPLString osPropertyName;
1518 osPropertyName.Printf("%s.%s", poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).(),
1519 poProperty->GetNamecxx . . $ GMLPropertyDefn#GetName(a9f41ea0e82d88cf).());
1520 GMLPropertyDefncxx . . $ GMLPropertyDefn# *poNewProperty =
1521 new GMLPropertyDefncxx . . $ GMLPropertyDefn#(osPropertyName);
1522
1523 poNewProperty->SetTypecxx . . $ GMLPropertyDefn#SetType(e56f951e2e23bc45).(poProperty->GetTypecxx . . $ GMLPropertyDefn#GetType(eb020ce77ce58ae).());
1524 CPLString osSrcElement;
1525 osSrcElement.Printf("member|%s|%s", poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).(),
1526 poProperty->GetSrcElementcxx . . $ GMLPropertyDefn#GetSrcElement(a9f41ea0e82d88cf).());
1527 poNewProperty->SetSrcElementcxx . . $ GMLPropertyDefn#SetSrcElement(85c52e162fed56f9).(osSrcElement);
1528 poNewProperty->SetWidthcxx . . $ GMLPropertyDefn#SetWidth(d4f767463ce0a6b3).(poProperty->GetWidthcxx . . $ GMLPropertyDefn#GetWidth(455f465bc33b4cdf).());
1529 poNewProperty->SetPrecisioncxx . . $ GMLPropertyDefn#SetPrecision(d4f767463ce0a6b3).(poProperty->GetPrecisioncxx . . $ GMLPropertyDefn#GetPrecision(455f465bc33b4cdf).());
1530 poNewProperty->SetNullablecxx . . $ GMLPropertyDefn#SetNullable(b45ddcbc8423892c).(poProperty->IsNullablecxx . . $ GMLPropertyDefn#IsNullable(50ce9a9e25b4a850).());
1531
1532 poJointClass->AddPropertycxx . . $ GMLFeatureClass#AddProperty(b7cb0caa1392178c).(poNewProperty);
1533 }
1534 for (int iField = 0; iField < poClass->GetGeometryPropertyCountcxx . . $ GMLFeatureClass#GetGeometryPropertyCount(455f465bc33b4cdf).();
1535 iField++)
1536 {
1537 GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *poProperty =
1538 poClass->GetGeometryPropertycxx . . $ GMLFeatureClass#GetGeometryProperty(d57792ed8f30a1b4).(iField);
1539 CPLString osPropertyName;
1540 osPropertyName.Printf("%s.%s", poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).(),
1541 poProperty->GetNamecxx . . $ GMLGeometryPropertyDefn#GetName(a9f41ea0e82d88cf).());
1542 CPLString osSrcElement;
1543 osSrcElement.Printf("member|%s|%s", poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).(),
1544 poProperty->GetSrcElementcxx . . $ GMLGeometryPropertyDefn#GetSrcElement(a9f41ea0e82d88cf).());
1545 GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *poNewProperty =
1546 new GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn#(osPropertyName, osSrcElement,
1547 poProperty->GetTypecxx . . $ GMLGeometryPropertyDefn#GetType(5a40c54c5ff210ce).(), -1,
1548 poProperty->IsNullablecxx . . $ GMLGeometryPropertyDefn#IsNullable(50ce9a9e25b4a850).());
1549 poJointClass->AddGeometryPropertycxx . . $ GMLFeatureClass#AddGeometryProperty(492bdec084017061).(poNewProperty);
1550 }
1551 }
1552 poJointClass->SetSchemaLockedcxx . . $ GMLFeatureClass#SetSchemaLocked(b45ddcbc8423892c).(true);
1553
1554 poReadercxx . . $ OGRGMLDataSource#poReader.->ClearClassescxx . . $ IGMLReader#ClearClasses(49f6e7a06ebc5aa8).();
1555 poReadercxx . . $ OGRGMLDataSource#poReader.->AddClasscxx . . $ IGMLReader#AddClass(53ba4273d06d20f8).(poJointClass);
1556 }
1557
1558 /************************************************************************/
1559 /* BuildJointClassFromScannedSchema() */
1560 /************************************************************************/
1561
1562 void OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::BuildJointClassFromScannedSchemacxx . . $ OGRGMLDataSource#BuildJointClassFromScannedSchema(49f6e7a06ebc5aa8).()
1563 {
1564 // Make sure that all properties of a same base feature type are
1565 // consecutive. If not, reorder.
1566 stdcxx . . $ std/::vector<stdcxx . . $ std/::vector<GMLPropertyDefncxx . . $ GMLPropertyDefn# *>> aapoProps;
1567 GMLFeatureClasscxx . . $ GMLFeatureClass# *poClass = poReadercxx . . $ OGRGMLDataSource#poReader.->GetClasscxx . . $ IGMLReader#GetClass(472756784324af7f).(0);
1568 CPLString osJointClassName = "join";
1569
1570 for (int iField = 0; iField < poClass->GetPropertyCountcxx . . $ GMLFeatureClass#GetPropertyCount(455f465bc33b4cdf).(); iField++)
1571 {
1572 GMLPropertyDefncxx . . $ GMLPropertyDefn# *poProp = poClass->GetPropertycxx . . $ GMLFeatureClass#GetProperty(b950e76b5d86c48f).(iField);
1573 CPLString osPrefix(poProp->GetNamecxx . . $ GMLPropertyDefn#GetName(a9f41ea0e82d88cf).());
1574 size_t iPos = osPrefix.find('.');
1575 if (iPos != stdcxx . . $ std/::string::npos)
1576 osPrefix.resize(iPos);
1577 int iSubClass = 0; // Used after for.
1578 for (; iSubClass < static_cast<int>(aapoProps.size()); iSubClass++)
1579 {
1580 CPLString osPrefixClass(aapoProps[iSubClass][0]->GetNamecxx . . $ GMLPropertyDefn#GetName(a9f41ea0e82d88cf).());
1581 iPos = osPrefixClass.find('.');
1582 if (iPos != stdcxx . . $ std/::string::npos)
1583 osPrefixClass.resize(iPos);
1584 if (osPrefix == osPrefixClass)
1585 break;
1586 }
1587 if (iSubClass == static_cast<int>(aapoProps.size()))
1588 {
1589 osJointClassName += "_";
1590 osJointClassName += osPrefix;
1591 aapoProps.push_back(stdcxx . . $ std/::vector<GMLPropertyDefncxx . . $ GMLPropertyDefn# *>());
1592 }
1593 aapoProps[iSubClass].push_back(poProp);
1594 }
1595 poClass->SetElementNamecxx . . $ GMLFeatureClass#SetElementName(85c52e162fed56f9).(poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).());
1596 poClass->SetNamecxx . . $ GMLFeatureClass#SetName(85c52e162fed56f9).(osJointClassName);
1597
1598 poClass->StealPropertiescxx . . $ GMLFeatureClass#StealProperties(49f6e7a06ebc5aa8).();
1599 stdcxx . . $ std/::vector<stdcxx . . $ std/::pair<CPLString, stdcxx . . $ std/::vector<GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *>>>
1600 aapoGeomProps;
1601 for (int iSubClass = 0; iSubClass < static_cast<int>(aapoProps.size());
1602 iSubClass++)
1603 {
1604 CPLString osPrefixClass(aapoProps[iSubClass][0]->GetNamecxx . . $ GMLPropertyDefn#GetName(a9f41ea0e82d88cf).());
1605 size_t iPos = osPrefixClass.find('.');
1606 if (iPos != stdcxx . . $ std/::string::npos)
1607 osPrefixClass.resize(iPos);
1608 aapoGeomProps.emplace_back(
1609 stdcxx . . $ std/::pair(osPrefixClass, stdcxx . . $ std/::vector<GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *>()));
1610 for (int iField = 0;
1611 iField < static_cast<int>(aapoProps[iSubClass].size()); iField++)
1612 {
1613 poClass->AddPropertycxx . . $ GMLFeatureClass#AddProperty(b7cb0caa1392178c).(aapoProps[iSubClass][iField]);
1614 }
1615 }
1616 aapoProps.resize(0);
1617
1618 // Reorder geometry fields too
1619 for (int iField = 0; iField < poClass->GetGeometryPropertyCountcxx . . $ GMLFeatureClass#GetGeometryPropertyCount(455f465bc33b4cdf).(); iField++)
1620 {
1621 GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *poProp = poClass->GetGeometryPropertycxx . . $ GMLFeatureClass#GetGeometryProperty(d57792ed8f30a1b4).(iField);
1622 CPLString osPrefix(poProp->GetNamecxx . . $ GMLGeometryPropertyDefn#GetName(a9f41ea0e82d88cf).());
1623 size_t iPos = osPrefix.find('.');
1624 if (iPos != stdcxx . . $ std/::string::npos)
1625 osPrefix.resize(iPos);
1626 int iSubClass = 0; // Used after for.
1627 for (; iSubClass < static_cast<int>(aapoGeomProps.size()); iSubClass++)
1628 {
1629 if (osPrefix == aapoGeomProps[iSubClass].first)
1630 break;
1631 }
1632 if (iSubClass == static_cast<int>(aapoGeomProps.size()))
1633 aapoGeomProps.emplace_back(
1634 stdcxx . . $ std/::pair(osPrefix, stdcxx . . $ std/::vector<GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *>()));
1635 aapoGeomProps[iSubClass].second.push_back(poProp);
1636 }
1637 poClass->StealGeometryPropertiescxx . . $ GMLFeatureClass#StealGeometryProperties(49f6e7a06ebc5aa8).();
1638 for (int iSubClass = 0; iSubClass < static_cast<int>(aapoGeomProps.size());
1639 iSubClass++)
1640 {
1641 for (int iField = 0;
1642 iField < static_cast<int>(aapoGeomProps[iSubClass].second.size());
1643 iField++)
1644 {
1645 poClass->AddGeometryPropertycxx . . $ GMLFeatureClass#AddGeometryProperty(492bdec084017061).(
1646 aapoGeomProps[iSubClass].second[iField]);
1647 }
1648 }
1649 }
1650
1651 /************************************************************************/
1652 /* TranslateGMLSchema() */
1653 /************************************************************************/
1654
1655 OGRLayercxx . . $ OGRLayer# *OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::TranslateGMLSchemacxx . . $ OGRGMLDataSource#TranslateGMLSchema(9a73fff96f3e603f).(GMLFeatureClasscxx . . $ GMLFeatureClass# *poClass)
1656
1657 {
1658 // Create an empty layer.
1659 const char *pszSRSName = poClass->GetSRSNamecxx . . $ GMLFeatureClass#GetSRSName(33a1f659e94feb42).();
1660 OGRSpatialReferenceRefCountedPtrcxx . . $ OGRSpatialReferenceRefCountedPtr# poSRScxx . . $ OGRRefCountedPtr#OGRRefCountedPtr(49f6e7a06ebc5aa8).;
1661 if (pszSRSName)
1662 {
1663 poSRS =cxx . . $ OGRRefCountedPtr#`operator=`(75ecb2b9da62a289). OGRSpatialReferenceRefCountedPtrcxx . . $ OGRSpatialReferenceRefCountedPtr#::makeInstancecxx . . $ OGRRefCountedPtr#makeInstance(1adaeb8070080dba).();
1664 poSRS->cxx . . $ OGRRefCountedPtrBase#`operator->`(5a2a78a048fb49a8).SetAxisMappingStrategycxx . . $ OGRSpatialReference#SetAxisMappingStrategy(3d39f43974738d6a).(m_bInvertAxisOrderIfLatLongcxx . . $ OGRGMLDataSource#m_bInvertAxisOrderIfLatLong.
1665 ? OAMS_TRADITIONAL_GIS_ORDER
1666 : OAMS_AUTHORITY_COMPLIANT);
1667 if (poSRS->cxx . . $ OGRRefCountedPtrBase#`operator->`(5a2a78a048fb49a8).SetFromUserInputcxx . . $ OGRSpatialReference#SetFromUserInput(5a7b06e3ce74da13).(
1668 pszSRSName,
1669 OGRSpatialReferencecxx . . $ OGRSpatialReference#::SET_FROM_USER_INPUT_LIMITATIONS_getcxx . . $ OGRSpatialReference#SET_FROM_USER_INPUT_LIMITATIONS_get(93405d8a1d31001f).()) !=
1670 OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!)
1671 {
1672 poSRS.resetcxx . . $ OGRRefCountedPtr#reset(49f6e7a06ebc5aa8).();
1673 }
1674 }
1675 else
1676 {
1677 pszSRSName = GetGlobalSRSNamecxx . . $ OGRGMLDataSource#GetGlobalSRSName(33a1f659e94feb42).();
1678
1679 if (pszSRSName && GML_IsLegitSRSNamecxx . . $ GML_IsLegitSRSName(c5f7da30cbc0f4e9).(pszSRSName))
1680 {
1681 poSRS =cxx . . $ OGRRefCountedPtr#`operator=`(75ecb2b9da62a289). OGRSpatialReferenceRefCountedPtrcxx . . $ OGRSpatialReferenceRefCountedPtr#::makeInstancecxx . . $ OGRRefCountedPtr#makeInstance(1adaeb8070080dba).();
1682 poSRS->cxx . . $ OGRRefCountedPtrBase#`operator->`(5a2a78a048fb49a8).SetAxisMappingStrategycxx . . $ OGRSpatialReference#SetAxisMappingStrategy(3d39f43974738d6a).(m_bInvertAxisOrderIfLatLongcxx . . $ OGRGMLDataSource#m_bInvertAxisOrderIfLatLong.
1683 ? OAMS_TRADITIONAL_GIS_ORDER
1684 : OAMS_AUTHORITY_COMPLIANT);
1685 if (poSRS->cxx . . $ OGRRefCountedPtrBase#`operator->`(5a2a78a048fb49a8).SetFromUserInputcxx . . $ OGRSpatialReference#SetFromUserInput(5a7b06e3ce74da13).(
1686 pszSRSName,
1687 OGRSpatialReferencecxx . . $ OGRSpatialReference#::
1688 SET_FROM_USER_INPUT_LIMITATIONS_getcxx . . $ OGRSpatialReference#SET_FROM_USER_INPUT_LIMITATIONS_get(93405d8a1d31001f).()) != OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!)
1689 {
1690 poSRS.resetcxx . . $ OGRRefCountedPtr#reset(49f6e7a06ebc5aa8).();
1691 }
1692
1693 if (poSRS !=cxx . . $ `operator!=`(b69b34e3f1dbec43). nullptr && m_bInvertAxisOrderIfLatLongcxx . . $ OGRGMLDataSource#m_bInvertAxisOrderIfLatLong. &&
1694 GML_IsSRSLatLongOrdercxx . . $ GML_IsSRSLatLongOrder(c5f7da30cbc0f4e9).(pszSRSName))
1695 {
1696 if (!poClass->HasExtentscxx . . $ GMLFeatureClass#HasExtents(50ce9a9e25b4a850).() && sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..IsInit())
1697 {
1698 poClass->SetExtentscxx . . $ GMLFeatureClass#SetExtents(52a61fa14d44b641).(sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinY, sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxY,
1699 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinX, sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxX);
1700 }
1701 }
1702 }
1703
1704 if (!poClass->HasExtentscxx . . $ GMLFeatureClass#HasExtents(50ce9a9e25b4a850).() && sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..IsInit())
1705 {
1706 poClass->SetExtentscxx . . $ GMLFeatureClass#SetExtents(52a61fa14d44b641).(sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinX, sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxX,
1707 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinY, sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxY);
1708 }
1709 }
1710
1711 // Report a COMPD_CS only if GML_REPORT_COMPD_CS is explicitly set to TRUE.
1712 if (poSRS !=cxx . . $ `operator!=`(b69b34e3f1dbec43). nullptr && poSRS->cxx . . $ OGRRefCountedPtrBase#`operator->`(5a2a78a048fb49a8).IsCompoundcxx . . $ OGRSpatialReference#IsCompound(455f465bc33b4cdf).())
1713 {
1714 const char *pszReportCompdCS =
1715 CPLGetConfigOption("GML_REPORT_COMPD_CS", nullptr);
1716 if (pszReportCompdCS == nullptr)
1717 {
1718 CPLDebug("GML", "Compound CRS detected but only horizontal part "
1719 "will be reported. Set the GML_REPORT_COMPD_CS=YES "
1720 "configuration option to get the Compound CRS");
1721 pszReportCompdCS = "FALSE";
1722 }
1723 if (!CPLTestBool(pszReportCompdCS))
1724 {
1725 OGR_SRSNodecxx . . $ OGR_SRSNode# *poCOMPD_CS = poSRS->cxx . . $ OGRRefCountedPtrBase#`operator->`(5a2a78a048fb49a8).GetAttrNodecxx . . $ OGRSpatialReference#GetAttrNode(4040a71e5f117954).("COMPD_CS");
1726 if (poCOMPD_CS != nullptr)
1727 {
1728 OGR_SRSNodecxx . . $ OGR_SRSNode# *poCandidateRoot = poCOMPD_CS->GetNodecxx . . $ OGR_SRSNode#GetNode(4040a71e5f117954).("PROJCS");
1729 if (poCandidateRoot == nullptr)
1730 poCandidateRoot = poCOMPD_CS->GetNodecxx . . $ OGR_SRSNode#GetNode(4040a71e5f117954).("GEOGCS");
1731 if (poCandidateRoot != nullptr)
1732 {
1733 poSRS->cxx . . $ OGRRefCountedPtrBase#`operator->`(5a2a78a048fb49a8).SetRootcxx . . $ OGRSpatialReference#SetRoot(f03252b7628cdb15).(poCandidateRoot->Clonecxx . . $ OGR_SRSNode#Clone(c740f29a186fe9aa).());
1734 }
1735 }
1736 }
1737 }
1738
1739 OGRLayercxx . . $ OGRLayer# *poLayer = new OGRGMLLayercxx . . $ OGRGMLLayer#(poClass->GetNamecxx . . $ GMLFeatureClass#GetName(a9f41ea0e82d88cf).(), false, this);
1740
1741 // Added attributes (properties).
1742 if (bExposeGMLIdcxx . . $ OGRGMLDataSource#bExposeGMLId.)
1743 {
1744 OGRFieldDefncxx . . $ OGRFieldDefn# oFieldcxx . . $ OGRFieldDefn#OGRFieldDefn(786ecb48a0b3b841).("gml_id", OFTString);
1745 oField.SetNullablecxx . . $ OGRFieldDefn#SetNullable(d4f767463ce0a6b3).(FALSEcxx . . $ `port/cpl_port.h:1180:9`!);
1746 poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->AddFieldDefncxx . . $ OGRFeatureDefn#AddFieldDefn(f8bad7d30df65bbb).(&oField);
1747 }
1748 else if (bExposeFidcxx . . $ OGRGMLDataSource#bExposeFid.)
1749 {
1750 OGRFieldDefncxx . . $ OGRFieldDefn# oFieldcxx . . $ OGRFieldDefn#OGRFieldDefn(786ecb48a0b3b841).("fid", OFTString);
1751 oField.SetNullablecxx . . $ OGRFieldDefn#SetNullable(d4f767463ce0a6b3).(FALSEcxx . . $ `port/cpl_port.h:1180:9`!);
1752 poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->AddFieldDefncxx . . $ OGRFeatureDefn#AddFieldDefn(f8bad7d30df65bbb).(&oField);
1753 }
1754
1755 for (int iField = 0; iField < poClass->GetGeometryPropertyCountcxx . . $ GMLFeatureClass#GetGeometryPropertyCount(455f465bc33b4cdf).(); iField++)
1756 {
1757 GMLGeometryPropertyDefncxx . . $ GMLGeometryPropertyDefn# *poProperty =
1758 poClass->GetGeometryPropertycxx . . $ GMLFeatureClass#GetGeometryProperty(d57792ed8f30a1b4).(iField);
1759
1760 // Patch wrong .gfs file produced by earlier versions
1761 if (poProperty->GetTypecxx . . $ GMLGeometryPropertyDefn#GetType(5a40c54c5ff210ce).() == wkbPolyhedralSurface &&
1762 strcmp(poProperty->GetNamecxx . . $ GMLGeometryPropertyDefn#GetName(a9f41ea0e82d88cf).(), "lod2Solid") == 0)
1763 {
1764 poProperty->SetTypecxx . . $ GMLGeometryPropertyDefn#SetType(f47ce3f1fe923726).(wkbPolyhedralSurfaceZ);
1765 }
1766
1767 OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn# oFieldcxx . . $ OGRGeomFieldDefn#OGRGeomFieldDefn(465d6c96388e9b45).(poProperty->GetNamecxx . . $ GMLGeometryPropertyDefn#GetName(a9f41ea0e82d88cf).(), poProperty->GetTypecxx . . $ GMLGeometryPropertyDefn#GetType(5a40c54c5ff210ce).());
1768 if (poClass->GetGeometryPropertyCountcxx . . $ GMLFeatureClass#GetGeometryPropertyCount(455f465bc33b4cdf).() == 1 &&
1769 poClass->GetFeatureCountcxx . . $ GMLFeatureClass#GetFeatureCount(a5d9f2bf8849668d).() == 0)
1770 {
1771 oField.SetTypecxx . . $ OGRGeomFieldDefn#SetType(f47ce3f1fe923726).(wkbUnknown);
1772 }
1773
1774 const auto &osSRSName = poProperty->GetSRSNamecxx . . $ GMLGeometryPropertyDefn#GetSRSName(f4fff0029955a25f).();
1775 if (!osSRSName.empty())
1776 {
1777 auto poSRS2 = OGRSpatialReferenceRefCountedPtrcxx . . $ OGRSpatialReferenceRefCountedPtr#::makeInstancecxx . . $ OGRRefCountedPtr#makeInstance(1adaeb8070080dba).();
1778 poSRS2->cxx . . $ OGRRefCountedPtrBase#`operator->`(5a2a78a048fb49a8).SetAxisMappingStrategycxx . . $ OGRSpatialReference#SetAxisMappingStrategy(3d39f43974738d6a).(m_bInvertAxisOrderIfLatLongcxx . . $ OGRGMLDataSource#m_bInvertAxisOrderIfLatLong.
1779 ? OAMS_TRADITIONAL_GIS_ORDER
1780 : OAMS_AUTHORITY_COMPLIANT);
1781 if (poSRS2->cxx . . $ OGRRefCountedPtrBase#`operator->`(5a2a78a048fb49a8).SetFromUserInputcxx . . $ OGRSpatialReference#SetFromUserInput(5a7b06e3ce74da13).(
1782 osSRSName.c_str(),
1783 OGRSpatialReferencecxx . . $ OGRSpatialReference#::
1784 SET_FROM_USER_INPUT_LIMITATIONS_getcxx . . $ OGRSpatialReference#SET_FROM_USER_INPUT_LIMITATIONS_get(93405d8a1d31001f).()) == OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!)
1785 {
1786 oField.SetSpatialRefcxx . . $ OGRGeomFieldDefn#SetSpatialRef(9ff39b79387a6086).(poSRS2.getcxx . . $ OGRRefCountedPtrBase#get(5a2a78a048fb49a8).());
1787 }
1788 }
1789 else
1790 {
1791 oField.SetSpatialRefcxx . . $ OGRGeomFieldDefn#SetSpatialRef(9ff39b79387a6086).(poSRS.getcxx . . $ OGRRefCountedPtrBase#get(5a2a78a048fb49a8).());
1792 }
1793 oField.SetNullablecxx . . $ OGRGeomFieldDefn#SetNullable(d4f767463ce0a6b3).(poProperty->IsNullablecxx . . $ GMLGeometryPropertyDefn#IsNullable(50ce9a9e25b4a850).());
1794 oField.SetCoordinatePrecisioncxx . . $ OGRGeomFieldDefn#SetCoordinatePrecision(a66dcf8fa4d01368).(poProperty->GetCoordinatePrecisioncxx . . $ GMLGeometryPropertyDefn#GetCoordinatePrecision(4cbff8bea018030e).());
1795 poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->AddGeomFieldDefncxx . . $ OGRFeatureDefn#AddGeomFieldDefn(9997450ff2bf2bb5).(&oField);
1796 }
1797
1798 if (poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).() == 1)
1799 {
1800 int iInsertPos = 0;
1801 for (const auto &osElt : m_aosGMLExtraElementscxx . . $ OGRGMLDataSource#m_aosGMLExtraElements.)
1802 {
1803 GMLPropertyDefncxx . . $ GMLPropertyDefn# *poProperty =
1804 new GMLPropertyDefncxx . . $ GMLPropertyDefn#(osElt.c_str(), osElt.c_str());
1805 poProperty->SetTypecxx . . $ GMLPropertyDefn#SetType(e56f951e2e23bc45).(GMLPT_Stringcxx . . $ GMLPT_String.);
1806 if (poClass->AddPropertycxx . . $ GMLFeatureClass#AddProperty(b7cb0caa1392178c).(poProperty, iInsertPos) == iInsertPos)
1807 ++iInsertPos;
1808 else
1809 delete poProperty;
1810 }
1811 }
1812
1813 for (int iField = 0; iField < poClass->GetPropertyCountcxx . . $ GMLFeatureClass#GetPropertyCount(455f465bc33b4cdf).(); iField++)
1814 {
1815 GMLPropertyDefncxx . . $ GMLPropertyDefn# *poProperty = poClass->GetPropertycxx . . $ GMLFeatureClass#GetProperty(b950e76b5d86c48f).(iField);
1816 OGRFieldSubType eSubType = poProperty->GetSubTypecxx . . $ GMLPropertyDefn#GetSubType(4db5e065ad90bc77).();
1817 const OGRFieldType eFType =
1818 GML_GetOGRFieldTypecxx . . $ GML_GetOGRFieldType(81aaa77e722cb32a).(poProperty->GetTypecxx . . $ GMLPropertyDefn#GetType(eb020ce77ce58ae).(), eSubType);
1819 OGRFieldDefncxx . . $ OGRFieldDefn# oFieldcxx . . $ OGRFieldDefn#OGRFieldDefn(786ecb48a0b3b841).(poProperty->GetNamecxx . . $ GMLPropertyDefn#GetName(a9f41ea0e82d88cf).(), eFType);
1820 oField.SetSubTypecxx . . $ OGRFieldDefn#SetSubType(89cba9d8fed1b3f9).(eSubType);
1821 if (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(oField.GetNameRef(), "ogr:"))
1822 oField.SetNamecxx . . $ OGRFieldDefn#SetName(85c52e162fed56f9).(poProperty->GetNamecxx . . $ GMLPropertyDefn#GetName(a9f41ea0e82d88cf).() + 4);
1823 if (poProperty->GetWidthcxx . . $ GMLPropertyDefn#GetWidth(455f465bc33b4cdf).() > 0)
1824 oField.SetWidthcxx . . $ OGRFieldDefn#SetWidth(d4f767463ce0a6b3).(poProperty->GetWidthcxx . . $ GMLPropertyDefn#GetWidth(455f465bc33b4cdf).());
1825 if (poProperty->GetPrecisioncxx . . $ GMLPropertyDefn#GetPrecision(455f465bc33b4cdf).() > 0)
1826 oField.SetPrecisioncxx . . $ OGRFieldDefn#SetPrecision(d4f767463ce0a6b3).(poProperty->GetPrecisioncxx . . $ GMLPropertyDefn#GetPrecision(455f465bc33b4cdf).());
1827 if (!bEmptyAsNullcxx . . $ OGRGMLDataSource#bEmptyAsNull.)
1828 oField.SetNullablecxx . . $ OGRFieldDefn#SetNullable(d4f767463ce0a6b3).(poProperty->IsNullablecxx . . $ GMLPropertyDefn#IsNullable(50ce9a9e25b4a850).());
1829 oField.SetUniquecxx . . $ OGRFieldDefn#SetUnique(d4f767463ce0a6b3).(poProperty->IsUniquecxx . . $ GMLPropertyDefn#IsUnique(50ce9a9e25b4a850).());
1830 oField.SetCommentcxx . . $ OGRFieldDefn#SetComment(9c546c94e5fcce4e).(poProperty->GetDocumentationcxx . . $ GMLPropertyDefn#GetDocumentation(f4fff0029955a25f).());
1831 poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->AddFieldDefncxx . . $ OGRFeatureDefn#AddFieldDefn(f8bad7d30df65bbb).(&oField);
1832 }
1833
1834 return poLayer;
1835 }
1836
1837 /************************************************************************/
1838 /* GetGlobalSRSName() */
1839 /************************************************************************/
1840
1841 const char *OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::GetGlobalSRSNamecxx . . $ OGRGMLDataSource#GetGlobalSRSName(33a1f659e94feb42).()
1842 {
1843 if (poReadercxx . . $ OGRGMLDataSource#poReader.->CanUseGlobalSRSNamecxx . . $ IGMLReader#CanUseGlobalSRSName(c9857a73d68e59ba).() || bUseGlobalSRSNamecxx . . $ OGRGMLDataSource#bUseGlobalSRSName.)
1844 return poReadercxx . . $ OGRGMLDataSource#poReader.->GetGlobalSRSNamecxx . . $ IGMLReader#GetGlobalSRSName(33a1f659e94feb42).();
1845 else
1846 return nullptr;
1847 }
1848
1849 /************************************************************************/
1850 /* Create() */
1851 /************************************************************************/
1852
1853 bool OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::Createcxx . . $ OGRGMLDataSource#Create(16997358fa22d8dc).(const char *pszFilename,
1854 CSLConstListcxx . . $ CSLConstList# papszOptions)
1855
1856 {
1857 if (fpOutputcxx . . $ OGRGMLDataSource#fpOutput. != nullptr || poReadercxx . . $ OGRGMLDataSource#poReader. != nullptr)
1858 {
1859 CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(false);
1860 return false;
1861 }
1862
1863 if (strcmp(pszFilename, "/dev/stdout") == 0)
1864 pszFilename = "/vsistdout/";
1865
1866 // Read options.
1867 CSLDestroy(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions.);
1868 papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions. = CSLDuplicate(papszOptions);
1869
1870 const char *pszFormat =
1871 CSLFetchNameValueDef(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "FORMAT", "GML3.2");
1872 bIsOutputGML3cxx . . $ OGRGMLDataSource#bIsOutputGML3. = EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszFormat, "GML3");
1873 bIsOutputGML3Deegreecxx . . $ OGRGMLDataSource#bIsOutputGML3Deegree. = EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszFormat, "GML3Deegree");
1874 bIsOutputGML32cxx . . $ OGRGMLDataSource#bIsOutputGML32. = EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszFormat, "GML3.2");
1875 if (bIsOutputGML3Deegreecxx . . $ OGRGMLDataSource#bIsOutputGML3Deegree. || bIsOutputGML32cxx . . $ OGRGMLDataSource#bIsOutputGML32.)
1876 bIsOutputGML3cxx . . $ OGRGMLDataSource#bIsOutputGML3. = true;
1877
1878 eSRSNameFormatcxx . . $ OGRGMLDataSource#eSRSNameFormat. = (bIsOutputGML3cxx . . $ OGRGMLDataSource#bIsOutputGML3.) ? SRSNAME_OGC_URNcxx . . $ SRSNAME_OGC_URN. : SRSNAME_SHORTcxx . . $ SRSNAME_SHORT.;
1879 if (bIsOutputGML3cxx . . $ OGRGMLDataSource#bIsOutputGML3.)
1880 {
1881 const char *pszLongSRS =
1882 CSLFetchNameValue(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "GML3_LONGSRS");
1883 const char *pszSRSNameFormat =
1884 CSLFetchNameValue(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "SRSNAME_FORMAT");
1885 if (pszSRSNameFormat)
1886 {
1887 if (pszLongSRS)
1888 {
1889 CPLError(CE_Warning, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!,
1890 "Both GML3_LONGSRS and SRSNAME_FORMAT specified. "
1891 "Ignoring GML3_LONGSRS");
1892 }
1893 if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSRSNameFormat, "SHORT"))
1894 eSRSNameFormatcxx . . $ OGRGMLDataSource#eSRSNameFormat. = SRSNAME_SHORTcxx . . $ SRSNAME_SHORT.;
1895 else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSRSNameFormat, "OGC_URN"))
1896 eSRSNameFormatcxx . . $ OGRGMLDataSource#eSRSNameFormat. = SRSNAME_OGC_URNcxx . . $ SRSNAME_OGC_URN.;
1897 else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSRSNameFormat, "OGC_URL"))
1898 eSRSNameFormatcxx . . $ OGRGMLDataSource#eSRSNameFormat. = SRSNAME_OGC_URLcxx . . $ SRSNAME_OGC_URL.;
1899 else
1900 {
1901 CPLError(CE_Warning, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!,
1902 "Invalid value for SRSNAME_FORMAT. "
1903 "Using SRSNAME_OGC_URN");
1904 }
1905 }
1906 else if (pszLongSRS && !CPLTestBool(pszLongSRS))
1907 eSRSNameFormatcxx . . $ OGRGMLDataSource#eSRSNameFormat. = SRSNAME_SHORTcxx . . $ SRSNAME_SHORT.;
1908 }
1909
1910 bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation. = CPLTestBool(
1911 CSLFetchNameValueDef(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "SPACE_INDENTATION", "YES"));
1912
1913 // Create the output file.
1914 osFilenamecxx . . $ OGRGMLDataSource#osFilename. = pszFilename;
1915 SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).(pszFilename);
1916
1917 if (strcmp(pszFilename, "/vsistdout/") == 0 ||
1918 STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszFilename, "/vsigzip/"))
1919 {
1920 fpOutputcxx . . $ OGRGMLDataSource#fpOutput. = VSIFOpenExL(pszFilename, "wb", true);
1921 bFpOutputIsNonSeekablecxx . . $ OGRGMLDataSource#bFpOutputIsNonSeekable. = true;
1922 bFpOutputSingleFilecxx . . $ OGRGMLDataSource#bFpOutputSingleFile. = true;
1923 }
1924 else if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszFilename, "/vsizip/"))
1925 {
1926 if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(CPLGetExtensionSafe(pszFilename).c_str(), "zip"))
1927 {
1928 SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).(
1929 CPLFormFilenameSafe(pszFilename, "out.gml", nullptr).c_str());
1930 }
1931
1932 fpOutputcxx . . $ OGRGMLDataSource#fpOutput. = VSIFOpenExL(GetDescriptioncxx . . $ GDALMajorObject#GetDescription(a9f41ea0e82d88cf).(), "wb", true);
1933 bFpOutputIsNonSeekablecxx . . $ OGRGMLDataSource#bFpOutputIsNonSeekable. = true;
1934 }
1935 else
1936 fpOutputcxx . . $ OGRGMLDataSource#fpOutput. = VSIFOpenExL(pszFilename, "wb+", true);
1937 if (fpOutputcxx . . $ OGRGMLDataSource#fpOutput. == nullptr)
1938 {
1939 CPLError(CE_Failure, CPLE_OpenFailedcxx . . $ `port/cpl_error.h:114:9`!,
1940 "Failed to create GML file %s: %s", pszFilename,
1941 VSIGetLastErrorMsg());
1942 return false;
1943 }
1944
1945 // Write out "standard" header.
1946 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "%s", "<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
1947
1948 if (!bFpOutputIsNonSeekablecxx . . $ OGRGMLDataSource#bFpOutputIsNonSeekable.)
1949 nSchemaInsertLocationcxx . . $ OGRGMLDataSource#nSchemaInsertLocation. = static_cast<int>(VSIFTellL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput.));
1950
1951 const char *pszPrefix = GetAppPrefixcxx . . $ OGRGMLDataSource#GetAppPrefix(a9f41ea0e82d88cf).();
1952 const char *pszTargetNameSpace = CSLFetchNameValueDef(
1953 papszOptions, "TARGET_NAMESPACE", "http://ogr.maptools.org/");
1954
1955 if (GMLFeatureCollectioncxx . . $ OGRGMLDataSource#GMLFeatureCollection(50ce9a9e25b4a850).())
1956 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "<gml:FeatureCollection");
1957 else if (RemoveAppPrefixcxx . . $ OGRGMLDataSource#RemoveAppPrefix(50ce9a9e25b4a850).())
1958 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "<FeatureCollection");
1959 else
1960 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "<%s:FeatureCollection", pszPrefix);
1961
1962 if (IsGML32Outputcxx . . $ OGRGMLDataSource#IsGML32Output(50ce9a9e25b4a850).())
1963 {
1964 char *pszGMLId = CPLEscapeString(
1965 CSLFetchNameValueDef(papszOptions, "GML_ID", "aFeatureCollection"),
1966 -1, CPLES_XMLcxx . . $ `port/cpl_string.h:155:9`!);
1967 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " gml:id=\"%s\"", pszGMLId);
1968 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszGMLId);
1969 }
1970
1971 // Write out schema info if provided in creation options.
1972 const char *pszSchemaURI = CSLFetchNameValue(papszOptions, "XSISCHEMAURI");
1973 const char *pszSchemaOpt = CSLFetchNameValue(papszOptions, "XSISCHEMA");
1974
1975 if (pszSchemaURI != nullptr)
1976 {
1977 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
1978 fpOutputcxx . . $ OGRGMLDataSource#fpOutput.,
1979 " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
1980 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " xsi:schemaLocation=\"%s\"", pszSchemaURI);
1981 }
1982 else if (pszSchemaOpt == nullptr || EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSchemaOpt, "EXTERNAL"))
1983 {
1984 char *pszBasename =
1985 CPLStrdup(CPLGetBasenameSafe(GetDescriptioncxx . . $ GDALMajorObject#GetDescription(a9f41ea0e82d88cf).()).c_str());
1986
1987 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
1988 fpOutputcxx . . $ OGRGMLDataSource#fpOutput.,
1989 " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
1990 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " xsi:schemaLocation=\"%s %s\"",
1991 pszTargetNameSpace,
1992 CPLResetExtensionSafe(pszBasename, "xsd").c_str());
1993 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszBasename);
1994 }
1995
1996 if (RemoveAppPrefixcxx . . $ OGRGMLDataSource#RemoveAppPrefix(50ce9a9e25b4a850).())
1997 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " xmlns=\"%s\"", pszTargetNameSpace);
1998 else
1999 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " xmlns:%s=\"%s\"", pszPrefix,
2000 pszTargetNameSpace);
2001
2002 if (IsGML32Outputcxx . . $ OGRGMLDataSource#IsGML32Output(50ce9a9e25b4a850).())
2003 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "%s",
2004 " xmlns:gml=\"http://www.opengis.net/gml/3.2\">");
2005 else
2006 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "%s",
2007 " xmlns:gml=\"http://www.opengis.net/gml\">");
2008
2009 return true;
2010 }
2011
2012 /************************************************************************/
2013 /* WriteTopElements() */
2014 /************************************************************************/
2015
2016 void OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::WriteTopElementscxx . . $ OGRGMLDataSource#WriteTopElements(49f6e7a06ebc5aa8).()
2017 {
2018 const char *pszDescription = CSLFetchNameValueDef(
2019 papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "DESCRIPTION", GetMetadataItemcxx . . $ GDALMajorObject#GetMetadataItem(1320557f0feba62c).("DESCRIPTION"));
2020 if (pszDescription != nullptr)
2021 {
2022 if (bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.)
2023 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " ");
2024 char *pszTmp = CPLEscapeString(pszDescription, -1, CPLES_XMLcxx . . $ `port/cpl_string.h:155:9`!);
2025 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "<gml:description>%s</gml:description>", pszTmp);
2026 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszTmp);
2027 }
2028
2029 const char *l_pszName = CSLFetchNameValueDef(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "NAME",
2030 GetMetadataItemcxx . . $ GDALMajorObject#GetMetadataItem(1320557f0feba62c).("NAME"));
2031 if (l_pszName != nullptr)
2032 {
2033 if (bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.)
2034 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " ");
2035 char *pszTmp = CPLEscapeString(l_pszName, -1, CPLES_XMLcxx . . $ `port/cpl_string.h:155:9`!);
2036 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "<gml:name>%s</gml:name>", pszTmp);
2037 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszTmp);
2038 }
2039
2040 // Should we initialize an area to place the boundedBy element?
2041 // We will need to seek back to fill it in.
2042 nBoundedByLocationcxx . . $ OGRGMLDataSource#nBoundedByLocation. = -1;
2043 if (CPLFetchBool(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "BOUNDEDBY", true))
2044 {
2045 if (!bFpOutputIsNonSeekablecxx . . $ OGRGMLDataSource#bFpOutputIsNonSeekable.)
2046 {
2047 nBoundedByLocationcxx . . $ OGRGMLDataSource#nBoundedByLocation. = static_cast<int>(VSIFTellL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput.));
2048
2049 if (nBoundedByLocationcxx . . $ OGRGMLDataSource#nBoundedByLocation. != -1)
2050 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "%350s", "");
2051 }
2052 else
2053 {
2054 if (bWriteSpaceIndentationcxx . . $ OGRGMLDataSource#bWriteSpaceIndentation.)
2055 VSIFPrintfL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., " ");
2056 if (IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).())
2057 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput.,
2058 "<gml:boundedBy><gml:Null /></gml:boundedBy>");
2059 else
2060 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpOutputcxx . . $ OGRGMLDataSource#fpOutput., "<gml:boundedBy><gml:null>missing</"
2061 "gml:null></gml:boundedBy>");
2062 }
2063 }
2064 }
2065
2066 /************************************************************************/
2067 /* DealWithOgrSchemaOpenOption() */
2068 /************************************************************************/
2069
2070 bool OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::DealWithOgrSchemaOpenOptioncxx . . $ OGRGMLDataSource#DealWithOgrSchemaOpenOption(425044c81b8374a5).(
2071 const GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo)
2072 {
2073 const stdcxx . . $ std/::string osFieldsSchemaOverrideParam =
2074 CSLFetchNameValueDef(poOpenInfo->papszOpenOptionscxx . . $ GDALOpenInfo#papszOpenOptions., "OGR_SCHEMA", "");
2075
2076 if (!osFieldsSchemaOverrideParam.empty())
2077 {
2078
2079 // GML driver does not support update at the moment so this will never happen
2080 if (poOpenInfo->eAccesscxx . . $ GDALOpenInfo#eAccess. == GA_Update)
2081 {
2082 CPLError(CE_Failure, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!,
2083 "OGR_SCHEMA open option is not supported in update mode.");
2084 return false;
2085 }
2086
2087 OGRSchemaOverridecxx . . $ OGRSchemaOverride# osSchemaOverridecxx . . $ OGRSchemaOverride#OGRSchemaOverride(ced63f7c635d850d).;
2088 const auto nErrorCount = CPLGetErrorCounter();
2089 if (!osSchemaOverride.LoadFromJSONcxx . . $ OGRSchemaOverride#LoadFromJSON(5d584287a5d23c74).(osFieldsSchemaOverrideParam) ||
2090 !osSchemaOverride.IsValidcxx . . $ OGRSchemaOverride#IsValid(50ce9a9e25b4a850).())
2091 {
2092 if (nErrorCount == CPLGetErrorCounter())
2093 {
2094 CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
2095 "Content of OGR_SCHEMA in %s is not valid",
2096 osFieldsSchemaOverrideParam.c_str());
2097 }
2098 return false;
2099 }
2100
2101 const auto &oLayerOverrides = osSchemaOverride.GetLayerOverridescxx . . $ OGRSchemaOverride#GetLayerOverrides(661e2bdcc975cd42).();
2102 for (const auto &oLayerFieldOverride : oLayerOverrides)
2103 {
2104 const auto &osLayerName = oLayerFieldOverride.GetLayerNamecxx . . $ OGRLayerSchemaOverride#GetLayerName(f4fff0029955a25f).();
2105 const bool bIsFullOverride{oLayerFieldOverride.IsFullOverridecxx . . $ OGRLayerSchemaOverride#IsFullOverride(50ce9a9e25b4a850).()};
2106 auto oNamedFieldOverrides =
2107 oLayerFieldOverridecxx . . $ std/map#map(46e52724c94dff27)..GetNamedFieldOverridescxx . . $ OGRLayerSchemaOverride#GetNamedFieldOverrides(5466da54ab09d21d).();
2108 const auto &oUnnamedFieldOverrides =
2109 oLayerFieldOverride.GetUnnamedFieldOverridescxx . . $ OGRLayerSchemaOverride#GetUnnamedFieldOverrides(3ab7679c19663181).();
2110
2111 const auto ProcessLayer =
2112 [&osLayerName, &oNamedFieldOverrides, &oUnnamedFieldOverrides,
2113 bIsFullOverride](GMLFeatureClasscxx . . $ GMLFeatureClass# *poClass)
2114 {
2115 stdcxx . . $ std/::vector<GMLPropertyDefncxx . . $ GMLPropertyDefn# *> aoProperties;
2116 // Patch field definitions
2117 for (int i = 0; i < poClass->GetPropertyCountcxx . . $ GMLFeatureClass#GetPropertyCount(455f465bc33b4cdf).(); i++)
2118 {
2119 auto poProperty = poClass->GetPropertycxx . . $ GMLFeatureClass#GetProperty(b950e76b5d86c48f).(i);
2120
2121 const auto PatchProperty =
2122 [poProperty](const OGRFieldDefnOverridecxx . . $ OGRFieldDefnOverride# &oFieldOverride)
2123 {
2124 const OGRFieldSubType eSubType =
2125 oFieldOverride.GetFieldSubTypecxx . . $ OGRFieldDefnOverride#GetFieldSubType(9a0aed4df502f9d1).().value_orcxx . . $ std/optional#value_or(7989909f4c805093).(OFSTNone);
2126
2127 if (oFieldOverride.GetFieldSubTypecxx . . $ OGRFieldDefnOverride#GetFieldSubType(9a0aed4df502f9d1).().has_valuecxx . . $ std/optional#has_value(3482b152b9333168).())
2128 {
2129 poProperty->SetSubTypecxx . . $ GMLPropertyDefn#SetSubType(89cba9d8fed1b3f9).(eSubType);
2130 }
2131
2132 if (oFieldOverride.GetFieldTypecxx . . $ OGRFieldDefnOverride#GetFieldType(f38c2d6b251dea2d).().has_valuecxx . . $ std/optional#has_value(3482b152b9333168).())
2133 {
2134 poProperty->SetTypecxx . . $ GMLPropertyDefn#SetType(e56f951e2e23bc45).(GML_FromOGRFieldTypecxx . . $ GML_FromOGRFieldType(5e9fe183570bdadf).(
2135 oFieldOverride.GetFieldTypecxx . . $ OGRFieldDefnOverride#GetFieldType(f38c2d6b251dea2d).().valuecxx . . $ std/optional#value(9772d62e20ffd8dd).(),
2136 eSubType));
2137 }
2138 if (oFieldOverride.GetFieldWidthcxx . . $ OGRFieldDefnOverride#GetFieldWidth(293109f3f0511d88).().has_valuecxx . . $ std/optional#has_value(3482b152b9333168).())
2139 {
2140 poProperty->SetWidthcxx . . $ GMLPropertyDefn#SetWidth(d4f767463ce0a6b3).(
2141 oFieldOverride.GetFieldWidthcxx . . $ OGRFieldDefnOverride#GetFieldWidth(293109f3f0511d88).().valuecxx . . $ std/optional#value(9772d62e20ffd8dd).());
2142 }
2143 if (oFieldOverride.GetFieldPrecisioncxx . . $ OGRFieldDefnOverride#GetFieldPrecision(293109f3f0511d88).().has_valuecxx . . $ std/optional#has_value(3482b152b9333168).())
2144 {
2145 poProperty->SetPrecisioncxx . . $ GMLPropertyDefn#SetPrecision(d4f767463ce0a6b3).(
2146 oFieldOverride.GetFieldPrecisioncxx . . $ OGRFieldDefnOverride#GetFieldPrecision(293109f3f0511d88).().valuecxx . . $ std/optional#value(9772d62e20ffd8dd).());
2147 }
2148 if (oFieldOverride.GetFieldNamecxx . . $ OGRFieldDefnOverride#GetFieldName(5ce91bc52c9d8e1).().has_valuecxx . . $ std/optional#has_value(3482b152b9333168).())
2149 {
2150 poProperty->SetNamecxx . . $ GMLPropertyDefn#SetName(85c52e162fed56f9).(
2151 oFieldOverride.GetFieldNamecxx . . $ OGRFieldDefnOverride#GetFieldName(5ce91bc52c9d8e1).().valuecxx . . $ std/optional#value(9772d62e20ffd8dd).().c_str());
2152 }
2153 };
2154
2155 auto oFieldOverrideIter =
2156 oNamedFieldOverrides.findcxx . . $ std/map#find(36f8d56706583706).(poProperty->GetNamecxx . . $ GMLPropertyDefn#GetName(a9f41ea0e82d88cf).());
2157 if (oFieldOverrideItercxx . . $ std/_Rb_tree_const_iterator#_Rb_tree_const_iterator(dc529b7882ffd73b). !=cxx . . $ std/`operator!=`(a84eb84a7a5e8237). oNamedFieldOverrides.cendcxx . . $ std/map#cend(b953fec338ad1a3b).())
2158 {
2159 const auto &oFieldOverride = oFieldOverrideIter->cxx . . $ std/_Rb_tree_iterator#`operator->`(34d6acfd341ba7ab).second;
2160 PatchProperty(cxx . . $ OGRGMLDataSource#DealWithOgrSchemaOpenOption(425044c81b8374a5).$anonymous_type_0#`operator()`(15d73c1bd5428b18).$anonymous_type_1#`operator()`(6517ccacfcc131dd).oFieldOverride);
2161
2162 if (bIsFullOverride)
2163 {
2164 aoProperties.push_back(poProperty);
2165 }
2166 oNamedFieldOverrides.erasecxx . . $ std/map#erase(9238c2f1608b9ba6).(oFieldOverrideIter);
2167 }
2168 else
2169 {
2170 for (const auto &oFieldOverride :
2171 oUnnamedFieldOverrides)
2172 {
2173 OGRFieldSubType eSubType =
2174 oFieldOverride.GetFieldSubTypecxx . . $ OGRFieldDefnOverride#GetFieldSubType(9a0aed4df502f9d1).().value_orcxx . . $ std/optional#value_or(7989909f4c805093).(
2175 OFSTNone);
2176 if ((!oFieldOverride.GetSrcFieldTypecxx . . $ OGRFieldDefnOverride#GetSrcFieldType(f38c2d6b251dea2d).()
2177 .has_valuecxx . . $ std/optional#has_value(3482b152b9333168).() ||
2178 GML_FromOGRFieldTypecxx . . $ GML_FromOGRFieldType(5e9fe183570bdadf).(
2179 oFieldOverride.GetSrcFieldTypecxx . . $ OGRFieldDefnOverride#GetSrcFieldType(f38c2d6b251dea2d).().valuecxx . . $ std/optional#value(9772d62e20ffd8dd).(),
2180 eSubType) == poProperty->GetTypecxx . . $ GMLPropertyDefn#GetType(eb020ce77ce58ae).()) &&
2181 (!oFieldOverride.GetSrcFieldSubTypecxx . . $ OGRFieldDefnOverride#GetSrcFieldSubType(9a0aed4df502f9d1).()
2182 .has_valuecxx . . $ std/optional#has_value(3482b152b9333168).() ||
2183 oFieldOverride.GetSrcFieldSubTypecxx . . $ OGRFieldDefnOverride#GetSrcFieldSubType(9a0aed4df502f9d1).().valuecxx . . $ std/optional#value(9772d62e20ffd8dd).() ==
2184 poProperty->GetSubTypecxx . . $ GMLPropertyDefn#GetSubType(4db5e065ad90bc77).()))
2185 {
2186 PatchProperty(cxx . . $ OGRGMLDataSource#DealWithOgrSchemaOpenOption(425044c81b8374a5).$anonymous_type_0#`operator()`(15d73c1bd5428b18).$anonymous_type_1#`operator()`(6517ccacfcc131dd).oFieldOverride);
2187 break;
2188 }
2189 }
2190 }
2191 }
2192
2193 // Error if any field override is not found
2194 if (!oNamedFieldOverrides.emptycxx . . $ std/map#empty(3482b152b9333168).())
2195 {
2196 CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
2197 "Field %s not found in layer %s",
2198 oNamedFieldOverrides.cbegincxx . . $ std/map#cbegin(b953fec338ad1a3b).()->cxx . . $ std/_Rb_tree_const_iterator#`operator->`(8e614c7de0b1573e).first.c_str(),
2199 osLayerName.c_str());
2200 return false;
2201 }
2202
2203 // Remove fields not in the override
2204 if (bIsFullOverride)
2205 {
2206 for (int j = 0; j < poClass->GetPropertyCountcxx . . $ GMLFeatureClass#GetPropertyCount(455f465bc33b4cdf).(); ++j)
2207 {
2208 const auto oProperty = poClass->GetPropertycxx . . $ GMLFeatureClass#GetProperty(b950e76b5d86c48f).(j);
2209 if (stdcxx . . $ std/::findcxx . . $ std/find(a92da12e15934614).(aoProperties.begin(), aoProperties.end(),
2210 oProperty) == aoProperties.end())
2211 {
2212 delete (oProperty);
2213 }
2214 }
2215
2216 poClass->StealPropertiescxx . . $ GMLFeatureClass#StealProperties(49f6e7a06ebc5aa8).();
2217
2218 for (const auto &oProperty : aoProperties)
2219 {
2220 poClass->AddPropertycxx . . $ GMLFeatureClass#AddProperty(b7cb0caa1392178c).(oProperty);
2221 }
2222 }
2223
2224 return true;
2225 };
2226
2227 CPLDebug("GML", "Applying schema override for layer %s",
2228 osLayerName.c_str());
2229
2230 if (osLayerName == "*")
2231 {
2232 for (int iClass = 0; iClass < poReadercxx . . $ OGRGMLDataSource#poReader.->GetClassCountcxx . . $ IGMLReader#GetClassCount(455f465bc33b4cdf).();
2233 ++iClass)
2234 {
2235 if (!ProcessLayer(cxx . . $ OGRGMLDataSource#DealWithOgrSchemaOpenOption(425044c81b8374a5).$anonymous_type_0#`operator()`(15d73c1bd5428b18).poReadercxx . . $ OGRGMLDataSource#poReader.->GetClasscxx . . $ IGMLReader#GetClass(472756784324af7f).(iClass)))
2236 return false;
2237 }
2238 }
2239 else
2240 {
2241 // Fail if the layer name does not exist
2242 const auto oClass = poReadercxx . . $ OGRGMLDataSource#poReader.->GetClasscxx . . $ IGMLReader#GetClass(aef30861fca1f104).(osLayerName.c_str());
2243 if (oClass == nullptr)
2244 {
2245 CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
2246 "Layer %s not found in", osLayerName.c_str());
2247 return false;
2248 }
2249 if (!ProcessLayer(cxx . . $ OGRGMLDataSource#DealWithOgrSchemaOpenOption(425044c81b8374a5).$anonymous_type_0#`operator()`(15d73c1bd5428b18).oClass))
2250 return false;
2251 }
2252 }
2253 }
2254 return true;
2255 }
2256
2257 /************************************************************************/
2258 /* DeclareNewWriteSRS() */
2259 /************************************************************************/
2260
2261 // Check that all SRS passed to ICreateLayer() and CreateGeomField()
2262 // are the same (or all null)
2263
2264 void OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::DeclareNewWriteSRScxx . . $ OGRGMLDataSource#DeclareNewWriteSRS(9ff39b79387a6086).(const OGRSpatialReferencecxx . . $ OGRSpatialReference# *poSRS)
2265 {
2266 if (m_bWriteGlobalSRScxx . . $ OGRGMLDataSource#m_bWriteGlobalSRS.)
2267 {
2268 if (!m_bWriteGlobalSRSInitcxx . . $ OGRGMLDataSource#m_bWriteGlobalSRSInit.)
2269 {
2270 m_bWriteGlobalSRSInitcxx . . $ OGRGMLDataSource#m_bWriteGlobalSRSInit. = true;
2271 if (poSRS)
2272 {
2273 m_poWriteGlobalSRScxx . . $ OGRGMLDataSource#m_poWriteGlobalSRS. =cxx . . $ OGRRefCountedPtr#`operator=`(75ecb2b9da62a289).
2274 OGRSpatialReferenceRefCountedPtrcxx . . $ OGRSpatialReferenceRefCountedPtr#::makeClonecxx . . $ OGRRefCountedPtr#makeClone(52807447ccd2a8c8).(poSRS);
2275 m_poWriteGlobalSRScxx . . $ OGRGMLDataSource#m_poWriteGlobalSRS.->cxx . . $ OGRRefCountedPtrBase#`operator->`(5a2a78a048fb49a8).SetAxisMappingStrategycxx . . $ OGRSpatialReference#SetAxisMappingStrategy(3d39f43974738d6a).(
2276 OAMS_TRADITIONAL_GIS_ORDER);
2277 }
2278 }
2279 else
2280 {
2281 if (m_poWriteGlobalSRScxx . . $ OGRGMLDataSource#m_poWriteGlobalSRS.)
2282 {
2283 const char *const apszOptions[] = {
2284 "IGNORE_DATA_AXIS_TO_SRS_AXIS_MAPPING=YES", nullptr};
2285 if (!poSRS ||
2286 !poSRS->IsSamecxx . . $ OGRSpatialReference#IsSame(237d09acedc929c6).(m_poWriteGlobalSRScxx . . $ OGRGMLDataSource#m_poWriteGlobalSRS..getcxx . . $ OGRRefCountedPtrBase#get(5a2a78a048fb49a8).(), apszOptions))
2287 {
2288 m_bWriteGlobalSRScxx . . $ OGRGMLDataSource#m_bWriteGlobalSRS. = false;
2289 }
2290 }
2291 else
2292 {
2293 if (poSRS)
2294 m_bWriteGlobalSRScxx . . $ OGRGMLDataSource#m_bWriteGlobalSRS. = false;
2295 }
2296 }
2297 }
2298 }
2299
2300 /************************************************************************/
2301 /* ICreateLayer() */
2302 /************************************************************************/
2303
2304 OGRLayercxx . . $ OGRLayer# *
2305 OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::ICreateLayercxx . . $ OGRGMLDataSource#ICreateLayer(d0342318947b6f88).(const char *pszLayerName,
2306 const OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn# *poSrcGeomFieldDefn,
2307 CSLConstListcxx . . $ CSLConstList# /*papszOptions*/)
2308 {
2309 // Verify we are in update mode.
2310 if (fpOutputcxx . . $ OGRGMLDataSource#fpOutput. == nullptr)
2311 {
2312 CPLError(CE_Failure, CPLE_NoWriteAccesscxx . . $ `port/cpl_error.h:122:9`!,
2313 "Data source %s opened for read access.\n"
2314 "New layer %s cannot be created.\n",
2315 GetDescriptioncxx . . $ GDALMajorObject#GetDescription(a9f41ea0e82d88cf).(), pszLayerName);
2316
2317 return nullptr;
2318 }
2319
2320 const auto eType =
2321 poSrcGeomFieldDefn ? poSrcGeomFieldDefn->GetTypecxx . . $ OGRGeomFieldDefn#GetType(5a40c54c5ff210ce).() : wkbNone;
2322 const auto poSRS =
2323 poSrcGeomFieldDefn ? poSrcGeomFieldDefn->GetSpatialRefcxx . . $ OGRGeomFieldDefn#GetSpatialRef(8a5496c2eeefaeaf).() : nullptr;
2324
2325 // Ensure name is safe as an element name.
2326 char *pszCleanLayerName = CPLStrdup(pszLayerName);
2327
2328 CPLCleanXMLElementName(pszCleanLayerName);
2329 if (strcmp(pszCleanLayerName, pszLayerName) != 0)
2330 {
2331 CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!,
2332 "Layer name '%s' adjusted to '%s' for XML validity.",
2333 pszLayerName, pszCleanLayerName);
2334 }
2335
2336 if (nLayerscxx . . $ OGRGMLDataSource#nLayers. == 0)
2337 {
2338 WriteTopElementscxx . . $ OGRGMLDataSource#WriteTopElements(49f6e7a06ebc5aa8).();
2339 }
2340
2341 // Create the layer object.
2342 OGRLayercxx . . $ OGRLayer# *poLayer = new OGRGMLLayercxx . . $ OGRGMLLayer#(pszCleanLayerName, true, this);
2343 OGRFeatureDefncxx . . $ OGRFeatureDefn# *poLayerDefn = poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).();
2344 poLayerDefn->SetGeomTypecxx . . $ OGRFeatureDefn#SetGeomType(f47ce3f1fe923726).(eType);
2345 if (eType != wkbNone)
2346 {
2347 auto poGeomFieldDefn = poLayerDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0);
2348 const char *pszGeomFieldName = poSrcGeomFieldDefn->GetNameRefcxx . . $ OGRGeomFieldDefn#GetNameRef(a9f41ea0e82d88cf).();
2349 if (!pszGeomFieldName || pszGeomFieldName[0] == 0)
2350 pszGeomFieldName = "geometryProperty";
2351 poGeomFieldDefn->SetNamecxx . . $ OGRGeomFieldDefn#SetName(85c52e162fed56f9).(pszGeomFieldName);
2352 poGeomFieldDefn->SetNullablecxx . . $ OGRGeomFieldDefn#SetNullable(d4f767463ce0a6b3).(poSrcGeomFieldDefn->IsNullablecxx . . $ OGRGeomFieldDefn#IsNullable(455f465bc33b4cdf).());
2353 DeclareNewWriteSRScxx . . $ OGRGMLDataSource#DeclareNewWriteSRS(9ff39b79387a6086).(poSRS);
2354 if (poSRS != nullptr)
2355 {
2356 auto poSRSClone = poSRS->Clonecxx . . $ OGRSpatialReference#Clone(1a0fa159535833d7).();
2357 poSRSClone->SetAxisMappingStrategycxx . . $ OGRSpatialReference#SetAxisMappingStrategy(3d39f43974738d6a).(OAMS_TRADITIONAL_GIS_ORDER);
2358 poGeomFieldDefn->SetSpatialRefcxx . . $ OGRGeomFieldDefn#SetSpatialRef(9ff39b79387a6086).(poSRSClone);
2359 poSRSClone->Dereferencecxx . . $ OGRSpatialReference#Dereference(b126dc7c1de90089).();
2360 }
2361 poGeomFieldDefn->SetCoordinatePrecisioncxx . . $ OGRGeomFieldDefn#SetCoordinatePrecision(a66dcf8fa4d01368).(
2362 poSrcGeomFieldDefn->GetCoordinatePrecisioncxx . . $ OGRGeomFieldDefn#GetCoordinatePrecision(4cbff8bea018030e).());
2363 }
2364
2365 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszCleanLayerName);
2366
2367 // Add layer to data source layer list.
2368 papoLayerscxx . . $ OGRGMLDataSource#papoLayers. = static_cast<OGRLayercxx . . $ OGRLayer# **>(
2369 CPLRealloc(papoLayerscxx . . $ OGRGMLDataSource#papoLayers., sizeof(OGRLayercxx . . $ OGRLayer# *) * (nLayerscxx . . $ OGRGMLDataSource#nLayers. + 1)));
2370
2371 papoLayerscxx . . $ OGRGMLDataSource#papoLayers.[nLayerscxx . . $ OGRGMLDataSource#nLayers.++] = poLayer;
2372
2373 return poLayer;
2374 }
2375
2376 /************************************************************************/
2377 /* TestCapability() */
2378 /************************************************************************/
2379
2380 int OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::TestCapabilitycxx . . $ OGRGMLDataSource#TestCapability(78f035161ffa9fe2).(const char *pszCap) const
2381
2382 {
2383 if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, ODsCCreateLayercxx . . $ `ogr/ogr_core.h:1040:9`!))
2384 return TRUEcxx . . $ `port/cpl_port.h:1184:9`!;
2385 else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, ODsCCreateGeomFieldAfterCreateLayercxx . . $ `ogr/ogr_core.h:1045:9`!))
2386 return TRUEcxx . . $ `port/cpl_port.h:1184:9`!;
2387 else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, ODsCCurveGeometriescxx . . $ `ogr/ogr_core.h:1048:9`!))
2388 return bIsOutputGML3cxx . . $ OGRGMLDataSource#bIsOutputGML3.;
2389 else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, ODsCZGeometriescxx . . $ `ogr/ogr_core.h:1058:9`!))
2390 return TRUEcxx . . $ `port/cpl_port.h:1184:9`!;
2391 else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, ODsCRandomLayerWritecxx . . $ `ogr/ogr_core.h:1065:9`!))
2392 return TRUEcxx . . $ `port/cpl_port.h:1184:9`!;
2393 else
2394 return FALSEcxx . . $ `port/cpl_port.h:1180:9`!;
2395 }
2396
2397 /************************************************************************/
2398 /* GetLayer() */
2399 /************************************************************************/
2400
2401 const OGRLayercxx . . $ OGRLayer# *OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::GetLayercxx . . $ OGRGMLDataSource#GetLayer(3ead67c79a3185c4).(int iLayer) const
2402
2403 {
2404 if (iLayer < 0 || iLayer >= nLayerscxx . . $ OGRGMLDataSource#nLayers.)
2405 return nullptr;
2406 else
2407 return papoLayerscxx . . $ OGRGMLDataSource#papoLayers.[iLayer];
2408 }
2409
2410 /************************************************************************/
2411 /* GrowExtents() */
2412 /************************************************************************/
2413
2414 void OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::GrowExtentscxx . . $ OGRGMLDataSource#GrowExtents(3ce6bd70c6ea6dde).(OGREnvelope3D *psGeomBounds,
2415 int nCoordDimension)
2416
2417 {
2418 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..Merge(*psGeomBounds);
2419 if (nCoordDimension == 3)
2420 bBBOX3Dcxx . . $ OGRGMLDataSource#bBBOX3D. = true;
2421 }
2422
2423 /************************************************************************/
2424 /* InsertHeader() */
2425 /* */
2426 /* This method is used to update boundedby info for a */
2427 /* dataset, and insert schema descriptions depending on */
2428 /* selection options in effect. */
2429 /************************************************************************/
2430
2431 void OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::InsertHeadercxx . . $ OGRGMLDataSource#InsertHeader(49f6e7a06ebc5aa8).()
2432
2433 {
2434 int nSchemaStart = 0;
2435
2436 if (bFpOutputSingleFilecxx . . $ OGRGMLDataSource#bFpOutputSingleFile.)
2437 return;
2438
2439 // Do we want to write the schema within the GML instance doc
2440 // or to a separate file? For now we only support external.
2441 const char *pszSchemaURI =
2442 CSLFetchNameValue(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "XSISCHEMAURI");
2443 const char *pszSchemaOpt =
2444 CSLFetchNameValue(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "XSISCHEMA");
2445
2446 const bool bGMLFeatureCollection = GMLFeatureCollectioncxx . . $ OGRGMLDataSource#GMLFeatureCollection(50ce9a9e25b4a850).();
2447
2448 if (pszSchemaURI != nullptr)
2449 return;
2450
2451 VSILFILE *fpSchema = nullptr;
2452 if (pszSchemaOpt == nullptr || EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSchemaOpt, "EXTERNAL"))
2453 {
2454 const stdcxx . . $ std/::string l_osXSDFilename =
2455 CPLResetExtensionSafe(GetDescriptioncxx . . $ GDALMajorObject#GetDescription(a9f41ea0e82d88cf).(), "xsd");
2456
2457 fpSchema = VSIFOpenL(l_osXSDFilename.c_str(), "wt");
2458 if (fpSchema == nullptr)
2459 {
2460 CPLError(CE_Failure, CPLE_OpenFailedcxx . . $ `port/cpl_error.h:114:9`!,
2461 "Failed to open file %.500s for schema output.",
2462 l_osXSDFilename.c_str());
2463 return;
2464 }
2465 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
2466 }
2467 else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSchemaOpt, "INTERNAL"))
2468 {
2469 if (fpOutputcxx . . $ OGRGMLDataSource#fpOutput. == nullptr)
2470 return;
2471 nSchemaStart = static_cast<int>(VSIFTellL(fpOutputcxx . . $ OGRGMLDataSource#fpOutput.));
2472 fpSchema = fpOutputcxx . . $ OGRGMLDataSource#fpOutput.;
2473 }
2474 else
2475 {
2476 return;
2477 }
2478
2479 // Write the schema section at the end of the file. Once
2480 // complete, we will read it back in, and then move the whole
2481 // file "down" enough to insert the schema at the beginning.
2482
2483 // Detect if there are fields of List types.
2484 bool bHasListFields = false;
2485
2486 const int nLayerCount = OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::GetLayerCountcxx . . $ OGRGMLDataSource#GetLayerCount(455f465bc33b4cdf).();
2487 for (int iLayer = 0; !bHasListFields && iLayer < nLayerCount; iLayer++)
2488 {
2489 OGRFeatureDefncxx . . $ OGRFeatureDefn# *poFDefn = papoLayerscxx . . $ OGRGMLDataSource#papoLayers.[iLayer]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).();
2490 for (int iField = 0;
2491 !bHasListFields && iField < poFDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).(); iField++)
2492 {
2493 OGRFieldDefncxx . . $ OGRFieldDefn# *poFieldDefn = poFDefn->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(iField);
2494
2495 if (poFieldDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTIntegerList ||
2496 poFieldDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTInteger64List ||
2497 poFieldDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTRealList ||
2498 poFieldDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTStringList)
2499 {
2500 bHasListFields = true;
2501 }
2502 }
2503 }
2504
2505 // Emit the start of the schema section.
2506 const char *pszPrefix = GetAppPrefixcxx . . $ OGRGMLDataSource#GetAppPrefix(a9f41ea0e82d88cf).();
2507 if (pszPrefix[0] == '\0')
2508 pszPrefix = "ogr";
2509 const char *pszTargetNameSpace = CSLFetchNameValueDef(
2510 papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "TARGET_NAMESPACE", "http://ogr.maptools.org/");
2511
2512 if (IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).())
2513 {
2514 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "<xs:schema ");
2515 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " targetNamespace=\"%s\"", pszTargetNameSpace);
2516 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " xmlns:%s=\"%s\"", pszPrefix,
2517 pszTargetNameSpace);
2518 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2519 " xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"");
2520 if (IsGML32Outputcxx . . $ OGRGMLDataSource#IsGML32Output(50ce9a9e25b4a850).())
2521 {
2522 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2523 " xmlns:gml=\"http://www.opengis.net/gml/3.2\"");
2524 if (!bGMLFeatureCollection)
2525 {
2526 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
2527 fpSchema,
2528 " xmlns:gmlsf=\"http://www.opengis.net/gmlsf/2.0\"");
2529 }
2530 }
2531 else
2532 {
2533 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " xmlns:gml=\"http://www.opengis.net/gml\"");
2534 if (!IsGML3DeegreeOutputcxx . . $ OGRGMLDataSource#IsGML3DeegreeOutput(50ce9a9e25b4a850).() && !bGMLFeatureCollection)
2535 {
2536 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2537 " xmlns:gmlsf=\"http://www.opengis.net/gmlsf\"");
2538 }
2539 }
2540 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " elementFormDefault=\"qualified\"");
2541 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " version=\"1.0\">");
2542
2543 if (IsGML32Outputcxx . . $ OGRGMLDataSource#IsGML32Output(50ce9a9e25b4a850).())
2544 {
2545 if (!bGMLFeatureCollection)
2546 {
2547 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "<xs:annotation>");
2548 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:appinfo "
2549 "source=\"http://schemas.opengis.net/"
2550 "gmlsfProfile/2.0/gmlsfLevels.xsd\">");
2551 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
2552 fpSchema,
2553 " <gmlsf:ComplianceLevel>%d</gmlsf:ComplianceLevel>",
2554 (bHasListFields) ? 1 : 0);
2555 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:appinfo>");
2556 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "</xs:annotation>");
2557 }
2558
2559 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2560 "<xs:import namespace=\"http://www.opengis.net/gml/3.2\" "
2561 "schemaLocation=\"http://schemas.opengis.net/gml/3.2.1/"
2562 "gml.xsd\"/>");
2563 if (!bGMLFeatureCollection)
2564 {
2565 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
2566 fpSchema,
2567 "<xs:import namespace=\"http://www.opengis.net/gmlsf/2.0\" "
2568 "schemaLocation=\"http://schemas.opengis.net/gmlsfProfile/"
2569 "2.0/gmlsfLevels.xsd\"/>");
2570 }
2571 }
2572 else
2573 {
2574 if (!IsGML3DeegreeOutputcxx . . $ OGRGMLDataSource#IsGML3DeegreeOutput(50ce9a9e25b4a850).() && !bGMLFeatureCollection)
2575 {
2576 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "<xs:annotation>");
2577 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2578 " <xs:appinfo "
2579 "source=\"http://schemas.opengis.net/gml/3.1.1/"
2580 "profiles/gmlsfProfile/1.0.0/gmlsfLevels.xsd\">");
2581 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
2582 fpSchema,
2583 " <gmlsf:ComplianceLevel>%d</gmlsf:ComplianceLevel>",
2584 (bHasListFields) ? 1 : 0);
2585 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2586 " "
2587 "<gmlsf:GMLProfileSchema>http://schemas.opengis.net/"
2588 "gml/3.1.1/profiles/gmlsfProfile/1.0.0/gmlsf.xsd</"
2589 "gmlsf:GMLProfileSchema>");
2590 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:appinfo>");
2591 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "</xs:annotation>");
2592 }
2593
2594 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2595 "<xs:import namespace=\"http://www.opengis.net/gml\" "
2596 "schemaLocation=\"http://schemas.opengis.net/gml/3.1.1/"
2597 "base/gml.xsd\"/>");
2598 if (!IsGML3DeegreeOutputcxx . . $ OGRGMLDataSource#IsGML3DeegreeOutput(50ce9a9e25b4a850).() && !bGMLFeatureCollection)
2599 {
2600 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
2601 fpSchema,
2602 "<xs:import namespace=\"http://www.opengis.net/gmlsf\" "
2603 "schemaLocation=\"http://schemas.opengis.net/gml/3.1.1/"
2604 "profiles/gmlsfProfile/1.0.0/gmlsfLevels.xsd\"/>");
2605 }
2606 }
2607 }
2608 else
2609 {
2610 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2611 "<xs:schema targetNamespace=\"%s\" xmlns:%s=\"%s\" "
2612 "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" "
2613 "xmlns:gml=\"http://www.opengis.net/gml\" "
2614 "elementFormDefault=\"qualified\" version=\"1.0\">",
2615 pszTargetNameSpace, pszPrefix, pszTargetNameSpace);
2616
2617 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2618 "<xs:import namespace=\"http://www.opengis.net/gml\" "
2619 "schemaLocation=\"http://schemas.opengis.net/gml/2.1.2/"
2620 "feature.xsd\"/>");
2621 }
2622
2623 // Define the FeatureCollection element
2624 if (!bGMLFeatureCollection)
2625 {
2626 bool bHasUniqueConstraints = false;
2627 for (int iLayer = 0; (iLayer < nLayerCount) && !bHasUniqueConstraints;
2628 iLayer++)
2629 {
2630 OGRFeatureDefncxx . . $ OGRFeatureDefn# *poFDefn = papoLayerscxx . . $ OGRGMLDataSource#papoLayers.[iLayer]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).();
2631 const int nFieldCount = poFDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).();
2632 for (int iField = 0;
2633 (iField < nFieldCount) && !bHasUniqueConstraints; iField++)
2634 {
2635 const OGRFieldDefncxx . . $ OGRFieldDefn# *poFieldDefn = poFDefn->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(iField);
2636 if (poFieldDefn->IsUniquecxx . . $ OGRFieldDefn#IsUnique(455f465bc33b4cdf).())
2637 bHasUniqueConstraints = true;
2638 }
2639 }
2640
2641 const char *pszFeatureMemberPrefix = pszPrefix;
2642 if (IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).())
2643 {
2644 if (IsGML32Outputcxx . . $ OGRGMLDataSource#IsGML32Output(50ce9a9e25b4a850).())
2645 {
2646 // GML Simple Features profile v2.0 mentions gml:AbstractGML as
2647 // substitutionGroup but using gml:AbstractFeature makes it
2648 // usablable by GMLJP2 v2.
2649 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2650 "<xs:element name=\"FeatureCollection\" "
2651 "type=\"%s:FeatureCollectionType\" "
2652 "substitutionGroup=\"gml:AbstractFeature\"%s>",
2653 pszPrefix, bHasUniqueConstraints ? "" : "/");
2654 }
2655 else if (IsGML3DeegreeOutputcxx . . $ OGRGMLDataSource#IsGML3DeegreeOutput(50ce9a9e25b4a850).())
2656 {
2657 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2658 "<xs:element name=\"FeatureCollection\" "
2659 "type=\"%s:FeatureCollectionType\" "
2660 "substitutionGroup=\"gml:_FeatureCollection\"%s>",
2661 pszPrefix, bHasUniqueConstraints ? "" : "/");
2662 }
2663 else
2664 {
2665 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2666 "<xs:element name=\"FeatureCollection\" "
2667 "type=\"%s:FeatureCollectionType\" "
2668 "substitutionGroup=\"gml:_GML\"%s>",
2669 pszPrefix, bHasUniqueConstraints ? "" : "/");
2670 }
2671 }
2672 else
2673 {
2674 pszFeatureMemberPrefix = "gml";
2675 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2676 "<xs:element name=\"FeatureCollection\" "
2677 "type=\"%s:FeatureCollectionType\" "
2678 "substitutionGroup=\"gml:_FeatureCollection\"%s>",
2679 pszPrefix, bHasUniqueConstraints ? "" : "/");
2680 }
2681
2682 if (bHasUniqueConstraints)
2683 {
2684 for (int iLayer = 0; iLayer < nLayerCount; iLayer++)
2685 {
2686 OGRFeatureDefncxx . . $ OGRFeatureDefn# *poFDefn = papoLayerscxx . . $ OGRGMLDataSource#papoLayers.[iLayer]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).();
2687 const int nFieldCount = poFDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).();
2688 for (int iField = 0; iField < nFieldCount; iField++)
2689 {
2690 const OGRFieldDefncxx . . $ OGRFieldDefn# *poFieldDefn =
2691 poFDefn->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(iField);
2692 if (poFieldDefn->IsUniquecxx . . $ OGRFieldDefn#IsUnique(455f465bc33b4cdf).())
2693 {
2694 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
2695 fpSchema,
2696 " <xs:unique name=\"uniqueConstraint_%s_%s\">",
2697 poFDefn->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).(), poFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).());
2698 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2699 " <xs:selector "
2700 "xpath=\"%s:featureMember/%s:%s\"/>",
2701 pszFeatureMemberPrefix, pszPrefix,
2702 poFDefn->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).());
2703 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:field xpath=\"%s:%s\"/>",
2704 pszPrefix, poFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).());
2705 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:unique>");
2706 }
2707 }
2708 }
2709 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "</xs:element>");
2710 }
2711 }
2712
2713 // Define the FeatureCollectionType
2714 if (IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).() && !bGMLFeatureCollection)
2715 {
2716 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "<xs:complexType name=\"FeatureCollectionType\">");
2717 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:complexContent>");
2718 if (IsGML3DeegreeOutputcxx . . $ OGRGMLDataSource#IsGML3DeegreeOutput(50ce9a9e25b4a850).())
2719 {
2720 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:extension "
2721 "base=\"gml:AbstractFeatureCollectionType\">");
2722 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:sequence>");
2723 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:element name=\"featureMember\" "
2724 "minOccurs=\"0\" maxOccurs=\"unbounded\">");
2725 }
2726 else
2727 {
2728 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2729 " <xs:extension base=\"gml:AbstractFeatureType\">");
2730 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
2731 fpSchema,
2732 " <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">");
2733 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:element name=\"featureMember\">");
2734 }
2735 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:complexType>");
2736 if (IsGML32Outputcxx . . $ OGRGMLDataSource#IsGML32Output(50ce9a9e25b4a850).())
2737 {
2738 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:complexContent>");
2739 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:extension "
2740 "base=\"gml:AbstractFeatureMemberType\">");
2741 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:sequence>");
2742 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
2743 fpSchema,
2744 " <xs:element ref=\"gml:AbstractFeature\"/>");
2745 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:sequence>");
2746 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:extension>");
2747 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:complexContent>");
2748 }
2749 else
2750 {
2751 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:sequence>");
2752 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2753 " <xs:element ref=\"gml:_Feature\"/>");
2754 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:sequence>");
2755 }
2756 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:complexType>");
2757 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:element>");
2758 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:sequence>");
2759 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:extension>");
2760 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:complexContent>");
2761 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "</xs:complexType>");
2762 }
2763 else if (!bGMLFeatureCollection)
2764 {
2765 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "<xs:complexType name=\"FeatureCollectionType\">");
2766 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:complexContent>");
2767 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
2768 fpSchema,
2769 " <xs:extension base=\"gml:AbstractFeatureCollectionType\">");
2770 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:attribute name=\"lockId\" "
2771 "type=\"xs:string\" use=\"optional\"/>");
2772 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:attribute name=\"scope\" "
2773 "type=\"xs:string\" use=\"optional\"/>");
2774 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:extension>");
2775 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:complexContent>");
2776 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "</xs:complexType>");
2777 }
2778
2779 // Define the schema for each layer.
2780 for (int iLayer = 0; iLayer < nLayerCount; iLayer++)
2781 {
2782 OGRFeatureDefncxx . . $ OGRFeatureDefn# *poFDefn = papoLayerscxx . . $ OGRGMLDataSource#papoLayers.[iLayer]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).();
2783
2784 // Emit initial stuff for a feature type.
2785 if (IsGML32Outputcxx . . $ OGRGMLDataSource#IsGML32Output(50ce9a9e25b4a850).())
2786 {
2787 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2788 "<xs:element name=\"%s\" type=\"%s:%s_Type\" "
2789 "substitutionGroup=\"gml:AbstractFeature\"/>",
2790 poFDefn->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).(), pszPrefix, poFDefn->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).());
2791 }
2792 else
2793 {
2794 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2795 "<xs:element name=\"%s\" type=\"%s:%s_Type\" "
2796 "substitutionGroup=\"gml:_Feature\"/>",
2797 poFDefn->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).(), pszPrefix, poFDefn->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).());
2798 }
2799
2800 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "<xs:complexType name=\"%s_Type\">",
2801 poFDefn->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).());
2802 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:complexContent>");
2803 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2804 " <xs:extension base=\"gml:AbstractFeatureType\">");
2805 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:sequence>");
2806
2807 for (int iGeomField = 0; iGeomField < poFDefn->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).();
2808 iGeomField++)
2809 {
2810 OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn# *poFieldDefn =
2811 poFDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(iGeomField);
2812
2813 // Define the geometry attribute.
2814 const char *pszGeometryTypeName = "GeometryPropertyType";
2815 const char *pszGeomTypeComment = "";
2816 OGRwkbGeometryType eGType = wkbFlattencxx . . $ `ogr/ogr_core.h:576:9`!(poFieldDefn->GetType());
2817 switch (eGType)
2818 {
2819 case wkbPoint:
2820 pszGeometryTypeName = "PointPropertyType";
2821 break;
2822 case wkbLineString:
2823 case wkbCircularString:
2824 case wkbCompoundCurve:
2825 if (IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).())
2826 {
2827 if (eGType == wkbLineString)
2828 pszGeomTypeComment =
2829 " <!-- restricted to LineString -->";
2830 else if (eGType == wkbCircularString)
2831 pszGeomTypeComment =
2832 " <!-- contains CircularString -->";
2833 else if (eGType == wkbCompoundCurve)
2834 pszGeomTypeComment =
2835 " <!-- contains CompoundCurve -->";
2836 pszGeometryTypeName = "CurvePropertyType";
2837 }
2838 else
2839 pszGeometryTypeName = "LineStringPropertyType";
2840 break;
2841 case wkbPolygon:
2842 case wkbCurvePolygon:
2843 if (IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).())
2844 {
2845 if (eGType == wkbPolygon)
2846 pszGeomTypeComment =
2847 " <!-- restricted to Polygon -->";
2848 else if (eGType == wkbCurvePolygon)
2849 pszGeomTypeComment =
2850 " <!-- contains CurvePolygon -->";
2851 pszGeometryTypeName = "SurfacePropertyType";
2852 }
2853 else
2854 pszGeometryTypeName = "PolygonPropertyType";
2855 break;
2856 case wkbMultiPoint:
2857 pszGeometryTypeName = "MultiPointPropertyType";
2858 break;
2859 case wkbMultiLineString:
2860 case wkbMultiCurve:
2861 if (IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).())
2862 {
2863 if (eGType == wkbMultiLineString)
2864 pszGeomTypeComment =
2865 " <!-- restricted to MultiLineString -->";
2866 else if (eGType == wkbMultiCurve)
2867 pszGeomTypeComment =
2868 " <!-- contains non-linear MultiCurve -->";
2869 pszGeometryTypeName = "MultiCurvePropertyType";
2870 }
2871 else
2872 pszGeometryTypeName = "MultiLineStringPropertyType";
2873 break;
2874 case wkbMultiPolygon:
2875 case wkbMultiSurface:
2876 if (IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).())
2877 {
2878 if (eGType == wkbMultiPolygon)
2879 pszGeomTypeComment =
2880 " <!-- restricted to MultiPolygon -->";
2881 else if (eGType == wkbMultiSurface)
2882 pszGeomTypeComment =
2883 " <!-- contains non-linear MultiSurface -->";
2884 pszGeometryTypeName = "MultiSurfacePropertyType";
2885 }
2886 else
2887 pszGeometryTypeName = "MultiPolygonPropertyType";
2888 break;
2889 case wkbGeometryCollection:
2890 pszGeometryTypeName = "MultiGeometryPropertyType";
2891 break;
2892 default:
2893 break;
2894 }
2895
2896 const auto poSRS = poFieldDefn->GetSpatialRefcxx . . $ OGRGeomFieldDefn#GetSpatialRef(8a5496c2eeefaeaf).();
2897 stdcxx . . $ std/::string osSRSNameComment;
2898 if (poSRS)
2899 {
2900 bool bCoordSwap = false;
2901 char *pszSRSName =
2902 GML_GetSRSNamecxx . . $ GML_GetSRSName(30d61418dc65e8e3).(poSRS, GetSRSNameFormatcxx . . $ OGRGMLDataSource#GetSRSNameFormat(cdddc96e9dacc204).(), &bCoordSwap);
2903 if (pszSRSName[0])
2904 {
2905 osSRSNameComment = "<!--";
2906 osSRSNameComment += pszSRSName;
2907 osSRSNameComment += " -->";
2908 }
2909 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszSRSName);
2910 }
2911
2912 int nMinOccurs = poFieldDefn->IsNullablecxx . . $ OGRGeomFieldDefn#IsNullable(455f465bc33b4cdf).() ? 0 : 1;
2913 const auto &oCoordPrec = poFieldDefn->GetCoordinatePrecisioncxx . . $ OGRGeomFieldDefn#GetCoordinatePrecision(4cbff8bea018030e).();
2914 if (oCoordPrec.dfXYResolutioncxx . . $ OGRGeomCoordinatePrecision#dfXYResolution. ==
2915 OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN. &&
2916 oCoordPrec.dfZResolutioncxx . . $ OGRGeomCoordinatePrecision#dfZResolution. == OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN.)
2917 {
2918 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
2919 fpSchema,
2920 " <xs:element name=\"%s\" type=\"gml:%s\" "
2921 "nillable=\"true\" minOccurs=\"%d\" maxOccurs=\"1\"/>%s%s",
2922 poFieldDefn->GetNameRefcxx . . $ OGRGeomFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), pszGeometryTypeName, nMinOccurs,
2923 pszGeomTypeComment, osSRSNameComment.c_str());
2924 }
2925 else
2926 {
2927 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2928 " <xs:element name=\"%s\" type=\"gml:%s\" "
2929 "nillable=\"true\" minOccurs=\"%d\" maxOccurs=\"1\">",
2930 poFieldDefn->GetNameRefcxx . . $ OGRGeomFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), pszGeometryTypeName,
2931 nMinOccurs);
2932 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:annotation>");
2933 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:appinfo "
2934 "source=\"http://ogr.maptools.org/\">");
2935 if (oCoordPrec.dfXYResolutioncxx . . $ OGRGeomCoordinatePrecision#dfXYResolution. !=
2936 OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN.)
2937 {
2938 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2939 " "
2940 "<ogr:xy_coordinate_resolution>%g</"
2941 "ogr:xy_coordinate_resolution>",
2942 oCoordPrec.dfXYResolutioncxx . . $ OGRGeomCoordinatePrecision#dfXYResolution.);
2943 }
2944 if (oCoordPrec.dfZResolutioncxx . . $ OGRGeomCoordinatePrecision#dfZResolution. !=
2945 OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN.)
2946 {
2947 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2948 " "
2949 "<ogr:z_coordinate_resolution>%g</"
2950 "ogr:z_coordinate_resolution>",
2951 oCoordPrec.dfZResolutioncxx . . $ OGRGeomCoordinatePrecision#dfZResolution.);
2952 }
2953 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:appinfo>");
2954 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:annotation>");
2955 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:element>%s%s",
2956 pszGeomTypeComment, osSRSNameComment.c_str());
2957 }
2958 }
2959
2960 // Emit each of the attributes.
2961 for (int iField = 0; iField < poFDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).(); iField++)
2962 {
2963 OGRFieldDefncxx . . $ OGRFieldDefn# *poFieldDefn = poFDefn->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(iField);
2964
2965 if (IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).() &&
2966 strcmp(poFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), "gml_id") == 0)
2967 continue;
2968 else if (!IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).() &&
2969 strcmp(poFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), "fid") == 0)
2970 continue;
2971
2972 const auto AddComment = [this, fpSchema, poFieldDefn]()
2973 {
2974 if (!poFieldDefn->GetCommentcxx . . $ OGRFieldDefn#GetComment(f4fff0029955a25f).().empty())
2975 {
2976 char *pszComment = CPLEscapeString(
2977 poFieldDefn->GetCommentcxx . . $ OGRFieldDefn#GetComment(f4fff0029955a25f).().c_str(), -1, CPLES_XMLcxx . . $ `port/cpl_string.h:155:9`!);
2978 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2979 " "
2980 "<xs:annotation><xs:documentation>%s</"
2981 "xs:documentation></xs:annotation>",
2982 pszComment);
2983 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszComment);
2984 }
2985 };
2986
2987 int nMinOccurs = poFieldDefn->IsNullablecxx . . $ OGRFieldDefn#IsNullable(455f465bc33b4cdf).() ? 0 : 1;
2988 const OGRFieldType eType = poFieldDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).();
2989 if (eType == OFTInteger || eType == OFTIntegerList)
2990 {
2991 int nWidth =
2992 poFieldDefn->GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).() > 0 ? poFieldDefn->GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).() : 16;
2993
2994 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
2995 " <xs:element name=\"%s\" nillable=\"true\" "
2996 "minOccurs=\"%d\" maxOccurs=\"%s\">",
2997 poFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), nMinOccurs,
2998 eType == OFTIntegerList ? "unbounded" : "1");
2999 AddComment(cxx . . $ OGRGMLDataSource#InsertHeader(49f6e7a06ebc5aa8).$anonymous_type_2#`operator()`(83f5f38750778ac8).);
3000 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:simpleType>");
3001 if (poFieldDefn->GetSubTypecxx . . $ OGRFieldDefn#GetSubType(4db5e065ad90bc77).() == OFSTBoolean)
3002 {
3003 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
3004 fpSchema,
3005 " <xs:restriction base=\"xs:boolean\">");
3006 }
3007 else if (poFieldDefn->GetSubTypecxx . . $ OGRFieldDefn#GetSubType(4db5e065ad90bc77).() == OFSTInt16)
3008 {
3009 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3010 " <xs:restriction base=\"xs:short\">");
3011 }
3012 else
3013 {
3014 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
3015 fpSchema,
3016 " <xs:restriction base=\"xs:integer\">");
3017 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3018 " <xs:totalDigits value=\"%d\"/>",
3019 nWidth);
3020 }
3021 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:restriction>");
3022 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:simpleType>");
3023 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:element>");
3024 }
3025 else if (eType == OFTInteger64 || eType == OFTInteger64List)
3026 {
3027 int nWidth =
3028 poFieldDefn->GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).() > 0 ? poFieldDefn->GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).() : 16;
3029
3030 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3031 " <xs:element name=\"%s\" nillable=\"true\" "
3032 "minOccurs=\"%d\" maxOccurs=\"%s\">",
3033 poFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), nMinOccurs,
3034 eType == OFTInteger64List ? "unbounded" : "1");
3035 AddComment(cxx . . $ OGRGMLDataSource#InsertHeader(49f6e7a06ebc5aa8).$anonymous_type_2#`operator()`(83f5f38750778ac8).);
3036 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:simpleType>");
3037 if (poFieldDefn->GetSubTypecxx . . $ OGRFieldDefn#GetSubType(4db5e065ad90bc77).() == OFSTBoolean)
3038 {
3039 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
3040 fpSchema,
3041 " <xs:restriction base=\"xs:boolean\">");
3042 }
3043 else if (poFieldDefn->GetSubTypecxx . . $ OGRFieldDefn#GetSubType(4db5e065ad90bc77).() == OFSTInt16)
3044 {
3045 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3046 " <xs:restriction base=\"xs:short\">");
3047 }
3048 else
3049 {
3050 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3051 " <xs:restriction base=\"xs:long\">");
3052 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3053 " <xs:totalDigits value=\"%d\"/>",
3054 nWidth);
3055 }
3056 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:restriction>");
3057 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:simpleType>");
3058 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:element>");
3059 }
3060 else if (eType == OFTReal || eType == OFTRealList)
3061 {
3062 int nWidth, nDecimals;
3063
3064 nWidth = poFieldDefn->GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).();
3065 nDecimals = poFieldDefn->GetPrecisioncxx . . $ OGRFieldDefn#GetPrecision(455f465bc33b4cdf).();
3066
3067 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3068 " <xs:element name=\"%s\" nillable=\"true\" "
3069 "minOccurs=\"%d\" maxOccurs=\"%s\">",
3070 poFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), nMinOccurs,
3071 eType == OFTRealList ? "unbounded" : "1");
3072 AddComment(cxx . . $ OGRGMLDataSource#InsertHeader(49f6e7a06ebc5aa8).$anonymous_type_2#`operator()`(83f5f38750778ac8).);
3073 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:simpleType>");
3074 if (poFieldDefn->GetSubTypecxx . . $ OGRFieldDefn#GetSubType(4db5e065ad90bc77).() == OFSTFloat32)
3075 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3076 " <xs:restriction base=\"xs:float\">");
3077 else
3078 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
3079 fpSchema,
3080 " <xs:restriction base=\"xs:decimal\">");
3081 if (nWidth > 0)
3082 {
3083 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3084 " <xs:totalDigits value=\"%d\"/>",
3085 nWidth);
3086 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3087 " <xs:fractionDigits value=\"%d\"/>",
3088 nDecimals);
3089 }
3090 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:restriction>");
3091 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:simpleType>");
3092 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:element>");
3093 }
3094 else if (eType == OFTString || eType == OFTStringList)
3095 {
3096 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3097 " <xs:element name=\"%s\" nillable=\"true\" "
3098 "minOccurs=\"%d\" maxOccurs=\"%s\">",
3099 poFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), nMinOccurs,
3100 eType == OFTStringList ? "unbounded" : "1");
3101 AddComment(cxx . . $ OGRGMLDataSource#InsertHeader(49f6e7a06ebc5aa8).$anonymous_type_2#`operator()`(83f5f38750778ac8).);
3102 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " <xs:simpleType>");
3103 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3104 " <xs:restriction base=\"xs:string\">");
3105 if (poFieldDefn->GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).() != 0)
3106 {
3107 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3108 " <xs:maxLength value=\"%d\"/>",
3109 poFieldDefn->GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).());
3110 }
3111 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:restriction>");
3112 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:simpleType>");
3113 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:element>");
3114 }
3115 else if (eType == OFTDate)
3116 {
3117 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3118 " <xs:element name=\"%s\" nillable=\"true\" "
3119 "minOccurs=\"%d\" maxOccurs=\"1\" type=\"xs:date\">",
3120 poFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), nMinOccurs);
3121 AddComment(cxx . . $ OGRGMLDataSource#InsertHeader(49f6e7a06ebc5aa8).$anonymous_type_2#`operator()`(83f5f38750778ac8).);
3122 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:element>");
3123 }
3124 else if (eType == OFTTime)
3125 {
3126 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema,
3127 " <xs:element name=\"%s\" nillable=\"true\" "
3128 "minOccurs=\"%d\" maxOccurs=\"1\" type=\"xs:time\">",
3129 poFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), nMinOccurs);
3130 AddComment(cxx . . $ OGRGMLDataSource#InsertHeader(49f6e7a06ebc5aa8).$anonymous_type_2#`operator()`(83f5f38750778ac8).);
3131 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:element>");
3132 }
3133 else if (eType == OFTDateTime)
3134 {
3135 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(
3136 fpSchema,
3137 " <xs:element name=\"%s\" nillable=\"true\" "
3138 "minOccurs=\"%d\" maxOccurs=\"1\" type=\"xs:dateTime\">",
3139 poFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), nMinOccurs);
3140 AddComment(cxx . . $ OGRGMLDataSource#InsertHeader(49f6e7a06ebc5aa8).$anonymous_type_2#`operator()`(83f5f38750778ac8).);
3141 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:element>");
3142 }
3143 else
3144 {
3145 // TODO.
3146 }
3147 } // Next field.
3148
3149 // Finish off feature type.
3150 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:sequence>");
3151 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:extension>");
3152 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, " </xs:complexContent>");
3153 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "</xs:complexType>");
3154 } // Next layer.
3155
3156 PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(fpSchema, "</xs:schema>");
3157
3158 // Move schema to the start of the file.
3159 if (fpSchema == fpOutputcxx . . $ OGRGMLDataSource#fpOutput.)
3160 {
3161 // Read the schema into memory.
3162 int nSchemaSize = static_cast<int>(VSIFTellL(fpSchema) - nSchemaStart);
3163 char *pszSchema = static_cast<char *>(CPLMalloc(nSchemaSize + 1));
3164
3165 VSIFSeekL(fpSchema, static_cast<vsi_l_offset>(nSchemaStart), SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!);
3166
3167 VSIFReadL(pszSchema, 1, nSchemaSize, fpSchema);
3168 pszSchema[nSchemaSize] = '\0';
3169
3170 // Move file data down by "schema size" bytes from after <?xml> header
3171 // so we have room insert the schema. Move in pretty big chunks.
3172 int nChunkSize = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(nSchemaStart - nSchemaInsertLocationcxx . . $ OGRGMLDataSource#nSchemaInsertLocation., 250000);
3173 char *pszChunk = static_cast<char *>(CPLMalloc(nChunkSize));
3174
3175 for (int nEndOfUnmovedData = nSchemaStart;
3176 nEndOfUnmovedData > nSchemaInsertLocationcxx . . $ OGRGMLDataSource#nSchemaInsertLocation.;)
3177 {
3178 const int nBytesToMove =
3179 stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(nChunkSize, nEndOfUnmovedData - nSchemaInsertLocationcxx . . $ OGRGMLDataSource#nSchemaInsertLocation.);
3180
3181 VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fpSchema, nEndOfUnmovedData - nBytesToMove, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!);
3182 VSIFReadL(pszChunk, 1, nBytesToMove, fpSchema);
3183 VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fpSchema, nEndOfUnmovedData - nBytesToMove + nSchemaSize,
3184 SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!);
3185 VSIFWriteL(pszChunk, 1, nBytesToMove, fpSchema);
3186
3187 nEndOfUnmovedData -= nBytesToMove;
3188 }
3189
3190 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszChunk);
3191
3192 // Write the schema in the opened slot.
3193 VSIFSeekL(fpSchema, static_cast<vsi_l_offset>(nSchemaInsertLocationcxx . . $ OGRGMLDataSource#nSchemaInsertLocation.),
3194 SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!);
3195 VSIFWriteL(pszSchema, 1, nSchemaSize, fpSchema);
3196
3197 VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fpSchema, 0, SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:116:9`!);
3198
3199 nBoundedByLocationcxx . . $ OGRGMLDataSource#nBoundedByLocation. += nSchemaSize;
3200
3201 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszSchema);
3202 }
3203 else
3204 {
3205 // Close external schema files.
3206 VSIFCloseL(fpSchema);
3207 }
3208 }
3209
3210 /************************************************************************/
3211 /* PrintLine() */
3212 /************************************************************************/
3213
3214 void OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::PrintLinecxx . . $ OGRGMLDataSource#PrintLine(1e8a1b964cd0cf62).(VSILFILE *fp, const char *fmt, ...)
3215 {
3216 CPLString osWork;
3217 va_list args;
3218
3219 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stdarg.h:51:9`!(args, fmt);
3220 osWork.vPrintf(fmt, args);
3221 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stdarg.h:53:9`!(args);
3222
3223 #ifdef _WIN32
3224 constexpr const char *pszEOL = "\r\n";
3225 #else
3226 constexpr const char *pszEOL = "\n";
3227 #endif
3228
3229 if (VSIFWriteL(osWork.data(), osWork.size(), 1, fp) != 1 ||
3230 VSIFWriteL(pszEOL, strlen(pszEOL), 1, fp) != 1)
3231 {
3232 m_bWriteErrorcxx . . $ OGRGMLDataSource#m_bWriteError. = true;
3233 ReportErrorcxx . . $ GDALDataset#ReportError(e42ccf14ddaff0e3).(CE_Failure, CPLE_FileIOcxx . . $ `port/cpl_error.h:112:9`!, "Could not write line %s",
3234 osWork.c_str());
3235 }
3236 }
3237
3238 /************************************************************************/
3239 /* OGRGMLSingleFeatureLayer */
3240 /************************************************************************/
3241
3242 class OGRGMLSingleFeatureLayercxx . . $ OGRGMLSingleFeatureLayer# final : public OGRLayercxx . . $ OGRLayer#
3243 {
3244 private:
3245 const int nValcxx . . $ OGRGMLSingleFeatureLayer#nVal.;
3246 OGRFeatureDefnRefCountedPtrcxx . . $ OGRFeatureDefnRefCountedPtr# poFeatureDefncxx . . $ OGRGMLSingleFeatureLayer#poFeatureDefn.{cxx . . $ OGRRefCountedPtr#OGRRefCountedPtr(62cf046bd695d6f2).};
3247 int iNextShapeIdcxx . . $ OGRGMLSingleFeatureLayer#iNextShapeId. = 0;
3248
3249 CPL_DISALLOW_COPY_ASSIGNcxx . . $ `port/cpl_port.h:1101:9`!(OGRGMLSingleFeatureLayer)
3250
3251 public:
3252 explicit OGRGMLSingleFeatureLayercxx . . $ OGRGMLSingleFeatureLayer#OGRGMLSingleFeatureLayer(d4f767463ce0a6b3).(int nVal);
3253
3254 void ResetReadingcxx . . $ OGRGMLSingleFeatureLayer#ResetReading(49f6e7a06ebc5aa8).() override
3255 {
3256 iNextShapeIdcxx . . $ OGRGMLSingleFeatureLayer#iNextShapeId. = 0;
3257 }
3258
3259 OGRFeaturecxx . . $ OGRFeature# *GetNextFeaturecxx . . $ OGRGMLSingleFeatureLayer#GetNextFeature(ec9eceddec1d9563).() override;
3260
3261 const OGRFeatureDefncxx . . $ OGRFeatureDefn# *GetLayerDefncxx . . $ OGRGMLSingleFeatureLayer#GetLayerDefn(448b209f43d15bcc).() const override
3262 {
3263 return poFeatureDefncxx . . $ OGRGMLSingleFeatureLayer#poFeatureDefn..getcxx . . $ OGRRefCountedPtrBase#get(5a2a78a048fb49a8).();
3264 }
3265
3266 int TestCapabilitycxx . . $ OGRGMLSingleFeatureLayer#TestCapability(78f035161ffa9fe2).(const char *) const override
3267 {
3268 return FALSEcxx . . $ `port/cpl_port.h:1180:9`!;
3269 }
3270 };
3271
3272 /************************************************************************/
3273 /* OGRGMLSingleFeatureLayer() */
3274 /************************************************************************/
3275
3276 OGRGMLSingleFeatureLayercxx . . $ OGRGMLSingleFeatureLayer#::OGRGMLSingleFeatureLayercxx . . $ OGRGMLSingleFeatureLayer#OGRGMLSingleFeatureLayer(d4f767463ce0a6b3).(int nValIn)
3277 : nValcxx . . $ OGRGMLSingleFeatureLayer#nVal.(nValIn),
3278 poFeatureDefncxx . . $ OGRGMLSingleFeatureLayer#poFeatureDefn.(OGRFeatureDefnRefCountedPtrcxx . . $ OGRFeatureDefnRefCountedPtr#::makeInstancecxx . . $ OGRRefCountedPtr#makeInstance(fd1a7f05ea0c312).("SELECT")),
3279 iNextShapeIdcxx . . $ OGRGMLSingleFeatureLayer#iNextShapeId.(0)
3280 {
3281 OGRFieldDefncxx . . $ OGRFieldDefn# oFieldcxx . . $ OGRFieldDefn#OGRFieldDefn(786ecb48a0b3b841).("Validates", OFTInteger);
3282 poFeatureDefncxx . . $ OGRGMLSingleFeatureLayer#poFeatureDefn.->cxx . . $ OGRRefCountedPtrBase#`operator->`(5a2a78a048fb49a8).AddFieldDefncxx . . $ OGRFeatureDefn#AddFieldDefn(f8bad7d30df65bbb).(&oField);
3283 }
3284
3285 /************************************************************************/
3286 /* GetNextFeature() */
3287 /************************************************************************/
3288
3289 OGRFeaturecxx . . $ OGRFeature# *OGRGMLSingleFeatureLayercxx . . $ OGRGMLSingleFeatureLayer#::GetNextFeaturecxx . . $ OGRGMLSingleFeatureLayer#GetNextFeature(ec9eceddec1d9563).()
3290 {
3291 if (iNextShapeIdcxx . . $ OGRGMLSingleFeatureLayer#iNextShapeId. != 0)
3292 return nullptr;
3293
3294 OGRFeaturecxx . . $ OGRFeature# *poFeature = new OGRFeaturecxx . . $ OGRFeature#OGRFeature(dc2636911e7adfe).(poFeatureDefncxx . . $ OGRGMLSingleFeatureLayer#poFeatureDefn..getcxx . . $ OGRRefCountedPtrBase#get(5a2a78a048fb49a8).());
3295 poFeature->SetFieldcxx . . $ OGRFeature#SetField(3e454b8ccf442868).(0, nValcxx . . $ OGRGMLSingleFeatureLayer#nVal.);
3296 poFeature->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(iNextShapeIdcxx . . $ OGRGMLSingleFeatureLayer#iNextShapeId.++);
3297 return poFeature;
3298 }
3299
3300 /************************************************************************/
3301 /* ExecuteSQL() */
3302 /************************************************************************/
3303
3304 OGRLayercxx . . $ OGRLayer# *OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::ExecuteSQLcxx . . $ OGRGMLDataSource#ExecuteSQL(1e911e025f8b6f61).(const char *pszSQLCommand,
3305 OGRGeometrycxx . . $ OGRGeometry# *poSpatialFilter,
3306 const char *pszDialect)
3307 {
3308 if (poReadercxx . . $ OGRGMLDataSource#poReader. != nullptr && EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszSQLCommand, "SELECT ValidateSchema()"))
3309 {
3310 bool bIsValid = false;
3311 if (!osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename..empty())
3312 {
3313 CPLErrorReset();
3314 bIsValid =
3315 CPL_TO_BOOL(CPLValidateXML(osFilenamecxx . . $ OGRGMLDataSource#osFilename., osXSDFilenamecxx . . $ OGRGMLDataSource#osXSDFilename., nullptr));
3316 }
3317 return new OGRGMLSingleFeatureLayercxx . . $ OGRGMLSingleFeatureLayer#(bIsValid);
3318 }
3319
3320 return GDALDatasetcxx . . $ GDALDataset#::ExecuteSQLcxx . . $ GDALDataset#ExecuteSQL(1e911e025f8b6f61).(pszSQLCommand, poSpatialFilter, pszDialect);
3321 }
3322
3323 /************************************************************************/
3324 /* ReleaseResultSet() */
3325 /************************************************************************/
3326
3327 void OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::ReleaseResultSetcxx . . $ OGRGMLDataSource#ReleaseResultSet(74233f8ea7d835ac).(OGRLayercxx . . $ OGRLayer# *poResultsSet)
3328 {
3329 delete poResultsSet;
3330 }
3331
3332 /************************************************************************/
3333 /* FindAndParseTopElements() */
3334 /************************************************************************/
3335
3336 void OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::FindAndParseTopElementscxx . . $ OGRGMLDataSource#FindAndParseTopElements(c6d3c1ec18bf8a4a).(VSILFILE *fp)
3337 {
3338 // Build a shortened XML file that contain only the global
3339 // boundedBy element, so as to be able to parse it easily.
3340
3341 char szStartTag[128];
3342 char *pszXML = static_cast<char *>(CPLMalloc(8192 + 128 + 3 + 1));
3343 VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fp, 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!);
3344 int nRead = static_cast<int>(VSIFReadL(pszXML, 1, 8192, fp));
3345 pszXML[nRead] = 0;
3346
3347 const char *pszStartTag = strchr(pszXML, '<');
3348 if (pszStartTag != nullptr)
3349 {
3350 while (pszStartTag != nullptr && pszStartTag[1] == '?')
3351 pszStartTag = strchr(pszStartTag + 1, '<');
3352
3353 if (pszStartTag != nullptr)
3354 {
3355 pszStartTag++;
3356 const char *pszEndTag = nullptr;
3357 for (const char *pszIter = pszStartTag; *pszIter != '\0'; pszIter++)
3358 {
3359 if (isspace(static_cast<unsigned char>(*pszIter)) ||
3360 *pszIter == '>')
3361 {
3362 pszEndTag = pszIter;
3363 break;
3364 }
3365 }
3366 if (pszEndTag != nullptr && pszEndTag - pszStartTag < 128)
3367 {
3368 memcpy(szStartTag, pszStartTag, pszEndTag - pszStartTag);
3369 szStartTag[pszEndTag - pszStartTag] = '\0';
3370 }
3371 else
3372 pszStartTag = nullptr;
3373 }
3374 }
3375
3376 const char *pszFeatureMember = strstr(pszXML, "<gml:featureMember");
3377 if (pszFeatureMember == nullptr)
3378 pszFeatureMember = strstr(pszXML, ":featureMember>");
3379 if (pszFeatureMember == nullptr)
3380 pszFeatureMember = strstr(pszXML, "<wfs:member>");
3381
3382 // Is it a standalone geometry ?
3383 if (pszFeatureMember == nullptr && pszStartTag != nullptr)
3384 {
3385 const char *pszElement = szStartTag;
3386 const char *pszColon = strchr(pszElement, ':');
3387 if (pszColon)
3388 pszElement = pszColon + 1;
3389 if (OGRGMLIsGeometryElementcxx . . $ OGRGMLIsGeometryElement(c5f7da30cbc0f4e9).(pszElement))
3390 {
3391 VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fp, 0, SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:116:9`!);
3392 const auto nLen = VSIFTellL(fp);
3393 if (nLen < 10 * 1024 * 1024U)
3394 {
3395 VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fp, 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!);
3396 stdcxx . . $ std/::string osBuffer;
3397 try
3398 {
3399 osBuffer.resize(static_cast<size_t>(nLen));
3400 VSIFReadL(&osBuffer[0], 1, osBuffer.size(), fp);
3401 }
3402 catch (const stdcxx . . $ std/::exception &)
3403 {
3404 }
3405 CPLPushErrorHandler(CPLQuietErrorHandler);
3406 CPLXMLNodecxx . . $ CPLXMLNode# *psTree = CPLParseXMLString(osBuffer.data());
3407 CPLPopErrorHandler();
3408 CPLErrorReset();
3409 if (psTree)
3410 {
3411 stdcxx . . $ std/::unique_ptr<OGRGML_SRSCachecxx . . $ OGRGML_SRSCache#,
3412 decltype(&OGRGML_SRSCache_Destroycxx . . $ OGRGML_SRSCache_Destroy(14f6cfaa1c456ace).)>
3413 srsCache{OGRGML_SRSCache_Createcxx . . $ OGRGML_SRSCache_Create(671e4a8fcf3c8079).(),
3414 OGRGML_SRSCache_Destroycxx . . $ OGRGML_SRSCache_Destroy(14f6cfaa1c456ace).};
3415 m_poStandaloneGeomcxx . . $ OGRGMLDataSource#m_poStandaloneGeom..reset(
3416 GML2OGRGeometry_XMLNodecxx . . $ GML2OGRGeometry_XMLNode(b5aff78fc839bf25).(psTree, false, srsCache.get(),
3417 0, 0, false, true, false));
3418
3419 if (m_poStandaloneGeomcxx . . $ OGRGMLDataSource#m_poStandaloneGeom.)
3420 {
3421 for (CPLXMLNodecxx . . $ CPLXMLNode# *psCur = psTree; psCur;
3422 psCur = psCur->psNextcxx . . $ CPLXMLNode#psNext.)
3423 {
3424 if (psCur->eTypecxx . . $ CPLXMLNode#eType. == CXT_Element &&
3425 strcmp(psCur->pszValuecxx . . $ CPLXMLNode#pszValue., szStartTag) == 0)
3426 {
3427 const char *pszSRSName =
3428 CPLGetXMLValue(psCur, "srsName", nullptr);
3429 if (pszSRSName)
3430 {
3431 m_oStandaloneGeomSRScxx . . $ OGRGMLDataSource#m_oStandaloneGeomSRS..SetFromUserInputcxx . . $ OGRSpatialReference#SetFromUserInput(5a7b06e3ce74da13).(
3432 pszSRSName,
3433 OGRSpatialReferencecxx . . $ OGRSpatialReference#::
3434 SET_FROM_USER_INPUT_LIMITATIONS_getcxx . . $ OGRSpatialReference#SET_FROM_USER_INPUT_LIMITATIONS_get(93405d8a1d31001f).());
3435 m_oStandaloneGeomSRScxx . . $ OGRGMLDataSource#m_oStandaloneGeomSRS..SetAxisMappingStrategycxx . . $ OGRSpatialReference#SetAxisMappingStrategy(3d39f43974738d6a).(
3436 OAMS_TRADITIONAL_GIS_ORDER);
3437 if (GML_IsSRSLatLongOrdercxx . . $ GML_IsSRSLatLongOrder(c5f7da30cbc0f4e9).(pszSRSName))
3438 m_poStandaloneGeomcxx . . $ OGRGMLDataSource#m_poStandaloneGeom.->swapXYcxx . . $ OGRGeometry#swapXY(49f6e7a06ebc5aa8).();
3439 }
3440 break;
3441 }
3442 }
3443 }
3444 CPLDestroyXMLNode(psTree);
3445 }
3446 }
3447 }
3448 }
3449
3450 const char *pszDescription = strstr(pszXML, "<gml:description>");
3451 if (pszDescription &&
3452 (pszFeatureMember == nullptr || pszDescription < pszFeatureMember))
3453 {
3454 pszDescription += strlen("<gml:description>");
3455 const char *pszEndDescription =
3456 strstr(pszDescription, "</gml:description>");
3457 if (pszEndDescription)
3458 {
3459 CPLString osTmp(pszDescription);
3460 osTmp.resize(pszEndDescription - pszDescription);
3461 char *pszTmp = CPLUnescapeString(osTmp, nullptr, CPLES_XMLcxx . . $ `port/cpl_string.h:155:9`!);
3462 if (pszTmp)
3463 SetMetadataItemcxx . . $ GDALMajorObject#SetMetadataItem(216fc8eb9053a851).("DESCRIPTION", pszTmp);
3464 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszTmp);
3465 }
3466 }
3467
3468 const char *l_pszName = strstr(pszXML, "<gml:name");
3469 if (l_pszName)
3470 l_pszName = strchr(l_pszName, '>');
3471 if (l_pszName &&
3472 (pszFeatureMember == nullptr || l_pszName < pszFeatureMember))
3473 {
3474 l_pszName++;
3475 const char *pszEndName = strstr(l_pszName, "</gml:name>");
3476 if (pszEndName)
3477 {
3478 CPLString osTmp(l_pszName);
3479 osTmp.resize(pszEndName - l_pszName);
3480 char *pszTmp = CPLUnescapeString(osTmp, nullptr, CPLES_XMLcxx . . $ `port/cpl_string.h:155:9`!);
3481 if (pszTmp)
3482 SetMetadataItemcxx . . $ GDALMajorObject#SetMetadataItem(216fc8eb9053a851).("NAME", pszTmp);
3483 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszTmp);
3484 }
3485 }
3486
3487 // Detect a few fields in gml: namespace inside features
3488 if (pszFeatureMember)
3489 {
3490 if (strstr(pszFeatureMember, "<gml:description>"))
3491 m_aosGMLExtraElementscxx . . $ OGRGMLDataSource#m_aosGMLExtraElements..push_back("description");
3492 if (strstr(pszFeatureMember, "<gml:identifier>") ||
3493 strstr(pszFeatureMember, "<gml:identifier "))
3494 m_aosGMLExtraElementscxx . . $ OGRGMLDataSource#m_aosGMLExtraElements..push_back("identifier");
3495 if (strstr(pszFeatureMember, "<gml:name>") ||
3496 strstr(pszFeatureMember, "<gml:name "))
3497 m_aosGMLExtraElementscxx . . $ OGRGMLDataSource#m_aosGMLExtraElements..push_back("name");
3498 }
3499
3500 char *pszEndBoundedBy = strstr(pszXML, "</wfs:boundedBy>");
3501 bool bWFSBoundedBy = false;
3502 if (pszEndBoundedBy != nullptr)
3503 bWFSBoundedBy = true;
3504 else
3505 pszEndBoundedBy = strstr(pszXML, "</gml:boundedBy>");
3506 if (pszStartTag != nullptr && pszEndBoundedBy != nullptr)
3507 {
3508 char szSRSName[128] = {};
3509
3510 // Find a srsName somewhere for some WFS 2.0 documents that have not it
3511 // set at the <wfs:boundedBy> element. e.g.
3512 // http://geoserv.weichand.de:8080/geoserver/wfs?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAME=bvv:gmd_ex
3513 if (bIsWFScxx . . $ OGRGMLDataSource#bIsWFS.)
3514 {
3515 ExtractSRSNamecxx . . $ ExtractSRSName(64fcc95e299940b4).(pszXML, szSRSName, sizeof(szSRSName));
3516 }
3517
3518 pszEndBoundedBy[strlen("</gml:boundedBy>")] = '\0';
3519 strcat(pszXML, "</");
3520 strcat(pszXML, szStartTag);
3521 strcat(pszXML, ">");
3522
3523 CPLPushErrorHandler(CPLQuietErrorHandler);
3524 CPLXMLNodecxx . . $ CPLXMLNode# *psXML = CPLParseXMLString(pszXML);
3525 CPLPopErrorHandler();
3526 CPLErrorReset();
3527 if (psXML != nullptr)
3528 {
3529 CPLXMLNodecxx . . $ CPLXMLNode# *psBoundedBy = nullptr;
3530 CPLXMLNodecxx . . $ CPLXMLNode# *psIter = psXML;
3531 while (psIter != nullptr)
3532 {
3533 psBoundedBy = CPLGetXMLNode(
3534 psIter, bWFSBoundedBy ? "wfs:boundedBy" : "gml:boundedBy");
3535 if (psBoundedBy != nullptr)
3536 break;
3537 psIter = psIter->psNextcxx . . $ CPLXMLNode#psNext.;
3538 }
3539
3540 const char *pszLowerCorner = nullptr;
3541 const char *pszUpperCorner = nullptr;
3542 const char *pszSRSName = nullptr;
3543 if (psBoundedBy != nullptr)
3544 {
3545 CPLXMLNodecxx . . $ CPLXMLNode# *psEnvelope =
3546 CPLGetXMLNode(psBoundedBy, "gml:Envelope");
3547 if (psEnvelope)
3548 {
3549 pszSRSName = CPLGetXMLValue(psEnvelope, "srsName", nullptr);
3550 pszLowerCorner =
3551 CPLGetXMLValue(psEnvelope, "gml:lowerCorner", nullptr);
3552 pszUpperCorner =
3553 CPLGetXMLValue(psEnvelope, "gml:upperCorner", nullptr);
3554 }
3555 }
3556
3557 if (bIsWFScxx . . $ OGRGMLDataSource#bIsWFS. && pszSRSName == nullptr && pszLowerCorner != nullptr &&
3558 pszUpperCorner != nullptr && szSRSName[0] != '\0')
3559 {
3560 pszSRSName = szSRSName;
3561 }
3562
3563 if (pszSRSName != nullptr && pszLowerCorner != nullptr &&
3564 pszUpperCorner != nullptr)
3565 {
3566 char **papszLC = CSLTokenizeString(pszLowerCorner);
3567 char **papszUC = CSLTokenizeString(pszUpperCorner);
3568 if (CSLCount(papszLC) >= 2 && CSLCount(papszUC) >= 2)
3569 {
3570 CPLDebug("GML", "Global SRS = %s", pszSRSName);
3571
3572 if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszSRSName,
3573 "http://www.opengis.net/gml/srs/epsg.xml#"))
3574 {
3575 stdcxx . . $ std/::string osWork;
3576 osWork.assign("EPSG:", 5);
3577 osWork.append(pszSRSName + 40);
3578 poReadercxx . . $ OGRGMLDataSource#poReader.->SetGlobalSRSNamecxx . . $ IGMLReader#SetGlobalSRSName(85c52e162fed56f9).(osWork.c_str());
3579 }
3580 else
3581 {
3582 poReadercxx . . $ OGRGMLDataSource#poReader.->SetGlobalSRSNamecxx . . $ IGMLReader#SetGlobalSRSName(85c52e162fed56f9).(pszSRSName);
3583 }
3584
3585 const double dfMinX = CPLAtofM(papszLC[0]);
3586 const double dfMinY = CPLAtofM(papszLC[1]);
3587 const double dfMaxX = CPLAtofM(papszUC[0]);
3588 const double dfMaxY = CPLAtofM(papszUC[1]);
3589
3590 SetExtentscxx . . $ OGRGMLDataSource#SetExtents(52a61fa14d44b641).(dfMinX, dfMinY, dfMaxX, dfMaxY);
3591 }
3592 CSLDestroy(papszLC);
3593 CSLDestroy(papszUC);
3594 }
3595
3596 CPLDestroyXMLNode(psXML);
3597 }
3598 }
3599
3600 CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszXML);
3601 }
3602
3603 /************************************************************************/
3604 /* SetExtents() */
3605 /************************************************************************/
3606
3607 void OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::SetExtentscxx . . $ OGRGMLDataSource#SetExtents(52a61fa14d44b641).(double dfMinX, double dfMinY, double dfMaxX,
3608 double dfMaxY)
3609 {
3610 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinX = dfMinX;
3611 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MinY = dfMinY;
3612 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxX = dfMaxX;
3613 sBoundingRectcxx . . $ OGRGMLDataSource#sBoundingRect..MaxY = dfMaxY;
3614 }
3615
3616 /************************************************************************/
3617 /* GetAppPrefix() */
3618 /************************************************************************/
3619
3620 const char *OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::GetAppPrefixcxx . . $ OGRGMLDataSource#GetAppPrefix(a9f41ea0e82d88cf).() const
3621 {
3622 return CSLFetchNameValueDef(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "PREFIX", "ogr");
3623 }
3624
3625 /************************************************************************/
3626 /* RemoveAppPrefix() */
3627 /************************************************************************/
3628
3629 bool OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::RemoveAppPrefixcxx . . $ OGRGMLDataSource#RemoveAppPrefix(50ce9a9e25b4a850).() const
3630 {
3631 if (CPLTestBool(
3632 CSLFetchNameValueDef(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "STRIP_PREFIX", "FALSE")))
3633 return true;
3634 const char *pszPrefix = GetAppPrefixcxx . . $ OGRGMLDataSource#GetAppPrefix(a9f41ea0e82d88cf).();
3635 return pszPrefix[0] == '\0';
3636 }
3637
3638 /************************************************************************/
3639 /* WriteFeatureBoundedBy() */
3640 /************************************************************************/
3641
3642 bool OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::WriteFeatureBoundedBycxx . . $ OGRGMLDataSource#WriteFeatureBoundedBy(50ce9a9e25b4a850).() const
3643 {
3644 return CPLTestBool(CSLFetchNameValueDef(
3645 papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "WRITE_FEATURE_BOUNDED_BY", "TRUE"));
3646 }
3647
3648 /************************************************************************/
3649 /* GetSRSDimensionLoc() */
3650 /************************************************************************/
3651
3652 const char *OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::GetSRSDimensionLoccxx . . $ OGRGMLDataSource#GetSRSDimensionLoc(a9f41ea0e82d88cf).() const
3653 {
3654 return CSLFetchNameValue(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "SRSDIMENSION_LOC");
3655 }
3656
3657 /************************************************************************/
3658 /* GMLFeatureCollection() */
3659 /************************************************************************/
3660
3661 bool OGRGMLDataSourcecxx . . $ OGRGMLDataSource#::GMLFeatureCollectioncxx . . $ OGRGMLDataSource#GMLFeatureCollection(50ce9a9e25b4a850).() const
3662 {
3663 return IsGML3Outputcxx . . $ OGRGMLDataSource#IsGML3Output(50ce9a9e25b4a850).() &&
3664 CPLFetchBool(papszCreateOptionscxx . . $ OGRGMLDataSource#papszCreateOptions., "GML_FEATURE_COLLECTION", false);
3665 }