1 : /******************************************************************************
2 : * $Id: ogr_ili2.h 13906 2008-03-01 13:08:28Z rouault $
3 : *
4 : * Project: Interlis 2 Translator
5 : * Purpose: Definition of classes for OGR Interlis 2 driver.
6 : * Author: Markus Schnider, Sourcepole AG
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2004, Pirmin Kalberer, Sourcepole AG
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_ILI2_H_INCLUDED
31 : #define _OGR_ILI2_H_INCLUDED
32 :
33 : #include "ogrsf_frmts.h"
34 : #include "ili2reader.h"
35 : #include "iom/iom.h"
36 :
37 : #include <string>
38 : #include <list>
39 :
40 : class OGRILI2DataSource;
41 :
42 : /************************************************************************/
43 : /* OGRILI2Layer */
44 : /************************************************************************/
45 :
46 : class OGRILI2Layer : public OGRLayer
47 : {
48 : private:
49 : OGRSpatialReference *poSRS;
50 : OGRFeatureDefn *poFeatureDefn;
51 : std::list<OGRFeature *> listFeature;
52 : std::list<OGRFeature *>::const_iterator listFeatureIt;
53 :
54 : int bWriter;
55 :
56 : OGRILI2DataSource *poDS;
57 :
58 : public:
59 : OGRILI2Layer( const char * pszName,
60 : OGRSpatialReference *poSRS,
61 : int bWriter,
62 : OGRwkbGeometryType eType,
63 : OGRILI2DataSource *poDS );
64 :
65 : ~OGRILI2Layer();
66 :
67 : OGRErr SetFeature(OGRFeature *poFeature);
68 :
69 : void ResetReading();
70 : OGRFeature * GetNextFeature();
71 :
72 : int GetFeatureCount( int bForce = TRUE );
73 :
74 : OGRErr CreateFeature( OGRFeature *poFeature );
75 :
76 0 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
77 :
78 : OGRErr CreateField( OGRFieldDefn *poField, int bApproxOK = TRUE );
79 :
80 : OGRSpatialReference *GetSpatialRef();
81 :
82 : int TestCapability( const char * );
83 : };
84 :
85 : /************************************************************************/
86 : /* OGRILI2DataSource */
87 : /************************************************************************/
88 :
89 : class OGRILI2DataSource : public OGRDataSource
90 : {
91 : private:
92 : std::list<OGRLayer *> listLayer;
93 :
94 : char *pszName;
95 : IILI2Reader *poReader;
96 : IOM_FILE fpTransfer; //for writing
97 : IOM_BASKET basket;
98 :
99 : int nLayers;
100 : OGRILI2Layer** papoLayers;
101 :
102 : public:
103 : OGRILI2DataSource();
104 : ~OGRILI2DataSource();
105 :
106 : int Open( const char *, int bTestOpen );
107 : int Create( const char *pszFile, char **papszOptions );
108 :
109 0 : const char *GetName() { return pszName; }
110 0 : IOM_BASKET GetBasket() { return basket; }
111 0 : int GetLayerCount() { return listLayer.size(); }
112 : OGRLayer *GetLayer( int );
113 :
114 : virtual OGRLayer *CreateLayer( const char *,
115 : OGRSpatialReference * = NULL,
116 : OGRwkbGeometryType = wkbUnknown,
117 : char ** = NULL );
118 :
119 : int TestCapability( const char * );
120 : };
121 :
122 : /************************************************************************/
123 : /* OGRILI2Driver */
124 : /************************************************************************/
125 :
126 : class OGRILI2Driver : public OGRSFDriver
127 178 : {
128 : public:
129 : ~OGRILI2Driver();
130 :
131 : const char *GetName();
132 : OGRDataSource *Open( const char *, int );
133 :
134 : virtual OGRDataSource *CreateDataSource( const char *pszName,
135 : char ** = NULL );
136 :
137 : int TestCapability( const char * );
138 : };
139 :
140 : #endif /* _OGR_ILI2_H_INCLUDED */
|