1 : /******************************************************************************
2 : * $Id: ogr_gml.h 20029 2010-07-11 18:38:23Z 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 : /************************************************************************/
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 112 : 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 : virtual const char *GetGeometryColumn();
86 : };
87 :
88 : /************************************************************************/
89 : /* OGRGMLDataSource */
90 : /************************************************************************/
91 :
92 : class OGRGMLDataSource : public OGRDataSource
93 : {
94 : OGRGMLLayer **papoLayers;
95 : int nLayers;
96 :
97 : char *pszName;
98 :
99 : OGRGMLLayer *TranslateGMLSchema( GMLFeatureClass * );
100 :
101 : char **papszCreateOptions;
102 :
103 : // output related parameters
104 : FILE *fpOutput;
105 : int bFpOutputIsStdout;
106 : OGREnvelope sBoundingRect;
107 : int nBoundedByLocation;
108 :
109 : int nSchemaInsertLocation;
110 :
111 : // input related parameters.
112 : IGMLReader *poReader;
113 : int bOutIsTempFile;
114 :
115 : void InsertHeader();
116 :
117 : public:
118 : OGRGMLDataSource();
119 : ~OGRGMLDataSource();
120 :
121 : int Open( const char *, int bTestOpen );
122 : int Create( const char *pszFile, char **papszOptions );
123 :
124 18 : const char *GetName() { return pszName; }
125 31 : int GetLayerCount() { return nLayers; }
126 : OGRLayer *GetLayer( int );
127 :
128 : virtual OGRLayer *CreateLayer( const char *,
129 : OGRSpatialReference * = NULL,
130 : OGRwkbGeometryType = wkbUnknown,
131 : char ** = NULL );
132 :
133 : int TestCapability( const char * );
134 :
135 2 : FILE *GetOutputFP() { return fpOutput; }
136 79 : IGMLReader *GetReader() { return poReader; }
137 :
138 : void GrowExtents( OGREnvelope *psGeomBounds );
139 :
140 : static void PrintLine(FILE* fp, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (2, 3);
141 : };
142 :
143 : /************************************************************************/
144 : /* OGRGMLDriver */
145 : /************************************************************************/
146 :
147 : class OGRGMLDriver : public OGRSFDriver
148 80 : {
149 : public:
150 : ~OGRGMLDriver();
151 :
152 : const char *GetName();
153 : OGRDataSource *Open( const char *, int );
154 :
155 : virtual OGRDataSource *CreateDataSource( const char *pszName,
156 : char ** = NULL );
157 :
158 : int TestCapability( const char * );
159 : };
160 :
161 : #endif /* _OGR_GML_H_INCLUDED */
|