1 : /******************************************************************************
2 : * $Id: ogr_gml.h 16241 2009-02-06 06:05:51Z warmerdam $
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 : /************************************************************************/
40 : /* OGRGMLLayer */
41 : /************************************************************************/
42 :
43 : class OGRGMLLayer : public OGRLayer
44 : {
45 : OGRSpatialReference *poSRS;
46 : OGRFeatureDefn *poFeatureDefn;
47 :
48 : int iNextGMLId;
49 : int nTotalGMLCount;
50 : int bInvalidFIDFound;
51 : char *pszFIDPrefix;
52 :
53 : int bWriter;
54 :
55 : OGRGMLDataSource *poDS;
56 :
57 : GMLFeatureClass *poFClass;
58 :
59 : public:
60 : OGRGMLLayer( const char * pszName,
61 : OGRSpatialReference *poSRS,
62 : int bWriter,
63 : OGRwkbGeometryType eType,
64 : OGRGMLDataSource *poDS );
65 :
66 : ~OGRGMLLayer();
67 :
68 : void ResetReading();
69 : OGRFeature * GetNextFeature();
70 :
71 : int GetFeatureCount( int bForce = TRUE );
72 : OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
73 :
74 : OGRErr CreateFeature( OGRFeature *poFeature );
75 :
76 110 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
77 :
78 : virtual OGRErr CreateField( OGRFieldDefn *poField,
79 : int bApproxOK = TRUE );
80 :
81 : virtual OGRSpatialReference *GetSpatialRef();
82 :
83 : int TestCapability( const char * );
84 : };
85 :
86 : /************************************************************************/
87 : /* OGRGMLDataSource */
88 : /************************************************************************/
89 :
90 : class OGRGMLDataSource : public OGRDataSource
91 : {
92 : OGRGMLLayer **papoLayers;
93 : int nLayers;
94 :
95 : char *pszName;
96 :
97 : OGRGMLLayer *TranslateGMLSchema( GMLFeatureClass * );
98 :
99 : char **papszCreateOptions;
100 :
101 : // output related parameters
102 : FILE *fpOutput;
103 : OGREnvelope sBoundingRect;
104 : int nBoundedByLocation;
105 :
106 : int nSchemaInsertLocation;
107 :
108 : // input related parameters.
109 : IGMLReader *poReader;
110 :
111 : void InsertHeader();
112 :
113 : public:
114 : OGRGMLDataSource();
115 : ~OGRGMLDataSource();
116 :
117 : int Open( const char *, int bTestOpen );
118 : int Create( const char *pszFile, char **papszOptions );
119 :
120 16 : const char *GetName() { return pszName; }
121 29 : int GetLayerCount() { return nLayers; }
122 : OGRLayer *GetLayer( int );
123 :
124 : virtual OGRLayer *CreateLayer( const char *,
125 : OGRSpatialReference * = NULL,
126 : OGRwkbGeometryType = wkbUnknown,
127 : char ** = NULL );
128 :
129 : int TestCapability( const char * );
130 :
131 2 : FILE *GetOutputFP() { return fpOutput; }
132 73 : IGMLReader *GetReader() { return poReader; }
133 :
134 : void GrowExtents( OGREnvelope *psGeomBounds );
135 : };
136 :
137 : /************************************************************************/
138 : /* OGRGMLDriver */
139 : /************************************************************************/
140 :
141 : class OGRGMLDriver : public OGRSFDriver
142 64 : {
143 : public:
144 : ~OGRGMLDriver();
145 :
146 : const char *GetName();
147 : OGRDataSource *Open( const char *, int );
148 :
149 : virtual OGRDataSource *CreateDataSource( const char *pszName,
150 : char ** = NULL );
151 :
152 : int TestCapability( const char * );
153 : };
154 :
155 : #endif /* _OGR_GML_H_INCLUDED */
|