1 : /******************************************************************************
2 : * $Id: ogr_gml.h 24294 2012-04-22 20:49:52Z 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 2572 : 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 : IGMLReader *poReader;
133 : int bOutIsTempFile;
134 :
135 : void InsertHeader();
136 :
137 : int bExposeGMLId;
138 : int bExposeFid;
139 : int bIsWFS;
140 :
141 : OGRSpatialReference* poGlobalSRS;
142 :
143 : int m_bInvertAxisOrderIfLatLong;
144 : int m_bConsiderEPSGAsURN;
145 : int m_bGetSecondaryGeometryOption;
146 :
147 : ReadMode eReadMode;
148 : GMLFeature *poStoredGMLFeature;
149 : OGRGMLLayer *poLastReadLayer;
150 :
151 : public:
152 : OGRGMLDataSource();
153 : ~OGRGMLDataSource();
154 :
155 : int Open( const char *, int bTestOpen );
156 : int Create( const char *pszFile, char **papszOptions );
157 :
158 126 : const char *GetName() { return pszName; }
159 612 : int GetLayerCount() { return nLayers; }
160 : OGRLayer *GetLayer( int );
161 :
162 : virtual OGRLayer *CreateLayer( const char *,
163 : OGRSpatialReference * = NULL,
164 : OGRwkbGeometryType = wkbUnknown,
165 : char ** = NULL );
166 :
167 : int TestCapability( const char * );
168 :
169 72 : VSILFILE *GetOutputFP() const { return fpOutput; }
170 1994 : IGMLReader *GetReader() const { return poReader; }
171 :
172 : void GrowExtents( OGREnvelope3D *psGeomBounds, int nCoordDimension );
173 :
174 692 : int ExposeId() const { return bExposeGMLId || bExposeFid; }
175 :
176 : static void PrintLine(VSILFILE* fp, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (2, 3);
177 :
178 122 : int IsGML3Output() const { return bIsOutputGML3; }
179 32 : int IsGML3DeegreeOutput() const { return bIsOutputGML3Deegree; }
180 138 : int IsGML32Output() const { return bIsOutputGML32; }
181 72 : int IsLongSRSRequired() const { return bIsLongSRSRequired; }
182 72 : int WriteSpaceIndentation() const { return bWriteSpaceIndentation; }
183 : const char *GetGlobalSRSName();
184 :
185 696 : int GetInvertAxisOrderIfLatLong() const { return m_bInvertAxisOrderIfLatLong; }
186 696 : int GetConsiderEPSGAsURN() const { return m_bConsiderEPSGAsURN; }
187 696 : int GetSecondaryGeometryOption() const { return m_bGetSecondaryGeometryOption; }
188 :
189 2154 : ReadMode GetReadMode() const { return eReadMode; }
190 46 : void SetStoredGMLFeature(GMLFeature* poStoredGMLFeatureIn) { poStoredGMLFeature = poStoredGMLFeatureIn; }
191 1552 : GMLFeature* PeekStoredGMLFeature() const { return poStoredGMLFeature; }
192 :
193 778 : OGRGMLLayer* GetLastReadLayer() const { return poLastReadLayer; }
194 138 : void SetLastReadLayer(OGRGMLLayer* poLayer) { poLastReadLayer = poLayer; }
195 :
196 : virtual OGRLayer * ExecuteSQL( const char *pszSQLCommand,
197 : OGRGeometry *poSpatialFilter,
198 : const char *pszDialect );
199 : virtual void ReleaseResultSet( OGRLayer * poResultsSet );
200 : };
201 :
202 : /************************************************************************/
203 : /* OGRGMLDriver */
204 : /************************************************************************/
205 :
206 : class OGRGMLDriver : public OGRSFDriver
207 389 : {
208 : public:
209 : ~OGRGMLDriver();
210 :
211 : const char *GetName();
212 : OGRDataSource *Open( const char *, int );
213 :
214 : virtual OGRDataSource *CreateDataSource( const char *pszName,
215 : char ** = NULL );
216 :
217 : int TestCapability( const char * );
218 : };
219 :
220 : #endif /* _OGR_GML_H_INCLUDED */
|