1 : /******************************************************************************
2 : * $Id: ogr_geometry.h 23589 2011-12-17 14:21:01Z rouault $
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 146770 : 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 : // backward compatibility to non-standard method names.
154 : OGRBoolean Intersect( OGRGeometry * ) const;
155 : OGRBoolean Equal( OGRGeometry * ) const;
156 : virtual OGRGeometry *SymmetricDifference( const OGRGeometry * ) const;
157 : virtual OGRGeometry *getBoundary() const;
158 :
159 : // Special HACK for DB2 7.2 support
160 : static int bGenerate_DB2_V72_BYTE_ORDER;
161 :
162 : virtual void swapXY();
163 : };
164 :
165 : /************************************************************************/
166 : /* OGRPoint */
167 : /************************************************************************/
168 :
169 : /**
170 : * Point class.
171 : *
172 : * Implements SFCOM IPoint methods.
173 : */
174 :
175 : class CPL_DLL OGRPoint : public OGRGeometry
176 : {
177 : double x;
178 : double y;
179 : double z;
180 :
181 : public:
182 : OGRPoint();
183 : OGRPoint( double x, double y );
184 : OGRPoint( double x, double y, double z );
185 : virtual ~OGRPoint();
186 :
187 : // IWks Interface
188 : virtual int WkbSize() const;
189 : virtual OGRErr importFromWkb( unsigned char *, int=-1 );
190 : virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
191 : virtual OGRErr importFromWkt( char ** );
192 : virtual OGRErr exportToWkt( char ** ppszDstText ) const;
193 :
194 : // IGeometry
195 : virtual int getDimension() const;
196 : virtual OGRGeometry *clone() const;
197 : virtual void empty();
198 : virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
199 : virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
200 : virtual OGRBoolean IsEmpty() const;
201 :
202 : // IPoint
203 71272 : double getX() const { return x; }
204 70988 : double getY() const { return y; }
205 39920 : double getZ() const { return z; }
206 :
207 : // Non standard
208 : virtual void setCoordinateDimension( int nDimension );
209 3302 : void setX( double xIn ) { x = xIn; if (nCoordDimension == 0) nCoordDimension = 2; }
210 3300 : void setY( double yIn ) { y = yIn; if (nCoordDimension == 0) nCoordDimension = 2; }
211 183 : void setZ( double zIn ) { z = zIn; nCoordDimension=3; }
212 :
213 : // ISpatialRelation
214 : virtual OGRBoolean Equals( OGRGeometry * ) const;
215 :
216 : // Non standard from OGRGeometry
217 : virtual const char *getGeometryName() const;
218 : virtual OGRwkbGeometryType getGeometryType() const;
219 : virtual OGRErr transform( OGRCoordinateTransformation *poCT );
220 : virtual void flattenTo2D();
221 :
222 : virtual void swapXY();
223 : };
224 :
225 : /************************************************************************/
226 : /* OGRCurve */
227 : /************************************************************************/
228 :
229 : /**
230 : * Abstract curve base class.
231 : */
232 :
233 : class CPL_DLL OGRCurve : public OGRGeometry
234 : {
235 : public:
236 : OGRCurve();
237 : virtual ~OGRCurve();
238 : // ICurve methods
239 : virtual double get_Length() const = 0;
240 : virtual void StartPoint(OGRPoint *) const = 0;
241 : virtual void EndPoint(OGRPoint *) const = 0;
242 : virtual int get_IsClosed() const;
243 : virtual void Value( double, OGRPoint * ) const = 0;
244 :
245 : };
246 :
247 : /************************************************************************/
248 : /* OGRLineString */
249 : /************************************************************************/
250 :
251 : /**
252 : * Concrete representation of a multi-vertex line.
253 : */
254 :
255 : class CPL_DLL OGRLineString : public OGRCurve
256 : {
257 : protected:
258 : int nPointCount;
259 : OGRRawPoint *paoPoints;
260 : double *padfZ;
261 :
262 : void Make3D();
263 : void Make2D();
264 :
265 : public:
266 : OGRLineString();
267 : virtual ~OGRLineString();
268 :
269 : // IWks Interface
270 : virtual int WkbSize() const;
271 : virtual OGRErr importFromWkb( unsigned char *, int = -1 );
272 : virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
273 : virtual OGRErr importFromWkt( char ** );
274 : virtual OGRErr exportToWkt( char ** ppszDstText ) const;
275 :
276 : // IGeometry interface
277 : virtual int getDimension() const;
278 : virtual OGRGeometry *clone() const;
279 : virtual void empty();
280 : virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
281 : virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
282 : virtual OGRBoolean IsEmpty() const;
283 :
284 : // ICurve methods
285 : virtual double get_Length() const;
286 : virtual void StartPoint(OGRPoint *) const;
287 : virtual void EndPoint(OGRPoint *) const;
288 : virtual void Value( double, OGRPoint * ) const;
289 :
290 : // ILineString methods
291 185300 : int getNumPoints() const { return nPointCount; }
292 : void getPoint( int, OGRPoint * ) const;
293 511753 : double getX( int i ) const { return paoPoints[i].x; }
294 513130 : double getY( int i ) const { return paoPoints[i].y; }
295 : double getZ( int i ) const;
296 :
297 : // ISpatialRelation
298 : virtual OGRBoolean Equals( OGRGeometry * ) const;
299 :
300 : // non standard.
301 : virtual void setCoordinateDimension( int nDimension );
302 : void setNumPoints( int );
303 : void setPoint( int, OGRPoint * );
304 : void setPoint( int, double, double );
305 : void setPoint( int, double, double, double );
306 : void setPoints( int, OGRRawPoint *, double * = NULL );
307 : void setPoints( int, double * padfX, double * padfY,
308 : double *padfZ = NULL );
309 : void addPoint( OGRPoint * );
310 : void addPoint( double, double );
311 : void addPoint( double, double, double );
312 :
313 : void getPoints( OGRRawPoint *, double * = NULL ) const;
314 : void getPoints( void* pabyX, int nXStride,
315 : void* pabyY, int nYStride,
316 : void* pabyZ = NULL, int nZStride = 0 ) const;
317 :
318 : void addSubLineString( const OGRLineString *,
319 : int nStartVertex = 0, int nEndVertex = -1 );
320 :
321 : // non-standard from OGRGeometry
322 : virtual OGRwkbGeometryType getGeometryType() const;
323 : virtual const char *getGeometryName() const;
324 : virtual OGRErr transform( OGRCoordinateTransformation *poCT );
325 : virtual void flattenTo2D();
326 : virtual void segmentize(double dfMaxLength);
327 :
328 : virtual void swapXY();
329 : };
330 :
331 : /************************************************************************/
332 : /* OGRLinearRing */
333 : /************************************************************************/
334 :
335 : /**
336 : * Concrete representation of a closed ring.
337 : *
338 : * This class is functionally equivelent to an OGRLineString, but has a
339 : * separate identity to maintain alignment with the OpenGIS simple feature
340 : * data model. It exists to serve as a component of an OGRPolygon.
341 : *
342 : * The OGRLinearRing has no corresponding free standing well known binary
343 : * representation, so importFromWkb() and exportToWkb() will not actually
344 : * work. There is a non-standard GDAL WKT representation though.
345 : *
346 : * Because OGRLinearRing is not a "proper" free standing simple features
347 : * object, it cannot be directly used on a feature via SetGeometry(), and
348 : * cannot genearally be used with GEOS for operations like Intersects().
349 : * Instead the polygon should be used, or the OGRLinearRing should be
350 : * converted to an OGRLineString for such operations.
351 : */
352 :
353 : class CPL_DLL OGRLinearRing : public OGRLineString
354 : {
355 : private:
356 : friend class OGRPolygon;
357 :
358 : // These are not IWks compatible ... just a convenience for OGRPolygon.
359 : virtual int _WkbSize( int b3D ) const;
360 : virtual OGRErr _importFromWkb( OGRwkbByteOrder, int b3D,
361 : unsigned char *, int=-1 );
362 : virtual OGRErr _exportToWkb( OGRwkbByteOrder, int b3D,
363 : unsigned char * ) const;
364 :
365 : public:
366 : OGRLinearRing();
367 : OGRLinearRing( OGRLinearRing * );
368 : ~OGRLinearRing();
369 :
370 : // Non standard.
371 : virtual const char *getGeometryName() const;
372 : virtual OGRGeometry *clone() const;
373 : virtual int isClockwise() const;
374 : virtual void reverseWindingOrder();
375 : virtual void closeRings();
376 : virtual double get_Area() const;
377 : OGRBoolean isPointInRing(const OGRPoint* pt, int bTestEnvelope = TRUE) const;
378 : OGRBoolean isPointOnRingBoundary(const OGRPoint* pt, int bTestEnvelope = TRUE) const;
379 :
380 : // IWks Interface - Note this isnt really a first class object
381 : // for the purposes of WKB form. These methods always fail since this
382 : // object cant be serialized on its own.
383 : virtual int WkbSize() const;
384 : virtual OGRErr importFromWkb( unsigned char *, int=-1 );
385 : virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
386 : };
387 :
388 : /************************************************************************/
389 : /* OGRSurface */
390 : /************************************************************************/
391 :
392 : /**
393 : * Abstract base class for 2 dimensional objects like polygons.
394 : */
395 :
396 : class CPL_DLL OGRSurface : public OGRGeometry
397 26074 : {
398 : public:
399 : virtual double get_Area() const = 0;
400 : virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const = 0;
401 : };
402 :
403 : /************************************************************************/
404 : /* OGRPolygon */
405 : /************************************************************************/
406 :
407 : /**
408 : * Concrete class representing polygons.
409 : *
410 : * Note that the OpenGIS simple features polygons consist of one outer
411 : * ring, and zero or more inner rings. A polygon cannot represent disconnected
412 : * regions (such as multiple islands in a political body). The
413 : * OGRMultiPolygon must be used for this.
414 : */
415 :
416 : class CPL_DLL OGRPolygon : public OGRSurface
417 : {
418 : int nRingCount;
419 : OGRLinearRing **papoRings;
420 :
421 : public:
422 : OGRPolygon();
423 : virtual ~OGRPolygon();
424 :
425 : // Non standard (OGRGeometry).
426 : virtual const char *getGeometryName() const;
427 : virtual OGRwkbGeometryType getGeometryType() const;
428 : virtual OGRGeometry *clone() const;
429 : virtual void empty();
430 : virtual OGRErr transform( OGRCoordinateTransformation *poCT );
431 : virtual void flattenTo2D();
432 : virtual OGRBoolean IsEmpty() const;
433 : virtual void segmentize(double dfMaxLength);
434 :
435 : // ISurface Interface
436 : virtual double get_Area() const;
437 : virtual int PointOnSurface( OGRPoint * poPoint ) const;
438 :
439 : // IWks Interface
440 : virtual int WkbSize() const;
441 : virtual OGRErr importFromWkb( unsigned char *, int = -1 );
442 : virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
443 : virtual OGRErr importFromWkt( char ** );
444 : virtual OGRErr exportToWkt( char ** ppszDstText ) const;
445 :
446 : // IGeometry
447 : virtual int getDimension() const;
448 : virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
449 : virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
450 :
451 : // ISpatialRelation
452 : virtual OGRBoolean Equals( OGRGeometry * ) const;
453 :
454 : // Non standard
455 : virtual void setCoordinateDimension( int nDimension );
456 :
457 : void addRing( OGRLinearRing * );
458 : void addRingDirectly( OGRLinearRing * );
459 :
460 : OGRLinearRing *getExteriorRing();
461 : const OGRLinearRing *getExteriorRing() const;
462 : int getNumInteriorRings() const;
463 : OGRLinearRing *getInteriorRing( int );
464 : const OGRLinearRing *getInteriorRing( int ) const;
465 :
466 : OGRBoolean IsPointOnSurface( const OGRPoint * ) const;
467 :
468 : virtual void closeRings();
469 :
470 : virtual void swapXY();
471 : };
472 :
473 : /************************************************************************/
474 : /* OGRGeometryCollection */
475 : /************************************************************************/
476 :
477 : /**
478 : * A collection of 1 or more geometry objects.
479 : *
480 : * All geometries must share a common spatial reference system, and
481 : * Subclasses may impose additional restrictions on the contents.
482 : */
483 :
484 : class CPL_DLL OGRGeometryCollection : public OGRGeometry
485 : {
486 : int nGeomCount;
487 : OGRGeometry **papoGeoms;
488 :
489 : OGRErr importFromWkbInternal( unsigned char * pabyData, int nSize, int nRecLevel );
490 : OGRErr importFromWktInternal( char **ppszInput, int nRecLevel );
491 :
492 : public:
493 : OGRGeometryCollection();
494 : virtual ~OGRGeometryCollection();
495 :
496 : // Non standard (OGRGeometry).
497 : virtual const char *getGeometryName() const;
498 : virtual OGRwkbGeometryType getGeometryType() const;
499 : virtual OGRGeometry *clone() const;
500 : virtual void empty();
501 : virtual OGRErr transform( OGRCoordinateTransformation *poCT );
502 : virtual void flattenTo2D();
503 : virtual OGRBoolean IsEmpty() const;
504 : virtual void segmentize(double dfMaxLength);
505 :
506 : // IWks Interface
507 : virtual int WkbSize() const;
508 : virtual OGRErr importFromWkb( unsigned char *, int = -1 );
509 : virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
510 : virtual OGRErr importFromWkt( char ** );
511 : virtual OGRErr exportToWkt( char ** ppszDstText ) const;
512 :
513 : virtual double get_Length() const;
514 : virtual double get_Area() const;
515 :
516 : // IGeometry methods
517 : virtual int getDimension() const;
518 : virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
519 : virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
520 :
521 : // IGeometryCollection
522 : int getNumGeometries() const;
523 : OGRGeometry *getGeometryRef( int );
524 : const OGRGeometry *getGeometryRef( int ) const;
525 :
526 : // ISpatialRelation
527 : virtual OGRBoolean Equals( OGRGeometry * ) const;
528 :
529 : // Non standard
530 : virtual void setCoordinateDimension( int nDimension );
531 : virtual OGRErr addGeometry( const OGRGeometry * );
532 : virtual OGRErr addGeometryDirectly( OGRGeometry * );
533 : virtual OGRErr removeGeometry( int iIndex, int bDelete = TRUE );
534 :
535 : void closeRings();
536 :
537 : virtual void swapXY();
538 : };
539 :
540 : /************************************************************************/
541 : /* OGRMultiPolygon */
542 : /************************************************************************/
543 :
544 : /**
545 : * A collection of non-overlapping OGRPolygons.
546 : *
547 : * Note that the IMultiSurface class hasn't been modelled, nor have any
548 : * of it's methods.
549 : */
550 :
551 : class CPL_DLL OGRMultiPolygon : public OGRGeometryCollection
552 651 : {
553 : public:
554 : OGRMultiPolygon();
555 : // Non standard (OGRGeometry).
556 : virtual const char *getGeometryName() const;
557 : virtual OGRwkbGeometryType getGeometryType() const;
558 : virtual OGRGeometry *clone() const;
559 : virtual OGRErr importFromWkt( char ** );
560 : virtual OGRErr exportToWkt( char ** ) const;
561 :
562 : // Non standard
563 : virtual OGRErr addGeometryDirectly( OGRGeometry * );
564 :
565 : virtual double get_Area() const;
566 : };
567 :
568 : /************************************************************************/
569 : /* OGRMultiPoint */
570 : /************************************************************************/
571 :
572 : /**
573 : * A collection of OGRPoints.
574 : */
575 :
576 : class CPL_DLL OGRMultiPoint : public OGRGeometryCollection
577 316 : {
578 : private:
579 : OGRErr importFromWkt_Bracketed( char **, int bHasM, int bHasZ );
580 :
581 : public:
582 : OGRMultiPoint();
583 : // Non standard (OGRGeometry).
584 : virtual const char *getGeometryName() const;
585 : virtual OGRwkbGeometryType getGeometryType() const;
586 : virtual OGRGeometry *clone() const;
587 : virtual OGRErr importFromWkt( char ** );
588 : virtual OGRErr exportToWkt( char ** ) const;
589 :
590 : // Non standard
591 : virtual OGRErr addGeometryDirectly( OGRGeometry * );
592 : };
593 :
594 : /************************************************************************/
595 : /* OGRMultiLineString */
596 : /************************************************************************/
597 :
598 : /**
599 : * A collection of OGRLineStrings.
600 : */
601 :
602 : class CPL_DLL OGRMultiLineString : public OGRGeometryCollection
603 : {
604 : public:
605 : OGRMultiLineString();
606 : ~OGRMultiLineString();
607 : // Non standard (OGRGeometry).
608 : virtual const char *getGeometryName() const;
609 : virtual OGRwkbGeometryType getGeometryType() const;
610 : virtual OGRGeometry *clone() const;
611 : virtual OGRErr importFromWkt( char ** );
612 : virtual OGRErr exportToWkt( char ** ) const;
613 :
614 : // Non standard
615 : virtual OGRErr addGeometryDirectly( OGRGeometry * );
616 : };
617 :
618 :
619 : /************************************************************************/
620 : /* OGRGeometryFactory */
621 : /************************************************************************/
622 :
623 : /**
624 : * Create geometry objects from well known text/binary.
625 : */
626 :
627 : class CPL_DLL OGRGeometryFactory
628 : {
629 : static OGRErr createFromFgfInternal( unsigned char *pabyData,
630 : OGRSpatialReference * poSR,
631 : OGRGeometry **ppoReturn,
632 : int nBytes,
633 : int *pnBytesConsumed,
634 : int nRecLevel );
635 : public:
636 : static OGRErr createFromWkb( unsigned char *, OGRSpatialReference *,
637 : OGRGeometry **, int = -1 );
638 : static OGRErr createFromWkt( char **, OGRSpatialReference *,
639 : OGRGeometry ** );
640 : static OGRErr createFromFgf( unsigned char *, OGRSpatialReference *,
641 : OGRGeometry **, int = -1, int * = NULL );
642 : static OGRGeometry *createFromGML( const char * );
643 : static OGRGeometry *createFromGEOS( GEOSGeom );
644 :
645 : static void destroyGeometry( OGRGeometry * );
646 : static OGRGeometry *createGeometry( OGRwkbGeometryType );
647 :
648 : static OGRGeometry * forceToPolygon( OGRGeometry * );
649 : static OGRGeometry * forceToMultiPolygon( OGRGeometry * );
650 : static OGRGeometry * forceToMultiPoint( OGRGeometry * );
651 : static OGRGeometry * forceToMultiLineString( OGRGeometry * );
652 :
653 : static OGRGeometry * organizePolygons( OGRGeometry **papoPolygons,
654 : int nPolygonCount,
655 : int *pbResultValidGeometry,
656 : const char **papszOptions = NULL);
657 :
658 : static void *getGEOSGeometryFactory();
659 :
660 : static int haveGEOS();
661 :
662 : static OGRGeometry* transformWithOptions( const OGRGeometry* poSrcGeom,
663 : OGRCoordinateTransformation *poCT,
664 : char** papszOptions );
665 :
666 : static OGRGeometry*
667 : approximateArcAngles( double dfX, double dfY, double dfZ,
668 : double dfPrimaryRadius, double dfSecondaryAxis,
669 : double dfRotation,
670 : double dfStartAngle, double dfEndAngle,
671 : double dfMaxAngleStepSizeDegrees );
672 : };
673 :
674 : OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType( const char *pszGeomType );
675 : const char CPL_DLL * OGRToOGCGeomType( OGRwkbGeometryType eGeomType );
676 :
677 : #endif /* ndef _OGR_GEOMETRY_H_INCLUDED */
|