OpenCPN Partial API docs
Loading...
Searching...
No Matches
ogr_s57.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright (c) 1999, Frank Warmerdam
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 ******************************************************************************/
22
29#ifndef _OGR_S57_H_INCLUDED
30#define _OGR_S57_H_INCLUDED
31
32#include "s57.h"
33
34// Misc error return codes
35#define BAD_FILE 10
36#define BAD_HEADER 11
37#define BAD_OPEN 12
38#define BAD_UPDATE 30
39
41
42/************************************************************************/
43/* OGRS57Layer */
44/* */
45/* Represents all features of a particular S57 object class. */
46/************************************************************************/
47
48class OGRS57Layer : public OGRLayer {
49 OGRGeometry *poFilterGeom;
50
51 OGRS57DataSource *poDS;
52
53 OGRFeatureDefn *poFeatureDefn;
54
55 int nCurrentModule;
56 int nRCNM;
57 int nOBJL;
58 int nNextFEIndex;
59 int nFeatureCount;
60
61public:
62 OGRS57Layer(OGRS57DataSource *poDS, OGRFeatureDefn *, int nFeatureCount = -1,
63 int nOBJL = -1);
64 virtual ~OGRS57Layer();
65
66 OGRGeometry *GetSpatialFilter() { return poFilterGeom; }
67 void SetSpatialFilter(OGRGeometry *);
68
69 void ResetReading();
70 OGRFeature *GetNextFeature();
71 OGRFeature *GetNextUnfilteredFeature();
72 virtual OGRFeature *GetFeature(long nFeatureId);
73
74 virtual int GetFeatureCount(int bForce = TRUE);
75 virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
76
77 OGRFeatureDefn *GetLayerDefn() { return poFeatureDefn; }
78
79 virtual OGRErr CreateFeature(OGRFeature *poFeature);
80 int TestCapability(const char *);
81
82 virtual OGRSpatialReference *GetSpatialRef();
83};
84
85/************************************************************************/
86/* OGRS57DataSource */
87/************************************************************************/
88typedef bool (*CallBackFunction)(void);
89
91 char *pszName;
92
93 int nLayers;
94 OGRS57Layer **papoLayers;
95
96 OGRSpatialReference *poSpatialRef;
97
98 char **papszOptions;
99
100 int nModules;
101 S57Reader **papoModules;
102
103 S57Writer *poWriter;
104
105 S57ClassRegistrar *poRegistrar;
106
107 int bClassCountSet;
108 int anClassCount[MAX_CLASSES];
109
110 int bExtentsSet;
111 OGREnvelope oExtents;
112
113public:
116
117 void SetOptionList(char **);
118 const char *GetOption(const char *);
119
120 int Open(const char *pszName, int bTestOpen = FALSE,
121 CallBackFunction p_callback = NULL);
122 int OpenMin(const char *pszName, int bTestOpen = FALSE);
123 int Create(const char *pszName, char **papszOptions);
124
134 bool IsSencPath(const char *path, const char *parent = "SENC");
135
136 const char *GetName() { return pszName; }
137 int GetLayerCount() { return nLayers; }
138 OGRLayer *GetLayer(int);
139 void AddLayer(OGRS57Layer *);
140 int TestCapability(const char *);
141
142 OGRSpatialReference *GetSpatialRef() { return poSpatialRef; }
143
144 int GetModuleCount() { return nModules; }
145 S57Reader *GetModule(int);
146 S57Writer *GetWriter() { return poWriter; }
147
148 S57ClassRegistrar *GetS57Registrar() { return poRegistrar; }
149 void SetS57Registrar(S57ClassRegistrar *p) { poRegistrar = p; }
150
151 OGRErr GetDSExtent(OGREnvelope *psExtent, int bForce = TRUE);
152};
153
154/************************************************************************/
155/* OGRS57Driver */
156/************************************************************************/
157
158class OGRS57Driver : public OGRSFDriver {
159public:
161
162 const char *GetName();
163 OGRDataSource *Open(const char *, int);
164 virtual OGRDataSource *CreateDataSource(const char *pszName, char ** = NULL);
165 int TestCapability(const char *);
166};
167
168#endif /* ndef _OGR_S57_H_INCLUDED */
bool IsSencPath(const char *path, const char *parent="SENC")
OpenCPN copies new cell files into a cache directory named 'SENC'.
Declarations for S-57 translator not including the binding onto OGRLayer/DataSource/Driver which are ...