1
/******************************************************************************
2
* $Id: ogr_sosi.h 21065 2010-11-05 18:47:30Z rouault $
4
* Project: SOSI Translator
5
* Purpose: Implements OGRSOSIDriver.
6
* Author: Thomas Hirsch, <thomas.hirsch statkart no>
8
******************************************************************************
9
* Copyright (c) 2010, Thomas Hirsch
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:
18
* The above copyright notice and this permission notice shall be included
19
* in all copies or substantial portions of the Software.
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
****************************************************************************/
30
#ifndef _OGR_SOSI_H_INCLUDED
31
#define _OGR_SOSI_H_INCLUDED
33
#include "ogrsf_frmts.h"
37
typedef std::map<CPLString, CPLString> S2S;
38
typedef std::map<CPLString, unsigned int> S2I;
40
void RegisterOGRSOSI();
42
class ORGSOSILayer; /* defined below */
43
class OGRSOSIDataSource; /* defined below */
45
/************************************************************************
47
* OGRSOSIDriver is the main driver class. It does not much, except *
48
* reporting on its capabilities and opening a single data source *
50
************************************************************************/
52
class OGRSOSIDriver : public OGRSFDriver {
58
const char *GetName();
59
OGRDataSource *Open( const char *, int );
60
int TestCapability( const char * );
61
OGRDataSource *CreateDataSource( const char *pszName, char **papszOptions = NULL);
64
/************************************************************************
66
* OGRSOSILayer reports all the OGR Features generated by the data *
67
* source, in an orderly fashion. *
68
************************************************************************/
70
class OGRSOSILayer : public OGRLayer {
74
OGRSOSIDataSource *poParent; /* used to call methods from data source */
75
LC_FILADM *poFileadm; /* ResetReading needs to refer to the file struct */
76
OGRFeatureDefn *poFeatureDefn; /* the common definition of all features returned by this layer */
80
LC_BGR oNextSerial; /* used by FYBA to iterate through features */
84
OGRSOSILayer( OGRSOSIDataSource *poPar, OGRFeatureDefn *poFeatDefn, LC_FILADM *poFil, S2I *poHeadDefn);
88
OGRFeature * GetNextFeature();
89
OGRFeatureDefn * GetLayerDefn();
90
OGRErr CreateField(OGRFieldDefn *poField, int bApproxOK=TRUE);
91
OGRErr CreateFeature(OGRFeature *poFeature);
92
int TestCapability( const char * );
93
OGRSpatialReference *GetSpatialRef();
96
/************************************************************************
98
* OGRSOSIDataSource reads a SOSI file, prebuilds the features, and *
99
* creates one OGRSOSILayer per geometry type *
100
************************************************************************/
101
class OGRSOSIDataSource : public OGRDataSource {
103
OGRSOSILayer **papoLayers;
106
#define MODE_READING 0
107
#define MODE_WRITING 1
110
void buildOGRPoint(long nSerial);
111
void buildOGRLineString(int nNumCoo, long nSerial);
112
void buildOGRMultiPoint(int nNumCoo, long nSerial);
116
OGRSpatialReference *poSRS;
117
const char *pszEncoding;
118
unsigned int nNumFeatures;
119
OGRGeometry **papoBuiltGeometries; /* OGRSOSIDataSource prebuilds some features upon opening, te be used
120
* by the more complex geometries later. */
122
LC_BASEADM *poBaseadm;
123
LC_FILADM *poFileadm;
125
S2I *poPolyHeaders; /* Contain the header definitions of the four feature layers */
131
~OGRSOSIDataSource();
133
int Open ( const char * pszFilename, int bUpdate);
134
int Create( const char * pszFilename );
135
const char *GetName() {
138
int GetLayerCount() {
141
OGRLayer *GetLayer( int );
142
OGRLayer *CreateLayer( const char *pszName, OGRSpatialReference *poSpatialRef=NULL, OGRwkbGeometryType eGType=wkbUnknown, char **papszOptions=NULL);
143
int TestCapability( const char * );
146
#endif /* _OGR_SOSI_H_INCLUDED */