1 : /******************************************************************************
2 : * $Id: ogr_s57.h 25311 2012-12-15 12:48:14Z rouault $
3 : *
4 : * Project: S-57 Translator
5 : * Purpose: Declarations for classes binding S57 support onto OGRLayer,
6 : * OGRDataSource and OGRDriver. See also s57.h.
7 : * Author: Frank Warmerdam, warmerdam@pobox.com
8 : *
9 : ******************************************************************************
10 : * Copyright (c) 1999, Frank Warmerdam
11 : *
12 : * Permission is hereby granted, free of charge, to any person obtaining a
13 : * copy of this software and associated documentation files (the "Software"),
14 : * to deal in the Software without restriction, including without limitation
15 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 : * and/or sell copies of the Software, and to permit persons to whom the
17 : * Software is furnished to do so, subject to the following conditions:
18 : *
19 : * The above copyright notice and this permission notice shall be included
20 : * in all copies or substantial portions of the Software.
21 : *
22 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 : * DEALINGS IN THE SOFTWARE.
29 : ****************************************************************************/
30 :
31 : #ifndef _OGR_S57_H_INCLUDED
32 : #define _OGR_S57_H_INCLUDED
33 :
34 : #include "ogrsf_frmts.h"
35 : #include "s57.h"
36 :
37 : class OGRS57DataSource;
38 :
39 : /************************************************************************/
40 : /* OGRS57Layer */
41 : /* */
42 : /* Represents all features of a particular S57 object class. */
43 : /************************************************************************/
44 :
45 : class OGRS57Layer : public OGRLayer
46 : {
47 : OGRS57DataSource *poDS;
48 :
49 : OGRFeatureDefn *poFeatureDefn;
50 :
51 : int nCurrentModule;
52 : int nRCNM;
53 : int nOBJL;
54 : int nNextFEIndex;
55 : int nFeatureCount;
56 :
57 : public:
58 : OGRS57Layer( OGRS57DataSource * poDS,
59 : OGRFeatureDefn *, int nFeatureCount = -1,
60 : int nOBJL = -1 );
61 : virtual ~OGRS57Layer();
62 :
63 : void ResetReading();
64 : OGRFeature * GetNextFeature();
65 : OGRFeature * GetNextUnfilteredFeature();
66 : virtual OGRFeature *GetFeature( long nFeatureId );
67 :
68 : virtual int GetFeatureCount( int bForce = TRUE );
69 : virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
70 :
71 330 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
72 :
73 : virtual OGRErr CreateFeature( OGRFeature *poFeature );
74 : int TestCapability( const char * );
75 :
76 : virtual OGRSpatialReference *GetSpatialRef();
77 : };
78 :
79 : /************************************************************************/
80 : /* OGRS57DataSource */
81 : /************************************************************************/
82 :
83 : class OGRS57DataSource : public OGRDataSource
84 : {
85 : char *pszName;
86 :
87 : int nLayers;
88 : OGRS57Layer **papoLayers;
89 :
90 : OGRSpatialReference *poSpatialRef;
91 :
92 : char **papszOptions;
93 :
94 : int nModules;
95 : S57Reader **papoModules;
96 :
97 : S57Writer *poWriter;
98 :
99 : int bExtentsSet;
100 : OGREnvelope oExtents;
101 :
102 : public:
103 : OGRS57DataSource();
104 : ~OGRS57DataSource();
105 :
106 : void SetOptionList( char ** );
107 : const char *GetOption( const char * );
108 :
109 : int Open( const char * pszName, int bTestOpen = FALSE );
110 : int Create( const char *pszName, char **papszOptions );
111 :
112 6 : const char *GetName() { return pszName; }
113 127 : int GetLayerCount() { return nLayers; }
114 : OGRLayer *GetLayer( int );
115 : void AddLayer( OGRS57Layer * );
116 : int TestCapability( const char * );
117 :
118 8 : OGRSpatialReference *GetSpatialRef() { return poSpatialRef; }
119 :
120 16 : int GetModuleCount() { return nModules; }
121 : S57Reader *GetModule( int );
122 0 : S57Writer *GetWriter() { return poWriter; }
123 :
124 : OGRErr GetDSExtent(OGREnvelope *psExtent, int bForce = TRUE);
125 : };
126 :
127 : /************************************************************************/
128 : /* OGRS57Driver */
129 : /************************************************************************/
130 :
131 : class OGRS57Driver : public OGRSFDriver
132 : {
133 : static S57ClassRegistrar *poRegistrar;
134 :
135 : public:
136 : OGRS57Driver();
137 : ~OGRS57Driver();
138 :
139 : const char *GetName();
140 : OGRDataSource *Open( const char *, int );
141 : virtual OGRDataSource *CreateDataSource( const char *pszName,
142 : char ** = NULL );
143 : int TestCapability( const char * );
144 :
145 : static S57ClassRegistrar *GetS57Registrar();
146 : };
147 :
148 : #endif /* ndef _OGR_S57_H_INCLUDED */
|