1 : /******************************************************************************
2 : * $Id: ogr_aeronavfaa.h 21376 2011-01-02 18:28:40Z rouault $
3 : *
4 : * Project: AeronavFAA Translator
5 : * Purpose: Definition of classes for OGR AeronavFAA driver.
6 : * Author: Even Rouault, even dot rouault at mines dash paris dot org
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2010, Even Rouault <even dot rouault at mines dash paris dot org>
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
22 : * OR 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_AeronavFAA_H_INCLUDED
31 : #define _OGR_AeronavFAA_H_INCLUDED
32 :
33 : #include "ogrsf_frmts.h"
34 :
35 :
36 : typedef struct
37 : {
38 : const char* pszFieldName;
39 : int nStartCol; /* starting at 1 */
40 : int nLastCol; /* starting at 1 */
41 : OGRFieldType eType;
42 : } RecordFieldDesc;
43 :
44 : typedef struct
45 : {
46 : int nFields;
47 : const RecordFieldDesc* pasFields;
48 : int nLatStartCol; /* starting at 1 */
49 : int nLonStartCol; /* starting at 1 */
50 : } RecordDesc;
51 :
52 :
53 :
54 : /************************************************************************/
55 : /* OGRAeronavFAALayer */
56 : /************************************************************************/
57 :
58 : class OGRAeronavFAALayer : public OGRLayer
59 : {
60 : protected:
61 : OGRFeatureDefn* poFeatureDefn;
62 : OGRSpatialReference *poSRS;
63 :
64 : VSILFILE* fpAeronavFAA;
65 : int bEOF;
66 :
67 : int nNextFID;
68 :
69 : const RecordDesc* psRecordDesc;
70 :
71 : virtual OGRFeature * GetNextRawFeature() = 0;
72 :
73 : public:
74 : OGRAeronavFAALayer(VSILFILE* fp, const char* pszLayerName);
75 : ~OGRAeronavFAALayer();
76 :
77 :
78 : virtual void ResetReading();
79 : virtual OGRFeature * GetNextFeature();
80 :
81 0 : virtual OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
82 :
83 : virtual int TestCapability( const char * );
84 :
85 0 : virtual OGRSpatialReference *GetSpatialRef() { return poSRS; }
86 :
87 : };
88 :
89 : /************************************************************************/
90 : /* OGRAeronavFAADOFLayer */
91 : /************************************************************************/
92 :
93 : class OGRAeronavFAADOFLayer : public OGRAeronavFAALayer
94 0 : {
95 : private:
96 : int GetLatLon(const char* pszLat, const char* pszLon, double& dfLat, double& dfLon);
97 :
98 : protected:
99 : virtual OGRFeature * GetNextRawFeature();
100 :
101 : public:
102 : OGRAeronavFAADOFLayer(VSILFILE* fp, const char* pszLayerName);
103 : };
104 :
105 : /************************************************************************/
106 : /* OGRAeronavFAANAVAIDLayer */
107 : /************************************************************************/
108 :
109 : class OGRAeronavFAANAVAIDLayer : public OGRAeronavFAALayer
110 0 : {
111 : private:
112 : int GetLatLon(const char* pszLat, const char* pszLon, double& dfLat, double& dfLon);
113 :
114 : protected:
115 : virtual OGRFeature * GetNextRawFeature();
116 :
117 : public:
118 : OGRAeronavFAANAVAIDLayer(VSILFILE* fp, const char* pszLayerName);
119 : };
120 :
121 : /************************************************************************/
122 : /* OGRAeronavFAARouteLayer */
123 : /************************************************************************/
124 :
125 : class OGRAeronavFAARouteLayer : public OGRAeronavFAALayer
126 0 : {
127 : private:
128 : int bIsDPOrSTARS;
129 : CPLString osLastReadLine;
130 : CPLString osAPTName;
131 : CPLString osStateName;
132 : int GetLatLon(const char* pszLat, const char* pszLon, double& dfLat, double& dfLon);
133 :
134 : protected:
135 : virtual OGRFeature * GetNextRawFeature();
136 :
137 : public:
138 : OGRAeronavFAARouteLayer(VSILFILE* fp, const char* pszLayerName, int bIsDPOrSTARS);
139 :
140 : virtual void ResetReading();
141 : };
142 :
143 : /************************************************************************/
144 : /* OGRAeronavFAAIAPLayer */
145 : /************************************************************************/
146 :
147 : class OGRAeronavFAAIAPLayer : public OGRAeronavFAALayer
148 0 : {
149 : private:
150 : CPLString osCityName;
151 : CPLString osStateName;
152 : CPLString osAPTName;
153 : CPLString osAPTId;
154 : int GetLatLon(const char* pszLat, const char* pszLon, double& dfLat, double& dfLon);
155 :
156 : protected:
157 : virtual OGRFeature * GetNextRawFeature();
158 :
159 : public:
160 : OGRAeronavFAAIAPLayer(VSILFILE* fp, const char* pszLayerName);
161 :
162 : virtual void ResetReading();
163 : };
164 :
165 : /************************************************************************/
166 : /* OGRAeronavFAADataSource */
167 : /************************************************************************/
168 :
169 : class OGRAeronavFAADataSource : public OGRDataSource
170 : {
171 : char* pszName;
172 :
173 : OGRLayer** papoLayers;
174 : int nLayers;
175 :
176 : public:
177 : OGRAeronavFAADataSource();
178 : ~OGRAeronavFAADataSource();
179 :
180 : int Open( const char * pszFilename,
181 : int bUpdate );
182 :
183 0 : virtual const char* GetName() { return pszName; }
184 :
185 0 : virtual int GetLayerCount() { return nLayers; }
186 : virtual OGRLayer* GetLayer( int );
187 :
188 : virtual int TestCapability( const char * );
189 : };
190 :
191 : /************************************************************************/
192 : /* OGRAeronavFAADriver */
193 : /************************************************************************/
194 :
195 : class OGRAeronavFAADriver : public OGRSFDriver
196 178 : {
197 : public:
198 : ~OGRAeronavFAADriver();
199 :
200 : virtual const char* GetName();
201 : virtual OGRDataSource* Open( const char *, int );
202 : virtual int TestCapability( const char * );
203 : };
204 :
205 :
206 : #endif /* ndef _OGR_AeronavFAA_H_INCLUDED */
|