1 : /******************************************************************************
2 : * $Id: ogr_mem.h 10645 2007-01-18 02:22:39Z warmerdam $
3 : *
4 : * Project: OpenGIS Simple Features Reference Implementation
5 : * Purpose: Private definitions within the OGR GMT driver.
6 : * Author: Frank Warmerdam, warmerdam@pobox.com
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2007, Frank Warmerdam <warmerdam@pobox.com>
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 _OGRGMT_H_INCLUDED
31 : #define _OGRGMT_H_INCLUDED
32 :
33 : #include "ogrsf_frmts.h"
34 : #include "ogr_api.h"
35 : #include "cpl_string.h"
36 :
37 : /************************************************************************/
38 : /* OGRGmtLayer */
39 : /************************************************************************/
40 :
41 : class OGRGmtLayer : public OGRLayer
42 : {
43 : OGRSpatialReference *poSRS;
44 : OGRFeatureDefn *poFeatureDefn;
45 :
46 : int iNextFID;
47 :
48 : OGRwkbGeometryType eWkbType;
49 :
50 : int bUpdate;
51 : int bHeaderComplete;
52 :
53 : int bRegionComplete;
54 : OGREnvelope sRegion;
55 : vsi_l_offset nRegionOffset;
56 :
57 : VSILFILE *fp;
58 :
59 : int ReadLine();
60 : CPLString osLine;
61 : char **papszKeyedValues;
62 :
63 : int ScanAheadForHole();
64 : int NextIsFeature();
65 :
66 : OGRFeature *GetNextRawFeature();
67 :
68 : OGRErr WriteGeometry( OGRGeometryH hGeom, int bHaveAngle );
69 : OGRErr CompleteHeader( OGRGeometry * );
70 :
71 : public:
72 : int bValidFile;
73 :
74 : OGRGmtLayer( const char *pszFilename, int bUpdate );
75 : ~OGRGmtLayer();
76 :
77 : void ResetReading();
78 : OGRFeature * GetNextFeature();
79 :
80 7 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
81 :
82 : OGRErr GetExtent(OGREnvelope *psExtent, int bForce);
83 :
84 : OGRErr CreateFeature( OGRFeature *poFeature );
85 :
86 : virtual OGRErr CreateField( OGRFieldDefn *poField,
87 : int bApproxOK = TRUE );
88 :
89 : virtual OGRSpatialReference *GetSpatialRef();
90 :
91 : int TestCapability( const char * );
92 : };
93 :
94 : /************************************************************************/
95 : /* OGRGmtDataSource */
96 : /************************************************************************/
97 :
98 : class OGRGmtDataSource : public OGRDataSource
99 : {
100 : OGRGmtLayer **papoLayers;
101 : int nLayers;
102 :
103 : char *pszName;
104 :
105 : int bUpdate;
106 :
107 : public:
108 : OGRGmtDataSource();
109 : ~OGRGmtDataSource();
110 :
111 : int Open( const char *pszFilename, int bUpdate );
112 : int Create( const char *pszFilename, char **papszOptions );
113 :
114 5 : const char *GetName() { return pszName; }
115 0 : int GetLayerCount() { return nLayers; }
116 : OGRLayer *GetLayer( int );
117 :
118 : virtual OGRLayer *CreateLayer( const char *,
119 : OGRSpatialReference * = NULL,
120 : OGRwkbGeometryType = wkbUnknown,
121 : char ** = NULL );
122 : int TestCapability( const char * );
123 : };
124 :
125 : /************************************************************************/
126 : /* OGRGmtDriver */
127 : /************************************************************************/
128 :
129 : class OGRGmtDriver : public OGRSFDriver
130 178 : {
131 : public:
132 : ~OGRGmtDriver();
133 :
134 : const char *GetName();
135 : OGRDataSource *Open( const char *, int );
136 :
137 : virtual OGRDataSource *CreateDataSource( const char *pszName,
138 : char ** = NULL );
139 :
140 : int TestCapability( const char * );
141 : };
142 :
143 :
144 : #endif /* ndef _OGRGMT_H_INCLUDED */
145 :
|