1 : /******************************************************************************
2 : * $Id: ogr_nas.h 24105 2012-03-10 12:08:04Z rouault $
3 : *
4 : * Project: NAS Reader
5 : * Purpose: Declarations for OGR wrapper classes for NAS, and NAS<->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_NAS_H_INCLUDED
32 : #define _OGR_NAS_H_INCLUDED
33 :
34 : #include "ogrsf_frmts.h"
35 : #include "nasreaderp.h"
36 : #include "ogr_api.h"
37 : #include <vector>
38 :
39 : class OGRNASDataSource;
40 :
41 : /************************************************************************/
42 : /* OGRNASLayer */
43 : /************************************************************************/
44 :
45 : class OGRNASLayer : public OGRLayer
46 : {
47 : OGRSpatialReference *poSRS;
48 : OGRFeatureDefn *poFeatureDefn;
49 :
50 : int iNextNASId;
51 : int nTotalNASCount;
52 :
53 : OGRNASDataSource *poDS;
54 :
55 : GMLFeatureClass *poFClass;
56 :
57 : public:
58 : OGRNASLayer( const char * pszName,
59 : OGRSpatialReference *poSRS,
60 : OGRwkbGeometryType eType,
61 : OGRNASDataSource *poDS );
62 :
63 : ~OGRNASLayer();
64 :
65 : void ResetReading();
66 : OGRFeature * GetNextFeature();
67 :
68 : int GetFeatureCount( int bForce = TRUE );
69 : OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
70 :
71 1421 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
72 :
73 : virtual OGRSpatialReference *GetSpatialRef();
74 :
75 : int TestCapability( const char * );
76 : };
77 :
78 : /************************************************************************/
79 : /* OGRNASRelationLayer */
80 : /************************************************************************/
81 :
82 : class OGRNASRelationLayer : public OGRLayer
83 : {
84 : OGRFeatureDefn *poFeatureDefn;
85 : OGRNASDataSource *poDS;
86 :
87 : int bPopulated;
88 : int iNextFeature;
89 : std::vector<CPLString> aoRelationCollection;
90 :
91 : public:
92 : OGRNASRelationLayer( OGRNASDataSource *poDS );
93 : ~OGRNASRelationLayer();
94 :
95 : void ResetReading();
96 : OGRFeature * GetNextFeature();
97 :
98 : int GetFeatureCount( int bForce = TRUE );
99 3 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
100 : int TestCapability( const char * );
101 :
102 : // For use populating.
103 : void AddRelation( const char *pszFromID,
104 : const char *pszType,
105 : const char *pszToID );
106 1 : void MarkRelationsPopulated() { bPopulated = TRUE; }
107 : };
108 :
109 : /************************************************************************/
110 : /* OGRNASDataSource */
111 : /************************************************************************/
112 :
113 : class OGRNASDataSource : public OGRDataSource
114 : {
115 : OGRLayer **papoLayers;
116 : int nLayers;
117 :
118 : OGRNASRelationLayer *poRelationLayer;
119 :
120 : char *pszName;
121 :
122 : OGRNASLayer *TranslateNASSchema( GMLFeatureClass * );
123 :
124 : // input related parameters.
125 : IGMLReader *poReader;
126 :
127 : void InsertHeader();
128 :
129 : public:
130 : OGRNASDataSource();
131 : ~OGRNASDataSource();
132 :
133 : int Open( const char *, int bTestOpen );
134 : int Create( const char *pszFile, char **papszOptions );
135 :
136 5 : const char *GetName() { return pszName; }
137 128 : int GetLayerCount() { return nLayers; }
138 : OGRLayer *GetLayer( int );
139 :
140 : int TestCapability( const char * );
141 :
142 480 : IGMLReader *GetReader() { return poReader; }
143 :
144 : void GrowExtents( OGREnvelope *psGeomBounds );
145 :
146 : void PopulateRelations();
147 : };
148 :
149 : /************************************************************************/
150 : /* OGRNASDriver */
151 : /************************************************************************/
152 :
153 : class OGRNASDriver : public OGRSFDriver
154 226 : {
155 : public:
156 : ~OGRNASDriver();
157 :
158 : const char *GetName();
159 : OGRDataSource *Open( const char *, int );
160 :
161 : int TestCapability( const char * );
162 : };
163 :
164 : #endif /* _OGR_NAS_H_INCLUDED */
|