~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to ogr/ogrsf_frmts/sosi/ogr_sosi.h

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * $Id: ogr_sosi.h 21065 2010-11-05 18:47:30Z rouault $
 
3
 *
 
4
 * Project:  SOSI Translator
 
5
 * Purpose:  Implements OGRSOSIDriver.
 
6
 * Author:   Thomas Hirsch, <thomas.hirsch statkart no>
 
7
 *
 
8
 ******************************************************************************
 
9
 * Copyright (c) 2010, Thomas Hirsch
 
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_SOSI_H_INCLUDED
 
31
#define _OGR_SOSI_H_INCLUDED
 
32
 
 
33
#include "ogrsf_frmts.h"
 
34
#include "fyba.h"
 
35
#include <map>
 
36
 
 
37
typedef std::map<CPLString, CPLString> S2S;
 
38
typedef std::map<CPLString, unsigned int> S2I;
 
39
 
 
40
void RegisterOGRSOSI();
 
41
 
 
42
class ORGSOSILayer;      /* defined below */
 
43
class OGRSOSIDataSource; /* defined below */
 
44
 
 
45
/************************************************************************
 
46
 *                           OGRSOSIDriver                              *
 
47
 * OGRSOSIDriver is the main driver class. It does not much, except     *
 
48
 * reporting on its capabilities and opening a single data source       *
 
49
 * currently                                                            *
 
50
 ************************************************************************/
 
51
 
 
52
class OGRSOSIDriver : public OGRSFDriver {
 
53
public:
 
54
 
 
55
    OGRSOSIDriver();
 
56
    ~OGRSOSIDriver();
 
57
 
 
58
    const char    *GetName();
 
59
    OGRDataSource *Open( const char *, int );
 
60
    int            TestCapability( const char * );
 
61
    OGRDataSource *CreateDataSource( const char *pszName, char **papszOptions = NULL);
 
62
};
 
63
 
 
64
/************************************************************************
 
65
 *                           OGRSOSILayer                               *
 
66
 * OGRSOSILayer reports all the OGR Features generated by the data      *
 
67
 * source, in an orderly fashion.                                       *
 
68
 ************************************************************************/
 
69
 
 
70
class OGRSOSILayer : public OGRLayer {
 
71
    FILE               *fp;
 
72
    int                 nNextFID;
 
73
 
 
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  */
 
77
    S2I                *poHeaderDefn;
 
78
 
 
79
    LC_SNR_ADM          oSnradm;
 
80
    LC_BGR              oNextSerial;  /* used by FYBA to iterate through features */
 
81
    LC_BGR             *poNextSerial;
 
82
 
 
83
public:
 
84
    OGRSOSILayer( OGRSOSIDataSource *poPar, OGRFeatureDefn *poFeatDefn, LC_FILADM *poFil, S2I *poHeadDefn);
 
85
    ~OGRSOSILayer();
 
86
 
 
87
    void                ResetReading();
 
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();
 
94
};
 
95
 
 
96
/************************************************************************
 
97
 *                           OGRSOSIDataSource                          *
 
98
 * OGRSOSIDataSource reads a SOSI file, prebuilds the features, and     *
 
99
 * creates one OGRSOSILayer per geometry type                           *
 
100
 ************************************************************************/
 
101
class OGRSOSIDataSource : public OGRDataSource {
 
102
    char                *pszName;
 
103
    OGRSOSILayer        **papoLayers;
 
104
    int                 nLayers;
 
105
    
 
106
#define MODE_READING 0
 
107
#define MODE_WRITING 1    
 
108
    int                 nMode;
 
109
 
 
110
    void                buildOGRPoint(long nSerial);
 
111
    void                buildOGRLineString(int nNumCoo, long nSerial);
 
112
    void                buildOGRMultiPoint(int nNumCoo, long nSerial);
 
113
 
 
114
public:
 
115
 
 
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. */
 
121
    //FYBA specific
 
122
    LC_BASEADM          *poBaseadm;
 
123
    LC_FILADM           *poFileadm;
 
124
 
 
125
    S2I                 *poPolyHeaders;   /* Contain the header definitions of the four feature layers */
 
126
    S2I                 *poPointHeaders;
 
127
    S2I                 *poCurveHeaders;
 
128
    S2I                 *poTextHeaders;
 
129
 
 
130
    OGRSOSIDataSource();
 
131
    ~OGRSOSIDataSource();
 
132
 
 
133
    int                 Open  ( const char * pszFilename, int bUpdate);
 
134
    int                 Create( const char * pszFilename );
 
135
    const char          *GetName() {
 
136
        return pszName;
 
137
    }
 
138
    int                 GetLayerCount() {
 
139
        return nLayers;
 
140
    }
 
141
    OGRLayer            *GetLayer( int );
 
142
    OGRLayer            *CreateLayer( const char *pszName, OGRSpatialReference  *poSpatialRef=NULL, OGRwkbGeometryType eGType=wkbUnknown, char **papszOptions=NULL);
 
143
    int                 TestCapability( const char * );
 
144
};
 
145
 
 
146
#endif /* _OGR_SOSI_H_INCLUDED */