root / trunk / libraries / libjni-gdal / include / ogr_geometry.h @ 7765
History | View | Annotate | Download (24.9 KB)
1 |
/******************************************************************************
|
---|---|
2 |
* $Id: ogr_geometry.h 7765 2006-10-03 07:05:18Z nacho $
|
3 |
*
|
4 |
* Project: OpenGIS Simple Features Reference Implementation
|
5 |
* Purpose: Classes for manipulating simple features that is not specific
|
6 |
* to a particular interface technology.
|
7 |
* Author: Frank Warmerdam, warmerda@home.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 |
* $Log$
|
32 |
* Revision 1.3 2006-10-03 07:05:18 nacho
|
33 |
* *** empty log message ***
|
34 |
*
|
35 |
* Revision 1.1 2006/07/18 16:21:00 nacho
|
36 |
* *** empty log message ***
|
37 |
*
|
38 |
* Revision 1.1 2006/06/29 16:23:27 nacho
|
39 |
* *** empty log message ***
|
40 |
*
|
41 |
* Revision 1.2 2006/01/09 12:50:13 nacho
|
42 |
* *** empty log message ***
|
43 |
*
|
44 |
* Revision 1.1 2005/07/27 08:22:55 igbrotru
|
45 |
* *** empty log message ***
|
46 |
*
|
47 |
* Revision 1.1 2005/01/11 15:23:01 igbrotru
|
48 |
* *** empty log message ***
|
49 |
*
|
50 |
* Revision 1.50 2004/09/17 15:05:36 fwarmerdam
|
51 |
* added get_Area() support
|
52 |
*
|
53 |
* Revision 1.49 2004/08/20 21:21:28 warmerda
|
54 |
* added support for managing a persistent geos::GeometryFactory
|
55 |
*
|
56 |
* Revision 1.48 2004/07/10 04:54:23 warmerda
|
57 |
* added GEOS methods, and closeRings
|
58 |
*
|
59 |
* Revision 1.47 2004/02/21 15:36:14 warmerda
|
60 |
* const correctness updates for geometry: bug 289
|
61 |
*
|
62 |
* Revision 1.46 2003/09/11 22:47:54 aamici
|
63 |
* add class constructors and destructors where needed in order to
|
64 |
* let the mingw/cygwin binutils produce sensible partially linked objet files
|
65 |
* with 'ld -r'.
|
66 |
*
|
67 |
* Revision 1.45 2003/08/27 15:40:37 warmerda
|
68 |
* added support for generating DB2 V7.2 compatible WKB
|
69 |
*
|
70 |
* Revision 1.44 2003/05/28 19:16:42 warmerda
|
71 |
* fixed up argument names and stuff for docs
|
72 |
*
|
73 |
* Revision 1.43 2003/04/28 15:39:33 warmerda
|
74 |
* ryan added forceToMultiPolyline and forceToMultiPoint
|
75 |
*
|
76 |
* Revision 1.42 2003/03/06 20:29:27 warmerda
|
77 |
* added GML import/export entry points
|
78 |
*
|
79 |
* Revision 1.41 2003/01/14 22:13:35 warmerda
|
80 |
* added isClockwise() method on OGRLinearRing
|
81 |
*
|
82 |
* Revision 1.40 2003/01/08 22:04:11 warmerda
|
83 |
* added forceToPolygon and forceToMultiPolygon methods
|
84 |
*
|
85 |
* Revision 1.39 2003/01/07 16:44:27 warmerda
|
86 |
* added removeGeometry
|
87 |
*
|
88 |
* Revision 1.38 2003/01/02 21:45:23 warmerda
|
89 |
* move OGRBuildPolygonsFromEdges into C API
|
90 |
*
|
91 |
* Revision 1.37 2002/10/25 15:20:50 warmerda
|
92 |
* fixed MULTIPOINT WKT format
|
93 |
*
|
94 |
* Revision 1.36 2002/10/24 20:53:02 warmerda
|
95 |
* expand tabs
|
96 |
*
|
97 |
* Revision 1.35 2002/09/26 18:13:17 warmerda
|
98 |
* moved some defs to ogr_core.h for sharing with ogr_api.h
|
99 |
*
|
100 |
* Revision 1.34 2002/09/11 13:47:17 warmerda
|
101 |
* preliminary set of fixes for 3D WKB enum
|
102 |
*
|
103 |
* Revision 1.33 2002/08/12 15:02:18 warmerda
|
104 |
* added OGRRawPoint and OGREnvelope initializes
|
105 |
*
|
106 |
* Revision 1.32 2002/05/02 19:45:36 warmerda
|
107 |
* added flattenTo2D() method
|
108 |
*
|
109 |
* Revision 1.31 2002/02/22 22:23:38 warmerda
|
110 |
* added tolerances when assembling polygons
|
111 |
*
|
112 |
* Revision 1.30 2002/02/18 21:12:23 warmerda
|
113 |
* added OGRBuildPolygonFromEdges
|
114 |
*
|
115 |
* Revision 1.29 2001/11/01 16:56:08 warmerda
|
116 |
* added createGeometry and destroyGeometry methods
|
117 |
*
|
118 |
* Revision 1.28 2001/09/21 16:24:20 warmerda
|
119 |
* added transform() and transformTo() methods
|
120 |
*
|
121 |
* Revision 1.27 2001/09/04 14:48:34 warmerda
|
122 |
* added some more 2.5D geometry types
|
123 |
*
|
124 |
* Revision 1.26 2001/05/24 18:05:18 warmerda
|
125 |
* substantial fixes to WKT support for MULTIPOINT/LINE/POLYGON
|
126 |
*
|
127 |
* Revision 1.25 2001/02/06 17:10:28 warmerda
|
128 |
* export entry points from DLL
|
129 |
*
|
130 |
* Revision 1.24 2001/01/19 21:10:47 warmerda
|
131 |
* replaced tabs
|
132 |
*
|
133 |
* Revision 1.23 2000/10/17 17:55:26 warmerda
|
134 |
* added comments for byte orders
|
135 |
*
|
136 |
* Revision 1.22 2000/04/26 18:25:55 warmerda
|
137 |
* added missing CPL_DLL attributes
|
138 |
*
|
139 |
* Revision 1.21 2000/03/14 21:38:17 warmerda
|
140 |
* added method to translate geometrytype to name
|
141 |
*
|
142 |
* Revision 1.20 1999/11/18 19:02:20 warmerda
|
143 |
* expanded tabs
|
144 |
*
|
145 |
* Revision 1.19 1999/11/04 16:26:12 warmerda
|
146 |
* Added the addGeometryDirectly() method for containers.
|
147 |
*
|
148 |
* Revision 1.18 1999/09/22 13:19:09 warmerda
|
149 |
* Added the addRingDirectly() method on OGRPolygon.
|
150 |
*
|
151 |
* Revision 1.17 1999/09/13 14:34:07 warmerda
|
152 |
* updated to use wkbZ of 0x8000 instead of 0x80000000
|
153 |
*
|
154 |
* Revision 1.16 1999/09/13 02:27:32 warmerda
|
155 |
* incorporated limited 2.5d support
|
156 |
*
|
157 |
* Revision 1.15 1999/08/29 17:14:29 warmerda
|
158 |
* Added wkbNone.
|
159 |
*
|
160 |
* Revision 1.14 1999/07/27 00:48:11 warmerda
|
161 |
* Added Equal() support
|
162 |
*
|
163 |
* Revision 1.13 1999/07/08 20:26:03 warmerda
|
164 |
* No longer override getGeometryType() on OGRLinearRing.
|
165 |
*
|
166 |
* Revision 1.12 1999/07/07 04:23:07 danmo
|
167 |
* Fixed typo in #define _OGR_..._H_INCLUDED line
|
168 |
*
|
169 |
* Revision 1.11 1999/07/06 21:36:46 warmerda
|
170 |
* tenatively added getEnvelope() and Intersect()
|
171 |
*
|
172 |
* Revision 1.10 1999/06/25 20:44:42 warmerda
|
173 |
* implemented assignSpatialReference, carry properly
|
174 |
*
|
175 |
* Revision 1.9 1999/05/31 20:44:11 warmerda
|
176 |
* ogr_geometry.h
|
177 |
*
|
178 |
* Revision 1.8 1999/05/31 15:01:59 warmerda
|
179 |
* OGRCurve now an abstract base class with essentially no implementation.
|
180 |
* Everything moved down to OGRLineString where it belongs. Also documented
|
181 |
* classes.
|
182 |
*
|
183 |
* Revision 1.7 1999/05/31 11:05:08 warmerda
|
184 |
* added some documentation
|
185 |
*
|
186 |
* Revision 1.6 1999/05/23 05:34:40 warmerda
|
187 |
* added support for clone(), multipolygons and geometry collections
|
188 |
*
|
189 |
* Revision 1.5 1999/05/20 14:35:44 warmerda
|
190 |
* added support for well known text format
|
191 |
*
|
192 |
* Revision 1.4 1999/05/17 14:39:13 warmerda
|
193 |
* Added ICurve, and some other IGeometry and related methods.
|
194 |
*
|
195 |
* Revision 1.3 1999/05/14 13:30:59 warmerda
|
196 |
* added IsEmpty() and IsSimple()
|
197 |
*
|
198 |
* Revision 1.2 1999/03/30 21:21:43 warmerda
|
199 |
* added linearring/polygon support
|
200 |
*
|
201 |
* Revision 1.1 1999/03/29 21:21:10 warmerda
|
202 |
* New
|
203 |
*
|
204 |
*/
|
205 |
|
206 |
#ifndef _OGR_GEOMETRY_H_INCLUDED
|
207 |
#define _OGR_GEOMETRY_H_INCLUDED
|
208 |
|
209 |
#include "ogr_core.h" |
210 |
#include "ogr_spatialref.h" |
211 |
|
212 |
/**
|
213 |
* \file ogr_geometry.h
|
214 |
*
|
215 |
* Simple feature geometry classes.
|
216 |
*/
|
217 |
|
218 |
/**
|
219 |
* Simple container for a position.
|
220 |
*/
|
221 |
class OGRRawPoint |
222 |
{ |
223 |
public:
|
224 |
OGRRawPoint() |
225 |
{ |
226 |
x = y = 0.0; |
227 |
} |
228 |
double x;
|
229 |
double y;
|
230 |
}; |
231 |
|
232 |
namespace geos { |
233 |
class Geometry; |
234 |
class GeometryFactory; |
235 |
}; |
236 |
|
237 |
/************************************************************************/
|
238 |
/* OGRGeometry */
|
239 |
/************************************************************************/
|
240 |
|
241 |
/**
|
242 |
* Abstract base class for all geometry classes.
|
243 |
*
|
244 |
* Note that the family of spatial analysis methods (Equal(), Disjoint(), ...,
|
245 |
* ConvexHull(), Buffer(), ...) are not implemented at ths time. Some other
|
246 |
* required and optional geometry methods have also been omitted at this
|
247 |
* time.
|
248 |
*/
|
249 |
|
250 |
class CPL_DLL OGRGeometry |
251 |
{ |
252 |
private:
|
253 |
OGRSpatialReference * poSRS; // may be NULL
|
254 |
|
255 |
public:
|
256 |
OGRGeometry(); |
257 |
virtual ~OGRGeometry(); |
258 |
|
259 |
// standard IGeometry
|
260 |
virtual int getDimension() const = 0; |
261 |
virtual int getCoordinateDimension() const = 0; |
262 |
virtual OGRBoolean IsEmpty() const { return 0; } |
263 |
virtual OGRBoolean IsSimple() const { return 1; } |
264 |
virtual void empty() = 0; |
265 |
virtual OGRGeometry *clone() const = 0; |
266 |
virtual void getEnvelope( OGREnvelope * psEnvelope ) const = 0; |
267 |
|
268 |
// IWks Interface
|
269 |
virtual int WkbSize() const = 0; |
270 |
virtual OGRErr importFromWkb( unsigned char *, int=-1 )=0; |
271 |
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const = 0; |
272 |
virtual OGRErr importFromWkt( char ** ppszInput ) = 0; |
273 |
virtual OGRErr exportToWkt( char ** ppszDstText ) const = 0; |
274 |
|
275 |
// non-standard
|
276 |
virtual OGRwkbGeometryType getGeometryType() const = 0; |
277 |
virtual const char *getGeometryName() const = 0; |
278 |
virtual void dumpReadable( FILE *, const char * = NULL ); |
279 |
virtual void flattenTo2D() = 0; |
280 |
virtual char * exportToGML() const; |
281 |
virtual geos::Geometry *exportToGEOS() const;
|
282 |
virtual void closeRings();
|
283 |
|
284 |
void assignSpatialReference( OGRSpatialReference * poSR );
|
285 |
OGRSpatialReference *getSpatialReference( void ) const { return poSRS; } |
286 |
|
287 |
virtual OGRErr transform( OGRCoordinateTransformation *poCT ) = 0;
|
288 |
OGRErr transformTo( OGRSpatialReference *poSR ); |
289 |
|
290 |
// ISpatialRelation
|
291 |
virtual OGRBoolean Intersect( OGRGeometry * ) const;
|
292 |
virtual OGRBoolean Equal( OGRGeometry * ) const = 0; |
293 |
virtual OGRBoolean Disjoint( const OGRGeometry * ) const; |
294 |
virtual OGRBoolean Touches( const OGRGeometry * ) const; |
295 |
virtual OGRBoolean Crosses( const OGRGeometry * ) const; |
296 |
virtual OGRBoolean Within( const OGRGeometry * ) const; |
297 |
virtual OGRBoolean Contains( const OGRGeometry * ) const; |
298 |
virtual OGRBoolean Overlaps( const OGRGeometry * ) const; |
299 |
// virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
|
300 |
|
301 |
virtual OGRGeometry *getBoundary() const;
|
302 |
virtual double Distance( const OGRGeometry * ) const; |
303 |
virtual OGRGeometry *ConvexHull() const;
|
304 |
virtual OGRGeometry *Buffer( double dfDist, int nQuadSegs = 30 ) const; |
305 |
virtual OGRGeometry *Intersection( const OGRGeometry *) const; |
306 |
virtual OGRGeometry *Union( const OGRGeometry * ) const; |
307 |
virtual OGRGeometry *Difference( const OGRGeometry * ) const; |
308 |
virtual OGRGeometry *SymmetricDifference( const OGRGeometry * ) const; |
309 |
|
310 |
// Special HACK for DB2 7.2 support
|
311 |
static int bGenerate_DB2_V72_BYTE_ORDER; |
312 |
}; |
313 |
|
314 |
/************************************************************************/
|
315 |
/* OGRPoint */
|
316 |
/************************************************************************/
|
317 |
|
318 |
/**
|
319 |
* Point class.
|
320 |
*
|
321 |
* Implements SFCOM IPoint methods.
|
322 |
*/
|
323 |
|
324 |
class CPL_DLL OGRPoint : public OGRGeometry |
325 |
{ |
326 |
double x;
|
327 |
double y;
|
328 |
double z;
|
329 |
|
330 |
public:
|
331 |
OGRPoint(); |
332 |
OGRPoint( double x, double y, double z = 0.0 ); |
333 |
virtual ~OGRPoint(); |
334 |
|
335 |
// IWks Interface
|
336 |
virtual int WkbSize() const; |
337 |
virtual OGRErr importFromWkb( unsigned char *, int=-1 ); |
338 |
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const; |
339 |
virtual OGRErr importFromWkt( char ** );
|
340 |
virtual OGRErr exportToWkt( char ** ppszDstText ) const; |
341 |
|
342 |
// IGeometry
|
343 |
virtual int getDimension() const; |
344 |
virtual int getCoordinateDimension() const; |
345 |
virtual OGRGeometry *clone() const;
|
346 |
virtual void empty();
|
347 |
virtual void getEnvelope( OGREnvelope * psEnvelope ) const; |
348 |
|
349 |
// IPoint
|
350 |
double getX() const { return x; } |
351 |
double getY() const { return y; } |
352 |
double getZ() const { return z; } |
353 |
|
354 |
// Non standard
|
355 |
void setX( double xIn ) { x = xIn; } |
356 |
void setY( double yIn ) { y = yIn; } |
357 |
void setZ( double zIn ) { z = zIn; } |
358 |
|
359 |
// ISpatialRelation
|
360 |
virtual OGRBoolean Equal( OGRGeometry * ) const;
|
361 |
|
362 |
// Non standard from OGRGeometry
|
363 |
virtual const char *getGeometryName() const; |
364 |
virtual OGRwkbGeometryType getGeometryType() const;
|
365 |
virtual OGRErr transform( OGRCoordinateTransformation *poCT ); |
366 |
virtual void flattenTo2D();
|
367 |
|
368 |
}; |
369 |
|
370 |
/************************************************************************/
|
371 |
/* OGRCurve */
|
372 |
/************************************************************************/
|
373 |
|
374 |
/**
|
375 |
* Abstract curve base class.
|
376 |
*/
|
377 |
|
378 |
class CPL_DLL OGRCurve : public OGRGeometry |
379 |
{ |
380 |
public:
|
381 |
OGRCurve(); |
382 |
virtual ~OGRCurve(); |
383 |
// ICurve methods
|
384 |
virtual double get_Length() const = 0; |
385 |
virtual void StartPoint(OGRPoint *) const = 0; |
386 |
virtual void EndPoint(OGRPoint *) const = 0; |
387 |
virtual int get_IsClosed() const; |
388 |
virtual void Value( double, OGRPoint * ) const = 0; |
389 |
|
390 |
}; |
391 |
|
392 |
/************************************************************************/
|
393 |
/* OGRLineString */
|
394 |
/************************************************************************/
|
395 |
|
396 |
/**
|
397 |
* Concrete representation of a multi-vertex line.
|
398 |
*/
|
399 |
|
400 |
class CPL_DLL OGRLineString : public OGRCurve |
401 |
{ |
402 |
protected:
|
403 |
int nPointCount;
|
404 |
OGRRawPoint *paoPoints; |
405 |
double *padfZ;
|
406 |
|
407 |
void Make3D();
|
408 |
void Make2D();
|
409 |
|
410 |
public:
|
411 |
OGRLineString(); |
412 |
virtual ~OGRLineString(); |
413 |
|
414 |
// IWks Interface
|
415 |
virtual int WkbSize() const; |
416 |
virtual OGRErr importFromWkb( unsigned char *, int = -1 ); |
417 |
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const; |
418 |
virtual OGRErr importFromWkt( char ** );
|
419 |
virtual OGRErr exportToWkt( char ** ppszDstText ) const; |
420 |
|
421 |
// IGeometry interface
|
422 |
virtual int getDimension() const; |
423 |
virtual int getCoordinateDimension() const; |
424 |
virtual OGRGeometry *clone() const;
|
425 |
virtual void empty();
|
426 |
virtual void getEnvelope( OGREnvelope * psEnvelope ) const; |
427 |
|
428 |
// ICurve methods
|
429 |
virtual double get_Length() const; |
430 |
virtual void StartPoint(OGRPoint *) const; |
431 |
virtual void EndPoint(OGRPoint *) const; |
432 |
virtual void Value( double, OGRPoint * ) const; |
433 |
|
434 |
// ILineString methods
|
435 |
int getNumPoints() const { return nPointCount; } |
436 |
void getPoint( int, OGRPoint * ) const; |
437 |
double getX( int i ) const { return paoPoints[i].x; } |
438 |
double getY( int i ) const { return paoPoints[i].y; } |
439 |
double getZ( int i ) const; |
440 |
|
441 |
// ISpatialRelation
|
442 |
virtual OGRBoolean Equal( OGRGeometry * ) const;
|
443 |
|
444 |
// non standard.
|
445 |
void setNumPoints( int ); |
446 |
void setPoint( int, OGRPoint * ); |
447 |
void setPoint( int, double, double, double = 0.0 ); |
448 |
void setPoints( int, OGRRawPoint *, double * = NULL ); |
449 |
void setPoints( int, double * padfX, double * padfY, |
450 |
double *padfZ = NULL ); |
451 |
void addPoint( OGRPoint * );
|
452 |
void addPoint( double, double, double = 0.0 ); |
453 |
|
454 |
// non-standard from OGRGeometry
|
455 |
virtual OGRwkbGeometryType getGeometryType() const;
|
456 |
virtual const char *getGeometryName() const; |
457 |
virtual OGRErr transform( OGRCoordinateTransformation *poCT ); |
458 |
virtual void flattenTo2D();
|
459 |
|
460 |
}; |
461 |
|
462 |
/************************************************************************/
|
463 |
/* OGRLinearRing */
|
464 |
/* */
|
465 |
/* This is an alias for OGRLineString for now. */
|
466 |
/************************************************************************/
|
467 |
|
468 |
/**
|
469 |
* Concrete representation of a closed ring.
|
470 |
*
|
471 |
* This class is functionally equivelent to an OGRLineString, but has a
|
472 |
* separate identity to maintain alignment with the OpenGIS simple feature
|
473 |
* data model. It exists to serve as a component of an OGRPolygon.
|
474 |
*/
|
475 |
|
476 |
class CPL_DLL OGRLinearRing : public OGRLineString |
477 |
{ |
478 |
private:
|
479 |
friend class OGRPolygon; |
480 |
|
481 |
// These are not IWks compatible ... just a convenience for OGRPolygon.
|
482 |
virtual int _WkbSize( int b3D ) const; |
483 |
virtual OGRErr _importFromWkb( OGRwkbByteOrder, int b3D,
|
484 |
unsigned char *, int=-1 ); |
485 |
virtual OGRErr _exportToWkb( OGRwkbByteOrder, int b3D,
|
486 |
unsigned char * ) const; |
487 |
|
488 |
public:
|
489 |
OGRLinearRing(); |
490 |
OGRLinearRing( OGRLinearRing * ); |
491 |
~OGRLinearRing(); |
492 |
|
493 |
// Non standard.
|
494 |
virtual const char *getGeometryName() const; |
495 |
virtual OGRGeometry *clone() const;
|
496 |
virtual int isClockwise() const; |
497 |
virtual void closeRings();
|
498 |
virtual double get_Area() const; |
499 |
|
500 |
// IWks Interface - Note this isnt really a first class object
|
501 |
// for the purposes of WKB form. These methods always fail since this
|
502 |
// object cant be serialized on its own.
|
503 |
virtual int WkbSize() const; |
504 |
virtual OGRErr importFromWkb( unsigned char *, int=-1 ); |
505 |
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const; |
506 |
}; |
507 |
|
508 |
/************************************************************************/
|
509 |
/* OGRSurface */
|
510 |
/************************************************************************/
|
511 |
|
512 |
/**
|
513 |
* Abstract base class for 2 dimensional objects like polygons.
|
514 |
*/
|
515 |
|
516 |
class CPL_DLL OGRSurface : public OGRGeometry |
517 |
{ |
518 |
public:
|
519 |
virtual double get_Area() const = 0; |
520 |
virtual OGRErr Centroid( OGRPoint * poPoint ) const = 0; |
521 |
virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const = 0; |
522 |
}; |
523 |
|
524 |
/************************************************************************/
|
525 |
/* OGRPolygon */
|
526 |
/************************************************************************/
|
527 |
|
528 |
/**
|
529 |
* Concrete class representing polygons.
|
530 |
*
|
531 |
* Note that the OpenGIS simple features polygons consist of one outer
|
532 |
* ring, and zero or more inner rings. A polygon cannot represent disconnected
|
533 |
* regions (such as multiple islands in a political body). The
|
534 |
* OGRMultiPolygon must be used for this.
|
535 |
*/
|
536 |
|
537 |
class CPL_DLL OGRPolygon : public OGRSurface |
538 |
{ |
539 |
int nRingCount;
|
540 |
OGRLinearRing **papoRings; |
541 |
|
542 |
public:
|
543 |
OGRPolygon(); |
544 |
virtual ~OGRPolygon(); |
545 |
|
546 |
// Non standard (OGRGeometry).
|
547 |
virtual const char *getGeometryName() const; |
548 |
virtual OGRwkbGeometryType getGeometryType() const;
|
549 |
virtual OGRGeometry *clone() const;
|
550 |
virtual void empty();
|
551 |
virtual OGRErr transform( OGRCoordinateTransformation *poCT ); |
552 |
virtual void flattenTo2D();
|
553 |
|
554 |
// ISurface Interface
|
555 |
virtual double get_Area() const; |
556 |
virtual int Centroid( OGRPoint * poPoint ) const; |
557 |
virtual int PointOnSurface( OGRPoint * poPoint ) const; |
558 |
|
559 |
// IWks Interface
|
560 |
virtual int WkbSize() const; |
561 |
virtual OGRErr importFromWkb( unsigned char *, int = -1 ); |
562 |
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const; |
563 |
virtual OGRErr importFromWkt( char ** );
|
564 |
virtual OGRErr exportToWkt( char ** ppszDstText ) const; |
565 |
|
566 |
// IGeometry
|
567 |
virtual int getDimension() const; |
568 |
virtual int getCoordinateDimension() const; |
569 |
virtual void getEnvelope( OGREnvelope * psEnvelope ) const; |
570 |
|
571 |
// ISpatialRelation
|
572 |
virtual OGRBoolean Equal( OGRGeometry * ) const;
|
573 |
|
574 |
// Non standard
|
575 |
void addRing( OGRLinearRing * );
|
576 |
void addRingDirectly( OGRLinearRing * );
|
577 |
|
578 |
OGRLinearRing *getExteriorRing(); |
579 |
const OGRLinearRing *getExteriorRing() const; |
580 |
int getNumInteriorRings() const; |
581 |
OGRLinearRing *getInteriorRing( int );
|
582 |
const OGRLinearRing *getInteriorRing( int ) const; |
583 |
|
584 |
virtual void closeRings();
|
585 |
}; |
586 |
|
587 |
/************************************************************************/
|
588 |
/* OGRGeometryCollection */
|
589 |
/************************************************************************/
|
590 |
|
591 |
/**
|
592 |
* A collection of 1 or more geometry objects.
|
593 |
*
|
594 |
* All geometries must share a common spatial reference system, and
|
595 |
* Subclasses may impose additional restrictions on the contents.
|
596 |
*/
|
597 |
|
598 |
class CPL_DLL OGRGeometryCollection : public OGRGeometry |
599 |
{ |
600 |
int nGeomCount;
|
601 |
OGRGeometry **papoGeoms; |
602 |
|
603 |
int nCoordinateDimension;
|
604 |
|
605 |
public:
|
606 |
OGRGeometryCollection(); |
607 |
virtual ~OGRGeometryCollection(); |
608 |
|
609 |
// Non standard (OGRGeometry).
|
610 |
virtual const char *getGeometryName() const; |
611 |
virtual OGRwkbGeometryType getGeometryType() const;
|
612 |
virtual OGRGeometry *clone() const;
|
613 |
virtual void empty();
|
614 |
virtual OGRErr transform( OGRCoordinateTransformation *poCT ); |
615 |
virtual void flattenTo2D();
|
616 |
|
617 |
// IWks Interface
|
618 |
virtual int WkbSize() const; |
619 |
virtual OGRErr importFromWkb( unsigned char *, int = -1 ); |
620 |
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const; |
621 |
virtual OGRErr importFromWkt( char ** );
|
622 |
virtual OGRErr exportToWkt( char ** ppszDstText ) const; |
623 |
|
624 |
// IGeometry methods
|
625 |
virtual int getDimension() const; |
626 |
virtual int getCoordinateDimension() const; |
627 |
virtual void getEnvelope( OGREnvelope * psEnvelope ) const; |
628 |
|
629 |
// IGeometryCollection
|
630 |
int getNumGeometries() const; |
631 |
OGRGeometry *getGeometryRef( int );
|
632 |
const OGRGeometry *getGeometryRef( int ) const; |
633 |
|
634 |
// ISpatialRelation
|
635 |
virtual OGRBoolean Equal( OGRGeometry * ) const;
|
636 |
|
637 |
// Non standard
|
638 |
virtual OGRErr addGeometry( const OGRGeometry * );
|
639 |
virtual OGRErr addGeometryDirectly( OGRGeometry * ); |
640 |
virtual OGRErr removeGeometry( int iIndex, int bDelete = TRUE ); |
641 |
|
642 |
void closeRings();
|
643 |
}; |
644 |
|
645 |
/************************************************************************/
|
646 |
/* OGRMultiPolygon */
|
647 |
/************************************************************************/
|
648 |
|
649 |
/**
|
650 |
* A collection of non-overlapping OGRPolygons.
|
651 |
*
|
652 |
* Note that the IMultiSurface class hasn't been modelled, nor have any
|
653 |
* of it's methods.
|
654 |
*/
|
655 |
|
656 |
class CPL_DLL OGRMultiPolygon : public OGRGeometryCollection |
657 |
{ |
658 |
public:
|
659 |
OGRMultiPolygon(); |
660 |
// Non standard (OGRGeometry).
|
661 |
virtual const char *getGeometryName() const; |
662 |
virtual OGRwkbGeometryType getGeometryType() const;
|
663 |
virtual OGRGeometry *clone() const;
|
664 |
virtual OGRErr importFromWkt( char ** );
|
665 |
virtual OGRErr exportToWkt( char ** ) const; |
666 |
|
667 |
// Non standard
|
668 |
virtual OGRErr addGeometryDirectly( OGRGeometry * ); |
669 |
|
670 |
double get_Area() const; |
671 |
}; |
672 |
|
673 |
/************************************************************************/
|
674 |
/* OGRMultiPoint */
|
675 |
/************************************************************************/
|
676 |
|
677 |
/**
|
678 |
* A collection of OGRPoints.
|
679 |
*/
|
680 |
|
681 |
class CPL_DLL OGRMultiPoint : public OGRGeometryCollection |
682 |
{ |
683 |
private:
|
684 |
OGRErr importFromWkt_Bracketed( char ** );
|
685 |
|
686 |
public:
|
687 |
OGRMultiPoint(); |
688 |
// Non standard (OGRGeometry).
|
689 |
virtual const char *getGeometryName() const; |
690 |
virtual OGRwkbGeometryType getGeometryType() const;
|
691 |
virtual OGRGeometry *clone() const;
|
692 |
virtual OGRErr importFromWkt( char ** );
|
693 |
virtual OGRErr exportToWkt( char ** ) const; |
694 |
|
695 |
// Non standard
|
696 |
virtual OGRErr addGeometryDirectly( OGRGeometry * ); |
697 |
}; |
698 |
|
699 |
/************************************************************************/
|
700 |
/* OGRMultiLineString */
|
701 |
/************************************************************************/
|
702 |
|
703 |
/**
|
704 |
* A collection of OGRLineStrings.
|
705 |
*/
|
706 |
|
707 |
class CPL_DLL OGRMultiLineString : public OGRGeometryCollection |
708 |
{ |
709 |
public:
|
710 |
OGRMultiLineString(); |
711 |
~OGRMultiLineString(); |
712 |
// Non standard (OGRGeometry).
|
713 |
virtual const char *getGeometryName() const; |
714 |
virtual OGRwkbGeometryType getGeometryType() const;
|
715 |
virtual OGRGeometry *clone() const;
|
716 |
virtual OGRErr importFromWkt( char ** );
|
717 |
virtual OGRErr exportToWkt( char ** ) const; |
718 |
|
719 |
// Non standard
|
720 |
virtual OGRErr addGeometryDirectly( OGRGeometry * ); |
721 |
}; |
722 |
|
723 |
|
724 |
/************************************************************************/
|
725 |
/* OGRGeometryFactory */
|
726 |
/************************************************************************/
|
727 |
|
728 |
/**
|
729 |
* Create geometry objects from well known text/binary.
|
730 |
*/
|
731 |
|
732 |
class CPL_DLL OGRGeometryFactory |
733 |
{ |
734 |
public:
|
735 |
static OGRErr createFromWkb( unsigned char *, OGRSpatialReference *, |
736 |
OGRGeometry **, int = -1 ); |
737 |
static OGRErr createFromWkt( char **, OGRSpatialReference *, |
738 |
OGRGeometry ** ); |
739 |
static OGRGeometry *createFromGML( const char * ); |
740 |
static OGRGeometry *createFromGEOS( const geos::Geometry * ); |
741 |
|
742 |
static void destroyGeometry( OGRGeometry * ); |
743 |
static OGRGeometry *createGeometry( OGRwkbGeometryType );
|
744 |
|
745 |
static OGRGeometry * forceToPolygon( OGRGeometry * );
|
746 |
static OGRGeometry * forceToMultiPolygon( OGRGeometry * );
|
747 |
static OGRGeometry * forceToMultiPoint( OGRGeometry * );
|
748 |
static OGRGeometry * forceToMultiLineString( OGRGeometry * );
|
749 |
|
750 |
static geos::GeometryFactory *getGEOSGeometryFactory();
|
751 |
|
752 |
}; |
753 |
|
754 |
#endif /* ndef _OGR_GEOMETRY_H_INCLUDED */ |