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