OpenCPN Partial API docs
Loading...
Searching...
No Matches
ogr_s57.h
1/******************************************************************************
2 *
3 * Project: S-57 Translator
4 * Purpose: Declarations for classes binding S57 support onto OGRLayer,
5 * OGRDataSource and OGRDriver. See also s57.h.
6 * Author: Frank Warmerdam, warmerda@home.com
7 *
8 ******************************************************************************
9 * Copyright (c) 1999, Frank Warmerdam
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 */
31
32#ifndef _OGR_S57_H_INCLUDED
33#define _OGR_S57_H_INCLUDED
34
35#include "gdal/ogrsf_frmts.h"
36#include "s57.h"
37
38// Misc error return codes
39#define BAD_FILE 10
40#define BAD_HEADER 11
41#define BAD_OPEN 12
42#define BAD_UPDATE 30
43
45
46/************************************************************************/
47/* OGRS57Layer */
48/* */
49/* Represents all features of a particular S57 object class. */
50/************************************************************************/
51
52class OGRS57Layer : public OGRLayer {
53 OGRGeometry *poFilterGeom;
54
55 OGRS57DataSource *poDS;
56
57 OGRFeatureDefn *poFeatureDefn;
58
59 int nCurrentModule;
60 int nRCNM;
61 int nOBJL;
62 int nNextFEIndex;
63 int nFeatureCount;
64
65public:
66 OGRS57Layer(OGRS57DataSource *poDS, OGRFeatureDefn *, int nFeatureCount = -1,
67 int nOBJL = -1);
68 virtual ~OGRS57Layer();
69
70 OGRGeometry *GetSpatialFilter() { return poFilterGeom; }
71 void SetSpatialFilter(OGRGeometry *);
72
73 void ResetReading();
74 OGRFeature *GetNextFeature();
75 OGRFeature *GetNextUnfilteredFeature();
76 virtual OGRFeature *GetFeature(long nFeatureId);
77
78 virtual int GetFeatureCount(int bForce = TRUE);
79 virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
80
81 OGRFeatureDefn *GetLayerDefn() { return poFeatureDefn; }
82
83 virtual OGRErr CreateFeature(OGRFeature *poFeature);
84 int TestCapability(const char *);
85
86 virtual OGRSpatialReference *GetSpatialRef();
87};
88
89/************************************************************************/
90/* OGRS57DataSource */
91/************************************************************************/
92typedef bool (*CallBackFunction)(void);
93
95 char *pszName;
96
97 int nLayers;
98 OGRS57Layer **papoLayers;
99
100 OGRSpatialReference *poSpatialRef;
101
102 char **papszOptions;
103
104 int nModules;
105 S57Reader **papoModules;
106
107 S57Writer *poWriter;
108
109 S57ClassRegistrar *poRegistrar;
110
111 int bClassCountSet;
112 int anClassCount[MAX_CLASSES];
113
114 int bExtentsSet;
115 OGREnvelope oExtents;
116
117public:
120
121 void SetOptionList(char **);
122 const char *GetOption(const char *);
123
124 int Open(const char *pszName, int bTestOpen = FALSE,
125 CallBackFunction p_callback = NULL);
126 int OpenMin(const char *pszName, int bTestOpen = FALSE);
127 int Create(const char *pszName, char **papszOptions);
128
129 const char *GetName() { return pszName; }
130 int GetLayerCount() { return nLayers; }
131 OGRLayer *GetLayer(int);
132 void AddLayer(OGRS57Layer *);
133 int TestCapability(const char *);
134
135 OGRSpatialReference *GetSpatialRef() { return poSpatialRef; }
136
137 int GetModuleCount() { return nModules; }
138 S57Reader *GetModule(int);
139 S57Writer *GetWriter() { return poWriter; }
140
141 S57ClassRegistrar *GetS57Registrar() { return poRegistrar; }
142 void SetS57Registrar(S57ClassRegistrar *p) { poRegistrar = p; }
143
144 OGRErr GetDSExtent(OGREnvelope *psExtent, int bForce = TRUE);
145};
146
147/************************************************************************/
148/* OGRS57Driver */
149/************************************************************************/
150
151class OGRS57Driver : public OGRSFDriver {
152public:
154
155 const char *GetName();
156 OGRDataSource *Open(const char *, int);
157 virtual OGRDataSource *CreateDataSource(const char *pszName, char ** = NULL);
158 int TestCapability(const char *);
159};
160
161#endif /* ndef _OGR_S57_H_INCLUDED */
Definition: s57.h:144
Definition: s57.h:249