File: ogr_arch.dox

package info (click to toggle)
gdal 1.10.1+dfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 84,320 kB
  • ctags: 74,726
  • sloc: cpp: 677,199; ansic: 162,820; python: 13,816; cs: 11,163; sh: 10,446; java: 5,279; perl: 4,429; php: 2,971; xml: 1,500; yacc: 934; makefile: 494; sql: 112
file content (239 lines) | stat: -rw-r--r-- 11,186 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*! \page ogr_arch OGR Architecture

This document is intended to document the OGR classes.  The OGR
classes are intended to be generic (not specific to OLE DB or COM or
Windows) but are used as a foundation for implementing OLE DB Provider
support, as well as client side support for SFCOM.  It is intended that
these same OGR classes could be used by an implementation of SFCORBA
for instance or used directly by C++ programs wanting to use an OpenGIS
simple features inspired API.<p>

Because OGR is modelled on the OpenGIS simple features data model, it is
very helpful to review the SFCOM, or other simple features interface
specifications which can be retrieved from the 
<a href="http://www.opengeospatial.org">Open Geospatial Consortium</a> web site.  Data
types, and method names are modelled on those from the interface 
specifications.<p>

\section ogr_arch_overview Class Overview

<ul>
<li> <b>Geometry</b> (<a href="ogr__geometry_8h-source.html">ogr_geometry.h</a>): 
The geometry classes (OGRGeometry, etc) encapsulate the OpenGIS model vector 
data as well as providing some geometry operations, and translation to/from
well known binary and text format.  A geometry includes a spatial reference
system (projection).<p>

<li> <b>Spatial Reference</b> 
(<a href="ogr__spatialref_8h-source.html">ogr_spatialref.h</a>):
An OGRSpatialReference encapsulates the definition of a projection and 
datum.<p>

<li> <b>Feature</b> (<a href="ogr__feature_8h-source.html">ogr_feature.h</a>):
The OGRFeature encapsulates the definition of a whole feature, that is a 
geometry and a set of attributes.<p>

<li> <b>Feature Class Definition</b>
(<a href="ogr__feature_8h-source.html">ogr_feature.h</a>): 
The OGRFeatureDefn class captures the schema (set of field definitions) for
a group of related features (normally a whole layer).<p>

<li> <b>Layer</b>
(<a href="ogrsf__frmts_8h-source.html">ogrsf_frmts.h</a>): 
OGRLayer is an abstract base class represent a layer of features in an 
OGRDataSource.<p>

<li> <b>Data Source</b>
(<a href="ogrsf__frmts_8h-source.html">ogrsf_frmts.h</a>): 
An OGRDataSource is an abstract base class
representing a file or database containing one or more OGRLayer
objects.<p>

<li> <b>Drivers</b> 
(<a href="ogrsf__frmts_8h-source.html">ogrsf_frmts.h</a>):
An OGRSFDriver represents a translator for a specific
format, opening OGRDataSource objects.  All available drivers are managed 
by the OGRSFDriverRegistrar.<p>

</ul>

\section ogr_arch_geometry Geometry

The geometry classes are represent various kinds of vector geometry.  All
the geometry classes derived from OGRGeometry which defines the common 
services of all geometries.  Types of geometry include OGRPoint, OGRLineString,
OGRPolygon, OGRGeometryCollection, OGRMultiPolygon, OGRMultiPoint, 
and OGRMultiLineString.<p>

Additional intermediate abstract base classes contain functionality that
could eventually be implemented by other geometry types.  These include
OGRCurve (base class for OGRLineString) and OGRSurface (base class for 
OGRPolygon).  Some intermediate interfaces modelled in the simple features
abstract model and SFCOM are not modelled in OGR at this time.  In most 
cases the methods are aggregated into other classes.  This may change.<p>

The OGRGeometryFactory is used to convert well known text, and well known
binary format data into geometries.  These are predefined ASCII and binary
formats for representing all the types of simple features geometries.<p>

In a manner based on the geometry object in SFCOM, the OGRGeometry includes
a reference to an OGRSpatialReference object, defining the spatial reference
system of that geometry.  This is normally a reference to a shared 
spatial reference object with reference counting for each of the 
OGRGeometry objects using it.<p>

Many of the spatial analysis methods (such as computing overlaps and so
forth) are not implemented at this time for OGRGeometry.<p>

While it is theoretically possible to derive other or more specific
geometry classes from the existing OGRGeometry classes, this isn't an
aspect that has been well thought out.  In particular, it would be
possible to create specialized classes using the OGRGeometryFactory without
modifying it.<p>


\section ogr_arch_srs Spatial Reference

The OGRSpatialReference class is intended to store an OpenGIS Spatial
Reference System definition.  Currently local, geographic and projected
coordinate systems are supported.  Vertical coordinate systems, geocentric 
coordinate systems, and compound (horizontal + vertical) coordinate systems
are not supported.<p>

The spatial coordinate system data model is inherited from the OpenGIS
<b>Well Known Text</b> format.  A simple form of this is defined in the
Simple Features specifications.  A more sophisticated form is found in 
the Coordinate Transformation specification.  The OGRSpatialReference is
built on the features of the Coordinate Transformation specification but
is intended to be compatible with the earlier simple features form.<p>

There is also an associated OGRCoordinateTransformation class that
encapsulates use of PROJ.4 for converting between different coordinate
systems.  There is a <a href="osr_tutorial.html">tutorial</a> available 
describing how to use the OGRSpatialReference class.<p>

\section ogr_arch_feature Feature / Feature Definition

The OGRGeometry captures the geometry of a vector feature ... the 
spatial position/region of a feature.  The OGRFeature contains this 
geometry, and adds feature attributes, feature id, 
and a feature class identify.<p>

The set of attributes, their types, names and so forth is represented
via the OGRFeatureDefn class.  One OGRFeatureDefn normally exists for a
layer of features.  The same definition is shared in a reference counted 
manner by the feature of that type (or feature class).<p>

The feature id (FID) of a feature is intended to be a unique identifier for
the feature within the layer it is a member of.  Freestanding features, or
features not yet written to a layer may have a null (OGRNullFID) feature id. 
The feature ids are modelled in OGR as a long integer; however, this is
not sufficiently expressive to model the natural feature ids in some
formats.  For instance, the GML feature id is a string, and the row id in
Oracle is larger than 4 bytes.<p>

The feature class
also contains an indicator of the types of geometry allowed for that feature
class (returned as an OGRwkbGeometryType from OGRFeatureDefn::GetGeomType()).
If this is wkbUnknown then any type of geometry is allowed.  This implies that
features in a given layer can potentially be of different geometry types
though they will always share a common attribute schema. <p>

The OGRFeatureDefn also contains a concept of default spatial reference
system for all features of that type and a feature class name (normally 
used as a layer name).<p>


\section ogr_arch_layer Layer

An OGRLayer represents a layer of features within a data source.  All 
features in an OGRLayer share a common schema and are of the same 
OGRFeatureDefn.  An OGRLayer class also contains methods for reading 
features from the data source. 
The OGRLayer can be thought of as a gateway for reading and
writing features from an underlying data source, normally a file format.
In SFCOM and other table based simple features implementation an OGRLayer
represents a spatial table.<p>

The OGRLayer includes methods for sequential and random reading and writing.
Read access (via the
OGRLayer::GetNextFeature() method) normally reads all features, one at a
time sequentially; however, it can be limited to return features intersecting
a particular geographic region by installing a spatial filter on the
OGRLayer (via the OGRLayer::SetSpatialFilter() method).<p>

One flaw in the
current OGR architecture is that the spatial filter is set directly on
the OGRLayer which is intended to be the only representative of a given
layer in a data source.  This means it isn't possible to have multiple
read operations active at one time with different spatial filters on 
each.  This aspect may be revised in the future to introduce an OGRLayerView
class or something similar.<p>

Another question that might arise is why the OGRLayer and OGRFeatureDefn
classes are distinct.  An OGRLayer always has a one-to-one relationship to
an OGRFeatureDefn, so why not amalgamate the classes.  There are two reasons:

<ol>

<li> As defined now OGRFeature and OGRFeatureDefn don't depend on OGRLayer,
so they can exist independently in memory without regard to a particular
layer in a data store. <p>

<li> The SF CORBA model does not have a concept of a layer with a single
fixed schema the way that the SFCOM and SFSQL models do.  The fact that
features belong to a feature collection that is potentially not directly
related to their current feature grouping may be important to implementing
SFCORBA support using OGR. 

</ol>

The OGRLayer class is an abstract base class.  An implementation is 
expected to be subclassed for each file format driver implemented. 
OGRLayers are normally owned directly by their OGRDataSource, and aren't
instantiated or destroyed directly.<p>

\section ogr_arch_data_source Data Source

An OGRDataSource represents a set of OGRLayer objects.  This usually 
represents a single file, set of files, database or gateway.  An OGRDataSource
has a list of OGRLayers which it owns but can return references to.<p>

OGRDataSource is an abstract base class.  An implementation is 
expected to be subclassed for each file format driver implemented.
OGRDataSource objects are not normally instantiated directly but rather with
the assistance of an OGRSFDriver.  Deleting an OGRDataSource closes access
to the underlying persistent data source, but does not normally result in 
deletion of that file.<p>

An OGRDataSource has a name (usually a filename) that can be used to reopen
the data source with an OGRSFDriver.<p>

The OGRDataSource also has support for executing a datasource specific
command, normally a form of SQL.   This is accomplished via the
OGRDataSource::ExecuteSQL() method.  While some datasources (such as PostGIS
and Oracle) pass the SQL through to an underlying database, OGR also includes
support for evaluating a subset of the SQL SELECT statement against any
datasource. <p>

\section ogr_arch_drivers Drivers

An OGRSFDriver object is instantiated for each file format supported.  
The OGRSFDriver objects are registered with the OGRSFDriverRegistrar, a
singleton class that is normally used to open new data sources.<p>

It is intended that a new OGRSFDriver derived class be implemented for each
file format to be supported (along with a file format specific 
OGRDataSource, and OGRLayer classes).<p>

On application startup registration
functions are normally called for each desired file format.  These functions
instantiate the appropriate OGRSFDriver objects, and register them with the
OGRSFDriverRegistrar.  When a data source is to be opened, the registrar
will normally try each OGRSFDriver in turn, until one succeeds, returning
an OGRDataSource object.<p>

It is not intended that the OGRSFDriverRegistrar be 
derived from.<p>

*/