OGR
ogr_geometry.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: ogr_geometry.h 33631 2016-03-04 06:28:09Z goatbar $
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  * Copyright (c) 2008-2014, Even Rouault <even dot rouault at mines-paris dot org>
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included
21  * in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  ****************************************************************************/
31 
32 #ifndef OGR_GEOMETRY_H_INCLUDED
33 #define OGR_GEOMETRY_H_INCLUDED
34 
35 #include "ogr_core.h"
36 #include "ogr_spatialref.h"
37 
48 {
49  public:
50  OGRRawPoint()
51  {
52  x = y = 0.0;
53  }
54 
55  OGRRawPoint(double xIn, double yIn) : x(xIn), y(yIn) {}
56  double x;
57  double y;
58 };
59 
60 typedef struct GEOSGeom_t *GEOSGeom;
61 typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
62 
63 class OGRPoint;
64 class OGRCurve;
65 class OGRCompoundCurve;
66 class OGRLinearRing;
67 class OGRLineString;
68 class OGRSurface;
69 class OGRCurvePolygon;
70 class OGRPolygon;
71 class OGRMultiSurface;
72 class OGRMultiPolygon;
73 class OGRMultiCurve;
74 class OGRMultiLineString;
75 
76 typedef OGRLineString* (*OGRCurveCasterToLineString)(OGRCurve*);
77 typedef OGRLinearRing* (*OGRCurveCasterToLinearRing)(OGRCurve*);
78 
79 typedef OGRPolygon* (*OGRSurfaceCasterToPolygon)(OGRSurface*);
80 typedef OGRCurvePolygon* (*OGRSurfaceCasterToCurvePolygon)(OGRSurface*);
81 
82 /************************************************************************/
83 /* OGRGeometry */
84 /************************************************************************/
85 
104 class CPL_DLL OGRGeometry
105 {
106  private:
107  OGRSpatialReference * poSRS; // may be NULL
108 
109  protected:
110  friend class OGRCurveCollection;
111 
112  unsigned int flags;
113 
114  OGRErr importPreambuleFromWkt( char ** ppszInput,
115  int* pbHasZ, int* pbHasM,
116  bool* pbIsEmpty );
117  OGRErr importCurveCollectionFromWkt( char ** ppszInput,
118  int bAllowEmptyComponent,
119  int bAllowLineString,
120  int bAllowCurve,
121  int bAllowCompoundCurve,
122  OGRErr (*pfnAddCurveDirectly)(OGRGeometry* poSelf, OGRCurve* poCurve) );
123  OGRErr importPreambuleFromWkb( unsigned char * pabyData,
124  int nSize,
125  OGRwkbByteOrder& eByteOrder,
126  OGRwkbVariant eWkbVariant );
127  OGRErr importPreambuleOfCollectionFromWkb(
128  unsigned char * pabyData,
129  int& nSize,
130  int& nDataOffset,
131  OGRwkbByteOrder& eByteOrder,
132  int nMinSubGeomSize,
133  int& nGeomCount,
134  OGRwkbVariant eWkbVariant );
135  OGRErr PointOnSurfaceInternal( OGRPoint * poPoint ) const;
136 
137  public:
138 
139 /************************************************************************/
140 /* Bit flags for OGRGeometry */
141 /* The OGR_G_NOT_EMPTY_POINT is used *only* for points. */
142 /* Do not use these outside of the core. */
143 /* Use Is3D, IsMeasured, set3D, and setMeasured instead */
144 /************************************************************************/
145 
146  static const unsigned int OGR_G_NOT_EMPTY_POINT = 0x1;
147  static const unsigned int OGR_G_3D = 0x2;
148  static const unsigned int OGR_G_MEASURED = 0x4;
149 
150  OGRGeometry();
151  OGRGeometry( const OGRGeometry& other );
152  virtual ~OGRGeometry();
153 
154  OGRGeometry& operator=( const OGRGeometry& other );
155 
156  // standard IGeometry
157  virtual int getDimension() const = 0;
158  virtual int getCoordinateDimension() const;
159  int CoordinateDimension() const;
160  virtual OGRBoolean IsEmpty() const;
161  virtual OGRBoolean IsValid() const;
162  virtual OGRBoolean IsSimple() const;
163  OGRBoolean Is3D() const { return flags & OGR_G_3D; }
164  OGRBoolean IsMeasured() const { return flags & OGR_G_MEASURED; }
165  virtual OGRBoolean IsRing() const;
166  virtual void empty() = 0;
167  virtual OGRGeometry *clone() const CPL_WARN_UNUSED_RESULT = 0;
168  virtual void getEnvelope( OGREnvelope * psEnvelope ) const = 0;
169  virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const = 0;
170 
171  // IWks Interface
172  virtual int WkbSize() const = 0;
173  virtual OGRErr importFromWkb( unsigned char *, int=-1, OGRwkbVariant=wkbVariantOldOgc )=0;
174  virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const = 0;
175  virtual OGRErr importFromWkt( char ** ppszInput ) = 0;
176  virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const = 0;
177 
178  // non-standard
179  virtual OGRwkbGeometryType getGeometryType() const = 0;
180  OGRwkbGeometryType getIsoGeometryType() const;
181  virtual const char *getGeometryName() const = 0;
182  virtual void dumpReadable( FILE *, const char * = NULL, char** papszOptions = NULL ) const;
183  virtual void flattenTo2D() = 0;
184  virtual char * exportToGML( const char* const * papszOptions = NULL ) const;
185  virtual char * exportToKML() const;
186  virtual char * exportToJson() const;
187 
188  static GEOSContextHandle_t createGEOSContext();
189  static void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt);
190  virtual GEOSGeom exportToGEOS(GEOSContextHandle_t hGEOSCtxt) const CPL_WARN_UNUSED_RESULT;
191  virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
192  virtual OGRGeometry* getCurveGeometry(const char* const* papszOptions = NULL) const CPL_WARN_UNUSED_RESULT;
193  virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
194  const char* const* papszOptions = NULL) const CPL_WARN_UNUSED_RESULT;
195 
196  virtual void closeRings();
197 
198  virtual void setCoordinateDimension( int nDimension );
199  virtual void set3D( OGRBoolean bIs3D );
200  virtual void setMeasured( OGRBoolean bIsMeasured );
201 
202  void assignSpatialReference( OGRSpatialReference * poSR );
203  OGRSpatialReference *getSpatialReference( void ) const { return poSRS; }
204 
205  virtual OGRErr transform( OGRCoordinateTransformation *poCT ) = 0;
206  OGRErr transformTo( OGRSpatialReference *poSR );
207 
208  virtual void segmentize(double dfMaxLength);
209 
210  // ISpatialRelation
211  virtual OGRBoolean Intersects( const OGRGeometry * ) const;
212  virtual OGRBoolean Equals( OGRGeometry * ) const = 0;
213  virtual OGRBoolean Disjoint( const OGRGeometry * ) const;
214  virtual OGRBoolean Touches( const OGRGeometry * ) const;
215  virtual OGRBoolean Crosses( const OGRGeometry * ) const;
216  virtual OGRBoolean Within( const OGRGeometry * ) const;
217  virtual OGRBoolean Contains( const OGRGeometry * ) const;
218  virtual OGRBoolean Overlaps( const OGRGeometry * ) const;
219 // virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
220 // virtual OGRGeometry *LocateAlong( double mValue ) const;
221 // virtual OGRGeometry *LocateBetween( double mStart, double mEnd ) const;
222 
223  virtual OGRGeometry *Boundary() const CPL_WARN_UNUSED_RESULT;
224  virtual double Distance( const OGRGeometry * ) const ;
225  virtual OGRGeometry *ConvexHull() const CPL_WARN_UNUSED_RESULT;
226  virtual OGRGeometry *Buffer( double dfDist, int nQuadSegs = 30 ) const CPL_WARN_UNUSED_RESULT;
227  virtual OGRGeometry *Intersection( const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
228  virtual OGRGeometry *Union( const OGRGeometry * ) const CPL_WARN_UNUSED_RESULT;
229  virtual OGRGeometry *UnionCascaded() const CPL_WARN_UNUSED_RESULT;
230  virtual OGRGeometry *Difference( const OGRGeometry * ) const CPL_WARN_UNUSED_RESULT;
231  virtual OGRGeometry *SymDifference( const OGRGeometry * ) const CPL_WARN_UNUSED_RESULT;
232  virtual OGRErr Centroid( OGRPoint * poPoint ) const;
233  virtual OGRGeometry *Simplify(double dTolerance) const CPL_WARN_UNUSED_RESULT;
234  OGRGeometry *SimplifyPreserveTopology(double dTolerance) const CPL_WARN_UNUSED_RESULT;
235  virtual OGRGeometry *DelaunayTriangulation(double dfTolerance, int bOnlyEdges) const CPL_WARN_UNUSED_RESULT;
236 
237  virtual OGRGeometry *Polygonize() const CPL_WARN_UNUSED_RESULT;
238 
239  // backward compatibility to non-standard method names.
240  OGRBoolean Intersect( OGRGeometry * ) const CPL_WARN_DEPRECATED("Non standard method. Use Intersects() instead");
241  OGRBoolean Equal( OGRGeometry * ) const CPL_WARN_DEPRECATED("Non standard method. Use Equals() instead");
242  OGRGeometry *SymmetricDifference( const OGRGeometry * ) const CPL_WARN_DEPRECATED("Non standard method. Use SymDifference() instead");
243  OGRGeometry *getBoundary() const CPL_WARN_DEPRECATED("Non standard method. Use Boundary() instead");
244 
245  // Special HACK for DB2 7.2 support
246  static int bGenerate_DB2_V72_BYTE_ORDER;
247 
248  virtual void swapXY();
249 
250  static OGRGeometry* CastToIdentity(OGRGeometry* poGeom) { return poGeom; }
251  static OGRGeometry* CastToError(OGRGeometry* poGeom);
252 };
253 
254 /************************************************************************/
255 /* OGRPoint */
256 /************************************************************************/
257 
264 class CPL_DLL OGRPoint : public OGRGeometry
265 {
266  double x;
267  double y;
268  double z;
269  double m;
270 
271  public:
272  OGRPoint();
273  OGRPoint( double x, double y );
274  OGRPoint( double x, double y, double z );
275  OGRPoint( double x, double y, double z, double m );
276  OGRPoint( const OGRPoint& other );
277  virtual ~OGRPoint();
278 
279  OGRPoint& operator=( const OGRPoint& other );
280 
281  // IWks Interface
282  virtual int WkbSize() const;
283  virtual OGRErr importFromWkb( unsigned char *, int=-1, OGRwkbVariant=wkbVariantOldOgc );
284  virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const;
285  virtual OGRErr importFromWkt( char ** );
286  virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const;
287 
288  // IGeometry
289  virtual int getDimension() const;
290  virtual OGRGeometry *clone() const;
291  virtual void empty();
292  virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
293  virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
294  virtual OGRBoolean IsEmpty() const { return !(flags & OGR_G_NOT_EMPTY_POINT); }
295 
296  // IPoint
297  double getX() const { return x; }
298  double getY() const { return y; }
299  double getZ() const { return z; }
300  double getM() const { return m; }
301 
302  // Non standard
303  virtual void setCoordinateDimension( int nDimension );
304  void setX( double xIn ) { x = xIn; flags |= OGR_G_NOT_EMPTY_POINT; }
305  void setY( double yIn ) { y = yIn; flags |= OGR_G_NOT_EMPTY_POINT; }
306  void setZ( double zIn ) { z = zIn; flags |= (OGR_G_NOT_EMPTY_POINT | OGR_G_3D); }
307  void setM( double mIn ) { m = mIn; flags |= (OGR_G_NOT_EMPTY_POINT | OGR_G_MEASURED); }
308 
309  // ISpatialRelation
310  virtual OGRBoolean Equals( OGRGeometry * ) const;
311  virtual OGRBoolean Intersects( const OGRGeometry * ) const;
312  virtual OGRBoolean Within( const OGRGeometry * ) const;
313 
314  // Non standard from OGRGeometry
315  virtual const char *getGeometryName() const;
316  virtual OGRwkbGeometryType getGeometryType() const;
317  virtual OGRErr transform( OGRCoordinateTransformation *poCT );
318  virtual void flattenTo2D();
319 
320  virtual void swapXY();
321 };
322 
323 /************************************************************************/
324 /* OGRPointIterator */
325 /************************************************************************/
326 
333 class CPL_DLL OGRPointIterator
334 {
335  public:
336  virtual ~OGRPointIterator();
337  virtual OGRBoolean getNextPoint(OGRPoint* p) = 0;
338 
339  static void destroy(OGRPointIterator*);
340 };
341 
342 /************************************************************************/
343 /* OGRCurve */
344 /************************************************************************/
345 
351 class CPL_DLL OGRCurve : public OGRGeometry
352 {
353  protected:
354  OGRCurve();
355  OGRCurve( const OGRCurve& other );
356 
357  virtual OGRCurveCasterToLineString GetCasterToLineString() const = 0;
358  virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const = 0;
359 
360  friend class OGRCurvePolygon;
361  friend class OGRCompoundCurve;
362  virtual int ContainsPoint( const OGRPoint* p ) const;
363  virtual double get_AreaOfCurveSegments() const = 0;
364 
365  public:
366  virtual ~OGRCurve();
367 
368  OGRCurve& operator=( const OGRCurve& other );
369 
370  // ICurve methods
371  virtual double get_Length() const = 0;
372  virtual void StartPoint(OGRPoint *) const = 0;
373  virtual void EndPoint(OGRPoint *) const = 0;
374  virtual int get_IsClosed() const;
375  virtual void Value( double, OGRPoint * ) const = 0;
376  virtual OGRLineString* CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
377  const char* const* papszOptions = NULL) const = 0;
378  virtual int getDimension() const;
379 
380  // non standard
381  virtual int getNumPoints() const = 0;
382  virtual OGRPointIterator* getPointIterator() const = 0;
383  virtual OGRBoolean IsConvex() const;
384  virtual double get_Area() const = 0;
385 
387  static OGRLineString* CastToLineString(OGRCurve* poCurve);
388  static OGRLinearRing* CastToLinearRing(OGRCurve* poCurve);
389 };
390 
391 /************************************************************************/
392 /* OGRSimpleCurve */
393 /************************************************************************/
394 
404 class CPL_DLL OGRSimpleCurve: public OGRCurve
405 {
406  protected:
407  friend class OGRGeometry;
408 
409  int nPointCount;
410  OGRRawPoint *paoPoints;
411  double *padfZ;
412  double *padfM;
413 
414  void Make3D();
415  void Make2D();
416  void RemoveM();
417  void AddM();
418 
419  OGRErr importFromWKTListOnly( char ** ppszInput, int bHasZ, int bHasM,
420  OGRRawPoint*& paoPointsIn, int& nMaxPoints,
421  double*& padfZIn );
422 
423  virtual double get_LinearArea() const;
424 
425  OGRSimpleCurve();
426  OGRSimpleCurve( const OGRSimpleCurve& other );
427 
428  public:
429  virtual ~OGRSimpleCurve();
430 
431  OGRSimpleCurve& operator=( const OGRSimpleCurve& other );
432 
433  // IWks Interface
434  virtual int WkbSize() const;
435  virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc );
436  virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const;
437  virtual OGRErr importFromWkt( char ** );
438  virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const;
439 
440  // IGeometry interface
441  virtual OGRGeometry *clone() const;
442  virtual void empty();
443  virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
444  virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
445  virtual OGRBoolean IsEmpty() const;
446 
447  // ICurve methods
448  virtual double get_Length() const;
449  virtual void StartPoint(OGRPoint *) const;
450  virtual void EndPoint(OGRPoint *) const;
451  virtual void Value( double, OGRPoint * ) const;
452  virtual double Project(const OGRPoint *) const;
453  virtual OGRLineString* getSubLine(double, double, int) const;
454 
455  // ILineString methods
456  virtual int getNumPoints() const { return nPointCount; }
457  void getPoint( int, OGRPoint * ) const;
458  double getX( int i ) const { return paoPoints[i].x; }
459  double getY( int i ) const { return paoPoints[i].y; }
460  double getZ( int i ) const;
461  double getM( int i ) const;
462 
463  // ISpatialRelation
464  virtual OGRBoolean Equals( OGRGeometry * ) const;
465 
466  // non standard.
467  virtual void setCoordinateDimension( int nDimension );
468  virtual void set3D( OGRBoolean bIs3D );
469  virtual void setMeasured( OGRBoolean bIsMeasured );
470  void setNumPoints( int nNewPointCount, int bZeroizeNewContent = TRUE );
471  void setPoint( int, OGRPoint * );
472  void setPoint( int, double, double );
473  void setZ( int, double );
474  void setM( int, double );
475  void setPoint( int, double, double, double );
476  void setPointM( int, double, double, double );
477  void setPoint( int, double, double, double, double );
478  void setPoints( int, OGRRawPoint *, double * = NULL );
479  void setPointsM( int, OGRRawPoint *, double * );
480  void setPoints( int, OGRRawPoint *, double *, double * );
481  void setPoints( int, double * padfX, double * padfY,
482  double *padfZIn = NULL );
483  void setPointsM( int, double * padfX, double * padfY,
484  double *padfMIn = NULL );
485  void setPoints( int, double * padfX, double * padfY,
486  double *padfZIn, double *padfMIn );
487  void addPoint( OGRPoint * );
488  void addPoint( double, double );
489  void addPoint( double, double, double );
490  void addPointM( double, double, double );
491  void addPoint( double, double, double, double );
492 
493  void getPoints( OGRRawPoint *, double * = NULL ) const;
494  void getPoints( OGRRawPoint *, double *, double * ) const;
495  void getPoints( void* pabyX, int nXStride,
496  void* pabyY, int nYStride,
497  void* pabyZ = NULL, int nZStride = 0 ) const;
498  void getPoints( void* pabyX, int nXStride,
499  void* pabyY, int nYStride,
500  void* pabyZ, int nZStride,
501  void* pabyM, int nMStride ) const;
502 
503  void addSubLineString( const OGRLineString *,
504  int nStartVertex = 0, int nEndVertex = -1 );
505  void reversePoints( void );
506  virtual OGRPointIterator* getPointIterator() const;
507 
508  // non-standard from OGRGeometry
509  virtual OGRErr transform( OGRCoordinateTransformation *poCT );
510  virtual void flattenTo2D();
511  virtual void segmentize(double dfMaxLength);
512 
513  virtual void swapXY();
514 };
515 
516 /************************************************************************/
517 /* OGRLineString */
518 /************************************************************************/
519 
527 class CPL_DLL OGRLineString : public OGRSimpleCurve
528 {
529  protected:
530  static OGRLineString* TransferMembersAndDestroy(
531  OGRLineString* poSrc,
532  OGRLineString* poDst);
533 
534  static OGRLinearRing* CastToLinearRing(OGRLineString* poLS);
535 
536  virtual OGRCurveCasterToLineString GetCasterToLineString() const;
537  virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const;
538 
539  virtual double get_AreaOfCurveSegments() const;
540 
541  public:
542  OGRLineString();
543  OGRLineString(const OGRLineString& other);
544  virtual ~OGRLineString();
545 
546  OGRLineString& operator=(const OGRLineString& other);
547 
548  virtual OGRLineString* CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
549  const char* const* papszOptions = NULL) const;
550  virtual OGRGeometry* getCurveGeometry(const char* const* papszOptions = NULL) const;
551  virtual double get_Area() const;
552 
553  // non-standard from OGRGeometry
554  virtual OGRwkbGeometryType getGeometryType() const;
555  virtual const char *getGeometryName() const;
556 };
557 
558 /************************************************************************/
559 /* OGRLinearRing */
560 /************************************************************************/
561 
582 class CPL_DLL OGRLinearRing : public OGRLineString
583 {
584  protected:
585  friend class OGRPolygon;
586 
587  // These are not IWks compatible ... just a convenience for OGRPolygon.
588  virtual int _WkbSize( int _flags ) const;
589  virtual OGRErr _importFromWkb( OGRwkbByteOrder, int _flags,
590  unsigned char *, int=-1 );
591  virtual OGRErr _exportToWkb( OGRwkbByteOrder, int _flags,
592  unsigned char * ) const;
593 
594  static OGRLineString* CastToLineString(OGRLinearRing* poLR);
595 
596  virtual OGRCurveCasterToLineString GetCasterToLineString() const;
597  virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const;
598 
599  public:
600  OGRLinearRing();
601  OGRLinearRing(const OGRLinearRing& other);
603  virtual ~OGRLinearRing();
604 
605  OGRLinearRing& operator=(const OGRLinearRing& other);
606 
607  // Non standard.
608  virtual const char *getGeometryName() const;
609  virtual OGRGeometry *clone() const;
610  virtual int isClockwise() const;
611  virtual void reverseWindingOrder();
612  virtual void closeRings();
613  OGRBoolean isPointInRing(const OGRPoint* pt, int bTestEnvelope = TRUE) const;
614  OGRBoolean isPointOnRingBoundary(const OGRPoint* pt, int bTestEnvelope = TRUE) const;
615 
616  // IWks Interface - Note this isn't really a first class object
617  // for the purposes of WKB form. These methods always fail since this
618  // object can't be serialized on its own.
619  virtual int WkbSize() const;
620  virtual OGRErr importFromWkb( unsigned char *, int=-1, OGRwkbVariant=wkbVariantOldOgc );
621  virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const;
622 };
623 
624 /************************************************************************/
625 /* OGRCircularString */
626 /************************************************************************/
627 
640 class CPL_DLL OGRCircularString : public OGRSimpleCurve
641 {
642  private:
643  void ExtendEnvelopeWithCircular( OGREnvelope * psEnvelope ) const;
644  OGRBoolean IsValidFast() const;
645  int IsFullCircle( double& cx, double& cy, double& square_R ) const;
646 
647  protected:
648  virtual OGRCurveCasterToLineString GetCasterToLineString() const;
649  virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const;
650  virtual int ContainsPoint( const OGRPoint* p ) const;
651  virtual double get_AreaOfCurveSegments() const;
652 
653  public:
655  OGRCircularString(const OGRCircularString& other);
656  virtual ~OGRCircularString();
657 
658  OGRCircularString& operator=(const OGRCircularString& other);
659 
660  // IWks Interface
661  virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc );
662  virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const;
663  virtual OGRErr importFromWkt( char ** );
664  virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const;
665 
666  // IGeometry interface
667  virtual OGRBoolean IsValid() const;
668  virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
669  virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
670 
671  // ICurve methods
672  virtual double get_Length() const;
673  virtual OGRLineString* CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
674  const char* const* papszOptions = NULL) const;
675  virtual void Value( double, OGRPoint * ) const;
676  virtual double get_Area() const;
677 
678  // non-standard from OGRGeometry
679  virtual OGRwkbGeometryType getGeometryType() const;
680  virtual const char *getGeometryName() const;
681  virtual void segmentize(double dfMaxLength);
682  virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
683  virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
684  const char* const* papszOptions = NULL) const;
685 };
686 
687 /************************************************************************/
688 /* OGRCurveCollection */
689 /************************************************************************/
690 
701 class CPL_DLL OGRCurveCollection
702 {
703  protected:
704  friend class OGRCompoundCurve;
705  friend class OGRCurvePolygon;
706  friend class OGRPolygon;
707 
708  int nCurveCount;
709  OGRCurve **papoCurves;
710 
711  public:
715 
717 
718  void empty(OGRGeometry* poGeom);
719  OGRBoolean IsEmpty() const;
720  void getEnvelope( OGREnvelope * psEnvelope ) const;
721  void getEnvelope( OGREnvelope3D * psEnvelope ) const;
722 
723  OGRErr addCurveDirectly( OGRGeometry* poGeom, OGRCurve* poCurve,
724  int bNeedRealloc );
725  int WkbSize() const;
726  OGRErr importPreambuleFromWkb( OGRGeometry* poGeom,
727  unsigned char * pabyData,
728  int& nSize,
729  int& nDataOffset,
730  OGRwkbByteOrder& eByteOrder,
731  int nMinSubGeomSize,
732  OGRwkbVariant eWkVariant );
733  OGRErr importBodyFromWkb( OGRGeometry* poGeom,
734  unsigned char * pabyData,
735  int nSize,
736  int nDataOffset,
737  int bAcceptCompoundCurve,
738  OGRErr (*pfnAddCurveDirectlyFromWkb)(OGRGeometry* poGeom, OGRCurve* poCurve),
739  OGRwkbVariant eWkVariant );
740  OGRErr exportToWkt( const OGRGeometry* poGeom, char ** ppszDstText ) const;
741  OGRErr exportToWkb( const OGRGeometry* poGeom, OGRwkbByteOrder,
742  unsigned char *, OGRwkbVariant eWkbVariant ) const;
743  OGRBoolean Equals(OGRCurveCollection *poOCC) const;
744  void setCoordinateDimension( OGRGeometry* poGeom, int nNewDimension );
745  void set3D( OGRGeometry* poGeom, OGRBoolean bIs3D );
746  void setMeasured( OGRGeometry* poGeom, OGRBoolean bIsMeasured );
747  int getNumCurves() const;
748  OGRCurve *getCurve( int );
749  const OGRCurve *getCurve( int ) const;
750  OGRCurve *stealCurve( int );
751  OGRErr transform( OGRGeometry* poGeom,
753  void flattenTo2D(OGRGeometry* poGeom);
754  void segmentize(double dfMaxLength);
755  void swapXY();
756  OGRBoolean hasCurveGeometry(int bLookForNonLinear) const;
757 };
758 
759 /************************************************************************/
760 /* OGRCompoundCurve */
761 /************************************************************************/
762 
773 class CPL_DLL OGRCompoundCurve : public OGRCurve
774 {
775  private:
776  OGRCurveCollection oCC;
777 
778  OGRErr addCurveDirectlyInternal( OGRCurve* poCurve,
779  double dfToleranceEps,
780  int bNeedRealloc );
781  static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf, OGRCurve* poCurve );
782  static OGRErr addCurveDirectlyFromWkb( OGRGeometry* poSelf, OGRCurve* poCurve );
783  OGRLineString* CurveToLineInternal(double dfMaxAngleStepSizeDegrees,
784  const char* const* papszOptions,
785  int bIsLinearRing) const;
786 
787  protected:
788  static OGRLineString* CastToLineString(OGRCompoundCurve* poCC);
789  static OGRLinearRing* CastToLinearRing(OGRCompoundCurve* poCC);
790 
791  virtual OGRCurveCasterToLineString GetCasterToLineString() const;
792  virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const;
793 
794  public:
796  OGRCompoundCurve(const OGRCompoundCurve& other);
797  virtual ~OGRCompoundCurve();
798 
799  OGRCompoundCurve& operator=(const OGRCompoundCurve& other);
800 
801  // IWks Interface
802  virtual int WkbSize() const;
803  virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc );
804  virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const;
805  virtual OGRErr importFromWkt( char ** );
806  virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const;
807 
808  // IGeometry interface
809  virtual OGRGeometry *clone() const;
810  virtual void empty();
811  virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
812  virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
813  virtual OGRBoolean IsEmpty() const;
814 
815  // ICurve methods
816  virtual double get_Length() const;
817  virtual void StartPoint(OGRPoint *) const;
818  virtual void EndPoint(OGRPoint *) const;
819  virtual void Value( double, OGRPoint * ) const;
820  virtual OGRLineString* CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
821  const char* const* papszOptions = NULL) const;
822 
823  virtual int getNumPoints() const;
824  virtual double get_AreaOfCurveSegments() const;
825  virtual double get_Area() const;
826 
827  // ISpatialRelation
828  virtual OGRBoolean Equals( OGRGeometry * ) const;
829 
830  // ICompoundCurve method
831  int getNumCurves() const;
832  OGRCurve *getCurve( int );
833  const OGRCurve *getCurve( int ) const;
834 
835  // non standard.
836  virtual void setCoordinateDimension( int nDimension );
837  virtual void set3D( OGRBoolean bIs3D );
838  virtual void setMeasured( OGRBoolean bIsMeasured );
839 
840  OGRErr addCurve( OGRCurve*, double dfToleranceEps = 1e-14 );
841  OGRErr addCurveDirectly( OGRCurve*, double dfToleranceEps = 1e-14 );
842  OGRCurve *stealCurve( int );
843  virtual OGRPointIterator* getPointIterator() const;
844 
845  // non-standard from OGRGeometry
846  virtual OGRwkbGeometryType getGeometryType() const;
847  virtual const char *getGeometryName() const;
848  virtual OGRErr transform( OGRCoordinateTransformation *poCT );
849  virtual void flattenTo2D();
850  virtual void segmentize(double dfMaxLength);
851  virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
852  virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
853  const char* const* papszOptions = NULL) const;
854 
855  virtual void swapXY();
856 };
857 
858 /************************************************************************/
859 /* OGRSurface */
860 /************************************************************************/
861 
866 class CPL_DLL OGRSurface : public OGRGeometry
867 {
868  protected:
869 
870  virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const = 0;
871  virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const = 0;
872 
873  public:
874  virtual double get_Area() const = 0;
875  virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const = 0;
876 
877  static OGRPolygon* CastToPolygon(OGRSurface* poSurface);
878  static OGRCurvePolygon* CastToCurvePolygon(OGRSurface* poSurface);
879 };
880 
881 
882 /************************************************************************/
883 /* OGRCurvePolygon */
884 /************************************************************************/
885 
899 class CPL_DLL OGRCurvePolygon : public OGRSurface
900 {
901  private:
902  OGRBoolean ContainsPoint( const OGRPoint* p ) const;
903  virtual int checkRing( OGRCurve * poNewRing ) const;
904  OGRErr addRingDirectlyInternal( OGRCurve* poCurve, int bNeedRealloc );
905  static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf, OGRCurve* poCurve );
906  static OGRErr addCurveDirectlyFromWkb( OGRGeometry* poSelf, OGRCurve* poCurve );
907 
908  protected:
909  friend class OGRPolygon;
910  OGRCurveCollection oCC;
911 
913 
914  virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const;
915  virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const;
916 
917  public:
918  OGRCurvePolygon();
920  virtual ~OGRCurvePolygon();
921 
923 
924  // Non standard (OGRGeometry).
925  virtual const char *getGeometryName() const;
926  virtual OGRwkbGeometryType getGeometryType() const;
927  virtual OGRGeometry *clone() const;
928  virtual void empty();
929  virtual OGRErr transform( OGRCoordinateTransformation *poCT );
930  virtual void flattenTo2D();
931  virtual OGRBoolean IsEmpty() const;
932  virtual void segmentize(double dfMaxLength);
933  virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
934  virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
935  const char* const* papszOptions = NULL) const;
936 
937  // ISurface Interface
938  virtual double get_Area() const;
939  virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const;
940 
941  // IWks Interface
942  virtual int WkbSize() const;
943  virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc );
944  virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const;
945  virtual OGRErr importFromWkt( char ** );
946  virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant eWkbVariant = wkbVariantOldOgc ) const;
947 
948  // IGeometry
949  virtual int getDimension() const;
950  virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
951  virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
952 
953  // ICurvePolygon
954  virtual OGRPolygon* CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
955  const char* const* papszOptions = NULL) const;
956 
957  // ISpatialRelation
958  virtual OGRBoolean Equals( OGRGeometry * ) const;
959  virtual OGRBoolean Intersects( const OGRGeometry * ) const;
960  virtual OGRBoolean Contains( const OGRGeometry * ) const;
961 
962  // Non standard
963  virtual void setCoordinateDimension( int nDimension );
964  virtual void set3D( OGRBoolean bIs3D );
965  virtual void setMeasured( OGRBoolean bIsMeasured );
966 
967  OGRErr addRing( OGRCurve * );
968  OGRErr addRingDirectly( OGRCurve * );
969 
971  const OGRCurve *getExteriorRingCurve() const;
972  int getNumInteriorRings() const;
974  const OGRCurve *getInteriorRingCurve( int ) const;
975 
977 
978  virtual void swapXY();
979 };
980 
981 /************************************************************************/
982 /* OGRPolygon */
983 /************************************************************************/
984 
994 class CPL_DLL OGRPolygon : public OGRCurvePolygon
995 {
996  protected:
997  friend class OGRMultiSurface;
998 
999  virtual int checkRing( OGRCurve * poNewRing ) const;
1000  OGRErr importFromWKTListOnly( char ** ppszInput, int bHasZ, int bHasM,
1001  OGRRawPoint*& paoPoints, int& nMaxPoints,
1002  double*& padfZ );
1003 
1004  static OGRCurvePolygon* CastToCurvePolygon(OGRPolygon* poPoly);
1005 
1006  virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const;
1007  virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const;
1008 
1009  public:
1010  OGRPolygon();
1011  OGRPolygon(const OGRPolygon& other);
1012  virtual ~OGRPolygon();
1013 
1014  OGRPolygon& operator=(const OGRPolygon& other);
1015 
1016  // Non standard (OGRGeometry).
1017  virtual const char *getGeometryName() const;
1018  virtual OGRwkbGeometryType getGeometryType() const;
1019  virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
1020  virtual OGRGeometry* getCurveGeometry(const char* const* papszOptions = NULL) const;
1021  virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
1022  const char* const* papszOptions = NULL) const;
1023 
1024  // ISurface Interface
1025  virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const;
1026 
1027  // IWks Interface
1028  virtual int WkbSize() const;
1029  virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc );
1030  virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const;
1031  virtual OGRErr importFromWkt( char ** );
1032  virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const;
1033 
1034  // ICurvePolygon
1035  virtual OGRPolygon* CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
1036  const char* const* papszOptions = NULL) const;
1037 
1038  OGRLinearRing *getExteriorRing();
1039  const OGRLinearRing *getExteriorRing() const;
1040  OGRLinearRing *getInteriorRing( int );
1041  const OGRLinearRing *getInteriorRing( int ) const;
1042 
1043  OGRLinearRing *stealExteriorRing();
1044  OGRLinearRing *stealInteriorRing(int);
1045 
1046  OGRBoolean IsPointOnSurface( const OGRPoint * ) const;
1047 
1048  virtual void closeRings();
1049 };
1050 
1051 /************************************************************************/
1052 /* OGRGeometryCollection */
1053 /************************************************************************/
1054 
1062 class CPL_DLL OGRGeometryCollection : public OGRGeometry
1063 {
1064  OGRErr importFromWkbInternal( unsigned char * pabyData, int nSize, int nRecLevel,
1065  OGRwkbVariant );
1066  OGRErr importFromWktInternal( char **ppszInput, int nRecLevel );
1067 
1068  protected:
1069  int nGeomCount;
1070  OGRGeometry **papoGeoms;
1071 
1072  OGRErr exportToWktInternal( char ** ppszDstText,
1073  OGRwkbVariant eWkbVariant,
1074  const char* pszSkipPrefix ) const;
1075  virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const;
1076 
1077  static OGRGeometryCollection* TransferMembersAndDestroy(OGRGeometryCollection* poSrc,
1078  OGRGeometryCollection* poDst);
1079 
1080  public:
1083  virtual ~OGRGeometryCollection();
1084 
1085  OGRGeometryCollection& operator=(const OGRGeometryCollection& other);
1086 
1087  // Non standard (OGRGeometry).
1088  virtual const char *getGeometryName() const;
1089  virtual OGRwkbGeometryType getGeometryType() const;
1090  virtual OGRGeometry *clone() const;
1091  virtual void empty();
1092  virtual OGRErr transform( OGRCoordinateTransformation *poCT );
1093  virtual void flattenTo2D();
1094  virtual OGRBoolean IsEmpty() const;
1095  virtual void segmentize(double dfMaxLength);
1096  virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
1097  virtual OGRGeometry* getCurveGeometry(const char* const* papszOptions = NULL) const;
1098  virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, const char* const* papszOptions = NULL) const;
1099 
1100  // IWks Interface
1101  virtual int WkbSize() const;
1102  virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc );
1103  virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const;
1104  virtual OGRErr importFromWkt( char ** );
1105  virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const;
1106 
1107  virtual double get_Length() const;
1108  virtual double get_Area() const;
1109 
1110  // IGeometry methods
1111  virtual int getDimension() const;
1112  virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
1113  virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const;
1114 
1115  // IGeometryCollection
1116  int getNumGeometries() const;
1117  OGRGeometry *getGeometryRef( int );
1118  const OGRGeometry *getGeometryRef( int ) const;
1119 
1120  // ISpatialRelation
1121  virtual OGRBoolean Equals( OGRGeometry * ) const;
1122 
1123  // Non standard
1124  virtual void setCoordinateDimension( int nDimension );
1125  virtual void set3D( OGRBoolean bIs3D );
1126  virtual void setMeasured( OGRBoolean bIsMeasured );
1127  virtual OGRErr addGeometry( const OGRGeometry * );
1128  virtual OGRErr addGeometryDirectly( OGRGeometry * );
1129  virtual OGRErr removeGeometry( int iIndex, int bDelete = TRUE );
1130 
1131  void closeRings();
1132 
1133  virtual void swapXY();
1134 };
1135 
1136 /************************************************************************/
1137 /* OGRMultiSurface */
1138 /************************************************************************/
1139 
1147 {
1148  protected:
1149  virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const;
1150 
1151  public:
1152  OGRMultiSurface();
1153  OGRMultiSurface(const OGRMultiSurface& other);
1154  virtual ~OGRMultiSurface();
1155 
1156  OGRMultiSurface& operator=(const OGRMultiSurface& other);
1157 
1158  // Non standard (OGRGeometry).
1159  virtual const char *getGeometryName() const;
1160  virtual OGRwkbGeometryType getGeometryType() const;
1161  virtual OGRErr importFromWkt( char ** );
1162  virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc ) const;
1163 
1164  // IMultiSurface methods
1165  virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const;
1166 
1167  // IGeometry methods
1168  virtual int getDimension() const;
1169 
1170  // Non standard
1171  virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
1172 
1173  static OGRMultiPolygon* CastToMultiPolygon(OGRMultiSurface* poMS);
1174 };
1175 
1176 /************************************************************************/
1177 /* OGRMultiPolygon */
1178 /************************************************************************/
1179 
1184 class CPL_DLL OGRMultiPolygon : public OGRMultiSurface
1185 {
1186  protected:
1187  virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const;
1188 
1189  public:
1190  OGRMultiPolygon();
1191  OGRMultiPolygon(const OGRMultiPolygon& other);
1192  virtual ~OGRMultiPolygon();
1193 
1194  OGRMultiPolygon& operator=(const OGRMultiPolygon& other);
1195 
1196  // Non standard (OGRGeometry).
1197  virtual const char *getGeometryName() const;
1198  virtual OGRwkbGeometryType getGeometryType() const;
1199  virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc ) const;
1200 
1201  // IMultiSurface methods
1202  virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const;
1203 
1204  // Non standard
1205  virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
1206 
1207  static OGRMultiSurface* CastToMultiSurface(OGRMultiPolygon* poMP);
1208 };
1209 
1210 /************************************************************************/
1211 /* OGRMultiPoint */
1212 /************************************************************************/
1213 
1218 class CPL_DLL OGRMultiPoint : public OGRGeometryCollection
1219 {
1220  private:
1221  OGRErr importFromWkt_Bracketed( char **, int bHasM, int bHasZ );
1222 
1223  protected:
1224  virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const;
1225 
1226  public:
1227  OGRMultiPoint();
1228  OGRMultiPoint(const OGRMultiPoint& other);
1229  virtual ~OGRMultiPoint();
1230 
1231  OGRMultiPoint& operator=(const OGRMultiPoint& other);
1232 
1233  // Non standard (OGRGeometry).
1234  virtual const char *getGeometryName() const;
1235  virtual OGRwkbGeometryType getGeometryType() const;
1236  virtual OGRErr importFromWkt( char ** );
1237  virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc ) const;
1238 
1239  // IGeometry methods
1240  virtual int getDimension() const;
1241 
1242  // Non standard
1243  virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
1244 };
1245 
1246 /************************************************************************/
1247 /* OGRMultiCurve */
1248 /************************************************************************/
1249 
1256 class CPL_DLL OGRMultiCurve : public OGRGeometryCollection
1257 {
1258  protected:
1259  static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf, OGRCurve* poCurve );
1260  virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const;
1261 
1262  public:
1263  OGRMultiCurve();
1264  OGRMultiCurve(const OGRMultiCurve& other);
1265  virtual ~OGRMultiCurve();
1266 
1267  OGRMultiCurve& operator=(const OGRMultiCurve& other);
1268 
1269  // Non standard (OGRGeometry).
1270  virtual const char *getGeometryName() const;
1271  virtual OGRwkbGeometryType getGeometryType() const;
1272  virtual OGRErr importFromWkt( char ** );
1273  virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc ) const;
1274 
1275  // IGeometry methods
1276  virtual int getDimension() const;
1277 
1278  // Non standard
1279  virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
1280 
1281  static OGRMultiLineString* CastToMultiLineString(OGRMultiCurve* poMC);
1282 };
1283 
1284 /************************************************************************/
1285 /* OGRMultiLineString */
1286 /************************************************************************/
1287 
1292 class CPL_DLL OGRMultiLineString : public OGRMultiCurve
1293 {
1294  protected:
1295  virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const;
1296 
1297  public:
1299  OGRMultiLineString(const OGRMultiLineString& other);
1300  virtual ~OGRMultiLineString();
1301 
1302  OGRMultiLineString& operator=(const OGRMultiLineString& other);
1303 
1304  // Non standard (OGRGeometry).
1305  virtual const char *getGeometryName() const;
1306  virtual OGRwkbGeometryType getGeometryType() const;
1307  virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc ) const;
1308 
1309  // Non standard
1310  virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
1311 
1312  static OGRMultiCurve* CastToMultiCurve(OGRMultiLineString* poMLS);
1313 };
1314 
1315 
1316 /************************************************************************/
1317 /* OGRGeometryFactory */
1318 /************************************************************************/
1319 
1324 class CPL_DLL OGRGeometryFactory
1325 {
1326  static OGRErr createFromFgfInternal( unsigned char *pabyData,
1327  OGRSpatialReference * poSR,
1328  OGRGeometry **ppoReturn,
1329  int nBytes,
1330  int *pnBytesConsumed,
1331  int nRecLevel );
1332  public:
1333  static OGRErr createFromWkb( unsigned char *, OGRSpatialReference *,
1334  OGRGeometry **, int = -1, OGRwkbVariant=wkbVariantOldOgc );
1335  static OGRErr createFromWkt( char **, OGRSpatialReference *,
1336  OGRGeometry ** );
1337  static OGRErr createFromFgf( unsigned char *, OGRSpatialReference *,
1338  OGRGeometry **, int = -1, int * = NULL );
1339  static OGRGeometry *createFromGML( const char * );
1340  static OGRGeometry *createFromGEOS( GEOSContextHandle_t hGEOSCtxt, GEOSGeom );
1341 
1342  static void destroyGeometry( OGRGeometry * );
1343  static OGRGeometry *createGeometry( OGRwkbGeometryType );
1344 
1345  static OGRGeometry * forceToPolygon( OGRGeometry * );
1346  static OGRGeometry * forceToLineString( OGRGeometry *, bool bOnlyInOrder = true );
1347  static OGRGeometry * forceToMultiPolygon( OGRGeometry * );
1348  static OGRGeometry * forceToMultiPoint( OGRGeometry * );
1349  static OGRGeometry * forceToMultiLineString( OGRGeometry * );
1350 
1351  static OGRGeometry * forceTo( OGRGeometry* poGeom,
1352  OGRwkbGeometryType eTargetType,
1353  const char*const* papszOptions = NULL );
1354 
1355  static OGRGeometry * organizePolygons( OGRGeometry **papoPolygons,
1356  int nPolygonCount,
1357  int *pbResultValidGeometry,
1358  const char **papszOptions = NULL);
1359  static int haveGEOS();
1360 
1361  static OGRGeometry* transformWithOptions( const OGRGeometry* poSrcGeom,
1363  char** papszOptions );
1364 
1365  static OGRGeometry*
1366  approximateArcAngles( double dfX, double dfY, double dfZ,
1367  double dfPrimaryRadius, double dfSecondaryAxis,
1368  double dfRotation,
1369  double dfStartAngle, double dfEndAngle,
1370  double dfMaxAngleStepSizeDegrees );
1371 
1372  static int GetCurveParmeters(double x0, double y0,
1373  double x1, double y1,
1374  double x2, double y2,
1375  double& R, double& cx, double& cy,
1376  double& alpha0, double& alpha1, double& alpha2 );
1377  static OGRLineString* curveToLineString( double x0, double y0, double z0,
1378  double x1, double y1, double z1,
1379  double x2, double y2, double z2,
1380  int bHasZ,
1381  double dfMaxAngleStepSizeDegrees,
1382  const char*const* papszOptions = NULL );
1383  static OGRCurve* curveFromLineString(const OGRLineString* poLS,
1384  const char*const* papszOptions = NULL);
1385 };
1386 
1387 OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType( const char *pszGeomType );
1388 const char CPL_DLL * OGRToOGCGeomType( OGRwkbGeometryType eGeomType );
1389 
1390 /* Prepared geometry API (needs GEOS >= 3.1.0) */
1391 typedef struct _OGRPreparedGeometry OGRPreparedGeometry;
1392 int OGRHasPreparedGeometrySupport();
1393 OGRPreparedGeometry* OGRCreatePreparedGeometry( const OGRGeometry* poGeom );
1394 void OGRDestroyPreparedGeometry( OGRPreparedGeometry* poPreparedGeom );
1395 int OGRPreparedGeometryIntersects( const OGRPreparedGeometry* poPreparedGeom,
1396  const OGRGeometry* poOtherGeom );
1397 int OGRPreparedGeometryContains( const OGRPreparedGeometry* poPreparedGeom,
1398  const OGRGeometry* poOtherGeom );
1399 
1400 #endif /* ndef OGR_GEOMETRY_H_INCLUDED */
virtual double get_Area() const
Get the area of the (closed) curve.
Definition: ogrcompoundcurve.cpp:810
virtual OGRPointIterator * getPointIterator() const
Returns a point iterator over the curve.
Definition: ogrcompoundcurve.cpp:712
virtual OGRBoolean IsEmpty() const
Returns TRUE (non-zero) if the object has no points.
Definition: ogr_geometry.h:294
virtual void setCoordinateDimension(int nDimension)
Set the coordinate dimension.
Definition: ogrgeometry.cpp:969
virtual void closeRings()
Force rings to be closed.
Definition: ogrpolygon.cpp:738
virtual void set3D(OGRBoolean bIs3D)
Add or remove the Z coordinate dimension.
Definition: ogrgeometry.cpp:992
virtual void setMeasured(OGRBoolean bIsMeasured)
Add or remove the M coordinate dimension.
Definition: ogrgeometry.cpp:1014
Definition: ogr_geometry.h:527
virtual OGRErr importFromWkt(char **ppszInput)=0
Assign geometry from well known text data.
virtual OGRErr importFromWkt(char **)
Assign geometry from well known text data.
Definition: ogrpolygon.cpp:402
double getY() const
Fetch Y coordinate.
Definition: ogr_geometry.h:298
virtual void swapXY()
Swap x and y coordinates.
Definition: ogrgeometry.cpp:5038
virtual void segmentize(double dfMaxLength)
Modify the geometry such it has no segment longer then the given distance.
Definition: ogrcurvepolygon.cpp:662
virtual OGRBoolean Equals(OGRGeometry *) const =0
Returns TRUE if two geometries are equivalent.
Definition: ogr_geometry.h:1324
virtual void StartPoint(OGRPoint *) const
Return the curve start point.
Definition: ogrcompoundcurve.cpp:287
virtual int WkbSize() const =0
Returns size of related binary representation.
virtual OGRGeometry * clone() const CPL_WARN_UNUSED_RESULT=0
Make a copy of this object.
OGRCurve * stealExteriorRingCurve()
"Steal" reference to external ring.
Definition: ogrcurvepolygon.cpp:284
virtual OGRErr transform(OGRCoordinateTransformation *poCT)
Apply arbitrary coordinate transformation to geometry.
Definition: ogrcurvepolygon.cpp:599
OGRCurve * getExteriorRingCurve()
Fetch reference to external polygon ring.
Definition: ogrcurvepolygon.cpp:205
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const
Returns if this geometry is or has curve geometry.
Definition: ogrpolygon.cpp:759
static OGRPolygon * CastToPolygon(OGRCurvePolygon *poCP)
Convert to polygon.
Definition: ogrcurvepolygon.cpp:743
virtual void setMeasured(OGRBoolean bIsMeasured)
Add or remove the M coordinate dimension.
Definition: ogrcurvepolygon.cpp:644
OGRCompoundCurve & operator=(const OGRCompoundCurve &other)
Assignment operator.
Definition: ogrcompoundcurve.cpp:90
static OGRLinearRing * CastToLinearRing(OGRCompoundCurve *poCC)
Cast to linear ring.
Definition: ogrcompoundcurve.cpp:761
Definition: ogr_geometry.h:1184
virtual void Value(double, OGRPoint *) const
Fetch point at given distance along curve.
Definition: ogrcompoundcurve.cpp:307
virtual OGRGeometry * clone() const
Make a copy of this object.
Definition: ogrcurvepolygon.cpp:106
virtual OGRErr importFromWkb(unsigned char *, int=-1, OGRwkbVariant=wkbVariantOldOgc)=0
Assign geometry from well known binary data.
Definition: ogr_geometry.h:640
OGRCurveCollection & operator=(const OGRCurveCollection &other)
Assignment operator.
Definition: ogrcurvecollection.cpp:102
virtual void flattenTo2D()=0
Convert geometry to strictly 2D. In a sense this converts all Z coordinates to 0.0.
Definition: ogr_geometry.h:351
Definition: ogr_geometry.h:1062
virtual OGRBoolean Equals(OGRGeometry *) const
Returns TRUE if two geometries are equivalent.
Definition: ogrcurvepolygon.cpp:579
int getNumInteriorRings() const
Fetch the number of internal rings.
Definition: ogrcurvepolygon.cpp:230
Definition: ogr_geometry.h:582
virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc) const =0
Convert a geometry into well known binary format.
OGRGeometry & operator=(const OGRGeometry &other)
Assignment operator.
Definition: ogrgeometry.cpp:124
virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
This method relates to the SFCOM IMultiSurface::get_PointOnSurface() method.
Definition: ogrmultisurface.cpp:289
virtual int WkbSize() const
Returns size of related binary representation.
Definition: ogrpolygon.cpp:264
virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known binary format.
Definition: ogrgeometrycollection.cpp:579
virtual OGRLineString * CurveToLine(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=NULL) const
Return a linestring from a curve geometry.
Definition: ogrcompoundcurve.cpp:365
virtual int WkbSize() const
Returns size of related binary representation.
Definition: ogrgeometrycollection.cpp:441
virtual int get_IsClosed() const
Return TRUE if curve is closed.
Definition: ogrcurve.cpp:98
virtual int getNumPoints() const
Return the number of points of a curve geometry.
Definition: ogrcompoundcurve.cpp:654
Definition: ogr_geometry.h:1146
virtual OGRErr importFromWkb(unsigned char *, int=-1, OGRwkbVariant=wkbVariantOldOgc)
Assign geometry from well known binary data.
Definition: ogrpolygon.cpp:284
Definition: ogr_geometry.h:773
Definition: ogr_geometry.h:47
OGRwkbGeometryType
Definition: ogr_core.h:333
virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known binary format.
Definition: ogrpolygon.cpp:329
OGRMultiSurface & operator=(const OGRMultiSurface &other)
Assignment operator.
Definition: ogrmultisurface.cpp:87
virtual int ContainsPoint(const OGRPoint *p) const
Returns if a point is contained in a (closed) curve.
Definition: ogrcurve.cpp:375
Definition: ogr_geometry.h:333
Definition: ogr_geometry.h:1256
virtual OGRErr importFromWkt(char **)
Assign geometry from well known text data.
Definition: ogrmultisurface.cpp:148
Definition: ogr_geometry.h:866
Definition: ogr_geometry.h:1292
virtual OGRErr exportToWkt(char **ppszDstText, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known text format.
Definition: ogrpolygon.cpp:570
virtual void getEnvelope(OGREnvelope *psEnvelope) const =0
Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure...
virtual OGRErr importFromWkb(unsigned char *, int=-1, OGRwkbVariant=wkbVariantOldOgc)
Assign geometry from well known binary data.
Definition: ogrgeometrycollection.cpp:565
virtual OGRBoolean Contains(const OGRGeometry *) const
Test for containment.
Definition: ogrcurvepolygon.cpp:696
Definition: ogr_geometry.h:104
virtual void empty()=0
Clear geometry information. This restores the geometry to it&#39;s initial state after construction...
virtual void segmentize(double dfMaxLength)
Modify the geometry such it has no segment longer then the given distance.
Definition: ogrgeometry.cpp:753
double getZ() const
Fetch Z coordinate.
Definition: ogr_geometry.h:299
void setX(double xIn)
Assign point X coordinate.
Definition: ogr_geometry.h:304
virtual OGRwkbGeometryType getGeometryType() const
Fetch geometry type.
Definition: ogrpolygon.cpp:104
virtual OGRBoolean IsEmpty() const
Returns TRUE (non-zero) if the object has no points.
Definition: ogrcurvepolygon.cpp:653
virtual OGRBoolean IsEmpty() const
Returns TRUE (non-zero) if the object has no points.
Definition: ogrgeometry.cpp:138
virtual OGRErr exportToWkt(char **ppszDstText, OGRwkbVariant=wkbVariantOldOgc) const =0
Convert a geometry into well known text format.
virtual int getDimension() const
Get the dimension of this object.
Definition: ogrcurvepolygon.cpp:161
void setZ(double zIn)
Assign point Z coordinate. Calling this method will force the geometry coordinate dimension to 3D (wk...
Definition: ogr_geometry.h:306
virtual void EndPoint(OGRPoint *) const
Return the curve end point.
Definition: ogrcompoundcurve.cpp:297
virtual void set3D(OGRBoolean bIs3D)
Add or remove the Z coordinate dimension.
Definition: ogrcurvepolygon.cpp:639
Definition: ogr_geometry.h:899
virtual double get_Area() const
Get the area of the surface object.
Definition: ogrcurvepolygon.cpp:609
virtual OGRGeometry * getLinearGeometry(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=NULL) const
Return, possibly approximate, non-curve version of this geometry.
Definition: ogrgeometrycollection.cpp:1228
Definition: ogr_geometry.h:701
void setY(double yIn)
Assign point Y coordinate.
Definition: ogr_geometry.h:305
Definition: ogr_spatialref.h:129
virtual OGRBoolean Intersects(const OGRGeometry *) const
Do these features intersect?
Definition: ogrcurvepolygon.cpp:712
Definition: ogr_core.h:441
Definition: ogr_core.h:161
OGRCurvePolygon()
Create an empty curve polygon.
Definition: ogrcurvepolygon.cpp:45
virtual void empty()
Clear geometry information. This restores the geometry to it&#39;s initial state after construction...
Definition: ogrcurvepolygon.cpp:134
virtual double get_AreaOfCurveSegments() const
Get the area of the purely curve portions of a (closed) curve.
Definition: ogrcompoundcurve.cpp:849
OGRErr addRingDirectly(OGRCurve *)
Add a ring to a polygon.
Definition: ogrcurvepolygon.cpp:370
Definition: ogr_geometry.h:264
OGRwkbVariant
Definition: ogr_core.h:439
virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
This method relates to the SFCOM ISurface::get_PointOnSurface() method.
Definition: ogrpolygon.cpp:708
virtual int getDimension() const
Get the dimension of this object.
Definition: ogrcurve.cpp:77
double getX() const
Fetch X coordinate.
Definition: ogr_geometry.h:297
Definition: ogr_geometry.h:994
Definition: ogr_geometry.h:404
Definition: ogr_core.h:48
virtual void getEnvelope(OGREnvelope *psEnvelope) const
Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure...
Definition: ogrcurvepolygon.cpp:559
virtual OGRErr exportToWkt(char **, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known text format.
Definition: ogrmultisurface.cpp:258
double getX(int i) const
Get X at vertex.
Definition: ogr_geometry.h:458
Definition: ogr_spatialref.h:576
OGRSpatialReference * getSpatialReference(void) const
Returns spatial reference system for object.
Definition: ogr_geometry.h:203
virtual OGRwkbGeometryType getGeometryType() const
Fetch geometry type.
Definition: ogrmultisurface.cpp:100
virtual int getNumPoints() const
Fetch vertex count.
Definition: ogr_geometry.h:456
static OGRCompoundCurve * CastToCompoundCurve(OGRCurve *puCurve)
Cast to compound curve.
Definition: ogrcurve.cpp:301
OGRErr addRing(OGRCurve *)
Add a ring to a polygon.
Definition: ogrcurvepolygon.cpp:311
OGRPolygon & operator=(const OGRPolygon &other)
Assignment operator.
Definition: ogrpolygon.cpp:91
virtual const char * getGeometryName() const
Fetch WKT name for geometry type.
Definition: ogrpolygon.cpp:121
virtual OGRErr transform(OGRCoordinateTransformation *poCT)=0
Apply arbitrary coordinate transformation to geometry.
virtual OGRPolygon * CurvePolyToPoly(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=NULL) const
Return a polygon from a curve polygon.
Definition: ogrpolygon.cpp:749
virtual void flattenTo2D()
Convert geometry to strictly 2D. In a sense this converts all Z coordinates to 0.0.
Definition: ogrcurvepolygon.cpp:171
virtual double get_Length() const
Returns the length of the curve.
Definition: ogrcompoundcurve.cpp:275
Definition: ogr_geometry.h:1218
virtual void swapXY()
Swap x and y coordinates.
Definition: ogrcurvepolygon.cpp:671
virtual void setCoordinateDimension(int nDimension)
Set the coordinate dimension.
Definition: ogrcurvepolygon.cpp:633
virtual OGRGeometry * getCurveGeometry(const char *const *papszOptions=NULL) const
Return curve version of this geometry.
Definition: ogrgeometrycollection.cpp:1249
virtual OGRBoolean IsConvex() const
Returns if a (closed) curve forms a convex shape.
Definition: ogrcurve.cpp:258
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const
Returns if this geometry is or has curve geometry.
Definition: ogrmultisurface.cpp:269
void closeRings()
Force rings to be closed.
Definition: ogrgeometrycollection.cpp:1044
OGRCurve * getInteriorRingCurve(int)
Fetch reference to indicated internal ring.
Definition: ogrcurvepolygon.cpp:259
virtual OGRGeometry * getLinearGeometry(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=NULL) const
Return, possibly approximate, non-curve version of this geometry.
Definition: ogrpolygon.cpp:768
virtual const char * getGeometryName() const
Fetch WKT name for geometry type.
Definition: ogrmultisurface.cpp:127
double getY(int i) const
Get Y at vertex.
Definition: ogr_geometry.h:459

Generated for GDAL by doxygen 1.8.11.