1 : /******************************************************************************
2 : * $Id: ogr_avc.h 14784 2008-06-28 22:25:49Z warmerdam $
3 : *
4 : * Project: Arc/Info Coverage (E00 & Binary) Reader
5 : * Purpose: Declarations for OGR wrapper classes for coverage access.
6 : * Author: Frank Warmerdam, warmerdam@pobox.com
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2002, Frank Warmerdam
10 : *
11 : * Permission is hereby granted, free of charge, to any person obtaining a
12 : * copy of this software and associated documentation files (the "Software"),
13 : * to deal in the Software without restriction, including without limitation
14 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 : * and/or sell copies of the Software, and to permit persons to whom the
16 : * Software is furnished to do so, subject to the following conditions:
17 : *
18 : * The above copyright notice and this permission notice shall be included
19 : * in all copies or substantial portions of the Software.
20 : *
21 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 : * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 : * DEALINGS IN THE SOFTWARE.
28 : ****************************************************************************/
29 :
30 : #ifndef _OGR_AVC_H_INCLUDED
31 : #define _OGR_AVC_H_INCLUDED
32 :
33 : #include "ogrsf_frmts.h"
34 : #include "avc.h"
35 :
36 : class OGRAVCDataSource;
37 :
38 : /************************************************************************/
39 : /* OGRAVCLayer */
40 : /************************************************************************/
41 :
42 : class OGRAVCLayer : public OGRLayer
43 : {
44 : protected:
45 : OGRFeatureDefn *poFeatureDefn;
46 :
47 : OGRAVCDataSource *poDS;
48 :
49 : AVCFileType eSectionType;
50 :
51 : int SetupFeatureDefinition( const char *pszName );
52 : int AppendTableDefinition( AVCTableDef *psTableDef );
53 :
54 : int MatchesSpatialFilter( void * );
55 : OGRFeature *TranslateFeature( void * );
56 :
57 : int TranslateTableFields( OGRFeature *poFeature,
58 : int nFieldBase,
59 : AVCTableDef *psTableDef,
60 : AVCField *pasFields );
61 :
62 : public:
63 : OGRAVCLayer( AVCFileType eSectionType,
64 : OGRAVCDataSource *poDS );
65 : ~OGRAVCLayer();
66 :
67 20 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
68 :
69 : virtual OGRSpatialReference *GetSpatialRef();
70 :
71 : virtual int TestCapability( const char * );
72 : };
73 :
74 : /************************************************************************/
75 : /* OGRAVCDataSource */
76 : /************************************************************************/
77 :
78 : class OGRAVCDataSource : public OGRDataSource
79 : {
80 : protected:
81 : OGRSpatialReference *poSRS;
82 : char *pszCoverageName;
83 :
84 : public:
85 : OGRAVCDataSource();
86 : ~OGRAVCDataSource();
87 :
88 : virtual OGRSpatialReference *GetSpatialRef();
89 :
90 : const char *GetCoverageName();
91 : };
92 :
93 : /* ==================================================================== */
94 : /* Binary Coverage Classes */
95 : /* ==================================================================== */
96 :
97 : class OGRAVCBinDataSource;
98 :
99 : /************************************************************************/
100 : /* OGRAVCBinLayer */
101 : /************************************************************************/
102 :
103 : class OGRAVCBinLayer : public OGRAVCLayer
104 : {
105 : AVCE00Section *psSection;
106 : AVCBinFile *hFile;
107 :
108 : OGRAVCBinLayer *poArcLayer;
109 : int bNeedReset;
110 :
111 : char szTableName[128];
112 : AVCBinFile *hTable;
113 : int nTableBaseField;
114 : int nTableAttrIndex;
115 :
116 : int nNextFID;
117 :
118 : int FormPolygonGeometry( OGRFeature *poFeature,
119 : AVCPal *psPAL );
120 :
121 : int CheckSetupTable();
122 : int AppendTableFields( OGRFeature *poFeature );
123 :
124 : public:
125 : OGRAVCBinLayer( OGRAVCBinDataSource *poDS,
126 : AVCE00Section *psSectionIn );
127 :
128 : ~OGRAVCBinLayer();
129 :
130 : void ResetReading();
131 : OGRFeature * GetNextFeature();
132 : OGRFeature * GetFeature( long nFID );
133 :
134 : int TestCapability( const char * );
135 : };
136 :
137 : /************************************************************************/
138 : /* OGRAVCBinDataSource */
139 : /************************************************************************/
140 :
141 : class OGRAVCBinDataSource : public OGRAVCDataSource
142 : {
143 : OGRLayer **papoLayers;
144 : int nLayers;
145 :
146 : char *pszName;
147 :
148 : AVCE00ReadPtr psAVC;
149 :
150 : public:
151 : OGRAVCBinDataSource();
152 : ~OGRAVCBinDataSource();
153 :
154 : int Open( const char *, int bTestOpen );
155 :
156 1 : const char *GetName() { return pszName; }
157 2 : int GetLayerCount() { return nLayers; }
158 : OGRLayer *GetLayer( int );
159 :
160 : int TestCapability( const char * );
161 :
162 13 : AVCE00ReadPtr GetInfo() { return psAVC; }
163 : };
164 :
165 : /************************************************************************/
166 : /* OGRAVCBinDriver */
167 : /************************************************************************/
168 :
169 : class OGRAVCBinDriver : public OGRSFDriver
170 64 : {
171 : public:
172 : ~OGRAVCBinDriver();
173 :
174 : const char *GetName();
175 : OGRDataSource *Open( const char *, int );
176 :
177 : int TestCapability( const char * );
178 : };
179 :
180 : /* ==================================================================== */
181 : /* E00 (ASCII) Coverage Classes */
182 : /* ==================================================================== */
183 :
184 : /************************************************************************/
185 : /* OGRAVCE00Layer */
186 : /************************************************************************/
187 : class OGRAVCE00Layer : public OGRAVCLayer
188 : {
189 : AVCE00Section *psSection;
190 : AVCE00ReadE00Ptr psRead;
191 : OGRAVCE00Layer *poArcLayer;
192 : int nFeatureCount;
193 : int bNeedReset;
194 : int nNextFID;
195 :
196 : AVCE00Section *psTableSection;
197 : AVCE00ReadE00Ptr psTableRead;
198 : char *pszTableFilename;
199 : int nTablePos;
200 : int nTableBaseField;
201 : int nTableAttrIndex;
202 :
203 : int FormPolygonGeometry( OGRFeature *poFeature,
204 : AVCPal *psPAL );
205 : public:
206 : OGRAVCE00Layer( OGRAVCDataSource *poDS,
207 : AVCE00Section *psSectionIn );
208 :
209 : ~OGRAVCE00Layer();
210 :
211 : void ResetReading();
212 : OGRFeature * GetNextFeature();
213 : OGRFeature *GetFeature( long nFID );
214 : int GetFeatureCount(int bForce);
215 : int CheckSetupTable(AVCE00Section *psTblSectionIn);
216 : int AppendTableFields( OGRFeature *poFeature );
217 : };
218 :
219 : /************************************************************************/
220 : /* OGRAVCE00DataSource */
221 : /************************************************************************/
222 :
223 : class OGRAVCE00DataSource : public OGRAVCDataSource
224 : {
225 : int nLayers;
226 : char *pszName;
227 : AVCE00ReadE00Ptr psE00;
228 : OGRAVCE00Layer **papoLayers;
229 :
230 : protected:
231 : int CheckAddTable(AVCE00Section *psTblSection);
232 :
233 : public:
234 : OGRAVCE00DataSource();
235 : ~OGRAVCE00DataSource();
236 :
237 : int Open(const char *, int bTestOpen);
238 :
239 0 : AVCE00ReadE00Ptr GetInfo() { return psE00; }
240 1 : const char *GetName() { return pszName; }
241 2 : int GetLayerCount() { return nLayers; }
242 :
243 : OGRLayer *GetLayer( int );
244 : int TestCapability( const char * );
245 : virtual OGRSpatialReference *GetSpatialRef();
246 : };
247 :
248 : /************************************************************************/
249 : /* OGRAVCE00Driver */
250 : /************************************************************************/
251 :
252 : class OGRAVCE00Driver : public OGRSFDriver
253 64 : {
254 : public:
255 : ~OGRAVCE00Driver();
256 :
257 : const char *GetName();
258 : OGRDataSource *Open( const char *, int );
259 :
260 : int TestCapability( const char * );
261 : };
262 :
263 : #endif /* _OGR_AVC_H_INCLUDED */
|