1 : /******************************************************************************
2 : * $Id: ogr_gml.h 24481 2012-05-20 12:50:29Z rouault $
3 : *
4 : * Project: GML Reader
5 : * Purpose: Declarations for OGR wrapper classes for GML, and GML<->OGR
6 : * translation of geometry.
7 : * Author: Frank Warmerdam, warmerdam@pobox.com
8 : *
9 : ******************************************************************************
10 : * Copyright (c) 2002, Frank Warmerdam
11 : *
12 : * Permission is hereby granted, free of charge, to any person obtaining a
13 : * copy of this software and associated documentation files (the "Software"),
14 : * to deal in the Software without restriction, including without limitation
15 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 : * and/or sell copies of the Software, and to permit persons to whom the
17 : * Software is furnished to do so, subject to the following conditions:
18 : *
19 : * The above copyright notice and this permission notice shall be included
20 : * in all copies or substantial portions of the Software.
21 : *
22 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 : * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 : * DEALINGS IN THE SOFTWARE.
29 : ****************************************************************************/
30 :
31 : #ifndef _OGR_GML_H_INCLUDED
32 : #define _OGR_GML_H_INCLUDED
33 :
34 : #include "ogrsf_frmts.h"
35 : #include "gmlreader.h"
36 :
37 : class OGRGMLDataSource;
38 :
39 : typedef enum
40 : {
41 : STANDARD,
42 : SEQUENTIAL_LAYERS,
43 : INTERLEAVED_LAYERS
44 : } ReadMode;
45 :
46 : /************************************************************************/
47 : /* OGRGMLLayer */
48 : /************************************************************************/
49 :
50 : class OGRGMLLayer : public OGRLayer
51 : {
52 : OGRSpatialReference *poSRS;
53 : OGRFeatureDefn *poFeatureDefn;
54 :
55 : int iNextGMLId;
56 : int nTotalGMLCount;
57 : int bInvalidFIDFound;
58 : char *pszFIDPrefix;
59 :
60 : int bWriter;
61 :
62 : OGRGMLDataSource *poDS;
63 :
64 : GMLFeatureClass *poFClass;
65 :
66 : void *hCacheSRS;
67 :
68 : int bUseOldFIDFormat;
69 :
70 : int bFaceHoleNegative;
71 :
72 : public:
73 : OGRGMLLayer( const char * pszName,
74 : OGRSpatialReference *poSRS,
75 : int bWriter,
76 : OGRwkbGeometryType eType,
77 : OGRGMLDataSource *poDS );
78 :
79 : ~OGRGMLLayer();
80 :
81 : void ResetReading();
82 : OGRFeature * GetNextFeature();
83 :
84 : int GetFeatureCount( int bForce = TRUE );
85 : OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
86 :
87 : OGRErr CreateFeature( OGRFeature *poFeature );
88 :
89 3545 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
90 :
91 : virtual OGRErr CreateField( OGRFieldDefn *poField,
92 : int bApproxOK = TRUE );
93 :
94 : virtual OGRSpatialReference *GetSpatialRef();
95 :
96 : int TestCapability( const char * );
97 :
98 : virtual const char *GetGeometryColumn();
99 : };
100 :
101 : /************************************************************************/
102 : /* OGRGMLDataSource */
103 : /************************************************************************/
104 :
105 : class OGRGMLDataSource : public OGRDataSource
106 : {
107 : OGRGMLLayer **papoLayers;
108 : int nLayers;
109 :
110 : char *pszName;
111 :
112 : OGRGMLLayer *TranslateGMLSchema( GMLFeatureClass * );
113 :
114 : char **papszCreateOptions;
115 :
116 : // output related parameters
117 : VSILFILE *fpOutput;
118 : int bFpOutputIsNonSeekable;
119 : int bFpOutputSingleFile;
120 : OGREnvelope3D sBoundingRect;
121 : int bBBOX3D;
122 : int nBoundedByLocation;
123 :
124 : int nSchemaInsertLocation;
125 : int bIsOutputGML3;
126 : int bIsOutputGML3Deegree; /* if TRUE, then bIsOutputGML3 is also TRUE */
127 : int bIsOutputGML32; /* if TRUE, then bIsOutputGML3 is also TRUE */
128 : int bIsLongSRSRequired;
129 : int bWriteSpaceIndentation;
130 :
131 : // input related parameters.
132 : CPLString osFilename;
133 : CPLString osXSDFilename;
134 :
135 : IGMLReader *poReader;
136 : int bOutIsTempFile;
137 :
138 : void InsertHeader();
139 :
140 : int bExposeGMLId;
141 : int bExposeFid;
142 : int bIsWFS;
143 :
144 : OGRSpatialReference* poGlobalSRS;
145 :
146 : int m_bInvertAxisOrderIfLatLong;
147 : int m_bConsiderEPSGAsURN;
148 : int m_bGetSecondaryGeometryOption;
149 :
150 : ReadMode eReadMode;
151 : GMLFeature *poStoredGMLFeature;
152 : OGRGMLLayer *poLastReadLayer;
153 :
154 : void FindAndParseBoundedBy(VSILFILE* fp);
155 : void SetExtents(double dfMinX, double dfMinY, double dfMaxX, double dfMaxY);
156 :
157 : public:
158 : OGRGMLDataSource();
159 : ~OGRGMLDataSource();
160 :
161 : int Open( const char *, int bTestOpen );
162 : int Create( const char *pszFile, char **papszOptions );
163 :
164 138 : const char *GetName() { return pszName; }
165 600 : int GetLayerCount() { return nLayers; }
166 : OGRLayer *GetLayer( int );
167 :
168 : virtual OGRLayer *CreateLayer( const char *,
169 : OGRSpatialReference * = NULL,
170 : OGRwkbGeometryType = wkbUnknown,
171 : char ** = NULL );
172 :
173 : int TestCapability( const char * );
174 :
175 85 : VSILFILE *GetOutputFP() const { return fpOutput; }
176 2007 : IGMLReader *GetReader() const { return poReader; }
177 :
178 : void GrowExtents( OGREnvelope3D *psGeomBounds, int nCoordDimension );
179 :
180 1150 : int ExposeId() const { return bExposeGMLId || bExposeFid; }
181 :
182 : static void PrintLine(VSILFILE* fp, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (2, 3);
183 :
184 255 : int IsGML3Output() const { return bIsOutputGML3; }
185 104 : int IsGML3DeegreeOutput() const { return bIsOutputGML3Deegree; }
186 332 : int IsGML32Output() const { return bIsOutputGML32; }
187 99 : int IsLongSRSRequired() const { return bIsLongSRSRequired; }
188 85 : int WriteSpaceIndentation() const { return bWriteSpaceIndentation; }
189 : const char *GetGlobalSRSName();
190 :
191 1148 : int GetInvertAxisOrderIfLatLong() const { return m_bInvertAxisOrderIfLatLong; }
192 1148 : int GetConsiderEPSGAsURN() const { return m_bConsiderEPSGAsURN; }
193 1148 : int GetSecondaryGeometryOption() const { return m_bGetSecondaryGeometryOption; }
194 :
195 1377 : ReadMode GetReadMode() const { return eReadMode; }
196 26 : void SetStoredGMLFeature(GMLFeature* poStoredGMLFeatureIn) { poStoredGMLFeature = poStoredGMLFeatureIn; }
197 1612 : GMLFeature* PeekStoredGMLFeature() const { return poStoredGMLFeature; }
198 :
199 1208 : OGRGMLLayer* GetLastReadLayer() const { return poLastReadLayer; }
200 133 : void SetLastReadLayer(OGRGMLLayer* poLayer) { poLastReadLayer = poLayer; }
201 :
202 : const char *GetAppPrefix();
203 :
204 : virtual OGRLayer * ExecuteSQL( const char *pszSQLCommand,
205 : OGRGeometry *poSpatialFilter,
206 : const char *pszDialect );
207 : virtual void ReleaseResultSet( OGRLayer * poResultsSet );
208 : };
209 :
210 : /************************************************************************/
211 : /* OGRGMLDriver */
212 : /************************************************************************/
213 :
214 : class OGRGMLDriver : public OGRSFDriver
215 226 : {
216 : public:
217 : ~OGRGMLDriver();
218 :
219 : const char *GetName();
220 : OGRDataSource *Open( const char *, int );
221 :
222 : virtual OGRDataSource *CreateDataSource( const char *pszName,
223 : char ** = NULL );
224 :
225 : int TestCapability( const char * );
226 : };
227 :
228 : #endif /* _OGR_GML_H_INCLUDED */
|