1 : /******************************************************************************
2 : * $Id: ogr_geometry.h 23966 2012-02-13 04:41:24Z warmerdam $
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, warmerdam@pobox.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 : #ifndef _OGR_GEOMETRY_H_INCLUDED
32 : #define _OGR_GEOMETRY_H_INCLUDED
33 :
34 : #include "ogr_core.h"
35 : #include "ogr_spatialref.h"
36 :
37 : /**
38 : * \file ogr_geometry.h
39 : *
40 : * Simple feature geometry classes.
41 : */
42 :
43 : /**
44 : * Simple container for a position.
45 : */
46 : class OGRRawPoint
47 : {
48 : public:
49 : OGRRawPoint()
50 : {
51 : x = y = 0.0;
52 : }
53 : double x;
54 : double y;
55 : };
56 :
57 : typedef struct GEOSGeom_t *GEOSGeom;
58 :
59 : /************************************************************************/
60 : /* OGRGeometry */
61 : /************************************************************************/
62 :
63 : class OGRPoint;
64 :
65 : /**
66 : * Abstract base class for all geometry classes.
67 : *
68 : * Some spatial analysis methods require that OGR is built on the GEOS library
69 : * to work properly. The precise meaning of methods that describe spatial relationships
70 : * between geometries is described in the SFCOM, or other simple features interface
71 : * specifications, like "OpenGISĀ® Implementation Specification for
72 : * Geographic information - Simple feature access - Part 1: Common architecture"
73 : * (<a href="http://www.opengeospatial.org/standards/sfa">OGC 06-103r3</a>)
74 : *
75 : */
76 :
77 : class CPL_DLL OGRGeometry
78 : {
79 : private:
80 : OGRSpatialReference * poSRS; // may be NULL
81 :
82 : protected:
83 : int nCoordDimension;
84 :
85 : public:
86 : OGRGeometry();
87 : virtual ~OGRGeometry();
88 :
89 : // standard IGeometry
90 : virtual int getDimension() const = 0;
91 : virtual int getCoordinateDimension() const;
92 : virtual OGRBoolean IsEmpty() const = 0;
93 : virtual OGRBoolean IsValid() const;
94 : virtual OGRBoolean IsSimple() const;
95 : virtual OGRBoolean IsRing() const;
96 : virtual void empty() = 0;
97 : virtual OGRGeometry *clone() const = 0;
98 : virtual void getEnvelope( OGREnvelope * psEnvelope ) const = 0;
99 : virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const = 0;
100 :
101 : // IWks Interface
102 : virtual int WkbSize() const = 0;
103 : virtual OGRErr importFromWkb( unsigned char *, int=-1 )=0;
104 : virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const = 0;
105 : virtual OGRErr importFromWkt( char ** ppszInput ) = 0;
106 : virtual OGRErr exportToWkt( char ** ppszDstText ) const = 0;
107 :
108 : // non-standard
109 : virtual OGRwkbGeometryType getGeometryType() const = 0;
110 : virtual const char *getGeometryName() const = 0;
111 : virtual void dumpReadable( FILE *, const char * = NULL, char** papszOptions = NULL ) const;
112 : virtual void flattenTo2D() = 0;
113 : virtual char * exportToGML( const char* const * papszOptions = NULL ) const;
114 : virtual char * exportToKML() const;
115 : virtual char * exportToJson() const;
116 : virtual GEOSGeom exportToGEOS() const;
117 : virtual void closeRings();
118 :
119 : virtual void setCoordinateDimension( int nDimension );
120 :
121 : void assignSpatialReference( OGRSpatialReference * poSR );
122 396320 : OGRSpatialReference *getSpatialReference( void ) const { return poSRS; }
123 :
124 : virtual OGRErr transform( OGRCoordinateTransformation *poCT ) = 0;
125 : OGRErr transformTo( OGRSpatialReference *poSR );
126 :
127 : virtual void segmentize(double dfMaxLength);
128 :
129 : // ISpatialRelation
130 : virtual OGRBoolean Intersects( OGRGeometry * ) const;
131 : virtual OGRBoolean Equals( OGRGeometry * ) const = 0;
132 : virtual OGRBoolean Disjoint( const OGRGeometry * ) const;
133 : virtual OGRBoolean Touches( const OGRGeometry * ) const;
134 : virtual OGRBoolean Crosses( const OGRGeometry * ) const;
135 : virtual OGRBoolean Within( const OGRGeometry * ) const;
136 : virtual OGRBoolean Contains( const OGRGeometry * ) const;
137 : virtual OGRBoolean Overlaps( const OGRGeometry * ) const;
138 : // virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
139 :
140 : virtual OGRGeometry *Boundary() const;
141 : virtual double Distance( const OGRGeometry * ) const;
142 : virtual OGRGeometry *ConvexHull() const;
143 : virtual OGRGeometry *Buffer( double dfDist, int nQuadSegs = 30 ) const;
144 : virtual OGRGeometry *Intersection( const OGRGeometry *) const;
145 : virtual OGRGeometry *Union( const OGRGeometry * ) const;
146 : virtual OGRGeometry *UnionCascaded() const;
147 : virtual OGRGeometry *Difference( const OGRGeometry * ) const;
148 : virtual OGRGeometry *SymDifference( const OGRGeometry * ) const;
149 : virtual OGRErr Centroid( OGRPoint * poPoint ) const;
150 : virtual OGRGeometry *Simplify(double dTolerance) const;
151 : OGRGeometry *SimplifyPreserveTopology(double dTolerance) const;
152 :
153 : virtual OGRGeometry *Polygonize() const;
154 :
155 : // backward compatibility to non-standard method names.
156 : OGRBoolean Intersect( OGRGeometry * ) const;
157 : OGRBoolean Equal( OGRGeometry * ) const;
158 : virtual OGRGeometry *SymmetricDifference( const OGRGeometry * ) const;
159 : virtual OGRGeometry *getBoundary() const;
160 :
161 : // Special HACK for DB2 7.2 support
162 : static int bGenerate_DB2_V72_BYTE_ORDER;
163 :
164 : virtual void swapXY();
165 : };
166 :
167 : /************************************************************************/
168 : /* OGRPoint */
169 : /************************************************************************/
170 :
171 : /**
172 : * Point class.
173 : *
174 : * Implements SFCOM IPoint methods.
175 : */
176 :
177 : class CPL_DLL OGRPoint : public OGRGeometry
178 : {
179 : double x;
180 : double y;
181 : double z;
182 :
183 : public:
184 : OGRPoint();
185 : OGRPoint( double x, double y );
186 : OGRPoint( double x, double y, double z );
187 : virtual ~OGRPoint();
188 :
189 : // IWks Interface
190 : virtual int WkbSize() const;
191 : virtual OGRErr importFromWkb( unsigned char *, int=-1 );
192 : virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
193 : virtual OGRErr importFromWkt( char ** );
194 : virtual OGRErr exportToWkt( char ** ppszDstText ) const;
195 :
196 : // IGeometry
197 : virtual int getDimension() const;
198 : virtual OGRGeometry *clone() const;
199 : virtual void empty();
200 : virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
201 : virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
202 : virtual OGRBoolean IsEmpty() const;
203 :
204 : // IPoint
205 148940 : double getX() const { return x; }
206 148372 : double getY() const { return y; }
207 80734 : double getZ() const { return z; }
208 :
209 : // Non standard
210 : virtual void setCoordinateDimension( int nDimension );
211 7978 : void setX( double xIn ) { x = xIn; if (nCoordDimension == 0) nCoordDimension = 2; }
212 7974 : void setY( double yIn ) { y = yIn; if (nCoordDimension == 0) nCoordDimension = 2; }
213 746 : void setZ( double zIn ) { z = zIn; nCoordDimension=3; }
214 :
215 : // ISpatialRelation
216 : virtual OGRBoolean Equals( OGRGeometry * ) const;
217 :
218 : // Non standard from OGRGeometry
219 : virtual const char *getGeometryName() const;
220 : virtual OGRwkbGeometryType getGeometryType() const;
221 : virtual OGRErr transform( OGRCoordinateTransformation *poCT );
222 : virtual void flattenTo2D();
223 :
224 : virtual void swapXY();
225 : };
226 :
227 : /************************************************************************/
228 : /* OGRCurve */
229 : /************************************************************************/
230 :
231 : /**
232 : * Abstract curve base class.
233 : */
234 :
235 : class CPL_DLL OGRCurve : public OGRGeometry
236 : {
237 : public:
238 : OGRCurve();
239 : virtual ~OGRCurve();
240 : // ICurve methods
241 : virtual double get_Length() const = 0;
242 : virtual void StartPoint(OGRPoint *) const = 0;
243 : virtual void EndPoint(OGRPoint *) const = 0;
244 : virtual int get_IsClosed() const;
245 : virtual void Value( double, OGRPoint * ) const = 0;
246 :
247 : };
248 :
249 : /************************************************************************/
250 : /* OGRLineString */
251 : /************************************************************************/
252 :
253 : /**
254 : * Concrete representation of a multi-vertex line.
255 : */
256 :
257 : class CPL_DLL OGRLineString : public OGRCurve
258 : {
259 : protected:
260 : int nPointCount;
261 : OGRRawPoint *paoPoints;
262 : double *padfZ;
263 :
264 : void Make3D();
265 : void Make2D();
266 :
267 : public:
268 : OGRLineString();
269 : virtual ~OGRLineString();
270 :
271 : // IWks Interface
272 : virtual int WkbSize() const;
273 : virtual OGRErr importFromWkb( unsigned char *, int = -1 );
274 : virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
275 : virtual OGRErr importFromWkt( char ** );
276 : virtual OGRErr exportToWkt( char ** ppszDstText ) const;
277 :
278 : // IGeometry interface
279 : virtual int getDimension() const;
280 : virtual OGRGeometry *clone() const;
281 : virtual void empty();
282 : virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
283 : virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
284 : virtual OGRBoolean IsEmpty() const;
285 :
286 : // ICurve methods
287 : virtual double get_Length() const;
288 : virtual void StartPoint(OGRPoint *) const;
289 : virtual void EndPoint(OGRPoint *) const;
290 : virtual void Value( double, OGRPoint * ) const;
291 :
292 : // ILineString methods
293 1186077 : int getNumPoints() const { return nPointCount; }
294 : void getPoint( int, OGRPoint * ) const;
295 1616709 : double getX( int i ) const { return paoPoints[i].x; }
296 1653835 : double getY( int i ) const { return paoPoints[i].y; }
297 : double getZ( int i ) const;
298 :
299 : // ISpatialRelation
300 : virtual OGRBoolean Equals( OGRGeometry * ) const;
301 :
302 : // non standard.
303 : virtual void setCoordinateDimension( int nDimension );
304 : void setNumPoints( int );
305 : void setPoint( int, OGRPoint * );
306 : void setPoint( int, double, double );
307 : void setPoint( int, double, double, double );
308 : void setPoints( int, OGRRawPoint *, double * = NULL );
309 : void setPoints( int, double * padfX, double * padfY,
310 : double *padfZ = NULL );
311 : void addPoint( OGRPoint * );
312 : void addPoint( double, double );
313 : void addPoint( double, double, double );
314 :
315 : void getPoints( OGRRawPoint *, double * = NULL ) const;
316 : void getPoints( void* pabyX, int nXStride,
317 : void* pabyY, int nYStride,
318 : void* pabyZ = NULL, int nZStride = 0 ) const;
319 :
320 : void addSubLineString( const OGRLineString *,
321 : int nStartVertex = 0, int nEndVertex = -1 );
322 : void reversePoints( void );
323 :
324 : // non-standard from OGRGeometry
325 : virtual OGRwkbGeometryType getGeometryType() const;
326 : virtual const char *getGeometryName() const;
327 : virtual OGRErr transform( OGRCoordinateTransformation *poCT );
328 : virtual void flattenTo2D();
329 : virtual void segmentize(double dfMaxLength);
330 :
331 : virtual void swapXY();
332 : };
333 :
334 : /************************************************************************/
335 : /* OGRLinearRing */
336 : /************************************************************************/
337 :
338 : /**
339 : * Concrete representation of a closed ring.
340 : *
341 : * This class is functionally equivelent to an OGRLineString, but has a
342 : * separate identity to maintain alignment with the OpenGIS simple feature
343 : * data model. It exists to serve as a component of an OGRPolygon.
344 : *
345 : * The OGRLinearRing has no corresponding free standing well known binary
346 : * representation, so importFromWkb() and exportToWkb() will not actually
347 : * work. There is a non-standard GDAL WKT representation though.
348 : *
349 : * Because OGRLinearRing is not a "proper" free standing simple features
350 : * object, it cannot be directly used on a feature via SetGeometry(), and
351 : * cannot genearally be used with GEOS for operations like Intersects().
352 : * Instead the polygon should be used, or the OGRLinearRing should be
353 : * converted to an OGRLineString for such operations.
354 : */
355 :
356 : class CPL_DLL OGRLinearRing : public OGRLineString
357 : {
358 : private:
359 : friend class OGRPolygon;
360 :
361 : // These are not IWks compatible ... just a convenience for OGRPolygon.
362 : virtual int _WkbSize( int b3D ) const;
363 : virtual OGRErr _importFromWkb( OGRwkbByteOrder, int b3D,
364 : unsigned char *, int=-1 );
365 : virtual OGRErr _exportToWkb( OGRwkbByteOrder, int b3D,
366 : unsigned char * ) const;
367 :
368 : public:
369 : OGRLinearRing();
370 : OGRLinearRing( OGRLinearRing * );
371 : ~OGRLinearRing();
372 :
373 : // Non standard.
374 : virtual const char *getGeometryName() const;
375 : virtual OGRGeometry *clone() const;
376 : virtual int isClockwise() const;
377 : virtual void reverseWindingOrder();
378 : virtual void closeRings();
379 : virtual double get_Area() const;
380 : OGRBoolean isPointInRing(const OGRPoint* pt, int bTestEnvelope = TRUE) const;
381 : OGRBoolean isPointOnRingBoundary(const OGRPoint* pt, int bTestEnvelope = TRUE) const;
382 :
383 : // IWks Interface - Note this isnt really a first class object
384 : // for the purposes of WKB form. These methods always fail since this
385 : // object cant be serialized on its own.
386 : virtual int WkbSize() const;
387 : virtual OGRErr importFromWkb( unsigned char *, int=-1 );
388 : virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
389 : };
390 :
391 : /************************************************************************/
392 : /* OGRSurface */
393 : /************************************************************************/
394 :
395 : /**
396 : * Abstract base class for 2 dimensional objects like polygons.
397 : */
398 :
399 : class CPL_DLL OGRSurface : public OGRGeometry
400 461450 : {
401 : public:
402 : virtual double get_Area() const = 0;
403 : virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const = 0;
404 : };
405 :
406 : /************************************************************************/
407 : /* OGRPolygon */
408 : /************************************************************************/
409 :
410 : /**
411 : * Concrete class representing polygons.
412 : *
413 : * Note that the OpenGIS simple features polygons consist of one outer
414 : * ring, and zero or more inner rings. A polygon cannot represent disconnected
415 : * regions (such as multiple islands in a political body). The
416 : * OGRMultiPolygon must be used for this.
417 : */
418 :
419 : class CPL_DLL OGRPolygon : public OGRSurface
420 : {
421 : int nRingCount;
422 : OGRLinearRing **papoRings;
423 :
424 : public:
425 : OGRPolygon();
426 : virtual ~OGRPolygon();
427 :
428 : // Non standard (OGRGeometry).
429 : virtual const char *getGeometryName() const;
430 : virtual OGRwkbGeometryType getGeometryType() const;
431 : virtual OGRGeometry *clone() const;
432 : virtual void empty();
433 : virtual OGRErr transform( OGRCoordinateTransformation *poCT );
434 : virtual void flattenTo2D();
435 : virtual OGRBoolean IsEmpty() const;
436 : virtual void segmentize(double dfMaxLength);
437 :
438 : // ISurface Interface
439 : virtual double get_Area() const;
440 : virtual int PointOnSurface( OGRPoint * poPoint ) const;
441 :
442 : // IWks Interface
443 : virtual int WkbSize() const;
444 : virtual OGRErr importFromWkb( unsigned char *, int = -1 );
445 : virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
446 : virtual OGRErr importFromWkt( char ** );
447 : virtual OGRErr exportToWkt( char ** ppszDstText ) const;
448 :
449 : // IGeometry
450 : virtual int getDimension() const;
451 : virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
452 : virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
453 :
454 : // ISpatialRelation
455 : virtual OGRBoolean Equals( OGRGeometry * ) const;
456 :
457 : // Non standard
458 : virtual void setCoordinateDimension( int nDimension );
459 :
460 : void addRing( OGRLinearRing * );
461 : void addRingDirectly( OGRLinearRing * );
462 :
463 : OGRLinearRing *getExteriorRing();
464 : const OGRLinearRing *getExteriorRing() const;
465 : int getNumInteriorRings() const;
466 : OGRLinearRing *getInteriorRing( int );
467 : const OGRLinearRing *getInteriorRing( int ) const;
468 :
469 : OGRBoolean IsPointOnSurface( const OGRPoint * ) const;
470 :
471 : virtual void closeRings();
472 :
473 : virtual void swapXY();
474 : };
475 :
476 : /************************************************************************/
477 : /* OGRGeometryCollection */
478 : /************************************************************************/
479 :
480 : /**
481 : * A collection of 1 or more geometry objects.
482 : *
483 : * All geometries must share a common spatial reference system, and
484 : * Subclasses may impose additional restrictions on the contents.
485 : */
486 :
487 : class CPL_DLL OGRGeometryCollection : public OGRGeometry
488 : {
489 : int nGeomCount;
490 : OGRGeometry **papoGeoms;
491 :
492 : OGRErr importFromWkbInternal( unsigned char * pabyData, int nSize, int nRecLevel );
493 : OGRErr importFromWktInternal( char **ppszInput, int nRecLevel );
494 :
495 : public:
496 : OGRGeometryCollection();
497 : virtual ~OGRGeometryCollection();
498 :
499 : // Non standard (OGRGeometry).
500 : virtual const char *getGeometryName() const;
501 : virtual OGRwkbGeometryType getGeometryType() const;
502 : virtual OGRGeometry *clone() const;
503 : virtual void empty();
504 : virtual OGRErr transform( OGRCoordinateTransformation *poCT );
505 : virtual void flattenTo2D();
506 : virtual OGRBoolean IsEmpty() const;
507 : virtual void segmentize(double dfMaxLength);
508 :
509 : // IWks Interface
510 : virtual int WkbSize() const;
511 : virtual OGRErr importFromWkb( unsigned char *, int = -1 );
512 : virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
513 : virtual OGRErr importFromWkt( char ** );
514 : virtual OGRErr exportToWkt( char ** ppszDstText ) const;
515 :
516 : virtual double get_Length() const;
517 : virtual double get_Area() const;
518 :
519 : // IGeometry methods
520 : virtual int getDimension() const;
521 : virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
522 : virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
523 :
524 : // IGeometryCollection
525 : int getNumGeometries() const;
526 : OGRGeometry *getGeometryRef( int );
527 : const OGRGeometry *getGeometryRef( int ) const;
528 :
529 : // ISpatialRelation
530 : virtual OGRBoolean Equals( OGRGeometry * ) const;
531 :
532 : // Non standard
533 : virtual void setCoordinateDimension( int nDimension );
534 : virtual OGRErr addGeometry( const OGRGeometry * );
535 : virtual OGRErr addGeometryDirectly( OGRGeometry * );
536 : virtual OGRErr removeGeometry( int iIndex, int bDelete = TRUE );
537 :
538 : void closeRings();
539 :
540 : virtual void swapXY();
541 : };
542 :
543 : /************************************************************************/
544 : /* OGRMultiPolygon */
545 : /************************************************************************/
546 :
547 : /**
548 : * A collection of non-overlapping OGRPolygons.
549 : *
550 : * Note that the IMultiSurface class hasn't been modelled, nor have any
551 : * of it's methods.
552 : */
553 :
554 : class CPL_DLL OGRMultiPolygon : public OGRGeometryCollection
555 1908 : {
556 : public:
557 : OGRMultiPolygon();
558 : // Non standard (OGRGeometry).
559 : virtual const char *getGeometryName() const;
560 : virtual OGRwkbGeometryType getGeometryType() const;
561 : virtual OGRGeometry *clone() const;
562 : virtual OGRErr importFromWkt( char ** );
563 : virtual OGRErr exportToWkt( char ** ) const;
564 :
565 : // Non standard
566 : virtual OGRErr addGeometryDirectly( OGRGeometry * );
567 :
568 : virtual double get_Area() const;
569 : };
570 :
571 : /************************************************************************/
572 : /* OGRMultiPoint */
573 : /************************************************************************/
574 :
575 : /**
576 : * A collection of OGRPoints.
577 : */
578 :
579 : class CPL_DLL OGRMultiPoint : public OGRGeometryCollection
580 837 : {
581 : private:
582 : OGRErr importFromWkt_Bracketed( char **, int bHasM, int bHasZ );
583 :
584 : public:
585 : OGRMultiPoint();
586 : // Non standard (OGRGeometry).
587 : virtual const char *getGeometryName() const;
588 : virtual OGRwkbGeometryType getGeometryType() const;
589 : virtual OGRGeometry *clone() const;
590 : virtual OGRErr importFromWkt( char ** );
591 : virtual OGRErr exportToWkt( char ** ) const;
592 :
593 : // Non standard
594 : virtual OGRErr addGeometryDirectly( OGRGeometry * );
595 : };
596 :
597 : /************************************************************************/
598 : /* OGRMultiLineString */
599 : /************************************************************************/
600 :
601 : /**
602 : * A collection of OGRLineStrings.
603 : */
604 :
605 : class CPL_DLL OGRMultiLineString : public OGRGeometryCollection
606 : {
607 : public:
608 : OGRMultiLineString();
609 : ~OGRMultiLineString();
610 : // Non standard (OGRGeometry).
611 : virtual const char *getGeometryName() const;
612 : virtual OGRwkbGeometryType getGeometryType() const;
613 : virtual OGRGeometry *clone() const;
614 : virtual OGRErr importFromWkt( char ** );
615 : virtual OGRErr exportToWkt( char ** ) const;
616 :
617 : // Non standard
618 : virtual OGRErr addGeometryDirectly( OGRGeometry * );
619 : };
620 :
621 :
622 : /************************************************************************/
623 : /* OGRGeometryFactory */
624 : /************************************************************************/
625 :
626 : /**
627 : * Create geometry objects from well known text/binary.
628 : */
629 :
630 : class CPL_DLL OGRGeometryFactory
631 : {
632 : static OGRErr createFromFgfInternal( unsigned char *pabyData,
633 : OGRSpatialReference * poSR,
634 : OGRGeometry **ppoReturn,
635 : int nBytes,
636 : int *pnBytesConsumed,
637 : int nRecLevel );
638 : public:
639 : static OGRErr createFromWkb( unsigned char *, OGRSpatialReference *,
640 : OGRGeometry **, int = -1 );
641 : static OGRErr createFromWkt( char **, OGRSpatialReference *,
642 : OGRGeometry ** );
643 : static OGRErr createFromFgf( unsigned char *, OGRSpatialReference *,
644 : OGRGeometry **, int = -1, int * = NULL );
645 : static OGRGeometry *createFromGML( const char * );
646 : static OGRGeometry *createFromGEOS( GEOSGeom );
647 :
648 : static void destroyGeometry( OGRGeometry * );
649 : static OGRGeometry *createGeometry( OGRwkbGeometryType );
650 :
651 : static OGRGeometry * forceToPolygon( OGRGeometry * );
652 : static OGRGeometry * forceToMultiPolygon( OGRGeometry * );
653 : static OGRGeometry * forceToMultiPoint( OGRGeometry * );
654 : static OGRGeometry * forceToMultiLineString( OGRGeometry * );
655 :
656 : static OGRGeometry * organizePolygons( OGRGeometry **papoPolygons,
657 : int nPolygonCount,
658 : int *pbResultValidGeometry,
659 : const char **papszOptions = NULL);
660 :
661 : static void *getGEOSGeometryFactory();
662 :
663 : static int haveGEOS();
664 :
665 : static OGRGeometry* transformWithOptions( const OGRGeometry* poSrcGeom,
666 : OGRCoordinateTransformation *poCT,
667 : char** papszOptions );
668 :
669 : static OGRGeometry*
670 : approximateArcAngles( double dfX, double dfY, double dfZ,
671 : double dfPrimaryRadius, double dfSecondaryAxis,
672 : double dfRotation,
673 : double dfStartAngle, double dfEndAngle,
674 : double dfMaxAngleStepSizeDegrees );
675 : };
676 :
677 : OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType( const char *pszGeomType );
678 : const char CPL_DLL * OGRToOGCGeomType( OGRwkbGeometryType eGeomType );
679 :
680 : #endif /* ndef _OGR_GEOMETRY_H_INCLUDED */
|