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 : FILE *fp;
58 :
59 : int ReadLine();
60 : CPLString osLine;
61 : char **papszKeyedValues;
62 :
63 : int ScanAheadForHole();
64 :
65 : OGRFeature *GetNextRawFeature();
66 :
67 : OGRErr WriteGeometry( OGRGeometryH hGeom, int bHaveAngle );
68 : OGRErr CompleteHeader( OGRGeometry * );
69 :
70 : public:
71 : int bValidFile;
72 :
73 : OGRGmtLayer( const char *pszFilename, int bUpdate );
74 : ~OGRGmtLayer();
75 :
76 : void ResetReading();
77 : OGRFeature * GetNextFeature();
78 :
79 3 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
80 :
81 : OGRErr GetExtent(OGREnvelope *psExtent, int bForce);
82 :
83 : OGRErr CreateFeature( OGRFeature *poFeature );
84 :
85 : virtual OGRErr CreateField( OGRFieldDefn *poField,
86 : int bApproxOK = TRUE );
87 :
88 : virtual OGRSpatialReference *GetSpatialRef();
89 :
90 : int TestCapability( const char * );
91 : };
92 :
93 : /************************************************************************/
94 : /* OGRGmtDataSource */
95 : /************************************************************************/
96 :
97 : class OGRGmtDataSource : public OGRDataSource
98 : {
99 : OGRGmtLayer **papoLayers;
100 : int nLayers;
101 :
102 : char *pszName;
103 :
104 : int bUpdate;
105 :
106 : public:
107 : OGRGmtDataSource();
108 : ~OGRGmtDataSource();
109 :
110 : int Open( const char *pszFilename, int bUpdate );
111 : int Create( const char *pszFilename, char **papszOptions );
112 :
113 2 : const char *GetName() { return pszName; }
114 0 : int GetLayerCount() { return nLayers; }
115 : OGRLayer *GetLayer( int );
116 :
117 : virtual OGRLayer *CreateLayer( const char *,
118 : OGRSpatialReference * = NULL,
119 : OGRwkbGeometryType = wkbUnknown,
120 : char ** = NULL );
121 : int TestCapability( const char * );
122 : };
123 :
124 : /************************************************************************/
125 : /* OGRGmtDriver */
126 : /************************************************************************/
127 :
128 : class OGRGmtDriver : public OGRSFDriver
129 80 : {
130 : public:
131 : ~OGRGmtDriver();
132 :
133 : const char *GetName();
134 : OGRDataSource *Open( const char *, int );
135 :
136 : virtual OGRDataSource *CreateDataSource( const char *pszName,
137 : char ** = NULL );
138 :
139 : int TestCapability( const char * );
140 : };
141 :
142 :
143 : #endif /* ndef _OGRGMT_H_INCLUDED */
144 :
|