source: trunk/gdal/ogr/ogr_geometry.h

Last change on this file was 41542, checked in by Even Rouault, 6 years ago

Use bool type for newly introduce methods

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 71.0 KB
Line 
1/******************************************************************************
2 * $Id: ogr_geometry.h 41542 2018-02-20 18:36:59Z 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 * 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 "cpl_json.h"
36#include "ogr_core.h"
37#include "ogr_spatialref.h"
38
39/**
40 * \file ogr_geometry.h
41 *
42 * Simple feature geometry classes.
43 */
44
45/**
46 * Simple container for a position.
47 */
48class OGRRawPoint
49{
50 public:
51 /** Constructor */
52 OGRRawPoint() : x(0.0), y(0.0) {}
53
54 /** Constructor */
55 OGRRawPoint(double xIn, double yIn) : x(xIn), y(yIn) {}
56
57 /** x */
58 double x;
59 /** y */
60 double y;
61};
62
63/** GEOS geometry type */
64typedef struct GEOSGeom_t *GEOSGeom;
65/** GEOS context handle type */
66typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
67/** SFCGAL geometry type */
68typedef void sfcgal_geometry_t;
69
70class OGRPoint;
71class OGRCurve;
72class OGRCompoundCurve;
73class OGRLinearRing;
74class OGRLineString;
75class OGRSurface;
76class OGRCurvePolygon;
77class OGRPolygon;
78class OGRMultiSurface;
79class OGRMultiPolygon;
80class OGRMultiCurve;
81class OGRMultiLineString;
82class OGRTriangle;
83class OGRPolyhedralSurface;
84class OGRTriangulatedSurface;
85
86//! @cond Doxygen_Suppress
87typedef OGRLineString* (*OGRCurveCasterToLineString)(OGRCurve*);
88typedef OGRLinearRing* (*OGRCurveCasterToLinearRing)(OGRCurve*);
89
90typedef OGRPolygon* (*OGRSurfaceCasterToPolygon)(OGRSurface*);
91typedef OGRCurvePolygon* (*OGRSurfaceCasterToCurvePolygon)(OGRSurface*);
92typedef OGRMultiPolygon* (*OGRPolyhedralSurfaceCastToMultiPolygon)(OGRPolyhedralSurface*);
93//! @endcond
94
95/************************************************************************/
96/* OGRGeometry */
97/************************************************************************/
98
99/**
100 * Abstract base class for all geometry classes.
101 *
102 * Some spatial analysis methods require that OGR is built on the GEOS library
103 * to work properly. The precise meaning of methods that describe spatial
104 * relationships between geometries is described in the SFCOM, or other simple
105 * features interface specifications, like "OpenGIS® Implementation
106 * Specification for Geographic information - Simple feature access - Part 1:
107 * Common architecture":
108 * <a href="http://www.opengeospatial.org/standards/sfa">OGC 06-103r4</a>
109 *
110 * In GDAL 2.0, the hierarchy of classes has been extended with
111 * <a href="https://portal.opengeospatial.org/files/?artifact_id=32024">
112 * (working draft) ISO SQL/MM Part 3 (ISO/IEC 13249-3)</a> curve geometries :
113 * CIRCULARSTRING (OGRCircularString), COMPOUNDCURVE (OGRCompoundCurve),
114 * CURVEPOLYGON (OGRCurvePolygon), MULTICURVE (OGRMultiCurve) and
115 * MULTISURFACE (OGRMultiSurface).
116 *
117 */
118
119class CPL_DLL OGRGeometry
120{
121 private:
122 OGRSpatialReference * poSRS; // may be NULL
123
124 protected:
125//! @cond Doxygen_Suppress
126 friend class OGRCurveCollection;
127
128 unsigned int flags;
129
130 OGRErr importPreambleFromWkt( char ** ppszInput,
131 int* pbHasZ, int* pbHasM,
132 bool* pbIsEmpty );
133 OGRErr importCurveCollectionFromWkt(
134 char ** ppszInput,
135 int bAllowEmptyComponent,
136 int bAllowLineString,
137 int bAllowCurve,
138 int bAllowCompoundCurve,
139 OGRErr (*pfnAddCurveDirectly)(OGRGeometry* poSelf,
140 OGRCurve* poCurve) );
141 OGRErr importPreambleFromWkb( const unsigned char * pabyData,
142 int nSize,
143 OGRwkbByteOrder& eByteOrder,
144 OGRwkbVariant eWkbVariant );
145 OGRErr importPreambleOfCollectionFromWkb(
146 const unsigned char * pabyData,
147 int& nSize,
148 int& nDataOffset,
149 OGRwkbByteOrder& eByteOrder,
150 int nMinSubGeomSize,
151 int& nGeomCount,
152 OGRwkbVariant eWkbVariant );
153 OGRErr PointOnSurfaceInternal( OGRPoint * poPoint ) const;
154 OGRBoolean IsSFCGALCompatible() const;
155//! @endcond
156
157 public:
158
159/************************************************************************/
160/* Bit flags for OGRGeometry */
161/* The OGR_G_NOT_EMPTY_POINT is used *only* for points. */
162/* Do not use these outside of the core. */
163/* Use Is3D, IsMeasured, set3D, and setMeasured instead */
164/************************************************************************/
165
166//! @cond Doxygen_Suppress
167 static const unsigned int OGR_G_NOT_EMPTY_POINT = 0x1;
168 static const unsigned int OGR_G_3D = 0x2;
169 static const unsigned int OGR_G_MEASURED = 0x4;
170//! @endcond
171
172 OGRGeometry();
173 OGRGeometry( const OGRGeometry& other );
174 virtual ~OGRGeometry();
175
176 OGRGeometry& operator=( const OGRGeometry& other );
177
178 // Standard IGeometry.
179 virtual int getDimension() const = 0;
180 virtual int getCoordinateDimension() const;
181 int CoordinateDimension() const;
182 virtual OGRBoolean IsEmpty() const = 0;
183 virtual OGRBoolean IsValid() const;
184 virtual OGRBoolean IsSimple() const;
185 /*! Returns whether the geometry has a Z component. */
186 OGRBoolean Is3D() const { return flags & OGR_G_3D; }
187 /*! Returns whether the geometry has a M component. */
188 OGRBoolean IsMeasured() const { return flags & OGR_G_MEASURED; }
189 virtual OGRBoolean IsRing() const;
190 virtual void empty() = 0;
191 virtual OGRGeometry *clone() const CPL_WARN_UNUSED_RESULT = 0;
192 virtual void getEnvelope( OGREnvelope * psEnvelope ) const = 0;
193 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const = 0;
194
195 // IWks Interface.
196 virtual int WkbSize() const = 0;
197 OGRErr importFromWkb( unsigned char *, int=-1,
198 OGRwkbVariant=wkbVariantOldOgc );
199 virtual OGRErr importFromWkb( const unsigned char *,
200 int,
201 OGRwkbVariant,
202 int& nBytesConsumedOut ) = 0;
203 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
204 OGRwkbVariant=wkbVariantOldOgc ) const = 0;
205 virtual OGRErr importFromWkt( char ** ppszInput ) = 0;
206 virtual OGRErr exportToWkt( char ** ppszDstText,
207 OGRwkbVariant=wkbVariantOldOgc ) const = 0;
208
209 // Non-standard.
210 virtual OGRwkbGeometryType getGeometryType() const = 0;
211 OGRwkbGeometryType getIsoGeometryType() const;
212 virtual const char *getGeometryName() const = 0;
213 virtual void dumpReadable( FILE *, const char * = nullptr
214 , char** papszOptions = nullptr ) const;
215 virtual void flattenTo2D() = 0;
216 virtual char * exportToGML( const char* const * papszOptions = nullptr ) const;
217 virtual char * exportToKML() const;
218 virtual char * exportToJson() const;
219
220 static GEOSContextHandle_t createGEOSContext();
221 static void freeGEOSContext( GEOSContextHandle_t hGEOSCtxt );
222 virtual GEOSGeom exportToGEOS( GEOSContextHandle_t hGEOSCtxt )
223 const CPL_WARN_UNUSED_RESULT;
224 virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
225 virtual OGRGeometry* getCurveGeometry(
226 const char* const* papszOptions = nullptr ) const CPL_WARN_UNUSED_RESULT;
227 virtual OGRGeometry* getLinearGeometry(
228 double dfMaxAngleStepSizeDegrees = 0,
229 const char* const* papszOptions = nullptr ) const CPL_WARN_UNUSED_RESULT;
230
231 // SFCGAL interfacing methods.
232//! @cond Doxygen_Suppress
233 static sfcgal_geometry_t* OGRexportToSFCGAL( OGRGeometry *poGeom );
234 static OGRGeometry* SFCGALexportToOGR( sfcgal_geometry_t* _geometry );
235//! @endcond
236 virtual void closeRings();
237
238 virtual void setCoordinateDimension( int nDimension );
239 virtual void set3D( OGRBoolean bIs3D );
240 virtual void setMeasured( OGRBoolean bIsMeasured );
241
242 virtual void assignSpatialReference( OGRSpatialReference * poSR );
243 OGRSpatialReference *getSpatialReference( void ) const { return poSRS; }
244
245 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) = 0;
246 OGRErr transformTo( OGRSpatialReference *poSR );
247
248 virtual void segmentize(double dfMaxLength);
249
250 // ISpatialRelation
251 virtual OGRBoolean Intersects( const OGRGeometry * ) const;
252 virtual OGRBoolean Equals( OGRGeometry * ) const = 0;
253 virtual OGRBoolean Disjoint( const OGRGeometry * ) const;
254 virtual OGRBoolean Touches( const OGRGeometry * ) const;
255 virtual OGRBoolean Crosses( const OGRGeometry * ) const;
256 virtual OGRBoolean Within( const OGRGeometry * ) const;
257 virtual OGRBoolean Contains( const OGRGeometry * ) const;
258 virtual OGRBoolean Overlaps( const OGRGeometry * ) const;
259// virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
260// virtual OGRGeometry *LocateAlong( double mValue ) const;
261// virtual OGRGeometry *LocateBetween( double mStart, double mEnd ) const;
262
263 virtual OGRGeometry *Boundary() const CPL_WARN_UNUSED_RESULT;
264 virtual double Distance( const OGRGeometry * ) const ;
265 virtual OGRGeometry *ConvexHull() const CPL_WARN_UNUSED_RESULT;
266 virtual OGRGeometry *Buffer( double dfDist, int nQuadSegs = 30 )
267 const CPL_WARN_UNUSED_RESULT;
268 virtual OGRGeometry *Intersection( const OGRGeometry *)
269 const CPL_WARN_UNUSED_RESULT;
270 virtual OGRGeometry *Union( const OGRGeometry * )
271 const CPL_WARN_UNUSED_RESULT;
272 virtual OGRGeometry *UnionCascaded() const CPL_WARN_UNUSED_RESULT;
273 virtual OGRGeometry *Difference( const OGRGeometry * )
274 const CPL_WARN_UNUSED_RESULT;
275 virtual OGRGeometry *SymDifference( const OGRGeometry * )
276 const CPL_WARN_UNUSED_RESULT;
277 virtual OGRErr Centroid( OGRPoint * poPoint ) const;
278 virtual OGRGeometry *Simplify(double dTolerance)
279 const CPL_WARN_UNUSED_RESULT;
280 OGRGeometry *SimplifyPreserveTopology(double dTolerance)
281 const CPL_WARN_UNUSED_RESULT;
282 virtual OGRGeometry *DelaunayTriangulation(
283 double dfTolerance, int bOnlyEdges ) const CPL_WARN_UNUSED_RESULT;
284
285 virtual OGRGeometry *Polygonize() const CPL_WARN_UNUSED_RESULT;
286
287 virtual double Distance3D( const OGRGeometry *poOtherGeom ) const;
288
289//! @cond Doxygen_Suppress
290 // backward compatibility to non-standard method names.
291 OGRBoolean Intersect( OGRGeometry * )
292 const CPL_WARN_DEPRECATED("Non standard method. "
293 "Use Intersects() instead");
294 OGRBoolean Equal( OGRGeometry * )
295 const CPL_WARN_DEPRECATED("Non standard method. "
296 "Use Equals() instead");
297 OGRGeometry *SymmetricDifference( const OGRGeometry * )
298 const CPL_WARN_DEPRECATED("Non standard method. "
299 "Use SymDifference() instead");
300 OGRGeometry *getBoundary()
301 const CPL_WARN_DEPRECATED("Non standard method. "
302 "Use Boundary() instead");
303//! @endcond
304
305//! @cond Doxygen_Suppress
306 // Special HACK for DB2 7.2 support
307 static int bGenerate_DB2_V72_BYTE_ORDER;
308//! @endcond
309
310 virtual void swapXY();
311//! @cond Doxygen_Suppress
312 static OGRGeometry* CastToIdentity( OGRGeometry* poGeom ) { return poGeom; }
313 static OGRGeometry* CastToError( OGRGeometry* poGeom );
314//! @endcond
315};
316
317/************************************************************************/
318/* OGRPoint */
319/************************************************************************/
320
321/**
322 * Point class.
323 *
324 * Implements SFCOM IPoint methods.
325 */
326
327class CPL_DLL OGRPoint : public OGRGeometry
328{
329 double x;
330 double y;
331 double z;
332 double m;
333
334 public:
335 OGRPoint();
336 OGRPoint( double x, double y );
337 OGRPoint( double x, double y, double z );
338 OGRPoint( double x, double y, double z, double m );
339 OGRPoint( const OGRPoint& other );
340 ~OGRPoint() override;
341
342 OGRPoint& operator=( const OGRPoint& other );
343
344 // IWks Interface
345 int WkbSize() const override;
346 OGRErr importFromWkb( const unsigned char *,
347 int,
348 OGRwkbVariant,
349 int& nBytesConsumedOut ) override;
350 OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
351 OGRwkbVariant=wkbVariantOldOgc )
352 const override;
353 OGRErr importFromWkt( char ** ) override;
354 OGRErr exportToWkt( char ** ppszDstText,
355 OGRwkbVariant=wkbVariantOldOgc )
356 const override;
357
358 // IGeometry
359 virtual int getDimension() const override;
360 virtual OGRGeometry *clone() const override;
361 virtual void empty() override;
362 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
363 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
364 virtual OGRBoolean IsEmpty() const override
365 { return !(flags & OGR_G_NOT_EMPTY_POINT); }
366
367 // IPoint
368 /** Return x */
369 double getX() const { return x; }
370 /** Return y */
371 double getY() const { return y; }
372 /** Return z */
373 double getZ() const { return z; }
374 /** Return m */
375 double getM() const { return m; }
376
377 // Non standard
378 virtual void setCoordinateDimension( int nDimension ) override;
379 /** Set x
380 * @param xIn x
381 */
382 void setX( double xIn ) { x = xIn; flags |= OGR_G_NOT_EMPTY_POINT; }
383 /** Set y
384 * @param yIn y
385 */
386 void setY( double yIn ) { y = yIn; flags |= OGR_G_NOT_EMPTY_POINT; }
387 /** Set z
388 * @param zIn z
389 */
390 void setZ( double zIn )
391 { z = zIn; flags |= (OGR_G_NOT_EMPTY_POINT | OGR_G_3D); }
392 /** Set m
393 * @param mIn m
394 */
395 void setM( double mIn )
396 { m = mIn; flags |= (OGR_G_NOT_EMPTY_POINT | OGR_G_MEASURED); }
397
398 // ISpatialRelation
399 virtual OGRBoolean Equals( OGRGeometry * ) const override;
400 virtual OGRBoolean Intersects( const OGRGeometry * ) const override;
401 virtual OGRBoolean Within( const OGRGeometry * ) const override;
402
403 // Non standard from OGRGeometry
404 virtual const char *getGeometryName() const override;
405 virtual OGRwkbGeometryType getGeometryType() const override;
406 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
407 virtual void flattenTo2D() override;
408
409 virtual void swapXY() override;
410};
411
412/************************************************************************/
413/* OGRPointIterator */
414/************************************************************************/
415
416/**
417 * Interface for a point iterator.
418 *
419 * @since GDAL 2.0
420 */
421
422class CPL_DLL OGRPointIterator
423{
424 public:
425 virtual ~OGRPointIterator();
426 virtual OGRBoolean getNextPoint( OGRPoint* p ) = 0;
427
428 static void destroy( OGRPointIterator* );
429};
430
431/************************************************************************/
432/* OGRCurve */
433/************************************************************************/
434
435/**
436 * Abstract curve base class for OGRLineString, OGRCircularString and
437 * OGRCompoundCurve
438 */
439
440class CPL_DLL OGRCurve : public OGRGeometry
441{
442 protected:
443//! @cond Doxygen_Suppress
444 OGRCurve();
445 OGRCurve( const OGRCurve& other );
446
447 virtual OGRCurveCasterToLineString GetCasterToLineString() const = 0;
448 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const = 0;
449
450 friend class OGRCurvePolygon;
451 friend class OGRCompoundCurve;
452//! @endcond
453 virtual int ContainsPoint( const OGRPoint* p ) const;
454 virtual int IntersectsPoint( const OGRPoint* p ) const;
455 virtual double get_AreaOfCurveSegments() const = 0;
456
457 public:
458 ~OGRCurve() override;
459
460//! @cond Doxygen_Suppress
461 OGRCurve& operator=( const OGRCurve& other );
462//! @endcond
463
464 // ICurve methods
465 virtual double get_Length() const = 0;
466 virtual void StartPoint( OGRPoint * ) const = 0;
467 virtual void EndPoint( OGRPoint * ) const = 0;
468 virtual int get_IsClosed() const;
469 virtual void Value( double, OGRPoint * ) const = 0;
470 virtual OGRLineString* CurveToLine( double dfMaxAngleStepSizeDegrees = 0,
471 const char* const* papszOptions = nullptr)
472 const = 0;
473 virtual int getDimension() const override;
474
475 // non standard
476 virtual int getNumPoints() const = 0;
477 virtual OGRPointIterator* getPointIterator() const = 0;
478 virtual OGRBoolean IsConvex() const;
479 virtual double get_Area() const = 0;
480
481 static OGRCompoundCurve* CastToCompoundCurve( OGRCurve* puCurve );
482 static OGRLineString* CastToLineString( OGRCurve* poCurve );
483 static OGRLinearRing* CastToLinearRing( OGRCurve* poCurve );
484};
485
486/************************************************************************/
487/* OGRSimpleCurve */
488/************************************************************************/
489
490/**
491 * Abstract curve base class for OGRLineString and OGRCircularString
492 *
493 * Note: this class does not exist in SQL/MM standard and exists for
494 * implementation convenience.
495 *
496 * @since GDAL 2.0
497 */
498
499class CPL_DLL OGRSimpleCurve: public OGRCurve
500{
501 protected:
502//! @cond Doxygen_Suppress
503 friend class OGRGeometry;
504
505 int nPointCount;
506 OGRRawPoint *paoPoints;
507 double *padfZ;
508 double *padfM;
509
510 void Make3D();
511 void Make2D();
512 void RemoveM();
513 void AddM();
514
515 OGRErr importFromWKTListOnly( char ** ppszInput, int bHasZ, int bHasM,
516 OGRRawPoint*& paoPointsIn,
517 int& nMaxPoints,
518 double*& padfZIn );
519
520//! @endcond
521
522 virtual double get_LinearArea() const;
523
524 OGRSimpleCurve();
525 OGRSimpleCurve( const OGRSimpleCurve& other );
526
527 public:
528 ~OGRSimpleCurve() override;
529
530 OGRSimpleCurve& operator=( const OGRSimpleCurve& other );
531
532 // IWks Interface.
533 virtual int WkbSize() const override;
534 virtual OGRErr importFromWkb( const unsigned char *,
535 int,
536 OGRwkbVariant,
537 int& nBytesConsumedOut ) override;
538 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
539 OGRwkbVariant=wkbVariantOldOgc )
540 const override;
541 virtual OGRErr importFromWkt( char ** ) override;
542 virtual OGRErr exportToWkt( char ** ppszDstText,
543 OGRwkbVariant=wkbVariantOldOgc )
544 const override;
545
546 // IGeometry interface.
547 virtual OGRGeometry *clone() const override;
548 virtual void empty() override;
549 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
550 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
551 virtual OGRBoolean IsEmpty() const override;
552
553 // ICurve methods.
554 virtual double get_Length() const override;
555 virtual void StartPoint( OGRPoint * ) const override;
556 virtual void EndPoint( OGRPoint * ) const override;
557 virtual void Value( double, OGRPoint * ) const override;
558 virtual double Project( const OGRPoint * ) const;
559 virtual OGRLineString* getSubLine( double, double, int ) const;
560
561 // ILineString methods.
562 virtual int getNumPoints() const override { return nPointCount; }
563 void getPoint( int, OGRPoint * ) const;
564 double getX( int i ) const { return paoPoints[i].x; }
565 double getY( int i ) const { return paoPoints[i].y; }
566 double getZ( int i ) const;
567 double getM( int i ) const;
568
569 // ISpatialRelation
570 virtual OGRBoolean Equals( OGRGeometry * ) const override;
571
572 // non standard.
573 virtual void setCoordinateDimension( int nDimension ) override;
574 virtual void set3D( OGRBoolean bIs3D ) override;
575 virtual void setMeasured( OGRBoolean bIsMeasured ) override;
576 void setNumPoints( int nNewPointCount,
577 int bZeroizeNewContent = TRUE );
578 void setPoint( int, OGRPoint * );
579 void setPoint( int, double, double );
580 void setZ( int, double );
581 void setM( int, double );
582 void setPoint( int, double, double, double );
583 void setPointM( int, double, double, double );
584 void setPoint( int, double, double, double, double );
585 void setPoints( int, OGRRawPoint *, double * = nullptr );
586 void setPointsM( int, OGRRawPoint *, double * );
587 void setPoints( int, OGRRawPoint *, double *, double * );
588 void setPoints( int, double * padfX, double * padfY,
589 double *padfZIn = nullptr );
590 void setPointsM( int, double * padfX, double * padfY,
591 double *padfMIn = nullptr );
592 void setPoints( int, double * padfX, double * padfY,
593 double *padfZIn, double *padfMIn );
594 void addPoint( const OGRPoint * );
595 void addPoint( double, double );
596 void addPoint( double, double, double );
597 void addPointM( double, double, double );
598 void addPoint( double, double, double, double );
599
600 void getPoints( OGRRawPoint *, double * = nullptr ) const;
601 void getPoints( void* pabyX, int nXStride,
602 void* pabyY, int nYStride,
603 void* pabyZ = nullptr, int nZStride = 0 ) const;
604 void getPoints( void* pabyX, int nXStride,
605 void* pabyY, int nYStride,
606 void* pabyZ, int nZStride,
607 void* pabyM, int nMStride ) const;
608
609 void addSubLineString( const OGRLineString *,
610 int nStartVertex = 0, int nEndVertex = -1 );
611 void reversePoints( void );
612 virtual OGRPointIterator* getPointIterator() const override;
613
614 // non-standard from OGRGeometry
615 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
616 virtual void flattenTo2D() override;
617 virtual void segmentize(double dfMaxLength) override;
618
619 virtual void swapXY() override;
620};
621
622/************************************************************************/
623/* OGRLineString */
624/************************************************************************/
625
626/**
627 * Concrete representation of a multi-vertex line.
628 *
629 * Note: for implementation convenience, we make it inherit from OGRSimpleCurve
630 * whereas SFSQL and SQL/MM only make it inherits from OGRCurve.
631 */
632
633class CPL_DLL OGRLineString : public OGRSimpleCurve
634{
635 static OGRLinearRing* CasterToLinearRing(OGRCurve* poCurve);
636
637 protected:
638//! @cond Doxygen_Suppress
639 static OGRLineString* TransferMembersAndDestroy(
640 OGRLineString* poSrc,
641 OGRLineString* poDst);
642
643 virtual OGRCurveCasterToLineString GetCasterToLineString()
644 const override;
645 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing()
646 const override;
647
648 virtual double get_AreaOfCurveSegments() const override;
649//! @endcond
650
651 static OGRLinearRing* CastToLinearRing( OGRLineString* poLS );
652
653 public:
654 OGRLineString();
655 OGRLineString( const OGRLineString& other );
656 ~OGRLineString() override;
657
658 OGRLineString& operator=(const OGRLineString& other);
659
660 virtual OGRLineString* CurveToLine( double dfMaxAngleStepSizeDegrees = 0,
661 const char* const* papszOptions = nullptr )
662 const override;
663 virtual OGRGeometry* getCurveGeometry(
664 const char* const* papszOptions = nullptr ) const override;
665 virtual double get_Area() const override;
666
667 // Non-standard from OGRGeometry.
668 virtual OGRwkbGeometryType getGeometryType() const override;
669 virtual const char *getGeometryName() const override;
670};
671
672/************************************************************************/
673/* OGRLinearRing */
674/************************************************************************/
675
676/**
677 * Concrete representation of a closed ring.
678 *
679 * This class is functionally equivalent to an OGRLineString, but has a
680 * separate identity to maintain alignment with the OpenGIS simple feature
681 * data model. It exists to serve as a component of an OGRPolygon.
682 *
683 * The OGRLinearRing has no corresponding free standing well known binary
684 * representation, so importFromWkb() and exportToWkb() will not actually
685 * work. There is a non-standard GDAL WKT representation though.
686 *
687 * Because OGRLinearRing is not a "proper" free standing simple features
688 * object, it cannot be directly used on a feature via SetGeometry(), and
689 * cannot generally be used with GEOS for operations like Intersects().
690 * Instead the polygon should be used, or the OGRLinearRing should be
691 * converted to an OGRLineString for such operations.
692 *
693 * Note: this class exists in SFSQL 1.2, but not in ISO SQL/MM Part 3.
694 */
695
696class CPL_DLL OGRLinearRing : public OGRLineString
697{
698 static OGRLineString* CasterToLineString( OGRCurve* poCurve );
699
700 protected:
701//! @cond Doxygen_Suppress
702 friend class OGRPolygon;
703 friend class OGRTriangle;
704
705 // These are not IWks compatible ... just a convenience for OGRPolygon.
706 virtual int _WkbSize( int _flags ) const;
707 virtual OGRErr _importFromWkb( OGRwkbByteOrder, int _flags,
708 const unsigned char *, int,
709 int& nBytesConsumedOut );
710 virtual OGRErr _exportToWkb( OGRwkbByteOrder, int _flags,
711 unsigned char * ) const;
712
713 virtual OGRCurveCasterToLineString GetCasterToLineString()
714 const override;
715 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing()
716 const override;
717//! @endcond
718
719 static OGRLineString* CastToLineString( OGRLinearRing* poLR );
720
721 public:
722 OGRLinearRing();
723 OGRLinearRing( const OGRLinearRing& other );
724 explicit OGRLinearRing( OGRLinearRing * );
725 ~OGRLinearRing() override;
726
727 OGRLinearRing& operator=( const OGRLinearRing& other );
728
729 // Non standard.
730 virtual const char *getGeometryName() const override;
731 virtual OGRGeometry *clone() const override;
732 virtual int isClockwise() const;
733 virtual void reverseWindingOrder();
734 virtual void closeRings() override;
735 OGRBoolean isPointInRing( const OGRPoint* pt,
736 int bTestEnvelope = TRUE ) const;
737 OGRBoolean isPointOnRingBoundary( const OGRPoint* pt,
738 int bTestEnvelope = TRUE ) const;
739 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
740
741 // IWks Interface - Note this isn't really a first class object
742 // for the purposes of WKB form. These methods always fail since this
743 // object can't be serialized on its own.
744 virtual int WkbSize() const override;
745 virtual OGRErr importFromWkb( const unsigned char *,
746 int,
747 OGRwkbVariant,
748 int& nBytesConsumedOut ) override;
749 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
750 OGRwkbVariant=wkbVariantOldOgc )
751 const override;
752};
753
754/************************************************************************/
755/* OGRCircularString */
756/************************************************************************/
757
758/**
759 * Concrete representation of a circular string, that is to say a curve made
760 * of one or several arc circles.
761 *
762 * Note: for implementation convenience, we make it inherit from OGRSimpleCurve
763 * whereas SQL/MM only makes it inherits from OGRCurve.
764 *
765 * Compatibility: ISO SQL/MM Part 3.
766 *
767 * @since GDAL 2.0
768 */
769
770class CPL_DLL OGRCircularString : public OGRSimpleCurve
771{
772 private:
773 void ExtendEnvelopeWithCircular( OGREnvelope * psEnvelope ) const;
774 OGRBoolean IsValidFast() const;
775 int IsFullCircle( double& cx, double& cy, double& square_R ) const;
776
777 protected:
778//! @cond Doxygen_Suppress
779 virtual OGRCurveCasterToLineString GetCasterToLineString()
780 const override;
781 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing()
782 const override;
783 virtual int IntersectsPoint( const OGRPoint* p ) const override;
784 virtual int ContainsPoint( const OGRPoint* p ) const override;
785 virtual double get_AreaOfCurveSegments() const override;
786//! @endcond
787
788 public:
789 OGRCircularString();
790 OGRCircularString( const OGRCircularString& other );
791 ~OGRCircularString() override;
792
793 OGRCircularString& operator=(const OGRCircularString& other);
794
795 // IWks Interface.
796 virtual OGRErr importFromWkb( const unsigned char *,
797 int,
798 OGRwkbVariant,
799 int& nBytesConsumedOut ) override;
800 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
801 OGRwkbVariant=wkbVariantOldOgc )
802 const override;
803 virtual OGRErr importFromWkt( char ** ) override;
804 virtual OGRErr exportToWkt( char ** ppszDstText,
805 OGRwkbVariant=wkbVariantOldOgc )
806 const override;
807
808 // IGeometry interface.
809 virtual OGRBoolean IsValid() const override;
810 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
811 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
812
813 // ICurve methods.
814 virtual double get_Length() const override;
815 virtual OGRLineString* CurveToLine( double dfMaxAngleStepSizeDegrees = 0,
816 const char* const* papszOptions = nullptr )
817 const override;
818 virtual void Value( double, OGRPoint * ) const override;
819 virtual double get_Area() const override;
820
821 // Non-standard from OGRGeometry.
822 virtual OGRwkbGeometryType getGeometryType() const override;
823 virtual const char *getGeometryName() const override;
824 virtual void segmentize( double dfMaxLength ) override;
825 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
826 const override;
827 virtual OGRGeometry* getLinearGeometry(
828 double dfMaxAngleStepSizeDegrees = 0,
829 const char* const* papszOptions = nullptr) const override;
830};
831
832/************************************************************************/
833/* OGRCurveCollection */
834/************************************************************************/
835
836/**
837 * Utility class to store a collection of curves. Used as a member of
838 * OGRCompoundCurve and OGRCurvePolygon.
839 *
840 * This class is only exported because of linking issues. It should never
841 * be directly used.
842 *
843 * @since GDAL 2.0
844 */
845
846//! @cond Doxygen_Suppress
847class CPL_DLL OGRCurveCollection
848{
849 protected:
850 friend class OGRCompoundCurve;
851 friend class OGRCurvePolygon;
852 friend class OGRPolygon;
853 friend class OGRTriangle;
854
855 int nCurveCount;
856 OGRCurve **papoCurves;
857
858 public:
859 OGRCurveCollection();
860 OGRCurveCollection(const OGRCurveCollection& other);
861 ~OGRCurveCollection();
862
863 OGRCurveCollection& operator=(const OGRCurveCollection& other);
864
865 void empty(OGRGeometry* poGeom);
866 OGRBoolean IsEmpty() const;
867 void getEnvelope( OGREnvelope * psEnvelope ) const;
868 void getEnvelope( OGREnvelope3D * psEnvelope ) const;
869
870 OGRErr addCurveDirectly( OGRGeometry* poGeom, OGRCurve* poCurve,
871 int bNeedRealloc );
872 int WkbSize() const;
873 OGRErr importPreambleFromWkb( OGRGeometry* poGeom,
874 const unsigned char * pabyData,
875 int& nSize,
876 int& nDataOffset,
877 OGRwkbByteOrder& eByteOrder,
878 int nMinSubGeomSize,
879 OGRwkbVariant eWkbVariant );
880 OGRErr importBodyFromWkb(
881 OGRGeometry* poGeom,
882 const unsigned char * pabyData,
883 int nSize,
884 int bAcceptCompoundCurve,
885 OGRErr (*pfnAddCurveDirectlyFromWkb)( OGRGeometry* poGeom,
886 OGRCurve* poCurve ),
887 OGRwkbVariant eWkbVariant,
888 int& nBytesConsumedOut );
889 OGRErr exportToWkt( const OGRGeometry* poGeom,
890 char ** ppszDstText ) const;
891 OGRErr exportToWkb( const OGRGeometry* poGeom, OGRwkbByteOrder,
892 unsigned char *,
893 OGRwkbVariant eWkbVariant ) const;
894 OGRBoolean Equals(OGRCurveCollection *poOCC) const;
895 void setCoordinateDimension( OGRGeometry* poGeom,
896 int nNewDimension );
897 void set3D( OGRGeometry* poGeom, OGRBoolean bIs3D );
898 void setMeasured( OGRGeometry* poGeom, OGRBoolean bIsMeasured );
899 void assignSpatialReference( OGRGeometry* poGeom, OGRSpatialReference * poSR );
900 int getNumCurves() const;
901 OGRCurve *getCurve( int );
902 const OGRCurve *getCurve( int ) const;
903 OGRCurve *stealCurve( int );
904
905 OGRErr removeCurve( int iIndex, bool bDelete = true );
906
907 OGRErr transform( OGRGeometry* poGeom,
908 OGRCoordinateTransformation *poCT );
909 void flattenTo2D( OGRGeometry* poGeom );
910 void segmentize( double dfMaxLength );
911 void swapXY();
912 OGRBoolean hasCurveGeometry(int bLookForNonLinear) const;
913};
914//! @endcond
915
916/************************************************************************/
917/* OGRCompoundCurve */
918/************************************************************************/
919
920/**
921 * Concrete representation of a compound curve, made of curves: OGRLineString
922 * and OGRCircularString. Each curve is connected by its first point to
923 * the last point of the previous curve.
924 *
925 * Compatibility: ISO SQL/MM Part 3.
926 *
927 * @since GDAL 2.0
928 */
929
930class CPL_DLL OGRCompoundCurve : public OGRCurve
931{
932 private:
933 OGRCurveCollection oCC;
934
935 OGRErr addCurveDirectlyInternal( OGRCurve* poCurve,
936 double dfToleranceEps,
937 int bNeedRealloc );
938 static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf,
939 OGRCurve* poCurve );
940 static OGRErr addCurveDirectlyFromWkb( OGRGeometry* poSelf,
941 OGRCurve* poCurve );
942 OGRLineString* CurveToLineInternal( double dfMaxAngleStepSizeDegrees,
943 const char* const* papszOptions,
944 int bIsLinearRing ) const;
945 static OGRLineString* CasterToLineString( OGRCurve* poCurve );
946 static OGRLinearRing* CasterToLinearRing( OGRCurve* poCurve );
947
948 protected:
949//! @cond Doxygen_Suppress
950 static OGRLineString* CastToLineString( OGRCompoundCurve* poCC );
951 static OGRLinearRing* CastToLinearRing( OGRCompoundCurve* poCC );
952
953 virtual OGRCurveCasterToLineString GetCasterToLineString()
954 const override;
955 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing()
956 const override;
957//! @endcond
958
959 public:
960 OGRCompoundCurve();
961 OGRCompoundCurve( const OGRCompoundCurve& other );
962 ~OGRCompoundCurve() override;
963
964 OGRCompoundCurve& operator=( const OGRCompoundCurve& other );
965
966 // IWks Interface
967 virtual int WkbSize() const override;
968 virtual OGRErr importFromWkb( const unsigned char *,
969 int,
970 OGRwkbVariant,
971 int& nBytesConsumedOut ) override;
972 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
973 OGRwkbVariant=wkbVariantOldOgc )
974 const override;
975 virtual OGRErr importFromWkt( char ** ) override;
976 virtual OGRErr exportToWkt( char ** ppszDstText,
977 OGRwkbVariant=wkbVariantOldOgc )
978 const override;
979
980 // IGeometry interface.
981 virtual OGRGeometry *clone() const override;
982 virtual void empty() override;
983 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
984 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
985 virtual OGRBoolean IsEmpty() const override;
986
987 // ICurve methods.
988 virtual double get_Length() const override;
989 virtual void StartPoint( OGRPoint * ) const override;
990 virtual void EndPoint( OGRPoint * ) const override;
991 virtual void Value( double, OGRPoint * ) const override;
992 virtual OGRLineString* CurveToLine( double dfMaxAngleStepSizeDegrees = 0,
993 const char* const* papszOptions = nullptr )
994 const override;
995
996 virtual int getNumPoints() const override;
997 virtual double get_AreaOfCurveSegments() const override;
998 virtual double get_Area() const override;
999
1000 // ISpatialRelation.
1001 virtual OGRBoolean Equals( OGRGeometry * ) const override;
1002
1003 // ICompoundCurve method.
1004 int getNumCurves() const;
1005 OGRCurve *getCurve( int );
1006 const OGRCurve *getCurve( int ) const;
1007
1008 // Non-standard.
1009 virtual void setCoordinateDimension( int nDimension ) override;
1010 virtual void set3D( OGRBoolean bIs3D ) override;
1011 virtual void setMeasured( OGRBoolean bIsMeasured ) override;
1012
1013 virtual void assignSpatialReference( OGRSpatialReference * poSR ) override;
1014
1015 OGRErr addCurve( OGRCurve*, double dfToleranceEps = 1e-14 );
1016 OGRErr addCurveDirectly( OGRCurve*, double dfToleranceEps = 1e-14 );
1017 OGRCurve *stealCurve( int );
1018 virtual OGRPointIterator* getPointIterator() const override;
1019
1020 // Non-standard from OGRGeometry.
1021 virtual OGRwkbGeometryType getGeometryType() const override;
1022 virtual const char *getGeometryName() const override;
1023 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
1024 virtual void flattenTo2D() override;
1025 virtual void segmentize(double dfMaxLength) override;
1026 virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE)
1027 const override;
1028 virtual OGRGeometry* getLinearGeometry(
1029 double dfMaxAngleStepSizeDegrees = 0,
1030 const char* const* papszOptions = nullptr) const override;
1031
1032 virtual void swapXY() override;
1033};
1034
1035/************************************************************************/
1036/* OGRSurface */
1037/************************************************************************/
1038
1039/**
1040 * Abstract base class for 2 dimensional objects like polygons or curve
1041 * polygons.
1042 */
1043
1044class CPL_DLL OGRSurface : public OGRGeometry
1045{
1046 protected:
1047//! @cond Doxygen_Suppress
1048 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const = 0;
1049 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const = 0;
1050//! @endcond
1051
1052 public:
1053 virtual double get_Area() const = 0;
1054 virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const = 0;
1055//! @cond Doxygen_Suppress
1056 static OGRPolygon* CastToPolygon(OGRSurface* poSurface);
1057 static OGRCurvePolygon* CastToCurvePolygon(OGRSurface* poSurface);
1058//! @endcond
1059};
1060
1061/************************************************************************/
1062/* OGRCurvePolygon */
1063/************************************************************************/
1064
1065/**
1066 * Concrete class representing curve polygons.
1067 *
1068 * Note that curve polygons consist of one outer (curve) ring, and zero or
1069 * more inner rings. A curve polygon cannot represent disconnected
1070 * regions (such as multiple islands in a political body). The
1071 * OGRMultiSurface must be used for this.
1072 *
1073 * Compatibility: ISO SQL/MM Part 3.
1074 *
1075 * @since GDAL 2.0
1076 */
1077
1078class CPL_DLL OGRCurvePolygon : public OGRSurface
1079{
1080 static OGRPolygon* CasterToPolygon(OGRSurface* poSurface);
1081
1082 private:
1083 OGRBoolean IntersectsPoint( const OGRPoint* p ) const;
1084 OGRBoolean ContainsPoint( const OGRPoint* p ) const;
1085 virtual int checkRing( OGRCurve * poNewRing ) const;
1086 OGRErr addRingDirectlyInternal( OGRCurve* poCurve,
1087 int bNeedRealloc );
1088 static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf,
1089 OGRCurve* poCurve );
1090 static OGRErr addCurveDirectlyFromWkb( OGRGeometry* poSelf,
1091 OGRCurve* poCurve );
1092
1093 protected:
1094//! @cond Doxygen_Suppress
1095 friend class OGRPolygon;
1096 friend class OGRTriangle;
1097 OGRCurveCollection oCC;
1098
1099 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon()
1100 const override;
1101 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon()
1102 const override;
1103//! @endcond
1104
1105 static OGRPolygon* CastToPolygon( OGRCurvePolygon* poCP );
1106
1107 public:
1108 OGRCurvePolygon();
1109 OGRCurvePolygon( const OGRCurvePolygon& );
1110 ~OGRCurvePolygon() override;
1111
1112 OGRCurvePolygon& operator=( const OGRCurvePolygon& other );
1113
1114 // Non standard (OGRGeometry).
1115 virtual const char *getGeometryName() const override;
1116 virtual OGRwkbGeometryType getGeometryType() const override;
1117 virtual OGRGeometry *clone() const override;
1118 virtual void empty() override;
1119 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
1120 virtual void flattenTo2D() override;
1121 virtual OGRBoolean IsEmpty() const override;
1122 virtual void segmentize( double dfMaxLength ) override;
1123 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
1124 const override;
1125 virtual OGRGeometry* getLinearGeometry(
1126 double dfMaxAngleStepSizeDegrees = 0,
1127 const char* const* papszOptions = nullptr ) const override;
1128
1129 // ISurface Interface
1130 virtual double get_Area() const override;
1131 virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const override;
1132
1133 // IWks Interface
1134 virtual int WkbSize() const override;
1135 virtual OGRErr importFromWkb( const unsigned char *,
1136 int,
1137 OGRwkbVariant,
1138 int& nBytesConsumedOut ) override;
1139 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
1140 OGRwkbVariant=wkbVariantOldOgc )
1141 const override;
1142 virtual OGRErr importFromWkt( char ** ) override;
1143 virtual OGRErr exportToWkt( char ** ppszDstText,
1144 OGRwkbVariant eWkbVariant = wkbVariantOldOgc )
1145 const override;
1146
1147 // IGeometry
1148 virtual int getDimension() const override;
1149 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
1150 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
1151
1152 // ICurvePolygon
1153 virtual OGRPolygon* CurvePolyToPoly(
1154 double dfMaxAngleStepSizeDegrees = 0,
1155 const char* const* papszOptions = nullptr ) const;
1156
1157 // ISpatialRelation
1158 virtual OGRBoolean Equals( OGRGeometry * ) const override;
1159 virtual OGRBoolean Intersects( const OGRGeometry * ) const override;
1160 virtual OGRBoolean Contains( const OGRGeometry * ) const override;
1161
1162 // Non standard
1163 virtual void setCoordinateDimension( int nDimension ) override;
1164 virtual void set3D( OGRBoolean bIs3D ) override;
1165 virtual void setMeasured( OGRBoolean bIsMeasured ) override;
1166
1167 virtual void assignSpatialReference( OGRSpatialReference * poSR ) override;
1168
1169 virtual OGRErr addRing( OGRCurve * );
1170 virtual OGRErr addRingDirectly( OGRCurve * );
1171
1172 OGRCurve *getExteriorRingCurve();
1173 const OGRCurve *getExteriorRingCurve() const;
1174 int getNumInteriorRings() const;
1175 OGRCurve *getInteriorRingCurve( int );
1176 const OGRCurve *getInteriorRingCurve( int ) const;
1177
1178 OGRCurve *stealExteriorRingCurve();
1179
1180 OGRErr removeRing( int iIndex, bool bDelete = true );
1181
1182 virtual void swapXY() override;
1183};
1184
1185/************************************************************************/
1186/* OGRPolygon */
1187/************************************************************************/
1188
1189/**
1190 * Concrete class representing polygons.
1191 *
1192 * Note that the OpenGIS simple features polygons consist of one outer ring
1193 * (linearring), and zero or more inner rings. A polygon cannot represent
1194 * disconnected regions (such as multiple islands in a political body). The
1195 * OGRMultiPolygon must be used for this.
1196 */
1197
1198class CPL_DLL OGRPolygon : public OGRCurvePolygon
1199{
1200 static OGRCurvePolygon* CasterToCurvePolygon(OGRSurface* poSurface);
1201
1202 protected:
1203//! @cond Doxygen_Suppress
1204 friend class OGRMultiSurface;
1205 friend class OGRPolyhedralSurface;
1206 friend class OGRTriangulatedSurface;
1207
1208 virtual int checkRing( OGRCurve * poNewRing ) const override;
1209 virtual OGRErr importFromWKTListOnly( char ** ppszInput,
1210 int bHasZ, int bHasM,
1211 OGRRawPoint*& paoPoints,
1212 int& nMaxPoints,
1213 double*& padfZ );
1214
1215 static OGRCurvePolygon* CastToCurvePolygon(OGRPolygon* poPoly);
1216
1217 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon()
1218 const override;
1219 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon()
1220 const override;
1221//! @endcond
1222
1223 public:
1224 OGRPolygon();
1225 OGRPolygon(const OGRPolygon& other);
1226 ~OGRPolygon() override;
1227
1228 OGRPolygon& operator=(const OGRPolygon& other);
1229
1230 // Non-standard (OGRGeometry).
1231 virtual const char *getGeometryName() const override;
1232 virtual OGRwkbGeometryType getGeometryType() const override;
1233 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
1234 const override;
1235 virtual OGRGeometry* getCurveGeometry(
1236 const char* const* papszOptions = nullptr ) const override;
1237 virtual OGRGeometry* getLinearGeometry(
1238 double dfMaxAngleStepSizeDegrees = 0,
1239 const char* const* papszOptions = nullptr) const override;
1240
1241 // ISurface Interface.
1242 virtual OGRErr PointOnSurface( OGRPoint * poPoint )
1243 const override;
1244
1245 // IWks Interface.
1246 virtual int WkbSize() const override;
1247 virtual OGRErr importFromWkb( const unsigned char *,
1248 int,
1249 OGRwkbVariant,
1250 int& nBytesConsumedOut ) override;
1251 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
1252 OGRwkbVariant=wkbVariantOldOgc )
1253 const override;
1254 virtual OGRErr importFromWkt( char ** ) override;
1255 virtual OGRErr exportToWkt( char ** ppszDstText,
1256 OGRwkbVariant=wkbVariantOldOgc )
1257 const override;
1258
1259 // ICurvePolygon.
1260 virtual OGRPolygon* CurvePolyToPoly(
1261 double dfMaxAngleStepSizeDegrees = 0,
1262 const char* const* papszOptions = nullptr ) const override;
1263
1264 OGRLinearRing *getExteriorRing();
1265 const OGRLinearRing *getExteriorRing() const;
1266 virtual OGRLinearRing *getInteriorRing( int );
1267 virtual const OGRLinearRing *getInteriorRing( int ) const;
1268
1269 OGRLinearRing *stealExteriorRing();
1270 virtual OGRLinearRing *stealInteriorRing(int);
1271
1272 OGRBoolean IsPointOnSurface( const OGRPoint * ) const;
1273
1274 virtual void closeRings() override;
1275};
1276
1277/************************************************************************/
1278/* OGRTriangle */
1279/************************************************************************/
1280
1281/**
1282 * Triangle class.
1283 *
1284 * @since GDAL 2.2
1285 */
1286
1287class CPL_DLL OGRTriangle : public OGRPolygon
1288{
1289 private:
1290 static OGRPolygon* CasterToPolygon(OGRSurface* poSurface);
1291 bool quickValidityCheck() const;
1292
1293 protected:
1294//! @cond Doxygen_Suppress
1295 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
1296 virtual OGRErr importFromWKTListOnly( char ** ppszInput,
1297 int bHasZ, int bHasM,
1298 OGRRawPoint*& paoPoints,
1299 int& nMaxPoints,
1300 double*& padfZ ) override;
1301//! @endcond
1302
1303 public:
1304 OGRTriangle();
1305 OGRTriangle( const OGRPoint &p, const OGRPoint &q, const OGRPoint &r );
1306 OGRTriangle( const OGRTriangle &other );
1307 OGRTriangle( const OGRPolygon &other, OGRErr &eErr );
1308 OGRTriangle& operator=( const OGRTriangle& other );
1309 ~OGRTriangle() override;
1310 virtual const char *getGeometryName() const override;
1311 virtual OGRwkbGeometryType getGeometryType() const override;
1312
1313 // IWks Interface.
1314 virtual OGRErr importFromWkb( const unsigned char *,
1315 int,
1316 OGRwkbVariant,
1317 int& nBytesConsumedOut ) override;
1318
1319 // New methods rewritten from OGRPolygon/OGRCurvePolygon/OGRGeometry.
1320 virtual OGRErr addRingDirectly( OGRCurve * poNewRing ) override;
1321
1322//! @cond Doxygen_Suppress
1323 static OGRGeometry* CastToPolygon( OGRGeometry* poGeom );
1324//! @endcond
1325};
1326
1327/************************************************************************/
1328/* OGRGeometryCollection */
1329/************************************************************************/
1330
1331/**
1332 * A collection of 1 or more geometry objects.
1333 *
1334 * All geometries must share a common spatial reference system, and
1335 * Subclasses may impose additional restrictions on the contents.
1336 */
1337
1338class CPL_DLL OGRGeometryCollection : public OGRGeometry
1339{
1340 OGRErr importFromWkbInternal( const unsigned char * pabyData,
1341 int nSize,
1342 int nRecLevel,
1343 OGRwkbVariant, int& nBytesConsumedOut );
1344 OGRErr importFromWktInternal( char **ppszInput, int nRecLevel );
1345
1346 protected:
1347//! @cond Doxygen_Suppress
1348 int nGeomCount;
1349 OGRGeometry **papoGeoms;
1350
1351 OGRErr exportToWktInternal( char ** ppszDstText,
1352 OGRwkbVariant eWkbVariant,
1353 const char* pszSkipPrefix ) const;
1354 static OGRGeometryCollection* TransferMembersAndDestroy(
1355 OGRGeometryCollection* poSrc,
1356 OGRGeometryCollection* poDst );
1357//! @endcond
1358 virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const;
1359
1360 public:
1361 OGRGeometryCollection();
1362 OGRGeometryCollection( const OGRGeometryCollection& other );
1363 ~OGRGeometryCollection() override;
1364
1365 OGRGeometryCollection& operator=( const OGRGeometryCollection& other );
1366
1367 // Non standard (OGRGeometry).
1368 virtual const char *getGeometryName() const override;
1369 virtual OGRwkbGeometryType getGeometryType() const override;
1370 virtual OGRGeometry *clone() const override;
1371 virtual void empty() override;
1372 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
1373 virtual void flattenTo2D() override;
1374 virtual OGRBoolean IsEmpty() const override;
1375 virtual void segmentize(double dfMaxLength) override;
1376 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
1377 const override;
1378 virtual OGRGeometry* getCurveGeometry(
1379 const char* const* papszOptions = nullptr ) const override;
1380 virtual OGRGeometry* getLinearGeometry(
1381 double dfMaxAngleStepSizeDegrees = 0,
1382 const char* const* papszOptions = nullptr ) const override;
1383
1384 // IWks Interface
1385 virtual int WkbSize() const override;
1386 virtual OGRErr importFromWkb( const unsigned char *,
1387 int,
1388 OGRwkbVariant,
1389 int& nBytesConsumedOut ) override;
1390 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
1391 OGRwkbVariant=wkbVariantOldOgc )
1392 const override;
1393 virtual OGRErr importFromWkt( char ** ) override;
1394 virtual OGRErr exportToWkt( char ** ppszDstText,
1395 OGRwkbVariant=wkbVariantOldOgc )
1396 const override;
1397
1398 virtual double get_Length() const;
1399 virtual double get_Area() const;
1400
1401 // IGeometry methods
1402 virtual int getDimension() const override;
1403 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
1404 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
1405
1406 // IGeometryCollection
1407 int getNumGeometries() const;
1408 OGRGeometry *getGeometryRef( int );
1409 const OGRGeometry *getGeometryRef( int ) const;
1410
1411 // ISpatialRelation
1412 virtual OGRBoolean Equals( OGRGeometry * ) const override;
1413
1414 // Non standard
1415 virtual void setCoordinateDimension( int nDimension ) override;
1416 virtual void set3D( OGRBoolean bIs3D ) override;
1417 virtual void setMeasured( OGRBoolean bIsMeasured ) override;
1418 virtual OGRErr addGeometry( const OGRGeometry * );
1419 virtual OGRErr addGeometryDirectly( OGRGeometry * );
1420 virtual OGRErr removeGeometry( int iIndex, int bDelete = TRUE );
1421
1422 virtual void assignSpatialReference( OGRSpatialReference * poSR ) override;
1423
1424 void closeRings() override;
1425
1426 virtual void swapXY() override;
1427
1428 static OGRGeometryCollection* CastToGeometryCollection(
1429 OGRGeometryCollection* poSrc );
1430};
1431
1432/************************************************************************/
1433/* OGRMultiSurface */
1434/************************************************************************/
1435
1436/**
1437 * A collection of non-overlapping OGRSurface.
1438 *
1439 * @since GDAL 2.0
1440 */
1441
1442class CPL_DLL OGRMultiSurface : public OGRGeometryCollection
1443{
1444 protected:
1445 virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType )
1446 const override;
1447
1448 public:
1449 OGRMultiSurface();
1450 OGRMultiSurface( const OGRMultiSurface& other );
1451 ~OGRMultiSurface() override;
1452
1453 OGRMultiSurface& operator=( const OGRMultiSurface& other );
1454
1455 // Non standard (OGRGeometry).
1456 virtual const char *getGeometryName() const override;
1457 virtual OGRwkbGeometryType getGeometryType() const override;
1458 virtual OGRErr importFromWkt( char ** ) override;
1459 virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc )
1460 const override;
1461
1462 // IMultiSurface methods
1463 virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const;
1464
1465 // IGeometry methods
1466 virtual int getDimension() const override;
1467
1468 // Non standard
1469 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
1470 const override;
1471
1472 static OGRMultiPolygon* CastToMultiPolygon( OGRMultiSurface* poMS );
1473};
1474
1475/************************************************************************/
1476/* OGRMultiPolygon */
1477/************************************************************************/
1478
1479/**
1480 * A collection of non-overlapping OGRPolygon.
1481 */
1482
1483class CPL_DLL OGRMultiPolygon : public OGRMultiSurface
1484{
1485 protected:
1486 virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType )
1487 const override;
1488 friend class OGRPolyhedralSurface;
1489 friend class OGRTriangulatedSurface;
1490
1491 private:
1492//! @cond Doxygen_Suppress
1493 OGRErr _addGeometryWithExpectedSubGeometryType(
1494 const OGRGeometry * poNewGeom,
1495 OGRwkbGeometryType eSubGeometryType );
1496 OGRErr _addGeometryDirectlyWithExpectedSubGeometryType(
1497 OGRGeometry * poNewGeom,
1498 OGRwkbGeometryType eSubGeometryType );
1499//! @endcond
1500
1501
1502 public:
1503 OGRMultiPolygon();
1504 OGRMultiPolygon( const OGRMultiPolygon& other );
1505 ~OGRMultiPolygon() override;
1506
1507 OGRMultiPolygon& operator=(const OGRMultiPolygon& other);
1508
1509 // Non-standard (OGRGeometry).
1510 virtual const char *getGeometryName() const override;
1511 virtual OGRwkbGeometryType getGeometryType() const override;
1512 virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc )
1513 const override;
1514
1515 // IMultiSurface methods
1516 virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const override;
1517
1518 // Non standard
1519 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
1520 const override;
1521
1522 static OGRMultiSurface* CastToMultiSurface( OGRMultiPolygon* poMP );
1523};
1524
1525/************************************************************************/
1526/* OGRPolyhedralSurface */
1527/************************************************************************/
1528
1529/**
1530 * PolyhedralSurface class.
1531 *
1532 * @since GDAL 2.2
1533 */
1534
1535class CPL_DLL OGRPolyhedralSurface : public OGRSurface
1536{
1537 protected:
1538//! @cond Doxygen_Suppress
1539 friend class OGRTriangulatedSurface;
1540 OGRMultiPolygon oMP;
1541 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon()
1542 const override;
1543 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon()
1544 const override;
1545 virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const;
1546 virtual const char* getSubGeometryName() const;
1547 virtual OGRwkbGeometryType getSubGeometryType() const;
1548 OGRErr exportToWktInternal (char ** ppszDstText, OGRwkbVariant eWkbVariant,
1549 const char* pszSkipPrefix ) const;
1550
1551 virtual OGRPolyhedralSurfaceCastToMultiPolygon GetCasterToMultiPolygon()
1552 const;
1553 static OGRMultiPolygon* CastToMultiPolygonImpl(OGRPolyhedralSurface* poPS);
1554//! @endcond
1555
1556 public:
1557 OGRPolyhedralSurface();
1558 OGRPolyhedralSurface( const OGRPolyhedralSurface &poGeom );
1559 ~OGRPolyhedralSurface() override;
1560 OGRPolyhedralSurface& operator=(const OGRPolyhedralSurface& other);
1561
1562 // IWks Interface.
1563 virtual int WkbSize() const override;
1564 virtual const char *getGeometryName() const override;
1565 virtual OGRwkbGeometryType getGeometryType() const override;
1566 virtual OGRErr importFromWkb( const unsigned char *,
1567 int,
1568 OGRwkbVariant,
1569 int& nBytesConsumedOut ) override;
1570 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
1571 OGRwkbVariant=wkbVariantOldOgc )
1572 const override;
1573 virtual OGRErr importFromWkt( char ** ) override;
1574 virtual OGRErr exportToWkt( char ** ppszDstText,
1575 OGRwkbVariant=wkbVariantOldOgc )
1576 const override;
1577
1578 // IGeometry methods.
1579 virtual int getDimension() const override;
1580
1581 virtual void empty() override;
1582
1583 virtual OGRGeometry *clone() const override;
1584 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
1585 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
1586
1587 virtual void flattenTo2D() override;
1588 virtual OGRErr transform( OGRCoordinateTransformation* ) override;
1589 virtual OGRBoolean Equals( OGRGeometry* ) const override;
1590 virtual double get_Area() const override;
1591 virtual OGRErr PointOnSurface( OGRPoint* ) const override;
1592
1593 static OGRMultiPolygon* CastToMultiPolygon( OGRPolyhedralSurface* poPS );
1594 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
1595 const override;
1596 virtual OGRErr addGeometry( const OGRGeometry * );
1597 OGRErr addGeometryDirectly( OGRGeometry *poNewGeom );
1598 int getNumGeometries() const;
1599 OGRGeometry* getGeometryRef(int i);
1600 const OGRGeometry* getGeometryRef(int i) const;
1601
1602 virtual OGRBoolean IsEmpty() const override;
1603 virtual void setCoordinateDimension( int nDimension ) override;
1604 virtual void set3D( OGRBoolean bIs3D ) override;
1605 virtual void setMeasured( OGRBoolean bIsMeasured ) override;
1606 virtual void swapXY() override;
1607 OGRErr removeGeometry( int iIndex, int bDelete = TRUE );
1608
1609 virtual void assignSpatialReference( OGRSpatialReference * poSR ) override;
1610};
1611
1612/************************************************************************/
1613/* OGRTriangulatedSurface */
1614/************************************************************************/
1615
1616/**
1617 * TriangulatedSurface class.
1618 *
1619 * @since GDAL 2.2
1620 */
1621
1622class CPL_DLL OGRTriangulatedSurface : public OGRPolyhedralSurface
1623{
1624 protected:
1625//! @cond Doxygen_Suppress
1626 virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType )
1627 const override;
1628 virtual const char* getSubGeometryName() const override;
1629 virtual OGRwkbGeometryType getSubGeometryType() const override;
1630
1631 virtual OGRPolyhedralSurfaceCastToMultiPolygon GetCasterToMultiPolygon()
1632 const override;
1633 static OGRMultiPolygon *
1634 CastToMultiPolygonImpl( OGRPolyhedralSurface* poPS );
1635//! @endcond
1636
1637 public:
1638 OGRTriangulatedSurface();
1639 OGRTriangulatedSurface( const OGRTriangulatedSurface &other );
1640 ~OGRTriangulatedSurface();
1641
1642 OGRTriangulatedSurface& operator=( const OGRTriangulatedSurface& other );
1643 virtual const char *getGeometryName() const override;
1644 virtual OGRwkbGeometryType getGeometryType() const override;
1645
1646 // IWks Interface.
1647 virtual OGRErr addGeometry( const OGRGeometry * ) override;
1648
1649 static OGRPolyhedralSurface *
1650 CastToPolyhedralSurface( OGRTriangulatedSurface* poTS );
1651};
1652
1653/************************************************************************/
1654/* OGRMultiPoint */
1655/************************************************************************/
1656
1657/**
1658 * A collection of OGRPoint.
1659 */
1660
1661class CPL_DLL OGRMultiPoint : public OGRGeometryCollection
1662{
1663 private:
1664 OGRErr importFromWkt_Bracketed( char **, int bHasM, int bHasZ );
1665
1666 protected:
1667 virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType )
1668 const override;
1669
1670 public:
1671 OGRMultiPoint();
1672 OGRMultiPoint(const OGRMultiPoint& other);
1673 ~OGRMultiPoint() override;
1674
1675 OGRMultiPoint& operator=(const OGRMultiPoint& other);
1676
1677 // Non-standard (OGRGeometry).
1678 virtual const char *getGeometryName() const override;
1679 virtual OGRwkbGeometryType getGeometryType() const override;
1680 virtual OGRErr importFromWkt( char ** ) override;
1681 virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc )
1682 const override;
1683
1684 // IGeometry methods.
1685 virtual int getDimension() const override;
1686
1687 // Non-standard.
1688 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
1689 const override;
1690};
1691
1692/************************************************************************/
1693/* OGRMultiCurve */
1694/************************************************************************/
1695
1696/**
1697 * A collection of OGRCurve.
1698 *
1699 * @since GDAL 2.0
1700 */
1701
1702class CPL_DLL OGRMultiCurve : public OGRGeometryCollection
1703{
1704 protected:
1705//! @cond Doxygen_Suppress
1706 static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf,
1707 OGRCurve* poCurve );
1708//! @endcond
1709 virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType )
1710 const override;
1711
1712 public:
1713 OGRMultiCurve();
1714 OGRMultiCurve( const OGRMultiCurve& other );
1715 ~OGRMultiCurve() override;
1716
1717 OGRMultiCurve& operator=( const OGRMultiCurve& other );
1718
1719 // Non standard (OGRGeometry).
1720 virtual const char *getGeometryName() const override;
1721 virtual OGRwkbGeometryType getGeometryType() const override;
1722 virtual OGRErr importFromWkt( char ** ) override;
1723 virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc )
1724 const override;
1725
1726 // IGeometry methods.
1727 virtual int getDimension() const override;
1728
1729 // Non-standard.
1730 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
1731 const override;
1732
1733 static OGRMultiLineString* CastToMultiLineString(OGRMultiCurve* poMC);
1734};
1735
1736/************************************************************************/
1737/* OGRMultiLineString */
1738/************************************************************************/
1739
1740/**
1741 * A collection of OGRLineString.
1742 */
1743
1744class CPL_DLL OGRMultiLineString : public OGRMultiCurve
1745{
1746 protected:
1747 virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType )
1748 const override;
1749
1750 public:
1751 OGRMultiLineString();
1752 OGRMultiLineString( const OGRMultiLineString& other );
1753 ~OGRMultiLineString() override;
1754
1755 OGRMultiLineString& operator=( const OGRMultiLineString& other );
1756
1757 // Non standard (OGRGeometry).
1758 virtual const char *getGeometryName() const override;
1759 virtual OGRwkbGeometryType getGeometryType() const override;
1760 virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc )
1761 const override;
1762
1763 // Non standard
1764 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
1765 const override;
1766
1767 static OGRMultiCurve* CastToMultiCurve( OGRMultiLineString* poMLS );
1768};
1769
1770/************************************************************************/
1771/* OGRGeometryFactory */
1772/************************************************************************/
1773
1774/**
1775 * Create geometry objects from well known text/binary.
1776 */
1777
1778class CPL_DLL OGRGeometryFactory
1779{
1780 static OGRErr createFromFgfInternal( unsigned char *pabyData,
1781 OGRSpatialReference * poSR,
1782 OGRGeometry **ppoReturn,
1783 int nBytes,
1784 int *pnBytesConsumed,
1785 int nRecLevel );
1786 public:
1787 static OGRErr createFromWkb( unsigned char *, OGRSpatialReference *,
1788 OGRGeometry **, int = -1,
1789 OGRwkbVariant=wkbVariantOldOgc );
1790 static OGRErr createFromWkb( const unsigned char * pabyData,
1791 OGRSpatialReference *,
1792 OGRGeometry **,
1793 int nSize,
1794 OGRwkbVariant eVariant,
1795 int& nBytesConsumedOut );
1796
1797 static OGRErr createFromWkt( char **, OGRSpatialReference *,
1798 OGRGeometry ** );
1799 static OGRErr createFromFgf( unsigned char *, OGRSpatialReference *,
1800 OGRGeometry **, int = -1, int * = nullptr );
1801 static OGRGeometry *createFromGML( const char * );
1802 static OGRGeometry *createFromGEOS( GEOSContextHandle_t hGEOSCtxt,
1803 GEOSGeom );
1804 static OGRGeometry *createFromGeoJson( const char *);
1805 static OGRGeometry *createFromGeoJson( const CPLJSONObject &oJSONObject );
1806
1807 static void destroyGeometry( OGRGeometry * );
1808 static OGRGeometry *createGeometry( OGRwkbGeometryType );
1809
1810 static OGRGeometry * forceToPolygon( OGRGeometry * );
1811 static OGRGeometry * forceToLineString( OGRGeometry *,
1812 bool bOnlyInOrder = true );
1813 static OGRGeometry * forceToMultiPolygon( OGRGeometry * );
1814 static OGRGeometry * forceToMultiPoint( OGRGeometry * );
1815 static OGRGeometry * forceToMultiLineString( OGRGeometry * );
1816
1817 static OGRGeometry * forceTo( OGRGeometry* poGeom,
1818 OGRwkbGeometryType eTargetType,
1819 const char*const* papszOptions = nullptr );
1820
1821 static OGRGeometry * organizePolygons( OGRGeometry **papoPolygons,
1822 int nPolygonCount,
1823 int *pbResultValidGeometry,
1824 const char **papszOptions = nullptr);
1825 static bool haveGEOS();
1826
1827 static OGRGeometry* transformWithOptions( const OGRGeometry* poSrcGeom,
1828 OGRCoordinateTransformation *poCT,
1829 char** papszOptions );
1830
1831 static OGRGeometry*
1832 approximateArcAngles( double dfX, double dfY, double dfZ,
1833 double dfPrimaryRadius, double dfSecondaryAxis,
1834 double dfRotation,
1835 double dfStartAngle, double dfEndAngle,
1836 double dfMaxAngleStepSizeDegrees );
1837
1838 static int GetCurveParmeters( double x0, double y0,
1839 double x1, double y1,
1840 double x2, double y2,
1841 double& R, double& cx, double& cy,
1842 double& alpha0, double& alpha1,
1843 double& alpha2 );
1844 static OGRLineString* curveToLineString(
1845 double x0, double y0, double z0,
1846 double x1, double y1, double z1,
1847 double x2, double y2, double z2,
1848 int bHasZ,
1849 double dfMaxAngleStepSizeDegrees,
1850 const char* const * papszOptions = nullptr );
1851 static OGRCurve* curveFromLineString(
1852 const OGRLineString* poLS,
1853 const char* const * papszOptions = nullptr);
1854};
1855
1856OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType( const char *pszGeomType );
1857const char CPL_DLL * OGRToOGCGeomType( OGRwkbGeometryType eGeomType );
1858
1859/** Prepared geometry API (needs GEOS >= 3.1.0) */
1860typedef struct _OGRPreparedGeometry OGRPreparedGeometry;
1861int OGRHasPreparedGeometrySupport();
1862OGRPreparedGeometry* OGRCreatePreparedGeometry( const OGRGeometry* poGeom );
1863void OGRDestroyPreparedGeometry( OGRPreparedGeometry* poPreparedGeom );
1864int OGRPreparedGeometryIntersects( const OGRPreparedGeometry* poPreparedGeom,
1865 const OGRGeometry* poOtherGeom );
1866int OGRPreparedGeometryContains( const OGRPreparedGeometry* poPreparedGeom,
1867 const OGRGeometry* poOtherGeom );
1868
1869#endif /* ndef OGR_GEOMETRY_H_INCLUDED */
Note: See TracBrowser for help on using the repository browser.