1 : /******************************************************************************
2 : * $Id: ogr_xplane.h $
3 : *
4 : * Project: X-Plane aeronautical data reader
5 : * Purpose: Definition of classes for OGR X-Plane aeronautical data driver.
6 : * Author: Even Rouault, even dot rouault at mines dash paris dot org
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2008, Even Rouault
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_XPLANE_H_INCLUDED
31 : #define _OGR_XPLANE_H_INCLUDED
32 :
33 : #include "ogrsf_frmts.h"
34 :
35 : class OGRXPlaneReader;
36 :
37 : /************************************************************************/
38 : /* OGRXPlaneLayer */
39 : /************************************************************************/
40 :
41 : class OGRXPlaneLayer : public OGRLayer
42 : {
43 : private:
44 : int nFID;
45 : int nFeatureArraySize;
46 : int nFeatureArrayMaxSize;
47 : int nFeatureArrayIndex;
48 :
49 : OGRFeature** papoFeatures;
50 : OGRSpatialReference *poSRS;
51 :
52 : protected:
53 : OGRXPlaneReader* poReader;
54 : OGRFeatureDefn* poFeatureDefn;
55 : OGRXPlaneLayer(const char* pszLayerName);
56 :
57 : void RegisterFeature(OGRFeature* poFeature);
58 :
59 : public:
60 : virtual ~OGRXPlaneLayer();
61 :
62 : void SetReader(OGRXPlaneReader* poReader);
63 0 : int IsEmpty() { return nFeatureArraySize == 0; }
64 : void AutoAdjustColumnsWidth();
65 :
66 : virtual void ResetReading();
67 : virtual OGRFeature * GetNextFeature();
68 : virtual OGRFeature * GetFeature( long nFID );
69 : virtual int GetFeatureCount( int bForce = TRUE );
70 0 : virtual OGRSpatialReference * GetSpatialRef() { return poSRS; }
71 :
72 203 : virtual OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
73 : virtual int TestCapability( const char * pszCap );
74 : };
75 :
76 :
77 : /************************************************************************/
78 : /* OGRXPlaneDataSource */
79 : /************************************************************************/
80 :
81 : class OGRXPlaneDataSource : public OGRDataSource
82 : {
83 : char* pszName;
84 :
85 : OGRXPlaneLayer** papoLayers;
86 : int nLayers;
87 :
88 : OGRXPlaneReader* poReader;
89 : int bReadWholeFile;
90 :
91 : void Reset();
92 :
93 : public:
94 : OGRXPlaneDataSource();
95 : ~OGRXPlaneDataSource();
96 :
97 : int Open( const char * pszFilename, int bReadWholeFile = TRUE );
98 :
99 : void RegisterLayer( OGRXPlaneLayer* poLayer );
100 :
101 203 : virtual int GetLayerCount() { return nLayers; }
102 : virtual OGRLayer* GetLayer( int );
103 4 : virtual const char* GetName() { return pszName; }
104 :
105 : virtual int TestCapability( const char * pszCap );
106 : };
107 :
108 : /************************************************************************/
109 : /* OGRXPlaneDriver */
110 : /************************************************************************/
111 :
112 : class OGRXPlaneDriver : public OGRSFDriver
113 160 : {
114 : public:
115 :
116 : virtual const char* GetName();
117 : OGRDataSource* Open( const char *, int );
118 :
119 : virtual int TestCapability( const char * pszCap );
120 : };
121 :
122 :
123 : #endif /* ndef _OGR_XPLANE_H_INCLUDED */
|