1 : /******************************************************************************
2 : * $Id: ogr_gml.h 23326 2011-11-05 19:26:54Z 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 : public:
71 : OGRGMLLayer( const char * pszName,
72 : OGRSpatialReference *poSRS,
73 : int bWriter,
74 : OGRwkbGeometryType eType,
75 : OGRGMLDataSource *poDS );
76 :
77 : ~OGRGMLLayer();
78 :
79 : void ResetReading();
80 : OGRFeature * GetNextFeature();
81 :
82 : int GetFeatureCount( int bForce = TRUE );
83 : OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
84 :
85 : OGRErr CreateFeature( OGRFeature *poFeature );
86 :
87 1172 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
88 :
89 : virtual OGRErr CreateField( OGRFieldDefn *poField,
90 : int bApproxOK = TRUE );
91 :
92 : virtual OGRSpatialReference *GetSpatialRef();
93 :
94 : int TestCapability( const char * );
95 :
96 : virtual const char *GetGeometryColumn();
97 : };
98 :
99 : /************************************************************************/
100 : /* OGRGMLDataSource */
101 : /************************************************************************/
102 :
103 : class OGRGMLDataSource : public OGRDataSource
104 : {
105 : OGRGMLLayer **papoLayers;
106 : int nLayers;
107 :
108 : char *pszName;
109 :
110 : OGRGMLLayer *TranslateGMLSchema( GMLFeatureClass * );
111 :
112 : char **papszCreateOptions;
113 :
114 : // output related parameters
115 : VSILFILE *fpOutput;
116 : int bFpOutputIsNonSeekable;
117 : int bFpOutputSingleFile;
118 : OGREnvelope3D sBoundingRect;
119 : int bBBOX3D;
120 : int nBoundedByLocation;
121 :
122 : int nSchemaInsertLocation;
123 : int bIsOutputGML3;
124 : int bIsOutputGML3Deegree; /* if TRUE, then bIsOutputGML3 is also TRUE */
125 : int bIsOutputGML32; /* if TRUE, then bIsOutputGML3 is also TRUE */
126 : int bIsLongSRSRequired;
127 : int bWriteSpaceIndentation;
128 :
129 : // input related parameters.
130 : IGMLReader *poReader;
131 : int bOutIsTempFile;
132 :
133 : void InsertHeader();
134 :
135 : int bExposeGMLId;
136 : int bExposeFid;
137 : int bIsWFS;
138 :
139 : OGRSpatialReference* poGlobalSRS;
140 :
141 : int m_bInvertAxisOrderIfLatLong;
142 : int m_bConsiderEPSGAsURN;
143 : int m_bGetSecondaryGeometryOption;
144 :
145 : ReadMode eReadMode;
146 : GMLFeature *poStoredGMLFeature;
147 : OGRGMLLayer *poLastReadLayer;
148 :
149 : public:
150 : OGRGMLDataSource();
151 : ~OGRGMLDataSource();
152 :
153 : int Open( const char *, int bTestOpen );
154 : int Create( const char *pszFile, char **papszOptions );
155 :
156 56 : const char *GetName() { return pszName; }
157 281 : int GetLayerCount() { return nLayers; }
158 : OGRLayer *GetLayer( int );
159 :
160 : virtual OGRLayer *CreateLayer( const char *,
161 : OGRSpatialReference * = NULL,
162 : OGRwkbGeometryType = wkbUnknown,
163 : char ** = NULL );
164 :
165 : int TestCapability( const char * );
166 :
167 36 : VSILFILE *GetOutputFP() const { return fpOutput; }
168 781 : IGMLReader *GetReader() const { return poReader; }
169 :
170 : void GrowExtents( OGREnvelope3D *psGeomBounds, int nCoordDimension );
171 :
172 303 : int ExposeId() const { return bExposeGMLId || bExposeFid; }
173 :
174 : static void PrintLine(VSILFILE* fp, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (2, 3);
175 :
176 61 : int IsGML3Output() const { return bIsOutputGML3; }
177 16 : int IsGML3DeegreeOutput() const { return bIsOutputGML3Deegree; }
178 69 : int IsGML32Output() const { return bIsOutputGML32; }
179 36 : int IsLongSRSRequired() const { return bIsLongSRSRequired; }
180 36 : int WriteSpaceIndentation() const { return bWriteSpaceIndentation; }
181 : const char *GetGlobalSRSName();
182 :
183 307 : int GetInvertAxisOrderIfLatLong() const { return m_bInvertAxisOrderIfLatLong; }
184 307 : int GetConsiderEPSGAsURN() const { return m_bConsiderEPSGAsURN; }
185 307 : int GetSecondaryGeometryOption() const { return m_bGetSecondaryGeometryOption; }
186 :
187 755 : ReadMode GetReadMode() const { return eReadMode; }
188 19 : void SetStoredGMLFeature(GMLFeature* poStoredGMLFeatureIn) { poStoredGMLFeature = poStoredGMLFeatureIn; }
189 564 : GMLFeature* PeekStoredGMLFeature() const { return poStoredGMLFeature; }
190 :
191 341 : OGRGMLLayer* GetLastReadLayer() const { return poLastReadLayer; }
192 67 : void SetLastReadLayer(OGRGMLLayer* poLayer) { poLastReadLayer = poLayer; }
193 : };
194 :
195 : /************************************************************************/
196 : /* OGRGMLDriver */
197 : /************************************************************************/
198 :
199 : class OGRGMLDriver : public OGRSFDriver
200 178 : {
201 : public:
202 : ~OGRGMLDriver();
203 :
204 : const char *GetName();
205 : OGRDataSource *Open( const char *, int );
206 :
207 : virtual OGRDataSource *CreateDataSource( const char *pszName,
208 : char ** = NULL );
209 :
210 : int TestCapability( const char * );
211 : };
212 :
213 : #endif /* _OGR_GML_H_INCLUDED */
|