GDAL
ogr_geometry.h
Go to the documentation of this file.
1/******************************************************************************
2 * $Id: ogr_geometry.h 9f57a8d3c5f327cb02bb78ef23479c4b74143220 2021-05-22 00:41:26 +0200 Momtchil Momtchev $
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 spatialys.com>
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_conv.h"
36#include "cpl_json.h"
37#include "ogr_core.h"
38#include "ogr_spatialref.h"
39
40#include <cmath>
41#include <memory>
42
48
50#ifndef DEFINEH_OGRGeometryH
51#define DEFINEH_OGRGeometryH
52#ifdef DEBUG
53typedef struct OGRGeometryHS *OGRGeometryH;
54#else
55typedef void *OGRGeometryH;
56#endif
57#endif /* DEFINEH_OGRGeometryH */
59
61enum class OGRWktFormat
62{
63 F,
64 G,
66};
67
69struct CPL_DLL OGRWktOptions
70{
71public:
77 bool round;
80
84 {
85 static int defPrecision = getDefaultPrecision();
86 static bool defRound = getDefaultRound();
87
88 precision = defPrecision;
89 round = defRound;
90 }
91
93 OGRWktOptions(const OGRWktOptions&) = default;
94
95private:
96 static int getDefaultPrecision();
97 static bool getDefaultRound();
98};
99
104{
105 public:
107 OGRRawPoint() : x(0.0), y(0.0) {}
108
110 OGRRawPoint(double xIn, double yIn) : x(xIn), y(yIn) {}
111
113 double x;
115 double y;
116};
117
119typedef struct GEOSGeom_t *GEOSGeom;
121typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
123typedef void sfcgal_geometry_t;
124
125class OGRPoint;
126class OGRCurve;
127class OGRCompoundCurve;
128class OGRSimpleCurve;
129class OGRLinearRing;
130class OGRLineString;
132class OGRSurface;
133class OGRCurvePolygon;
134class OGRPolygon;
135class OGRMultiPoint;
136class OGRMultiSurface;
137class OGRMultiPolygon;
138class OGRMultiCurve;
141class OGRTriangle;
144
146typedef OGRLineString* (*OGRCurveCasterToLineString)(OGRCurve*);
147typedef OGRLinearRing* (*OGRCurveCasterToLinearRing)(OGRCurve*);
148
149typedef OGRPolygon* (*OGRSurfaceCasterToPolygon)(OGRSurface*);
150typedef OGRCurvePolygon* (*OGRSurfaceCasterToCurvePolygon)(OGRSurface*);
151typedef OGRMultiPolygon* (*OGRPolyhedralSurfaceCastToMultiPolygon)(OGRPolyhedralSurface*);
153
158{
159 public:
161 virtual ~IOGRGeometryVisitor() = default;
162
164 virtual void visit(OGRPoint*) = 0;
166 virtual void visit(OGRLineString*) = 0;
168 virtual void visit(OGRLinearRing*) = 0;
170 virtual void visit(OGRPolygon*) = 0;
172 virtual void visit(OGRMultiPoint*) = 0;
174 virtual void visit(OGRMultiLineString*) = 0;
176 virtual void visit(OGRMultiPolygon*) = 0;
178 virtual void visit(OGRGeometryCollection*) = 0;
180 virtual void visit(OGRCircularString*) = 0;
182 virtual void visit(OGRCompoundCurve*) = 0;
184 virtual void visit(OGRCurvePolygon*) = 0;
186 virtual void visit(OGRMultiCurve*) = 0;
188 virtual void visit(OGRMultiSurface*) = 0;
190 virtual void visit(OGRTriangle*) = 0;
192 virtual void visit(OGRPolyhedralSurface*) = 0;
194 virtual void visit(OGRTriangulatedSurface*) = 0;
195};
196
205{
206 void _visit(OGRSimpleCurve* poGeom);
207
208 public:
209
210 void visit(OGRPoint*) override {}
211 void visit(OGRLineString*) override;
212 void visit(OGRLinearRing*) override;
213 void visit(OGRPolygon*) override;
214 void visit(OGRMultiPoint*) override;
215 void visit(OGRMultiLineString*) override;
216 void visit(OGRMultiPolygon*) override;
217 void visit(OGRGeometryCollection*) override;
218 void visit(OGRCircularString*) override;
219 void visit(OGRCompoundCurve*) override;
220 void visit(OGRCurvePolygon*) override;
221 void visit(OGRMultiCurve*) override;
222 void visit(OGRMultiSurface*) override;
223 void visit(OGRTriangle*) override;
224 void visit(OGRPolyhedralSurface*) override;
225 void visit(OGRTriangulatedSurface*) override;
226};
227
232{
233 public:
235 virtual ~IOGRConstGeometryVisitor() = default;
236
238 virtual void visit(const OGRPoint*) = 0;
240 virtual void visit(const OGRLineString*) = 0;
242 virtual void visit(const OGRLinearRing*) = 0;
244 virtual void visit(const OGRPolygon*) = 0;
246 virtual void visit(const OGRMultiPoint*) = 0;
248 virtual void visit(const OGRMultiLineString*) = 0;
250 virtual void visit(const OGRMultiPolygon*) = 0;
252 virtual void visit(const OGRGeometryCollection*) = 0;
254 virtual void visit(const OGRCircularString*) = 0;
256 virtual void visit(const OGRCompoundCurve*) = 0;
258 virtual void visit(const OGRCurvePolygon*) = 0;
260 virtual void visit(const OGRMultiCurve*) = 0;
262 virtual void visit(const OGRMultiSurface*) = 0;
264 virtual void visit(const OGRTriangle*) = 0;
266 virtual void visit(const OGRPolyhedralSurface*) = 0;
268 virtual void visit(const OGRTriangulatedSurface*) = 0;
269};
270
279{
280 void _visit(const OGRSimpleCurve* poGeom);
281
282 public:
283
284 void visit(const OGRPoint*) override {}
285 void visit(const OGRLineString*) override;
286 void visit(const OGRLinearRing*) override;
287 void visit(const OGRPolygon*) override;
288 void visit(const OGRMultiPoint*) override;
289 void visit(const OGRMultiLineString*) override;
290 void visit(const OGRMultiPolygon*) override;
291 void visit(const OGRGeometryCollection*) override;
292 void visit(const OGRCircularString*) override;
293 void visit(const OGRCompoundCurve*) override;
294 void visit(const OGRCurvePolygon*) override;
295 void visit(const OGRMultiCurve*) override;
296 void visit(const OGRMultiSurface*) override;
297 void visit(const OGRTriangle*) override;
298 void visit(const OGRPolyhedralSurface*) override;
299 void visit(const OGRTriangulatedSurface*) override;
300};
301
302/************************************************************************/
303/* OGRGeometry */
304/************************************************************************/
305
325
326class CPL_DLL OGRGeometry
327{
328 private:
329 OGRSpatialReference * poSRS = nullptr; // may be NULL
330
331 protected:
333 friend class OGRCurveCollection;
334
335 unsigned int flags = 0;
336
337 OGRErr importPreambleFromWkt( const char ** ppszInput,
338 int* pbHasZ, int* pbHasM,
339 bool* pbIsEmpty );
340 OGRErr importCurveCollectionFromWkt(
341 const char ** ppszInput,
342 int bAllowEmptyComponent,
343 int bAllowLineString,
344 int bAllowCurve,
345 int bAllowCompoundCurve,
346 OGRErr (*pfnAddCurveDirectly)(OGRGeometry* poSelf,
347 OGRCurve* poCurve) );
348 OGRErr importPreambleFromWkb( const unsigned char * pabyData,
349 size_t nSize,
350 OGRwkbByteOrder& eByteOrder,
351 OGRwkbVariant eWkbVariant );
352 OGRErr importPreambleOfCollectionFromWkb(
353 const unsigned char * pabyData,
354 size_t& nSize,
355 size_t& nDataOffset,
356 OGRwkbByteOrder& eByteOrder,
357 size_t nMinSubGeomSize,
358 int& nGeomCount,
359 OGRwkbVariant eWkbVariant );
360 OGRErr PointOnSurfaceInternal( OGRPoint * poPoint ) const;
361 OGRBoolean IsSFCGALCompatible() const;
362
363 void HomogenizeDimensionalityWith( OGRGeometry* poOtherGeom );
364 std::string wktTypeString(OGRwkbVariant variant) const;
365
367
368 public:
369
370/************************************************************************/
371/* Bit flags for OGRGeometry */
372/* The OGR_G_NOT_EMPTY_POINT is used *only* for points. */
373/* Do not use these outside of the core. */
374/* Use Is3D, IsMeasured, set3D, and setMeasured instead */
375/************************************************************************/
376
378 static const unsigned int OGR_G_NOT_EMPTY_POINT = 0x1;
379 static const unsigned int OGR_G_3D = 0x2;
380 static const unsigned int OGR_G_MEASURED = 0x4;
382
383 OGRGeometry();
384 OGRGeometry( const OGRGeometry& other );
385 virtual ~OGRGeometry();
386
387 OGRGeometry& operator=( const OGRGeometry& other );
388
390 bool operator==( const OGRGeometry& other ) const { return CPL_TO_BOOL(Equals(&other)); }
391
393 bool operator!=( const OGRGeometry& other ) const { return !CPL_TO_BOOL(Equals(&other)); }
394
395 // Standard IGeometry.
396 virtual int getDimension() const = 0;
397 virtual int getCoordinateDimension() const;
398 int CoordinateDimension() const;
399 virtual OGRBoolean IsEmpty() const = 0;
400 virtual OGRBoolean IsValid() const;
401 virtual OGRGeometry* MakeValid(CSLConstList papszOptions = nullptr) const;
402 virtual OGRGeometry* Normalize() const;
403 virtual OGRBoolean IsSimple() const;
405 OGRBoolean Is3D() const { return flags & OGR_G_3D; }
407 OGRBoolean IsMeasured() const { return flags & OGR_G_MEASURED; }
408 virtual OGRBoolean IsRing() const;
409 virtual void empty() = 0;
410 virtual OGRGeometry *clone() const CPL_WARN_UNUSED_RESULT = 0;
411 virtual void getEnvelope( OGREnvelope * psEnvelope ) const = 0;
412 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const = 0;
413
414 // IWks Interface.
415 virtual size_t WkbSize() const = 0;
416 OGRErr importFromWkb( const GByte*, size_t=static_cast<size_t>(-1),
418 virtual OGRErr importFromWkb( const unsigned char *,
419 size_t,
421 size_t& nBytesConsumedOut ) = 0;
422 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
424 virtual OGRErr importFromWkt( const char ** ppszInput ) = 0;
425
426#ifndef DOXYGEN_XML
430 OGRErr importFromWkt( char ** ppszInput )
432 CPL_WARN_DEPRECATED("Use importFromWkt(const char**) instead")
434 {
435 return importFromWkt( const_cast<const char**>(ppszInput) );
436 }
437#endif
438
439 OGRErr exportToWkt( char ** ppszDstText,
441
446 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
447 OGRErr *err = nullptr) const = 0;
448
449 // Non-standard.
452 virtual const char *getGeometryName() const = 0;
453 virtual void dumpReadable( FILE *, const char * = nullptr
454 , char** papszOptions = nullptr ) const;
455 virtual void flattenTo2D() = 0;
456 virtual char * exportToGML( const char* const * papszOptions = nullptr ) const;
457 virtual char * exportToKML() const;
458 virtual char * exportToJson() const;
459
461 virtual void accept(IOGRGeometryVisitor* visitor) = 0;
462
464 virtual void accept(IOGRConstGeometryVisitor* visitor) const = 0;
465
467 static void freeGEOSContext( GEOSContextHandle_t hGEOSCtxt );
468 virtual GEOSGeom exportToGEOS( GEOSContextHandle_t hGEOSCtxt )
470 virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
471 virtual OGRGeometry* getCurveGeometry(
472 const char* const* papszOptions = nullptr ) const CPL_WARN_UNUSED_RESULT;
473 virtual OGRGeometry* getLinearGeometry(
474 double dfMaxAngleStepSizeDegrees = 0,
475 const char* const* papszOptions = nullptr ) const CPL_WARN_UNUSED_RESULT;
476
477 // SFCGAL interfacing methods.
479 static sfcgal_geometry_t* OGRexportToSFCGAL( const OGRGeometry *poGeom );
480 static OGRGeometry* SFCGALexportToOGR( const sfcgal_geometry_t* _geometry );
482 virtual void closeRings();
483
484 virtual void setCoordinateDimension( int nDimension );
485 virtual void set3D( OGRBoolean bIs3D );
486 virtual void setMeasured( OGRBoolean bIsMeasured );
487
488 virtual void assignSpatialReference( OGRSpatialReference * poSR );
489 OGRSpatialReference *getSpatialReference( void ) const { return poSRS; }
490
493
494 virtual void segmentize(double dfMaxLength);
495
496 // ISpatialRelation
497 virtual OGRBoolean Intersects( const OGRGeometry * ) const;
498 virtual OGRBoolean Equals( const OGRGeometry * ) const = 0;
499 virtual OGRBoolean Disjoint( const OGRGeometry * ) const;
500 virtual OGRBoolean Touches( const OGRGeometry * ) const;
501 virtual OGRBoolean Crosses( const OGRGeometry * ) const;
502 virtual OGRBoolean Within( const OGRGeometry * ) const;
503 virtual OGRBoolean Contains( const OGRGeometry * ) const;
504 virtual OGRBoolean Overlaps( const OGRGeometry * ) const;
505// virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
506// virtual OGRGeometry *LocateAlong( double mValue ) const;
507// virtual OGRGeometry *LocateBetween( double mStart, double mEnd ) const;
508
509 virtual OGRGeometry *Boundary() const CPL_WARN_UNUSED_RESULT;
510 virtual double Distance( const OGRGeometry * ) const ;
511 virtual OGRGeometry *ConvexHull() const CPL_WARN_UNUSED_RESULT;
512 virtual OGRGeometry *Buffer( double dfDist, int nQuadSegs = 30 )
514 virtual OGRGeometry *Intersection( const OGRGeometry *)
516 virtual OGRGeometry *Union( const OGRGeometry * )
518 virtual OGRGeometry *UnionCascaded() const CPL_WARN_UNUSED_RESULT;
519 virtual OGRGeometry *Difference( const OGRGeometry * )
521 virtual OGRGeometry *SymDifference( const OGRGeometry * )
523 virtual OGRErr Centroid( OGRPoint * poPoint ) const;
524 virtual OGRGeometry *Simplify(double dTolerance)
526 OGRGeometry *SimplifyPreserveTopology(double dTolerance)
528 virtual OGRGeometry *DelaunayTriangulation(
529 double dfTolerance, int bOnlyEdges ) const CPL_WARN_UNUSED_RESULT;
530
531 virtual OGRGeometry *Polygonize() const CPL_WARN_UNUSED_RESULT;
532
533 virtual double Distance3D( const OGRGeometry *poOtherGeom ) const;
534
536 // backward compatibility to non-standard method names.
537 OGRBoolean Intersect( OGRGeometry * )
538 const CPL_WARN_DEPRECATED("Non standard method. "
539 "Use Intersects() instead");
540 OGRBoolean Equal( OGRGeometry * )
541 const CPL_WARN_DEPRECATED("Non standard method. "
542 "Use Equals() instead");
543 OGRGeometry *SymmetricDifference( const OGRGeometry * )
544 const CPL_WARN_DEPRECATED("Non standard method. "
545 "Use SymDifference() instead");
546 OGRGeometry *getBoundary()
547 const CPL_WARN_DEPRECATED("Non standard method. "
548 "Use Boundary() instead");
550
552 // Special HACK for DB2 7.2 support
553 static int bGenerate_DB2_V72_BYTE_ORDER;
555
556 virtual void swapXY();
558 static OGRGeometry* CastToIdentity( OGRGeometry* poGeom ) { return poGeom; }
559 static OGRGeometry* CastToError( OGRGeometry* poGeom );
561
565 static inline OGRGeometryH ToHandle(OGRGeometry* poGeom)
566 { return reinterpret_cast<OGRGeometryH>(poGeom); }
567
571 static inline OGRGeometry* FromHandle(OGRGeometryH hGeom)
572 { return reinterpret_cast<OGRGeometry*>(hGeom); }
573
579 { return cpl::down_cast<OGRPoint*>(this); }
580
585 inline const OGRPoint* toPoint() const
586 { return cpl::down_cast<const OGRPoint*>(this); }
587
593 { return cpl::down_cast<OGRCurve*>(this); }
594
599 inline const OGRCurve* toCurve() const
600 { return cpl::down_cast<const OGRCurve*>(this); }
601
608
613 inline const OGRSimpleCurve* toSimpleCurve() const
615
622
627 inline const OGRLineString* toLineString() const
629
636
641 inline const OGRLinearRing* toLinearRing() const
643
650
657
664
671
677 { return cpl::down_cast<OGRSurface*>(this); }
678
683 inline const OGRSurface* toSurface() const
684 { return cpl::down_cast<const OGRSurface*>(this); }
685
691 { return cpl::down_cast<OGRPolygon*>(this); }
692
697 inline const OGRPolygon* toPolygon() const
698 { return cpl::down_cast<const OGRPolygon*>(this); }
699
705 { return cpl::down_cast<OGRTriangle*>(this); }
706
711 inline const OGRTriangle* toTriangle() const
712 { return cpl::down_cast<const OGRTriangle*>(this); }
713
720
725 inline const OGRCurvePolygon* toCurvePolygon() const
727
734
741
748
753 inline const OGRMultiPoint* toMultiPoint() const
755
762
769
776
781 inline const OGRMultiPolygon* toMultiPolygon() const
783
790
795 inline const OGRMultiCurve* toMultiCurve() const
797
804
809 inline const OGRMultiSurface* toMultiSurface() const
811
818
825
832
839
840};
841
843struct CPL_DLL OGRGeometryUniquePtrDeleter
844{
845 void operator()(OGRGeometry*) const;
846};
848
852typedef std::unique_ptr<OGRGeometry, OGRGeometryUniquePtrDeleter> OGRGeometryUniquePtr;
853
854
856#define OGR_FORBID_DOWNCAST_TO(name) \
857 inline OGR ## name * to ## name() = delete; \
858 inline const OGR ## name * to ## name() const = delete;
859
860#define OGR_FORBID_DOWNCAST_TO_POINT OGR_FORBID_DOWNCAST_TO(Point)
861#define OGR_FORBID_DOWNCAST_TO_CURVE OGR_FORBID_DOWNCAST_TO(Curve)
862#define OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE OGR_FORBID_DOWNCAST_TO(SimpleCurve)
863#define OGR_FORBID_DOWNCAST_TO_LINESTRING OGR_FORBID_DOWNCAST_TO(LineString)
864#define OGR_FORBID_DOWNCAST_TO_LINEARRING OGR_FORBID_DOWNCAST_TO(LinearRing)
865#define OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING OGR_FORBID_DOWNCAST_TO(CircularString)
866#define OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE OGR_FORBID_DOWNCAST_TO(CompoundCurve)
867#define OGR_FORBID_DOWNCAST_TO_SURFACE OGR_FORBID_DOWNCAST_TO(Surface)
868#define OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON OGR_FORBID_DOWNCAST_TO(CurvePolygon)
869#define OGR_FORBID_DOWNCAST_TO_POLYGON OGR_FORBID_DOWNCAST_TO(Polygon)
870#define OGR_FORBID_DOWNCAST_TO_TRIANGLE OGR_FORBID_DOWNCAST_TO(Triangle)
871#define OGR_FORBID_DOWNCAST_TO_MULTIPOINT OGR_FORBID_DOWNCAST_TO(MultiPoint)
872#define OGR_FORBID_DOWNCAST_TO_MULTICURVE OGR_FORBID_DOWNCAST_TO(MultiCurve)
873#define OGR_FORBID_DOWNCAST_TO_MULTILINESTRING OGR_FORBID_DOWNCAST_TO(MultiLineString)
874#define OGR_FORBID_DOWNCAST_TO_MULTISURFACE OGR_FORBID_DOWNCAST_TO(MultiSurface)
875#define OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON OGR_FORBID_DOWNCAST_TO(MultiPolygon)
876#define OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION OGR_FORBID_DOWNCAST_TO(GeometryCollection)
877#define OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE OGR_FORBID_DOWNCAST_TO(PolyhedralSurface)
878#define OGR_FORBID_DOWNCAST_TO_TIN OGR_FORBID_DOWNCAST_TO(TriangulatedSurface)
879
880#define OGR_ALLOW_UPCAST_TO(name) \
881 inline OGR ## name * to ## name() { return this; } \
882 inline const OGR ## name * to ## name() const { return this; }
883
884#ifndef SUPPRESS_OGR_ALLOW_CAST_TO_THIS_WARNING
885#define CAST_TO_THIS_WARNING CPL_WARN_DEPRECATED("Casting to this is useless")
886#else
887#define CAST_TO_THIS_WARNING
888#endif
889
890#define OGR_ALLOW_CAST_TO_THIS(name) \
891 inline OGR ## name * to ## name() CAST_TO_THIS_WARNING { return this; } \
892 inline const OGR ## name * to ## name() const CAST_TO_THIS_WARNING { return this; }
893
894#define OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
895 OGR_FORBID_DOWNCAST_TO_CURVE \
896 OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE \
897 OGR_FORBID_DOWNCAST_TO_LINESTRING \
898 OGR_FORBID_DOWNCAST_TO_LINEARRING \
899 OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
900 OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE
901
902#define OGR_FORBID_DOWNCAST_TO_ALL_SURFACES \
903 OGR_FORBID_DOWNCAST_TO_SURFACE \
904 OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON \
905 OGR_FORBID_DOWNCAST_TO_POLYGON \
906 OGR_FORBID_DOWNCAST_TO_TRIANGLE \
907 OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
908 OGR_FORBID_DOWNCAST_TO_TIN
909
910#define OGR_FORBID_DOWNCAST_TO_ALL_SINGLES \
911 OGR_FORBID_DOWNCAST_TO_POINT \
912 OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
913 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
914
915#define OGR_FORBID_DOWNCAST_TO_ALL_MULTI \
916 OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
917 OGR_FORBID_DOWNCAST_TO_MULTIPOINT \
918 OGR_FORBID_DOWNCAST_TO_MULTICURVE \
919 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
920 OGR_FORBID_DOWNCAST_TO_MULTISURFACE \
921 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
922
924
925/************************************************************************/
926/* OGRPoint */
927/************************************************************************/
928
934
935class CPL_DLL OGRPoint : public OGRGeometry
936{
937 double x;
938 double y;
939 double z;
940 double m;
941
942 public:
943 OGRPoint();
944 OGRPoint( double x, double y );
945 OGRPoint( double x, double y, double z );
946 OGRPoint( double x, double y, double z, double m );
947 OGRPoint( const OGRPoint& other );
948 static OGRPoint* createXYM( double x, double y, double m );
949 ~OGRPoint() override;
950
951 OGRPoint& operator=( const OGRPoint& other );
952
953 // IWks Interface
954 size_t WkbSize() const override;
955 OGRErr importFromWkb( const unsigned char *,
956 size_t,
958 size_t& nBytesConsumedOut ) override;
959 OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
961 const override;
962
963#ifndef DOXYGEN_XML
965#endif
966
967 OGRErr importFromWkt( const char ** ) override;
968
969#ifndef DOXYGEN_XML
971#endif
972
977 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
978 OGRErr *err = nullptr) const override;
979
980 // IGeometry
981 virtual int getDimension() const override;
982 virtual OGRPoint *clone() const override;
983 virtual void empty() override;
984 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
985 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
986 virtual OGRBoolean IsEmpty() const override
987 { return !(flags & OGR_G_NOT_EMPTY_POINT); }
988
989 // IPoint
991 double getX() const { return x; }
993 double getY() const { return y; }
995 double getZ() const { return z; }
997 double getM() const { return m; }
998
999 // Non standard
1000 virtual void setCoordinateDimension( int nDimension ) override;
1004 void setX( double xIn ) { x = xIn; if( std::isnan(x) || std::isnan(y) ) flags &= ~OGR_G_NOT_EMPTY_POINT; else flags |= OGR_G_NOT_EMPTY_POINT; }
1008 void setY( double yIn ) { y = yIn; if( std::isnan(x) || std::isnan(y) ) flags &= ~OGR_G_NOT_EMPTY_POINT; else flags |= OGR_G_NOT_EMPTY_POINT; }
1012 void setZ( double zIn )
1013 { z = zIn; flags |= OGR_G_3D; }
1014
1017 void setM( double mIn )
1018 { m = mIn; flags |= OGR_G_MEASURED; }
1019
1020 // ISpatialRelation
1021 virtual OGRBoolean Equals( const OGRGeometry * ) const override;
1022 virtual OGRBoolean Intersects( const OGRGeometry * ) const override;
1023 virtual OGRBoolean Within( const OGRGeometry * ) const override;
1024
1025 // Non standard from OGRGeometry
1026 virtual const char *getGeometryName() const override;
1027 virtual OGRwkbGeometryType getGeometryType() const override;
1028 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
1029 virtual void flattenTo2D() override;
1030 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
1031 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
1032
1033 virtual void swapXY() override;
1034
1035 OGR_ALLOW_CAST_TO_THIS(Point)
1036 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
1037 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1038 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1039};
1040
1041/************************************************************************/
1042/* OGRPointIterator */
1043/************************************************************************/
1044
1050
1051class CPL_DLL OGRPointIterator
1052{
1053 public:
1054 virtual ~OGRPointIterator();
1056
1057 static void destroy( OGRPointIterator* );
1058};
1059
1060/************************************************************************/
1061/* OGRCurve */
1062/************************************************************************/
1063
1068
1069class CPL_DLL OGRCurve : public OGRGeometry
1070{
1071 protected:
1073 OGRCurve();
1074 OGRCurve( const OGRCurve& other );
1075
1076 virtual OGRCurveCasterToLineString GetCasterToLineString() const = 0;
1077 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const = 0;
1078
1079 friend class OGRCurvePolygon;
1080 friend class OGRCompoundCurve;
1082 virtual int ContainsPoint( const OGRPoint* p ) const;
1083 virtual int IntersectsPoint( const OGRPoint* p ) const;
1084 virtual double get_AreaOfCurveSegments() const = 0;
1085
1086 private:
1087
1088 class CPL_DLL ConstIterator
1089 {
1090 struct Private;
1091 std::unique_ptr<Private> m_poPrivate;
1092 public:
1093 ConstIterator(const OGRCurve* poSelf, bool bStart);
1094 ConstIterator(ConstIterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
1095 ~ConstIterator();
1096 const OGRPoint& operator*() const;
1097 ConstIterator& operator++();
1098 bool operator!=(const ConstIterator& it) const;
1099 };
1100
1101 friend inline ConstIterator begin(const OGRCurve*);
1102 friend inline ConstIterator end(const OGRCurve*);
1103
1104 public:
1105 ~OGRCurve() override;
1106
1108 OGRCurve& operator=( const OGRCurve& other );
1110
1113
1122 ConstIterator begin() const;
1124 ConstIterator end() const;
1125
1126 // IGeometry
1127 virtual OGRCurve *clone() const override = 0;
1128
1129 // ICurve methods
1130 virtual double get_Length() const = 0;
1131 virtual void StartPoint( OGRPoint * ) const = 0;
1132 virtual void EndPoint( OGRPoint * ) const = 0;
1133 virtual int get_IsClosed() const;
1134 virtual void Value( double, OGRPoint * ) const = 0;
1135 virtual OGRLineString* CurveToLine( double dfMaxAngleStepSizeDegrees = 0,
1136 const char* const* papszOptions = nullptr)
1137 const = 0;
1138 virtual int getDimension() const override;
1139
1140 // non standard
1141 virtual int getNumPoints() const = 0;
1143 virtual OGRBoolean IsConvex() const;
1144 virtual double get_Area() const = 0;
1145
1150
1153 inline const OGRSimpleCurve* toSimpleCurve() const
1155
1156 static OGRCompoundCurve* CastToCompoundCurve( OGRCurve* puCurve );
1157 static OGRLineString* CastToLineString( OGRCurve* poCurve );
1158 static OGRLinearRing* CastToLinearRing( OGRCurve* poCurve );
1159
1160 OGR_FORBID_DOWNCAST_TO_POINT
1161 OGR_ALLOW_CAST_TO_THIS(Curve)
1162 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1163 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1164};
1165
1167
1168inline OGRCurve::ConstIterator begin(const OGRCurve* poCurve) { return poCurve->begin(); }
1170inline OGRCurve::ConstIterator end(const OGRCurve* poCurve) { return poCurve->end(); }
1172
1173/************************************************************************/
1174/* OGRSimpleCurve */
1175/************************************************************************/
1176
1185
1186class CPL_DLL OGRSimpleCurve: public OGRCurve
1187{
1188 protected:
1190 friend class OGRGeometry;
1191
1192 int nPointCount;
1193 OGRRawPoint *paoPoints;
1194 double *padfZ;
1195 double *padfM;
1196
1197 void Make3D();
1198 void Make2D();
1199 void RemoveM();
1200 void AddM();
1201
1202 OGRErr importFromWKTListOnly( const char ** ppszInput, int bHasZ, int bHasM,
1203 OGRRawPoint*& paoPointsIn,
1204 int& nMaxPoints,
1205 double*& padfZIn );
1207
1208 virtual double get_LinearArea() const;
1209
1211 OGRSimpleCurve( const OGRSimpleCurve& other );
1212
1213 private:
1214 class CPL_DLL Iterator
1215 {
1216 struct Private;
1217 std::unique_ptr<Private> m_poPrivate;
1218 void update();
1219 public:
1220 Iterator(OGRSimpleCurve* poSelf, int nPos);
1221 Iterator(Iterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
1222 ~Iterator();
1223 OGRPoint& operator*();
1224 Iterator& operator++();
1225 bool operator!=(const Iterator& it) const;
1226 };
1227
1228 friend inline Iterator begin(OGRSimpleCurve*);
1229 friend inline Iterator end(OGRSimpleCurve*);
1230
1231 class CPL_DLL ConstIterator
1232 {
1233 struct Private;
1234 std::unique_ptr<Private> m_poPrivate;
1235 public:
1236 ConstIterator(const OGRSimpleCurve* poSelf, int nPos);
1237 ConstIterator(ConstIterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
1238 ~ConstIterator();
1239 const OGRPoint& operator*() const;
1240 ConstIterator& operator++();
1241 bool operator!=(const ConstIterator& it) const;
1242 };
1243
1244 friend inline ConstIterator begin(const OGRSimpleCurve*);
1245 friend inline ConstIterator end(const OGRSimpleCurve*);
1246
1247 public:
1248 ~OGRSimpleCurve() override;
1249
1250 OGRSimpleCurve& operator=( const OGRSimpleCurve& other );
1251
1254
1263 Iterator begin();
1265 Iterator end();
1274 ConstIterator begin() const;
1276 ConstIterator end() const;
1277
1278 // IWks Interface.
1279 virtual size_t WkbSize() const override;
1280 virtual OGRErr importFromWkb( const unsigned char *,
1281 size_t,
1283 size_t& nBytesConsumedOut ) override;
1284 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
1286 const override;
1287
1288#ifndef DOXYGEN_XML
1290#endif
1291
1292 OGRErr importFromWkt( const char ** ) override;
1293
1294#ifndef DOXYGEN_XML
1296#endif
1297
1302 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
1303 OGRErr *err = nullptr) const override;
1304
1305 // IGeometry interface.
1306 virtual void empty() override;
1307 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
1308 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
1309 virtual OGRBoolean IsEmpty() const override;
1310 virtual OGRSimpleCurve *clone() const override = 0;
1311
1312 // ICurve methods.
1313 virtual double get_Length() const override;
1314 virtual void StartPoint( OGRPoint * ) const override;
1315 virtual void EndPoint( OGRPoint * ) const override;
1316 virtual void Value( double, OGRPoint * ) const override;
1317 virtual double Project( const OGRPoint * ) const;
1318 virtual OGRLineString* getSubLine( double, double, int ) const;
1319
1320 // ILineString methods.
1321 virtual int getNumPoints() const override { return nPointCount; }
1322 void getPoint( int, OGRPoint * ) const;
1323 double getX( int i ) const { return paoPoints[i].x; }
1324 double getY( int i ) const { return paoPoints[i].y; }
1325 double getZ( int i ) const;
1326 double getM( int i ) const;
1327
1328 // ISpatialRelation
1329 virtual OGRBoolean Equals( const OGRGeometry * ) const override;
1330
1331 // non standard.
1332 virtual void setCoordinateDimension( int nDimension ) override;
1333 virtual void set3D( OGRBoolean bIs3D ) override;
1334 virtual void setMeasured( OGRBoolean bIsMeasured ) override;
1335 void setNumPoints( int nNewPointCount,
1336 int bZeroizeNewContent = TRUE );
1337 void setPoint( int, OGRPoint * );
1338 void setPoint( int, double, double );
1339 void setZ( int, double );
1340 void setM( int, double );
1341 void setPoint( int, double, double, double );
1342 void setPointM( int, double, double, double );
1343 void setPoint( int, double, double, double, double );
1344 void setPoints( int, const OGRRawPoint *, const double * = nullptr );
1345 void setPointsM( int, const OGRRawPoint *, const double * );
1346 void setPoints( int, const OGRRawPoint *, const double *, const double * );
1347 void setPoints( int, const double * padfX, const double * padfY,
1348 const double *padfZIn = nullptr );
1349 void setPointsM( int, const double * padfX, const double * padfY,
1350 const double *padfMIn = nullptr );
1351 void setPoints( int, const double * padfX, const double * padfY,
1352 const double *padfZIn, const double *padfMIn );
1353 void addPoint( const OGRPoint * );
1354 void addPoint( double, double );
1355 void addPoint( double, double, double );
1356 void addPointM( double, double, double );
1357 void addPoint( double, double, double, double );
1358
1359 bool removePoint( int );
1360
1361 void getPoints( OGRRawPoint *, double * = nullptr ) const;
1362 void getPoints( void* pabyX, int nXStride,
1363 void* pabyY, int nYStride,
1364 void* pabyZ = nullptr, int nZStride = 0,
1365 void* pabyM = nullptr, int nMStride = 0 ) const;
1366
1367 void addSubLineString( const OGRLineString *,
1368 int nStartVertex = 0, int nEndVertex = -1 );
1369 void reversePoints( void );
1370 virtual OGRPointIterator* getPointIterator() const override;
1371
1372 // non-standard from OGRGeometry
1373 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
1374 virtual void flattenTo2D() override;
1375 virtual void segmentize(double dfMaxLength) override;
1376
1377 virtual void swapXY() override;
1378
1379 OGR_ALLOW_UPCAST_TO(Curve)
1380 OGR_ALLOW_CAST_TO_THIS(SimpleCurve)
1381};
1382
1384
1385inline OGRSimpleCurve::Iterator begin(OGRSimpleCurve* poCurve) { return poCurve->begin(); }
1387inline OGRSimpleCurve::Iterator end(OGRSimpleCurve* poCurve) { return poCurve->end(); }
1388
1390inline OGRSimpleCurve::ConstIterator begin(const OGRSimpleCurve* poCurve) { return poCurve->begin(); }
1392inline OGRSimpleCurve::ConstIterator end(const OGRSimpleCurve* poCurve) { return poCurve->end(); }
1394
1395/************************************************************************/
1396/* OGRLineString */
1397/************************************************************************/
1398
1405
1406class CPL_DLL OGRLineString : public OGRSimpleCurve
1407{
1408 // cppcheck-suppress unusedPrivateFunction
1409 static OGRLinearRing* CasterToLinearRing(OGRCurve* poCurve);
1410
1411 protected:
1413 static OGRLineString* TransferMembersAndDestroy(
1414 OGRLineString* poSrc,
1415 OGRLineString* poDst);
1416
1417 virtual OGRCurveCasterToLineString GetCasterToLineString()
1418 const override;
1419 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing()
1420 const override;
1421
1422 virtual double get_AreaOfCurveSegments() const override;
1424
1426
1427 public:
1430 ~OGRLineString() override;
1431
1432 OGRLineString& operator=(const OGRLineString& other);
1433
1434 virtual OGRLineString *clone() const override;
1435 virtual OGRLineString* CurveToLine( double dfMaxAngleStepSizeDegrees = 0,
1436 const char* const* papszOptions = nullptr )
1437 const override;
1439 const char* const* papszOptions = nullptr ) const override;
1440 virtual double get_Area() const override;
1441
1442 // Non-standard from OGRGeometry.
1443 virtual OGRwkbGeometryType getGeometryType() const override;
1444 virtual const char *getGeometryName() const override;
1445
1447 inline OGRSimpleCurve* toUpperClass() { return this; }
1449 inline const OGRSimpleCurve* toUpperClass() const { return this; }
1450
1451 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
1452 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
1453
1454 OGR_ALLOW_UPCAST_TO(SimpleCurve)
1455 OGR_ALLOW_CAST_TO_THIS(LineString)
1456};
1457
1458/************************************************************************/
1459/* OGRLinearRing */
1460/************************************************************************/
1461
1481
1482class CPL_DLL OGRLinearRing : public OGRLineString
1483{
1484 static OGRLineString* CasterToLineString( OGRCurve* poCurve );
1485
1486 // IWks Interface - Note this isn't really a first class object
1487 // for the purposes of WKB form. These methods always fail since this
1488 // object can't be serialized on its own.
1489 virtual size_t WkbSize() const override;
1490 virtual OGRErr importFromWkb( const unsigned char *,
1491 size_t,
1493 size_t& nBytesConsumedOut ) override;
1494 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
1496 const override;
1497
1498 protected:
1500 friend class OGRPolygon;
1501 friend class OGRTriangle;
1502
1503 // These are not IWks compatible ... just a convenience for OGRPolygon.
1504 virtual size_t _WkbSize( int _flags ) const;
1505 virtual OGRErr _importFromWkb( OGRwkbByteOrder, int _flags,
1506 const unsigned char *, size_t,
1507 size_t& nBytesConsumedOut );
1508 virtual OGRErr _exportToWkb( OGRwkbByteOrder, int _flags,
1509 unsigned char * ) const;
1510
1511 virtual OGRCurveCasterToLineString GetCasterToLineString()
1512 const override;
1513 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing()
1514 const override;
1516
1518
1519 public:
1522 explicit OGRLinearRing( OGRLinearRing * );
1523 ~OGRLinearRing() override;
1524
1525 OGRLinearRing& operator=( const OGRLinearRing& other );
1526
1527 // Non standard.
1528 virtual const char *getGeometryName() const override;
1529 virtual OGRLinearRing *clone() const override;
1530 virtual int isClockwise() const;
1531 virtual void reverseWindingOrder();
1532 virtual void closeRings() override;
1534 int bTestEnvelope = TRUE ) const;
1536 int bTestEnvelope = TRUE ) const;
1537 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
1538
1540 inline OGRLineString* toUpperClass() { return this; }
1542 inline const OGRLineString* toUpperClass() const { return this; }
1543
1544 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
1545 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
1546
1547 OGR_ALLOW_UPCAST_TO(LineString)
1548 OGR_ALLOW_CAST_TO_THIS(LinearRing)
1549};
1550
1551/************************************************************************/
1552/* OGRCircularString */
1553/************************************************************************/
1554
1566
1567class CPL_DLL OGRCircularString : public OGRSimpleCurve
1568{
1569 private:
1570 void ExtendEnvelopeWithCircular( OGREnvelope * psEnvelope ) const;
1571 OGRBoolean IsValidFast() const;
1572 int IsFullCircle( double& cx, double& cy, double& square_R ) const;
1573
1574 protected:
1576 virtual OGRCurveCasterToLineString GetCasterToLineString()
1577 const override;
1578 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing()
1579 const override;
1580 virtual int IntersectsPoint( const OGRPoint* p ) const override;
1581 virtual int ContainsPoint( const OGRPoint* p ) const override;
1582 virtual double get_AreaOfCurveSegments() const override;
1584
1585 public:
1588 ~OGRCircularString() override;
1589
1591
1592 // IWks Interface.
1593 virtual OGRErr importFromWkb( const unsigned char *,
1594 size_t,
1596 size_t& nBytesConsumedOut ) override;
1597 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
1599 const override;
1600
1601#ifndef DOXYGEN_XML
1603#endif
1604
1605 OGRErr importFromWkt( const char ** ) override;
1606
1607#ifndef DOXYGEN_XML
1609#endif
1610
1615 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
1616 OGRErr *err = nullptr) const override;
1617
1618 // IGeometry interface.
1619 virtual OGRBoolean IsValid() const override;
1620 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
1621 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
1622 virtual OGRCircularString *clone() const override;
1623
1624 // ICurve methods.
1625 virtual double get_Length() const override;
1626 virtual OGRLineString* CurveToLine( double dfMaxAngleStepSizeDegrees = 0,
1627 const char* const* papszOptions = nullptr )
1628 const override;
1629 virtual void Value( double, OGRPoint * ) const override;
1630 virtual double get_Area() const override;
1631
1632 // Non-standard from OGRGeometry.
1633 virtual OGRwkbGeometryType getGeometryType() const override;
1634 virtual const char *getGeometryName() const override;
1635 virtual void segmentize( double dfMaxLength ) override;
1636 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
1637 const override;
1639 double dfMaxAngleStepSizeDegrees = 0,
1640 const char* const* papszOptions = nullptr) const override;
1641
1643 inline OGRSimpleCurve* toUpperClass() { return this; }
1645 inline const OGRSimpleCurve* toUpperClass() const { return this; }
1646
1647 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
1648 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
1649
1650 OGR_ALLOW_UPCAST_TO(SimpleCurve)
1651 OGR_ALLOW_CAST_TO_THIS(CircularString)
1652};
1653
1654/************************************************************************/
1655/* OGRCurveCollection */
1656/************************************************************************/
1657
1667
1669class CPL_DLL OGRCurveCollection
1670{
1671 protected:
1672 friend class OGRCompoundCurve;
1673 friend class OGRCurvePolygon;
1674 friend class OGRPolygon;
1675 friend class OGRTriangle;
1676
1677 int nCurveCount = 0;
1678 OGRCurve **papoCurves = nullptr;
1679
1680 public:
1681 OGRCurveCollection();
1682 OGRCurveCollection(const OGRCurveCollection& other);
1683 ~OGRCurveCollection();
1684
1685 OGRCurveCollection& operator=(const OGRCurveCollection& other);
1686
1688 typedef OGRCurve ChildType;
1689
1693 OGRCurve** begin() { return papoCurves; }
1695 OGRCurve** end() { return papoCurves + nCurveCount; }
1699 const OGRCurve* const* begin() const { return papoCurves; }
1701 const OGRCurve* const* end() const { return papoCurves + nCurveCount; }
1702
1703 void empty(OGRGeometry* poGeom);
1704 OGRBoolean IsEmpty() const;
1705 void getEnvelope( OGREnvelope * psEnvelope ) const;
1706 void getEnvelope( OGREnvelope3D * psEnvelope ) const;
1707
1708 OGRErr addCurveDirectly( OGRGeometry* poGeom, OGRCurve* poCurve,
1709 int bNeedRealloc );
1710 size_t WkbSize() const;
1711 OGRErr importPreambleFromWkb( OGRGeometry* poGeom,
1712 const unsigned char * pabyData,
1713 size_t& nSize,
1714 size_t& nDataOffset,
1715 OGRwkbByteOrder& eByteOrder,
1716 size_t nMinSubGeomSize,
1717 OGRwkbVariant eWkbVariant );
1718 OGRErr importBodyFromWkb(
1719 OGRGeometry* poGeom,
1720 const unsigned char * pabyData,
1721 size_t nSize,
1722 bool bAcceptCompoundCurve,
1723 OGRErr (*pfnAddCurveDirectlyFromWkb)( OGRGeometry* poGeom,
1724 OGRCurve* poCurve ),
1725 OGRwkbVariant eWkbVariant,
1726 size_t& nBytesConsumedOut );
1727 std::string exportToWkt(const OGRGeometry *geom, const OGRWktOptions& opts,
1728 OGRErr *err) const;
1729 OGRErr exportToWkb( const OGRGeometry* poGeom, OGRwkbByteOrder,
1730 unsigned char *,
1731 OGRwkbVariant eWkbVariant ) const;
1732 OGRBoolean Equals(const OGRCurveCollection *poOCC) const;
1733 void setCoordinateDimension( OGRGeometry* poGeom,
1734 int nNewDimension );
1735 void set3D( OGRGeometry* poGeom, OGRBoolean bIs3D );
1736 void setMeasured( OGRGeometry* poGeom, OGRBoolean bIsMeasured );
1737 void assignSpatialReference( OGRGeometry* poGeom, OGRSpatialReference * poSR );
1738 int getNumCurves() const;
1739 OGRCurve *getCurve( int );
1740 const OGRCurve *getCurve( int ) const;
1741 OGRCurve *stealCurve( int );
1742
1743 OGRErr removeCurve( int iIndex, bool bDelete = true );
1744
1745 OGRErr transform( OGRGeometry* poGeom,
1746 OGRCoordinateTransformation *poCT );
1747 void flattenTo2D( OGRGeometry* poGeom );
1748 void segmentize( double dfMaxLength );
1749 void swapXY();
1750 OGRBoolean hasCurveGeometry(int bLookForNonLinear) const;
1751};
1753
1754/************************************************************************/
1755/* OGRCompoundCurve */
1756/************************************************************************/
1757
1767
1768class CPL_DLL OGRCompoundCurve : public OGRCurve
1769{
1770 private:
1771 OGRCurveCollection oCC{};
1772
1773 OGRErr addCurveDirectlyInternal( OGRCurve* poCurve,
1774 double dfToleranceEps,
1775 int bNeedRealloc );
1776 static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf,
1777 OGRCurve* poCurve );
1778 static OGRErr addCurveDirectlyFromWkb( OGRGeometry* poSelf,
1779 OGRCurve* poCurve );
1780 OGRLineString* CurveToLineInternal( double dfMaxAngleStepSizeDegrees,
1781 const char* const* papszOptions,
1782 int bIsLinearRing ) const;
1783 // cppcheck-suppress unusedPrivateFunction
1784 static OGRLineString* CasterToLineString( OGRCurve* poCurve );
1785 // cppcheck-suppress unusedPrivateFunction
1786 static OGRLinearRing* CasterToLinearRing( OGRCurve* poCurve );
1787
1788 protected:
1792
1793 virtual OGRCurveCasterToLineString GetCasterToLineString()
1794 const override;
1795 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing()
1796 const override;
1798
1799 public:
1802 ~OGRCompoundCurve() override;
1803
1805
1808
1812 ChildType** begin() { return oCC.begin(); }
1814 ChildType** end() { return oCC.end(); }
1818 const ChildType* const * begin() const { return oCC.begin(); }
1820 const ChildType* const * end() const { return oCC.end(); }
1821
1822 // IWks Interface
1823 virtual size_t WkbSize() const override;
1824 virtual OGRErr importFromWkb( const unsigned char *,
1825 size_t,
1827 size_t& nBytesConsumedOut ) override;
1828 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
1830 const override;
1831
1832#ifndef DOXYGEN_XML
1834#endif
1835
1836 OGRErr importFromWkt( const char ** ) override;
1837
1838#ifndef DOXYGEN_XML
1840#endif
1841
1846 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
1847 OGRErr *err = nullptr) const override;
1848
1849 // IGeometry interface.
1850 virtual OGRCompoundCurve *clone() const override;
1851 virtual void empty() override;
1852 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
1853 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
1854 virtual OGRBoolean IsEmpty() const override;
1855
1856 // ICurve methods.
1857 virtual double get_Length() const override;
1858 virtual void StartPoint( OGRPoint * ) const override;
1859 virtual void EndPoint( OGRPoint * ) const override;
1860 virtual void Value( double, OGRPoint * ) const override;
1861 virtual OGRLineString* CurveToLine( double dfMaxAngleStepSizeDegrees = 0,
1862 const char* const* papszOptions = nullptr )
1863 const override;
1864
1865 virtual int getNumPoints() const override;
1866 virtual double get_AreaOfCurveSegments() const override;
1867 virtual double get_Area() const override;
1868
1869 // ISpatialRelation.
1870 virtual OGRBoolean Equals( const OGRGeometry * ) const override;
1871
1872 // ICompoundCurve method.
1873 int getNumCurves() const;
1874 OGRCurve *getCurve( int );
1875 const OGRCurve *getCurve( int ) const;
1876
1877 // Non-standard.
1878 virtual void setCoordinateDimension( int nDimension ) override;
1879 virtual void set3D( OGRBoolean bIs3D ) override;
1880 virtual void setMeasured( OGRBoolean bIsMeasured ) override;
1881
1882 virtual void assignSpatialReference( OGRSpatialReference * poSR ) override;
1883
1884 OGRErr addCurve( OGRCurve*, double dfToleranceEps = 1e-14 );
1885 OGRErr addCurveDirectly( OGRCurve*, double dfToleranceEps = 1e-14 );
1886 OGRCurve *stealCurve( int );
1887 virtual OGRPointIterator* getPointIterator() const override;
1888
1889 // Non-standard from OGRGeometry.
1890 virtual OGRwkbGeometryType getGeometryType() const override;
1891 virtual const char *getGeometryName() const override;
1892 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
1893 virtual void flattenTo2D() override;
1894 virtual void segmentize(double dfMaxLength) override;
1895 virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE)
1896 const override;
1897 virtual OGRGeometry* getLinearGeometry(
1898 double dfMaxAngleStepSizeDegrees = 0,
1899 const char* const* papszOptions = nullptr) const override;
1900 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
1901 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
1902
1903 virtual void swapXY() override;
1904
1905 OGR_ALLOW_UPCAST_TO(Curve)
1906 OGR_ALLOW_CAST_TO_THIS(CompoundCurve)
1907};
1908
1910
1911inline const OGRCompoundCurve::ChildType* const * begin(const OGRCompoundCurve* poCurve) { return poCurve->begin(); }
1913inline const OGRCompoundCurve::ChildType* const * end(const OGRCompoundCurve* poCurve) { return poCurve->end(); }
1914
1916inline OGRCompoundCurve::ChildType** begin(OGRCompoundCurve* poCurve) { return poCurve->begin(); }
1918inline OGRCompoundCurve::ChildType** end(OGRCompoundCurve* poCurve) { return poCurve->end(); }
1920
1921/************************************************************************/
1922/* OGRSurface */
1923/************************************************************************/
1924
1929
1930class CPL_DLL OGRSurface : public OGRGeometry
1931{
1932 protected:
1934 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const = 0;
1935 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const = 0;
1937
1938 public:
1939 virtual double get_Area() const = 0;
1940 virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const
1941 { return PointOnSurfaceInternal(poPoint); }
1942 virtual OGRSurface *clone() const override = 0;
1943
1945 static OGRPolygon* CastToPolygon(OGRSurface* poSurface);
1946 static OGRCurvePolygon* CastToCurvePolygon(OGRSurface* poSurface);
1948
1949 OGR_FORBID_DOWNCAST_TO_POINT
1950 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
1951 OGR_ALLOW_CAST_TO_THIS(Surface)
1952 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1953};
1954
1955/************************************************************************/
1956/* OGRCurvePolygon */
1957/************************************************************************/
1958
1971
1972class CPL_DLL OGRCurvePolygon : public OGRSurface
1973{
1974 static OGRPolygon* CasterToPolygon(OGRSurface* poSurface);
1975
1976 private:
1977 OGRBoolean IntersectsPoint( const OGRPoint* p ) const;
1978 OGRBoolean ContainsPoint( const OGRPoint* p ) const;
1979 virtual int checkRing( OGRCurve * poNewRing ) const;
1980 OGRErr addRingDirectlyInternal( OGRCurve* poCurve,
1981 int bNeedRealloc );
1982 static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf,
1983 OGRCurve* poCurve );
1984 static OGRErr addCurveDirectlyFromWkb( OGRGeometry* poSelf,
1985 OGRCurve* poCurve );
1986
1987 protected:
1989 friend class OGRPolygon;
1990 friend class OGRTriangle;
1991 OGRCurveCollection oCC{};
1992
1993 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon()
1994 const override;
1995 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon()
1996 const override;
1997
1999
2000 static OGRPolygon* CastToPolygon( OGRCurvePolygon* poCP );
2001
2002 public:
2005 ~OGRCurvePolygon() override;
2006
2007 OGRCurvePolygon& operator=( const OGRCurvePolygon& other );
2008
2011
2015 ChildType** begin() { return oCC.begin(); }
2017 ChildType** end() { return oCC.end(); }
2021 const ChildType* const * begin() const { return oCC.begin(); }
2023 const ChildType* const * end() const { return oCC.end(); }
2024
2025 // Non standard (OGRGeometry).
2026 virtual const char *getGeometryName() const override;
2027 virtual OGRwkbGeometryType getGeometryType() const override;
2028 virtual OGRCurvePolygon *clone() const override;
2029 virtual void empty() override;
2030 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
2031 virtual void flattenTo2D() override;
2032 virtual OGRBoolean IsEmpty() const override;
2033 virtual void segmentize( double dfMaxLength ) override;
2034 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
2035 const override;
2036 virtual OGRGeometry* getLinearGeometry(
2037 double dfMaxAngleStepSizeDegrees = 0,
2038 const char* const* papszOptions = nullptr ) const override;
2039
2040 // ISurface Interface
2041 virtual double get_Area() const override;
2042
2043 // IWks Interface
2044 virtual size_t WkbSize() const override;
2045 virtual OGRErr importFromWkb( const unsigned char *,
2046 size_t,
2048 size_t& nBytesConsumedOut ) override;
2049 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
2051 const override;
2052
2053#ifndef DOXYGEN_XML
2055#endif
2056
2057 OGRErr importFromWkt( const char ** ) override;
2058
2059#ifndef DOXYGEN_XML
2061#endif
2062
2067 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
2068 OGRErr *err = nullptr) const override;
2069
2070 // IGeometry
2071 virtual int getDimension() const override;
2072 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
2073 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
2074
2075 // ICurvePolygon
2076 virtual OGRPolygon* CurvePolyToPoly(
2077 double dfMaxAngleStepSizeDegrees = 0,
2078 const char* const* papszOptions = nullptr ) const;
2079
2080 // ISpatialRelation
2081 virtual OGRBoolean Equals( const OGRGeometry * ) const override;
2082 virtual OGRBoolean Intersects( const OGRGeometry * ) const override;
2083 virtual OGRBoolean Contains( const OGRGeometry * ) const override;
2084
2085 // Non standard
2086 virtual void setCoordinateDimension( int nDimension ) override;
2087 virtual void set3D( OGRBoolean bIs3D ) override;
2088 virtual void setMeasured( OGRBoolean bIsMeasured ) override;
2089
2090 virtual void assignSpatialReference( OGRSpatialReference * poSR ) override;
2091
2092 virtual OGRErr addRing( OGRCurve * );
2093 virtual OGRErr addRingDirectly( OGRCurve * );
2094
2095 OGRCurve *getExteriorRingCurve();
2096 const OGRCurve *getExteriorRingCurve() const;
2097 int getNumInteriorRings() const;
2098 OGRCurve *getInteriorRingCurve( int );
2099 const OGRCurve *getInteriorRingCurve( int ) const;
2100
2101 OGRCurve *stealExteriorRingCurve();
2102
2103 OGRErr removeRing( int iIndex, bool bDelete = true );
2104 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
2105 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
2106
2107 virtual void swapXY() override;
2108
2109 OGR_ALLOW_UPCAST_TO(Surface)
2110 OGR_ALLOW_CAST_TO_THIS(CurvePolygon)
2111};
2112
2114
2115inline const OGRCurvePolygon::ChildType* const * begin(const OGRCurvePolygon* poGeom) { return poGeom->begin(); }
2117inline const OGRCurvePolygon::ChildType* const * end(const OGRCurvePolygon* poGeom) { return poGeom->end(); }
2118
2120inline OGRCurvePolygon::ChildType** begin(OGRCurvePolygon* poGeom) { return poGeom->begin(); }
2122inline OGRCurvePolygon::ChildType** end(OGRCurvePolygon* poGeom) { return poGeom->end(); }
2124
2125/************************************************************************/
2126/* OGRPolygon */
2127/************************************************************************/
2128
2137
2138class CPL_DLL OGRPolygon : public OGRCurvePolygon
2139{
2140 static OGRCurvePolygon* CasterToCurvePolygon(OGRSurface* poSurface);
2141
2142 protected:
2144 friend class OGRMultiSurface;
2145 friend class OGRPolyhedralSurface;
2146 friend class OGRTriangulatedSurface;
2147
2148 virtual int checkRing( OGRCurve * poNewRing ) const override;
2149 virtual OGRErr importFromWKTListOnly( const char ** ppszInput,
2150 int bHasZ, int bHasM,
2151 OGRRawPoint*& paoPoints,
2152 int& nMaxPoints,
2153 double*& padfZ );
2154
2155 static OGRCurvePolygon* CastToCurvePolygon(OGRPolygon* poPoly);
2156
2157 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon()
2158 const override;
2159 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon()
2160 const override;
2162
2163 public:
2165 OGRPolygon(const OGRPolygon& other);
2166 ~OGRPolygon() override;
2167
2168 OGRPolygon& operator=(const OGRPolygon& other);
2169
2172
2176 ChildType** begin() { return reinterpret_cast<ChildType**>(oCC.begin()); }
2178 ChildType** end() { return reinterpret_cast<ChildType**>(oCC.end()); }
2182 const ChildType* const* begin() const { return reinterpret_cast<const ChildType* const*>(oCC.begin()); }
2184 const ChildType* const* end() const { return reinterpret_cast<const ChildType* const*>(oCC.end()); }
2185
2186 // Non-standard (OGRGeometry).
2187 virtual const char *getGeometryName() const override;
2188 virtual OGRwkbGeometryType getGeometryType() const override;
2189 virtual OGRPolygon *clone() const override;
2190 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
2191 const override;
2192 virtual OGRGeometry* getCurveGeometry(
2193 const char* const* papszOptions = nullptr ) const override;
2194 virtual OGRGeometry* getLinearGeometry(
2195 double dfMaxAngleStepSizeDegrees = 0,
2196 const char* const* papszOptions = nullptr) const override;
2197
2198 // IWks Interface.
2199 virtual size_t WkbSize() const override;
2200 virtual OGRErr importFromWkb( const unsigned char *,
2201 size_t,
2203 size_t& nBytesConsumedOut ) override;
2204 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
2206 const override;
2207
2208#ifndef DOXYGEN_XML
2210#endif
2211
2212 OGRErr importFromWkt( const char ** ) override;
2213
2214#ifndef DOXYGEN_XML
2216#endif
2217
2222 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
2223 OGRErr *err = nullptr) const override;
2224
2225 // ICurvePolygon.
2226 virtual OGRPolygon* CurvePolyToPoly(
2227 double dfMaxAngleStepSizeDegrees = 0,
2228 const char* const* papszOptions = nullptr ) const override;
2229
2230 OGRLinearRing *getExteriorRing();
2231 const OGRLinearRing *getExteriorRing() const;
2232 virtual OGRLinearRing *getInteriorRing( int );
2233 virtual const OGRLinearRing *getInteriorRing( int ) const;
2234
2235 OGRLinearRing *stealExteriorRing();
2236 virtual OGRLinearRing *stealInteriorRing(int);
2237
2238 OGRBoolean IsPointOnSurface( const OGRPoint * ) const;
2239
2241 inline OGRCurvePolygon* toUpperClass() { return this; }
2243 inline const OGRCurvePolygon* toUpperClass() const { return this; }
2244
2245 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
2246 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
2247
2248 virtual void closeRings() override;
2249
2250 OGR_ALLOW_UPCAST_TO(CurvePolygon)
2251 OGR_ALLOW_CAST_TO_THIS(Polygon)
2252};
2253
2255
2256inline const OGRPolygon::ChildType* const * begin(const OGRPolygon* poGeom) { return poGeom->begin(); }
2258inline const OGRPolygon::ChildType* const * end(const OGRPolygon* poGeom) { return poGeom->end(); }
2259
2261inline OGRPolygon::ChildType** begin(OGRPolygon* poGeom) { return poGeom->begin(); }
2263inline OGRPolygon::ChildType** end(OGRPolygon* poGeom) { return poGeom->end(); }
2265
2266/************************************************************************/
2267/* OGRTriangle */
2268/************************************************************************/
2269
2275
2276class CPL_DLL OGRTriangle : public OGRPolygon
2277{
2278 private:
2279 // cppcheck-suppress unusedPrivateFunction
2280 static OGRPolygon* CasterToPolygon(OGRSurface* poSurface);
2281 bool quickValidityCheck() const;
2282
2283 protected:
2285 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2286 virtual OGRErr importFromWKTListOnly( const char ** ppszInput,
2287 int bHasZ, int bHasM,
2288 OGRRawPoint*& paoPoints,
2289 int& nMaxPoints,
2290 double*& padfZ ) override;
2292
2293 public:
2295 OGRTriangle( const OGRPoint &p, const OGRPoint &q, const OGRPoint &r );
2296 OGRTriangle( const OGRTriangle &other );
2297 OGRTriangle( const OGRPolygon &other, OGRErr &eErr );
2298 OGRTriangle& operator=( const OGRTriangle& other );
2299 ~OGRTriangle() override;
2300 virtual const char *getGeometryName() const override;
2301 virtual OGRwkbGeometryType getGeometryType() const override;
2302 virtual OGRTriangle *clone() const override;
2303
2304 // IWks Interface.
2305 virtual OGRErr importFromWkb( const unsigned char *,
2306 size_t,
2308 size_t& nBytesConsumedOut ) override;
2309
2310 // New methods rewritten from OGRPolygon/OGRCurvePolygon/OGRGeometry.
2311 virtual OGRErr addRingDirectly( OGRCurve * poNewRing ) override;
2312
2314 inline OGRPolygon* toUpperClass() { return this; }
2316 inline const OGRPolygon* toUpperClass() const { return this; }
2317
2318 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
2319 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
2320
2322 static OGRGeometry* CastToPolygon( OGRGeometry* poGeom );
2324
2325 OGR_ALLOW_UPCAST_TO(Polygon)
2326 OGR_ALLOW_CAST_TO_THIS(Triangle)
2327};
2328
2329/************************************************************************/
2330/* OGRGeometryCollection */
2331/************************************************************************/
2332
2339
2340class CPL_DLL OGRGeometryCollection : public OGRGeometry
2341{
2342 OGRErr importFromWkbInternal( const unsigned char * pabyData,
2343 size_t nSize,
2344 int nRecLevel,
2345 OGRwkbVariant, size_t& nBytesConsumedOut );
2346 OGRErr importFromWktInternal( const char **ppszInput, int nRecLevel );
2347
2348 protected:
2350 int nGeomCount = 0;
2351 OGRGeometry **papoGeoms = nullptr;
2352
2353 std::string exportToWktInternal(const OGRWktOptions& opts, OGRErr *err,
2354 std::string exclude = std::string()) const;
2355 static OGRGeometryCollection* TransferMembersAndDestroy(
2356 OGRGeometryCollection* poSrc,
2357 OGRGeometryCollection* poDst );
2360
2361 public:
2364 ~OGRGeometryCollection() override;
2365
2367
2369 typedef OGRGeometry ChildType;
2370
2374 ChildType** begin() { return papoGeoms; }
2376 ChildType** end() { return papoGeoms + nGeomCount; }
2380 const ChildType* const* begin() const { return papoGeoms; }
2382 const ChildType* const* end() const { return papoGeoms + nGeomCount; }
2383
2384 // Non standard (OGRGeometry).
2385 virtual const char *getGeometryName() const override;
2386 virtual OGRwkbGeometryType getGeometryType() const override;
2387 virtual OGRGeometryCollection *clone() const override;
2388 virtual void empty() override;
2389 virtual OGRErr transform( OGRCoordinateTransformation *poCT ) override;
2390 virtual void flattenTo2D() override;
2391 virtual OGRBoolean IsEmpty() const override;
2392 virtual void segmentize(double dfMaxLength) override;
2393 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
2394 const override;
2395 virtual OGRGeometry* getCurveGeometry(
2396 const char* const* papszOptions = nullptr ) const override;
2397 virtual OGRGeometry* getLinearGeometry(
2398 double dfMaxAngleStepSizeDegrees = 0,
2399 const char* const* papszOptions = nullptr ) const override;
2400
2401 // IWks Interface
2402 virtual size_t WkbSize() const override;
2403 virtual OGRErr importFromWkb( const unsigned char *,
2404 size_t,
2406 size_t& nBytesConsumedOut ) override;
2407 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
2409 const override;
2410
2411#ifndef DOXYGEN_XML
2413#endif
2414
2415 OGRErr importFromWkt( const char ** ) override;
2416
2417#ifndef DOXYGEN_XML
2419#endif
2420
2425 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
2426 OGRErr *err = nullptr) const override;
2427
2428 virtual double get_Length() const;
2429 virtual double get_Area() const;
2430
2431 // IGeometry methods
2432 virtual int getDimension() const override;
2433 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
2434 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
2435
2436 // IGeometryCollection
2437 int getNumGeometries() const;
2438 OGRGeometry *getGeometryRef( int );
2439 const OGRGeometry *getGeometryRef( int ) const;
2440
2441 // ISpatialRelation
2442 virtual OGRBoolean Equals( const OGRGeometry * ) const override;
2443
2444 // Non standard
2445 virtual void setCoordinateDimension( int nDimension ) override;
2446 virtual void set3D( OGRBoolean bIs3D ) override;
2447 virtual void setMeasured( OGRBoolean bIsMeasured ) override;
2448 virtual OGRErr addGeometry( const OGRGeometry * );
2449 virtual OGRErr addGeometryDirectly( OGRGeometry * );
2450 virtual OGRErr removeGeometry( int iIndex, int bDelete = TRUE );
2451
2452 virtual void assignSpatialReference( OGRSpatialReference * poSR ) override;
2453
2454 void closeRings() override;
2455
2456 virtual void swapXY() override;
2457
2458 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
2459 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
2460
2461 static OGRGeometryCollection* CastToGeometryCollection(
2462 OGRGeometryCollection* poSrc );
2463
2464 OGR_FORBID_DOWNCAST_TO_POINT
2465 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
2466 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
2467 OGR_ALLOW_CAST_TO_THIS(GeometryCollection)
2468};
2469
2471
2472inline const OGRGeometryCollection::ChildType* const * begin(const OGRGeometryCollection* poGeom) { return poGeom->begin(); }
2474inline const OGRGeometryCollection::ChildType* const * end(const OGRGeometryCollection* poGeom) { return poGeom->end(); }
2475
2477inline OGRGeometryCollection::ChildType** begin(OGRGeometryCollection* poGeom) { return poGeom->begin(); }
2479inline OGRGeometryCollection::ChildType** end(OGRGeometryCollection* poGeom) { return poGeom->end(); }
2481
2482/************************************************************************/
2483/* OGRMultiSurface */
2484/************************************************************************/
2485
2491
2493{
2494 protected:
2496 const override;
2497
2498 public:
2501 ~OGRMultiSurface() override;
2502
2503 OGRMultiSurface& operator=( const OGRMultiSurface& other );
2504
2507
2511 ChildType** begin() { return reinterpret_cast<ChildType**>(papoGeoms); }
2513 ChildType** end() { return reinterpret_cast<ChildType**>(papoGeoms + nGeomCount); }
2517 const ChildType* const* begin() const { return reinterpret_cast<const ChildType* const*>(papoGeoms); }
2519 const ChildType* const* end() const { return reinterpret_cast<const ChildType* const*>(papoGeoms + nGeomCount); }
2520
2521 // Non standard (OGRGeometry).
2522 virtual const char *getGeometryName() const override;
2523 virtual OGRwkbGeometryType getGeometryType() const override;
2524 virtual OGRMultiSurface *clone() const override;
2525
2526#ifndef DOXYGEN_XML
2528#endif
2529
2530 OGRErr importFromWkt( const char ** ) override;
2531
2532#ifndef DOXYGEN_XML
2534#endif
2535
2540 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
2541 OGRErr *err = nullptr) const override;
2542
2543 // IMultiSurface methods
2544 virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const;
2545
2546 // IGeometry methods
2547 virtual int getDimension() const override;
2548
2549 // IGeometryCollection
2554
2555 // Non standard
2556 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
2557 const override;
2558
2560 inline OGRGeometryCollection* toUpperClass() { return this; }
2562 inline const OGRGeometryCollection* toUpperClass() const { return this; }
2563
2564 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
2565 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
2566
2567 static OGRMultiPolygon* CastToMultiPolygon( OGRMultiSurface* poMS );
2568
2569 OGR_ALLOW_CAST_TO_THIS(MultiSurface)
2570 OGR_ALLOW_UPCAST_TO(GeometryCollection)
2571 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
2572 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
2573 OGR_FORBID_DOWNCAST_TO_MULTICURVE
2574};
2575
2577
2578inline const OGRMultiSurface::ChildType* const * begin(const OGRMultiSurface* poGeom) { return poGeom->begin(); }
2580inline const OGRMultiSurface::ChildType* const * end(const OGRMultiSurface* poGeom) { return poGeom->end(); }
2581
2583inline OGRMultiSurface::ChildType** begin(OGRMultiSurface* poGeom) { return poGeom->begin(); }
2585inline OGRMultiSurface::ChildType** end(OGRMultiSurface* poGeom) { return poGeom->end(); }
2587
2588/************************************************************************/
2589/* OGRMultiPolygon */
2590/************************************************************************/
2591
2595
2596class CPL_DLL OGRMultiPolygon : public OGRMultiSurface
2597{
2598 protected:
2600 const override;
2601 friend class OGRPolyhedralSurface;
2602 friend class OGRTriangulatedSurface;
2603
2604 private:
2606 OGRErr _addGeometryWithExpectedSubGeometryType(
2607 const OGRGeometry * poNewGeom,
2608 OGRwkbGeometryType eSubGeometryType );
2609 OGRErr _addGeometryDirectlyWithExpectedSubGeometryType(
2610 OGRGeometry * poNewGeom,
2611 OGRwkbGeometryType eSubGeometryType );
2613
2614
2615 public:
2618 ~OGRMultiPolygon() override;
2619
2621
2624
2628 ChildType** begin() { return reinterpret_cast<ChildType**>(papoGeoms); }
2630 ChildType** end() { return reinterpret_cast<ChildType**>(papoGeoms + nGeomCount); }
2634 const ChildType* const* begin() const { return reinterpret_cast<const ChildType* const*>(papoGeoms); }
2636 const ChildType* const* end() const { return reinterpret_cast<const ChildType* const*>(papoGeoms + nGeomCount); }
2637
2638 // IGeometryCollection
2643
2644 // Non-standard (OGRGeometry).
2645 virtual const char *getGeometryName() const override;
2646 virtual OGRwkbGeometryType getGeometryType() const override;
2647 virtual OGRMultiPolygon *clone() const override;
2648
2649#ifndef DOXYGEN_XML
2651#endif
2652
2657 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
2658 OGRErr *err = nullptr) const override;
2659
2660 // Non standard
2661 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
2662 const override;
2663
2665 inline OGRGeometryCollection* toUpperClass() { return this; }
2667 inline const OGRGeometryCollection* toUpperClass() const { return this; }
2668
2669 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
2670 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
2671
2672 static OGRMultiSurface* CastToMultiSurface( OGRMultiPolygon* poMP );
2673
2674 OGR_ALLOW_CAST_TO_THIS(MultiPolygon)
2675 OGR_ALLOW_UPCAST_TO(MultiSurface)
2676};
2677
2679
2680inline const OGRMultiPolygon::ChildType* const * begin(const OGRMultiPolygon* poGeom) { return poGeom->begin(); }
2682inline const OGRMultiPolygon::ChildType* const * end(const OGRMultiPolygon* poGeom) { return poGeom->end(); }
2683
2685inline OGRMultiPolygon::ChildType** begin(OGRMultiPolygon* poGeom) { return poGeom->begin(); }
2687inline OGRMultiPolygon::ChildType** end(OGRMultiPolygon* poGeom) { return poGeom->end(); }
2689
2690/************************************************************************/
2691/* OGRPolyhedralSurface */
2692/************************************************************************/
2693
2699
2700class CPL_DLL OGRPolyhedralSurface : public OGRSurface
2701{
2702 protected:
2704 friend class OGRTriangulatedSurface;
2705 OGRMultiPolygon oMP{};
2706 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon()
2707 const override;
2708 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon()
2709 const override;
2710 virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const;
2711 virtual const char* getSubGeometryName() const;
2712 virtual OGRwkbGeometryType getSubGeometryType() const;
2713 std::string exportToWktInternal (const OGRWktOptions& opts, OGRErr *err) const;
2714
2715 virtual OGRPolyhedralSurfaceCastToMultiPolygon GetCasterToMultiPolygon()
2716 const;
2717 static OGRMultiPolygon* CastToMultiPolygonImpl(OGRPolyhedralSurface* poPS);
2719
2720 public:
2725
2728
2732 ChildType** begin() { return oMP.begin(); }
2734 ChildType** end() { return oMP.end(); }
2738 const ChildType* const* begin() const { return oMP.begin(); }
2740 const ChildType* const* end() const { return oMP.end(); }
2741
2742 // IWks Interface.
2743 virtual size_t WkbSize() const override;
2744 virtual const char *getGeometryName() const override;
2745 virtual OGRwkbGeometryType getGeometryType() const override;
2746 virtual OGRErr importFromWkb( const unsigned char *,
2747 size_t,
2749 size_t& nBytesConsumedOut ) override;
2750 virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *,
2752 const override;
2753
2754#ifndef DOXYGEN_XML
2756#endif
2757
2758 OGRErr importFromWkt( const char ** ) override;
2759
2760#ifndef DOXYGEN_XML
2762#endif
2763
2768 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
2769 OGRErr *err = nullptr) const override;
2770
2771 // IGeometry methods.
2772 virtual int getDimension() const override;
2773
2774 virtual void empty() override;
2775
2776 virtual OGRPolyhedralSurface *clone() const override;
2777 virtual void getEnvelope( OGREnvelope * psEnvelope ) const override;
2778 virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const override;
2779
2780 virtual void flattenTo2D() override;
2781 virtual OGRErr transform( OGRCoordinateTransformation* ) override;
2782 virtual OGRBoolean Equals( const OGRGeometry* ) const override;
2783 virtual double get_Area() const override;
2784 virtual OGRErr PointOnSurface( OGRPoint* ) const override;
2785
2786 static OGRMultiPolygon* CastToMultiPolygon( OGRPolyhedralSurface* poPS );
2787 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
2788 const override;
2789 virtual OGRErr addGeometry( const OGRGeometry * );
2790 OGRErr addGeometryDirectly( OGRGeometry *poNewGeom );
2791 int getNumGeometries() const;
2792 OGRPolygon* getGeometryRef(int i);
2793 const OGRPolygon* getGeometryRef(int i) const;
2794
2795 virtual OGRBoolean IsEmpty() const override;
2796 virtual void setCoordinateDimension( int nDimension ) override;
2797 virtual void set3D( OGRBoolean bIs3D ) override;
2798 virtual void setMeasured( OGRBoolean bIsMeasured ) override;
2799 virtual void swapXY() override;
2800 OGRErr removeGeometry( int iIndex, int bDelete = TRUE );
2801
2802 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
2803 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
2804
2805 virtual void assignSpatialReference( OGRSpatialReference * poSR ) override;
2806
2807 OGR_ALLOW_CAST_TO_THIS(PolyhedralSurface)
2808 OGR_ALLOW_UPCAST_TO(Surface)
2809};
2810
2812
2813inline const OGRPolyhedralSurface::ChildType* const * begin(const OGRPolyhedralSurface* poGeom) { return poGeom->begin(); }
2815inline const OGRPolyhedralSurface::ChildType* const * end(const OGRPolyhedralSurface* poGeom) { return poGeom->end(); }
2816
2818inline OGRPolyhedralSurface::ChildType** begin(OGRPolyhedralSurface* poGeom) { return poGeom->begin(); }
2820inline OGRPolyhedralSurface::ChildType** end(OGRPolyhedralSurface* poGeom) { return poGeom->end(); }
2822
2823/************************************************************************/
2824/* OGRTriangulatedSurface */
2825/************************************************************************/
2826
2832
2834{
2835 protected:
2837 virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType )
2838 const override;
2839 virtual const char* getSubGeometryName() const override;
2840 virtual OGRwkbGeometryType getSubGeometryType() const override;
2841
2842 virtual OGRPolyhedralSurfaceCastToMultiPolygon GetCasterToMultiPolygon()
2843 const override;
2844 static OGRMultiPolygon *
2845 CastToMultiPolygonImpl( OGRPolyhedralSurface* poPS );
2847
2848 public:
2852
2855
2859 ChildType** begin() { return reinterpret_cast<ChildType**>(oMP.begin()); }
2861 ChildType** end() { return reinterpret_cast<ChildType**>(oMP.end()); }
2865 const ChildType* const* begin() const { return reinterpret_cast<const ChildType* const*>(oMP.begin()); }
2867 const ChildType* const* end() const { return reinterpret_cast<const ChildType* const*>(oMP.end()); }
2868
2869 OGRTriangulatedSurface& operator=( const OGRTriangulatedSurface& other );
2870 virtual const char *getGeometryName() const override;
2871 virtual OGRwkbGeometryType getGeometryType() const override;
2872 virtual OGRTriangulatedSurface *clone() const override;
2873
2878
2879 // IWks Interface.
2880 virtual OGRErr addGeometry( const OGRGeometry * ) override;
2881
2883 inline OGRPolyhedralSurface* toUpperClass() { return this; }
2885 inline const OGRPolyhedralSurface* toUpperClass() const { return this; }
2886
2887 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
2888 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
2889
2890 static OGRPolyhedralSurface *
2891 CastToPolyhedralSurface( OGRTriangulatedSurface* poTS );
2892
2893 OGR_ALLOW_CAST_TO_THIS(TriangulatedSurface)
2894 OGR_ALLOW_UPCAST_TO(PolyhedralSurface)
2895};
2896
2898
2899inline const OGRTriangulatedSurface::ChildType* const * begin(const OGRTriangulatedSurface* poGeom) { return poGeom->begin(); }
2901inline const OGRTriangulatedSurface::ChildType* const * end(const OGRTriangulatedSurface* poGeom) { return poGeom->end(); }
2902
2904inline OGRTriangulatedSurface::ChildType** begin(OGRTriangulatedSurface* poGeom) { return poGeom->begin(); }
2906inline OGRTriangulatedSurface::ChildType** end(OGRTriangulatedSurface* poGeom) { return poGeom->end(); }
2908
2909/************************************************************************/
2910/* OGRMultiPoint */
2911/************************************************************************/
2912
2916
2918{
2919 private:
2920 OGRErr importFromWkt_Bracketed( const char **, int bHasM, int bHasZ );
2921
2922 protected:
2924 const override;
2925
2926 public:
2929 ~OGRMultiPoint() override;
2930
2931 OGRMultiPoint& operator=(const OGRMultiPoint& other);
2932
2935
2939 ChildType** begin() { return reinterpret_cast<ChildType**>(papoGeoms); }
2941 ChildType** end() { return reinterpret_cast<ChildType**>(papoGeoms + nGeomCount); }
2945 const ChildType* const* begin() const { return reinterpret_cast<const ChildType* const*>(papoGeoms); }
2947 const ChildType* const* end() const { return reinterpret_cast<const ChildType* const*>(papoGeoms + nGeomCount); }
2948
2949 // IGeometryCollection
2954
2955 // Non-standard (OGRGeometry).
2956 virtual const char *getGeometryName() const override;
2957 virtual OGRwkbGeometryType getGeometryType() const override;
2958 virtual OGRMultiPoint *clone() const override;
2959
2960#ifndef DOXYGEN_XML
2962#endif
2963
2964 OGRErr importFromWkt( const char ** ) override;
2965
2966#ifndef DOXYGEN_XML
2968#endif
2969
2974 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
2975 OGRErr *err = nullptr) const override;
2976
2977 // IGeometry methods.
2978 virtual int getDimension() const override;
2979
2981 inline OGRGeometryCollection* toUpperClass() { return this; }
2983 inline const OGRGeometryCollection* toUpperClass() const { return this; }
2984
2985 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
2986 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
2987
2988 // Non-standard.
2989 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
2990 const override;
2991
2992 OGR_ALLOW_CAST_TO_THIS(MultiPoint)
2993 OGR_ALLOW_UPCAST_TO(GeometryCollection)
2994 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
2995 OGR_FORBID_DOWNCAST_TO_MULTICURVE
2996 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
2997 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
2998};
2999
3001
3002inline const OGRMultiPoint::ChildType* const * begin(const OGRMultiPoint* poGeom) { return poGeom->begin(); }
3004inline const OGRMultiPoint::ChildType* const * end(const OGRMultiPoint* poGeom) { return poGeom->end(); }
3005
3007inline OGRMultiPoint::ChildType** begin(OGRMultiPoint* poGeom) { return poGeom->begin(); }
3009inline OGRMultiPoint::ChildType** end(OGRMultiPoint* poGeom) { return poGeom->end(); }
3011
3012/************************************************************************/
3013/* OGRMultiCurve */
3014/************************************************************************/
3015
3021
3023{
3024 protected:
3026 static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf,
3027 OGRCurve* poCurve );
3030 const override;
3031
3032 public:
3035 ~OGRMultiCurve() override;
3036
3037 OGRMultiCurve& operator=( const OGRMultiCurve& other );
3038
3041
3045 ChildType** begin() { return reinterpret_cast<ChildType**>(papoGeoms); }
3047 ChildType** end() { return reinterpret_cast<ChildType**>(papoGeoms + nGeomCount); }
3051 const ChildType* const* begin() const { return reinterpret_cast<const ChildType* const*>(papoGeoms); }
3053 const ChildType* const* end() const { return reinterpret_cast<const ChildType* const*>(papoGeoms + nGeomCount); }
3054
3055 // IGeometryCollection
3060
3061 // Non standard (OGRGeometry).
3062 virtual const char *getGeometryName() const override;
3063 virtual OGRwkbGeometryType getGeometryType() const override;
3064 virtual OGRMultiCurve *clone() const override;
3065
3066#ifndef DOXYGEN_XML
3068#endif
3069
3070 OGRErr importFromWkt( const char ** ) override;
3071
3072#ifndef DOXYGEN_XML
3074#endif
3075
3080 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
3081 OGRErr *err = nullptr) const override;
3082
3083 // IGeometry methods.
3084 virtual int getDimension() const override;
3085
3086 // Non-standard.
3087 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
3088 const override;
3089
3091 inline OGRGeometryCollection* toUpperClass() { return this; }
3093 inline const OGRGeometryCollection* toUpperClass() const { return this; }
3094
3095 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
3096 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
3097
3098 static OGRMultiLineString* CastToMultiLineString(OGRMultiCurve* poMC);
3099
3100 OGR_ALLOW_CAST_TO_THIS(MultiCurve)
3101 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3102 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3103 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3104 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3105};
3106
3108
3109inline const OGRMultiCurve::ChildType* const * begin(const OGRMultiCurve* poGeom) { return poGeom->begin(); }
3111inline const OGRMultiCurve::ChildType* const * end(const OGRMultiCurve* poGeom) { return poGeom->end(); }
3112
3114inline OGRMultiCurve::ChildType** begin(OGRMultiCurve* poGeom) { return poGeom->begin(); }
3116inline OGRMultiCurve::ChildType** end(OGRMultiCurve* poGeom) { return poGeom->end(); }
3118
3119/************************************************************************/
3120/* OGRMultiLineString */
3121/************************************************************************/
3122
3126
3127class CPL_DLL OGRMultiLineString : public OGRMultiCurve
3128{
3129 protected:
3131 const override;
3132
3133 public:
3136 ~OGRMultiLineString() override;
3137
3139
3142
3146 ChildType** begin() { return reinterpret_cast<ChildType**>(papoGeoms); }
3148 ChildType** end() { return reinterpret_cast<ChildType**>(papoGeoms + nGeomCount); }
3152 const ChildType* const* begin() const { return reinterpret_cast<const ChildType* const*>(papoGeoms); }
3154 const ChildType* const* end() const { return reinterpret_cast<const ChildType* const*>(papoGeoms + nGeomCount); }
3155
3156 // IGeometryCollection
3161
3162 // Non standard (OGRGeometry).
3163 virtual const char *getGeometryName() const override;
3164 virtual OGRwkbGeometryType getGeometryType() const override;
3165 virtual OGRMultiLineString *clone() const override;
3166
3167#ifndef DOXYGEN_XML
3169#endif
3170
3175 virtual std::string exportToWkt(const OGRWktOptions& opts = OGRWktOptions(),
3176 OGRErr *err = nullptr) const override;
3177
3178 // Non standard
3179 virtual OGRBoolean hasCurveGeometry( int bLookForNonLinear = FALSE )
3180 const override;
3181
3183 inline OGRGeometryCollection* toUpperClass() { return this; }
3185 inline const OGRGeometryCollection* toUpperClass() const { return this; }
3186
3187 virtual void accept(IOGRGeometryVisitor* visitor) override { visitor->visit(this); }
3188 virtual void accept(IOGRConstGeometryVisitor* visitor) const override { visitor->visit(this); }
3189
3190 static OGRMultiCurve* CastToMultiCurve( OGRMultiLineString* poMLS );
3191
3192 OGR_ALLOW_CAST_TO_THIS(MultiLineString)
3193 OGR_ALLOW_UPCAST_TO(MultiCurve)
3194 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3195 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3196 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3197};
3198
3200
3201inline const OGRMultiLineString::ChildType* const * begin(const OGRMultiLineString* poGeom) { return poGeom->begin(); }
3203inline const OGRMultiLineString::ChildType* const * end(const OGRMultiLineString* poGeom) { return poGeom->end(); }
3204
3206inline OGRMultiLineString::ChildType** begin(OGRMultiLineString* poGeom) { return poGeom->begin(); }
3208inline OGRMultiLineString::ChildType** end(OGRMultiLineString* poGeom) { return poGeom->end(); }
3210
3211/************************************************************************/
3212/* OGRGeometryFactory */
3213/************************************************************************/
3214
3218
3220{
3221 static OGRErr createFromFgfInternal( const unsigned char *pabyData,
3222 OGRSpatialReference * poSR,
3223 OGRGeometry **ppoReturn,
3224 int nBytes,
3225 int *pnBytesConsumed,
3226 int nRecLevel );
3227 public:
3228 static OGRErr createFromWkb( const void *, OGRSpatialReference *,
3229 OGRGeometry **, size_t = static_cast<size_t>(-1),
3231 static OGRErr createFromWkb( const void * pabyData,
3233 OGRGeometry **,
3234 size_t nSize,
3235 OGRwkbVariant eVariant,
3236 size_t& nBytesConsumedOut );
3237 static OGRErr createFromWkt( const char* , OGRSpatialReference *,
3238 OGRGeometry ** );
3239 static OGRErr createFromWkt( const char **, OGRSpatialReference *,
3240 OGRGeometry ** );
3244 static OGRErr createFromWkt( char ** ppszInput, OGRSpatialReference * poSRS,
3245 OGRGeometry ** ppoGeom )
3246 CPL_WARN_DEPRECATED("Use createFromWkt(const char**, ...) instead")
3247 {
3248 return createFromWkt( const_cast<const char**>(ppszInput), poSRS, ppoGeom);
3249 }
3250
3251 static OGRErr createFromFgf( const void*, OGRSpatialReference *,
3252 OGRGeometry **, int = -1, int * = nullptr );
3253 static OGRGeometry *createFromGML( const char * );
3254 static OGRGeometry *createFromGEOS( GEOSContextHandle_t hGEOSCtxt,
3255 GEOSGeom );
3256 static OGRGeometry *createFromGeoJson( const char *, int = -1 );
3257 static OGRGeometry *createFromGeoJson( const CPLJSONObject &oJSONObject );
3258
3259 static void destroyGeometry( OGRGeometry * );
3260 static OGRGeometry *createGeometry( OGRwkbGeometryType );
3261
3262 static OGRGeometry * forceToPolygon( OGRGeometry * );
3263 static OGRGeometry * forceToLineString( OGRGeometry *,
3264 bool bOnlyInOrder = true );
3265 static OGRGeometry * forceToMultiPolygon( OGRGeometry * );
3266 static OGRGeometry * forceToMultiPoint( OGRGeometry * );
3267 static OGRGeometry * forceToMultiLineString( OGRGeometry * );
3268
3269 static OGRGeometry * forceTo( OGRGeometry* poGeom,
3270 OGRwkbGeometryType eTargetType,
3271 const char*const* papszOptions = nullptr );
3272
3273 static OGRGeometry * removeLowerDimensionSubGeoms( const OGRGeometry* poGeom );
3274
3275 static OGRGeometry * organizePolygons( OGRGeometry **papoPolygons,
3276 int nPolygonCount,
3277 int *pbResultValidGeometry,
3278 const char **papszOptions = nullptr);
3279 static bool haveGEOS();
3280
3282 class CPL_DLL TransformWithOptionsCache
3283 {
3284 friend class OGRGeometryFactory;
3285 struct Private;
3286 std::unique_ptr<Private> d;
3287
3288 public:
3289 TransformWithOptionsCache();
3290 ~TransformWithOptionsCache();
3291 };
3292
3293 static OGRGeometry* transformWithOptions( const OGRGeometry* poSrcGeom,
3295 char** papszOptions,
3297
3298 static OGRGeometry*
3299 approximateArcAngles( double dfX, double dfY, double dfZ,
3300 double dfPrimaryRadius, double dfSecondaryAxis,
3301 double dfRotation,
3302 double dfStartAngle, double dfEndAngle,
3303 double dfMaxAngleStepSizeDegrees,
3304 const bool bUseMaxGap = false );
3305
3306 static int GetCurveParameters( double x0, double y0,
3307 double x1, double y1,
3308 double x2, double y2,
3309 double& R, double& cx, double& cy,
3310 double& alpha0, double& alpha1,
3311 double& alpha2 );
3313 double x0, double y0, double z0,
3314 double x1, double y1, double z1,
3315 double x2, double y2, double z2,
3316 int bHasZ,
3317 double dfMaxAngleStepSizeDegrees,
3318 const char* const * papszOptions = nullptr );
3320 const OGRLineString* poLS,
3321 const char* const * papszOptions = nullptr);
3322};
3323
3324OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType( const char *pszGeomType );
3325const char CPL_DLL * OGRToOGCGeomType( OGRwkbGeometryType eGeomType );
3326
3328typedef struct _OGRPreparedGeometry OGRPreparedGeometry;
3329
3330struct CPL_DLL OGRPreparedGeometryUniquePtrDeleter
3331{
3332 void operator()(OGRPreparedGeometry*) const;
3333};
3335
3339typedef std::unique_ptr<OGRPreparedGeometry, OGRPreparedGeometryUniquePtrDeleter> OGRPreparedGeometryUniquePtr;
3340
3341#endif /* ndef OGR_GEOMETRY_H_INCLUDED */
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition cpl_json.h:54
OGRGeometry visitor interface.
Definition ogr_geometry.h:232
virtual void visit(const OGRCurvePolygon *)=0
Visit OGRCurvePolygon.
virtual void visit(const OGRPolyhedralSurface *)=0
Visit OGRPolyhedralSurface.
virtual void visit(const OGRCompoundCurve *)=0
Visit OGRCompoundCurve.
virtual void visit(const OGRMultiLineString *)=0
Visit OGRMultiLineString.
virtual void visit(const OGRTriangulatedSurface *)=0
Visit OGRTriangulatedSurface.
virtual void visit(const OGRPolygon *)=0
Visit OGRPolygon.
virtual void visit(const OGRMultiPolygon *)=0
Visit OGRMultiPolygon.
virtual void visit(const OGRTriangle *)=0
Visit OGRTriangle.
virtual void visit(const OGRLineString *)=0
Visit OGRLineString.
virtual void visit(const OGRMultiPoint *)=0
Visit OGRMultiPoint.
virtual void visit(const OGRMultiCurve *)=0
Visit OGRMultiCurve.
virtual void visit(const OGRGeometryCollection *)=0
Visit OGRGeometryCollection.
virtual void visit(const OGRPoint *)=0
Visit OGRPoint.
virtual ~IOGRConstGeometryVisitor()=default
Destructor/.
virtual void visit(const OGRMultiSurface *)=0
Visit OGRMultiSurface.
virtual void visit(const OGRLinearRing *)=0
Visit OGRLinearRing.
virtual void visit(const OGRCircularString *)=0
Visit OGRCircularString.
OGRGeometry visitor interface.
Definition ogr_geometry.h:158
virtual void visit(OGRMultiSurface *)=0
Visit OGRMultiSurface.
virtual void visit(OGRLinearRing *)=0
Visit OGRLinearRing.
virtual void visit(OGRTriangle *)=0
Visit OGRTriangle.
virtual void visit(OGRCircularString *)=0
Visit OGRCircularString.
virtual void visit(OGRPolygon *)=0
Visit OGRPolygon.
virtual void visit(OGRLineString *)=0
Visit OGRLineString.
virtual void visit(OGRCompoundCurve *)=0
Visit OGRCompoundCurve.
virtual void visit(OGRTriangulatedSurface *)=0
Visit OGRTriangulatedSurface.
virtual void visit(OGRPoint *)=0
Visit OGRPoint.
virtual void visit(OGRCurvePolygon *)=0
Visit OGRCurvePolygon.
virtual void visit(OGRGeometryCollection *)=0
Visit OGRGeometryCollection.
virtual void visit(OGRPolyhedralSurface *)=0
Visit OGRPolyhedralSurface.
virtual void visit(OGRMultiPolygon *)=0
Visit OGRMultiPolygon.
virtual ~IOGRGeometryVisitor()=default
Destructor/.
virtual void visit(OGRMultiLineString *)=0
Visit OGRMultiLineString.
virtual void visit(OGRMultiPoint *)=0
Visit OGRMultiPoint.
virtual void visit(OGRMultiCurve *)=0
Visit OGRMultiCurve.
Concrete representation of a circular string, that is to say a curve made of one or several arc circl...
Definition ogr_geometry.h:1568
OGRCircularString & operator=(const OGRCircularString &other)
Assignment operator.
Definition ogrcircularstring.cpp:95
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1647
virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override
Assign geometry from well known binary data.
Definition ogrcircularstring.cpp:148
virtual OGRCircularString * clone() const override
Make a copy of this object.
Definition ogrcircularstring.cpp:135
OGRCircularString()
Create an empty circular string.
virtual void Value(double, OGRPoint *) const override
Fetch point at given distance along curve.
Definition ogrcircularstring.cpp:577
virtual OGRBoolean IsValid() const override
Test if the geometry is valid.
Definition ogrcircularstring.cpp:717
virtual void segmentize(double dfMaxLength) override
Modify the geometry such it has no segment longer then the given distance.
Definition ogrcircularstring.cpp:363
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1645
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const override
Export a circular string to WKT.
Definition ogrcircularstring.cpp:216
virtual OGRwkbGeometryType getGeometryType() const override
Fetch geometry type.
Definition ogrcircularstring.cpp:108
virtual void getEnvelope(OGREnvelope *psEnvelope) const override
Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
Definition ogrcircularstring.cpp:341
virtual double get_Length() const override
Returns the length of the curve.
Definition ogrcircularstring.cpp:237
OGRCircularString(const OGRCircularString &other)
Copy constructor.
virtual double get_Area() const override
Get the area of the (closed) curve.
Definition ogrcircularstring.cpp:877
virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc) const override
Convert a geometry into well known binary format.
Definition ogrcircularstring.cpp:174
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition ogrcircularstring.cpp:125
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:1643
OGRErr importFromWkt(const char **) override
deprecated
Definition ogrcircularstring.cpp:197
virtual OGRGeometry * getLinearGeometry(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const override
Return, possibly approximate, non-curve version of this geometry.
Definition ogrcircularstring.cpp:738
virtual OGRLineString * CurveToLine(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const override
Return a linestring from a curve geometry.
Definition ogrcircularstring.cpp:674
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1648
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const override
Returns if this geometry is or has curve geometry.
Definition ogrcircularstring.cpp:728
Utility class to store a collection of curves.
Definition ogr_geometry.h:1769
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1901
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:1820
const ChildType *const * begin() const
Return begin of curve iterator.
Definition ogr_geometry.h:1818
OGRCompoundCurve & operator=(const OGRCompoundCurve &other)
Assignment operator.
Definition ogrcompoundcurve.cpp:87
OGRCompoundCurve(const OGRCompoundCurve &other)
Copy constructor.
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:1807
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:1814
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:1812
OGRCompoundCurve()
Create an empty compound curve.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1900
Interface for transforming between coordinate systems.
Definition ogr_spatialref.h:751
Concrete class representing curve polygons.
Definition ogr_geometry.h:1973
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2104
static OGRPolygon * CastToPolygon(OGRCurvePolygon *poCP)
Convert to polygon.
Definition ogrcurvepolygon.cpp:814
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:2010
OGRCurvePolygon()
Create an empty curve polygon.
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:2023
const ChildType *const * begin() const
Return begin of curve iterator.
Definition ogr_geometry.h:2021
OGRCurvePolygon & operator=(const OGRCurvePolygon &other)
Assignment operator.
Definition ogrcurvepolygon.cpp:88
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:2015
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:2017
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2105
OGRCurvePolygon(const OGRCurvePolygon &)
Copy constructor.
Abstract curve base class for OGRLineString, OGRCircularString and OGRCompoundCurve.
Definition ogr_geometry.h:1070
virtual OGRPointIterator * getPointIterator() const =0
Returns a point iterator over the curve.
virtual int getDimension() const override
Get the dimension of this object.
Definition ogrcurve.cpp:72
virtual int IntersectsPoint(const OGRPoint *p) const
Returns if a point intersects a (closed) curve.
Definition ogrcurve.cpp:416
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:1153
virtual double get_Length() const =0
Returns the length of the curve.
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:1112
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:1148
virtual double get_AreaOfCurveSegments() const =0
Get the area of the purely curve portions of a (closed) curve.
virtual int ContainsPoint(const OGRPoint *p) const
Returns if a point is contained in a (closed) curve.
Definition ogrcurve.cpp:396
virtual int get_IsClosed() const
Return TRUE if curve is closed.
Definition ogrcurve.cpp:95
virtual double get_Area() const =0
Get the area of the (closed) curve.
virtual void Value(double, OGRPoint *) const =0
Fetch point at given distance along curve.
static OGRLineString * CastToLineString(OGRCurve *poCurve)
Cast to linestring.
Definition ogrcurve.cpp:353
virtual int getNumPoints() const =0
Return the number of points of a curve geometry.
virtual void StartPoint(OGRPoint *) const =0
Return the curve start point.
virtual void EndPoint(OGRPoint *) const =0
Return the curve end point.
virtual OGRBoolean IsConvex() const
Returns if a (closed) curve forms a convex shape.
Definition ogrcurve.cpp:276
virtual OGRLineString * CurveToLine(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const =0
Return a linestring from a curve geometry.
static OGRLinearRing * CastToLinearRing(OGRCurve *poCurve)
Cast to linear ring.
Definition ogrcurve.cpp:375
virtual OGRCurve * clone() const override=0
Make a copy of this object.
OGRGeometry visitor default implementation.
Definition ogr_geometry.h:279
void visit(const OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:284
OGRGeometry visitor default implementation.
Definition ogr_geometry.h:205
void visit(OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:210
Simple container for a bounding region in 3D.
Definition ogr_core.h:199
Simple container for a bounding region (rectangle)
Definition ogr_core.h:58
A collection of 1 or more geometry objects.
Definition ogr_geometry.h:2341
ChildType ** end()
Return end of sub-geometry iterator.
Definition ogr_geometry.h:2376
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2458
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2459
virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const
Returns whether a geometry of the specified geometry type can be a member of this collection.
Definition ogrgeometrycollection.cpp:1180
const ChildType *const * begin() const
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:2380
const ChildType *const * end() const
Return end of sub-geometry iterator.
Definition ogr_geometry.h:2382
ChildType ** begin()
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:2374
OGRGeometryCollection & operator=(const OGRGeometryCollection &other)
Assignment operator.
Definition ogrgeometrycollection.cpp:111
OGRGeometry * getGeometryRef(int)
Fetch geometry from container.
Definition ogrgeometrycollection.cpp:262
OGRGeometryCollection()
Create an empty geometry collection.
OGRGeometry ChildType
Type of child elements.
Definition ogr_geometry.h:2369
Opaque class used as argument to transformWithOptions()
Definition ogr_geometry.h:3283
Create geometry objects from well known text/binary.
Definition ogr_geometry.h:3220
static OGRGeometry * transformWithOptions(const OGRGeometry *poSrcGeom, OGRCoordinateTransformation *poCT, char **papszOptions, const TransformWithOptionsCache &cache=TransformWithOptionsCache())
Transform a geometry.
Definition ogrgeometryfactory.cpp:3842
static OGRErr createFromWkt(char **ppszInput, OGRSpatialReference *poSRS, OGRGeometry **ppoGeom)
Deprecated.
Definition ogr_geometry.h:3244
static OGRCurve * curveFromLineString(const OGRLineString *poLS, const char *const *papszOptions=nullptr)
Try to convert a linestring approximating curves into a curve.
Definition ogrgeometryfactory.cpp:5991
static OGRLineString * curveToLineString(double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, int bHasZ, double dfMaxAngleStepSizeDegrees, const char *const *papszOptions=nullptr)
Converts an arc circle into an approximate line string.
Definition ogrgeometryfactory.cpp:5200
static OGRGeometry * approximateArcAngles(double dfX, double dfY, double dfZ, double dfPrimaryRadius, double dfSecondaryAxis, double dfRotation, double dfStartAngle, double dfEndAngle, double dfMaxAngleStepSizeDegrees, const bool bUseMaxGap=false)
Stroke arc to linestring.
Definition ogrgeometryfactory.cpp:4149
static OGRErr createFromWkt(const char *, OGRSpatialReference *, OGRGeometry **)
Create a geometry object of the appropriate type from its well known text representation.
Definition ogrgeometryfactory.cpp:511
static int GetCurveParameters(double x0, double y0, double x1, double y1, double x2, double y2, double &R, double &cx, double &cy, double &alpha0, double &alpha1, double &alpha2)
Returns the parameter of an arc circle.
Definition ogrgeometryfactory.cpp:4940
static OGRErr createFromWkb(const void *, OGRSpatialReference *, OGRGeometry **, size_t=static_cast< size_t >(-1), OGRwkbVariant=wkbVariantOldOgc)
Create a geometry object of the appropriate type from its well known binary representation.
Definition ogrgeometryfactory.cpp:106
Abstract base class for all geometry classes.
Definition ogr_geometry.h:327
const OGRSurface * toSurface() const
Down-cast to OGRSurface*.
Definition ogr_geometry.h:683
static void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt)
Destroy a GEOS context.
Definition ogrgeometry.cpp:3022
const OGRCurvePolygon * toCurvePolygon() const
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:725
virtual void getEnvelope(OGREnvelope *psEnvelope) const =0
Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
const OGRMultiCurve * toMultiCurve() const
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:795
virtual OGRGeometry * getCurveGeometry(const char *const *papszOptions=nullptr) const
Return curve version of this geometry.
Definition ogrgeometry.cpp:3261
const OGRPolyhedralSurface * toPolyhedralSurface() const
Down-cast to OGRPolyhedralSurface*.
Definition ogr_geometry.h:823
virtual OGRBoolean Intersects(const OGRGeometry *) const
Do these features intersect?
Definition ogrgeometry.cpp:504
const OGRMultiPoint * toMultiPoint() const
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:753
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const
Returns if this geometry is or has curve geometry.
Definition ogrgeometry.cpp:3193
const OGRMultiPolygon * toMultiPolygon() const
Down-cast to OGRMultiPolygon*.
Definition ogr_geometry.h:781
virtual GEOSGeom exportToGEOS(GEOSContextHandle_t hGEOSCtxt) const
Returns a GEOSGeom object corresponding to the geometry.
Definition ogrgeometry.cpp:3063
OGRPolyhedralSurface * toPolyhedralSurface()
Down-cast to OGRPolyhedralSurface*.
Definition ogr_geometry.h:816
const OGRMultiSurface * toMultiSurface() const
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:809
OGRPoint * toPoint()
Down-cast to OGRPoint*.
Definition ogr_geometry.h:578
virtual OGRGeometry * clone() const =0
Make a copy of this object.
virtual OGRErr transform(OGRCoordinateTransformation *poCT)=0
Apply arbitrary coordinate transformation to geometry.
virtual OGRErr importFromWkt(const char **ppszInput)=0
Assign geometry from well known text data.
bool operator!=(const OGRGeometry &other) const
Returns if two geometries are different.
Definition ogr_geometry.h:393
OGRTriangle * toTriangle()
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:704
OGRLineString * toLineString()
Down-cast to OGRLineString*.
Definition ogr_geometry.h:620
int CoordinateDimension() const
Get the dimension of the coordinates in this object.
Definition ogrgeometry.cpp:900
const OGRLinearRing * toLinearRing() const
Down-cast to OGRLinearRing*.
Definition ogr_geometry.h:641
OGRGeometry * SimplifyPreserveTopology(double dTolerance) const
Simplify the geometry while preserving topology.
Definition ogrgeometry.cpp:5699
const OGRPoint * toPoint() const
Down-cast to OGRPoint*.
Definition ogr_geometry.h:585
virtual void swapXY()
Swap x and y coordinates.
Definition ogrgeometry.cpp:6001
virtual void empty()=0
Clear geometry information.
virtual OGRGeometry * Simplify(double dTolerance) const
Simplify the geometry.
Definition ogrgeometry.cpp:5620
virtual void assignSpatialReference(OGRSpatialReference *poSR)
Assign spatial reference to this object.
Definition ogrgeometry.cpp:434
virtual OGRBoolean Overlaps(const OGRGeometry *) const
Test for overlap.
Definition ogrgeometry.cpp:5250
virtual OGRBoolean IsEmpty() const =0
Returns TRUE (non-zero) if the object has no points.
virtual OGRGeometry * DelaunayTriangulation(double dfTolerance, int bOnlyEdges) const
Return a Delaunay triangulation of the vertices of the geometry.
Definition ogrgeometry.cpp:5786
virtual int getCoordinateDimension() const
Get the dimension of the coordinates in this object.
Definition ogrgeometry.cpp:881
OGRMultiLineString * toMultiLineString()
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:760
OGRMultiSurface * toMultiSurface()
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:802
static OGRGeometry * FromHandle(OGRGeometryH hGeom)
Convert a OGRGeometryH to a OGRGeometry*.
Definition ogr_geometry.h:571
virtual void flattenTo2D()=0
Convert geometry to strictly 2D.
virtual void setMeasured(OGRBoolean bIsMeasured)
Add or remove the M coordinate dimension.
Definition ogrgeometry.cpp:1070
virtual void accept(IOGRConstGeometryVisitor *visitor) const =0
Accept a visitor.
const OGRGeometryCollection * toGeometryCollection() const
Down-cast to OGRGeometryCollection*.
Definition ogr_geometry.h:739
OGRSpatialReference * getSpatialReference(void) const
Returns spatial reference system for object.
Definition ogr_geometry.h:489
virtual OGRBoolean IsValid() const
Test if the geometry is valid.
Definition ogrgeometry.cpp:2145
const OGRMultiLineString * toMultiLineString() const
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:767
virtual OGRGeometry * Difference(const OGRGeometry *) const
Compute difference.
Definition ogrgeometry.cpp:4583
virtual OGRGeometry * MakeValid(CSLConstList papszOptions=nullptr) const
Attempts to make an invalid geometry valid without losing vertices.
Definition ogrgeometry.cpp:3657
virtual double Distance(const OGRGeometry *) const
Compute distance between two geometries.
Definition ogrgeometry.cpp:3289
virtual OGRBoolean Equals(const OGRGeometry *) const =0
Returns TRUE if two geometries are equivalent.
virtual void setCoordinateDimension(int nDimension)
Set the coordinate dimension.
Definition ogrgeometry.cpp:1024
virtual char * exportToJson() const
Convert a geometry into GeoJSON format.
Definition ogrgeometry.cpp:2955
virtual int getDimension() const =0
Get the dimension of this object.
virtual OGRGeometry * ConvexHull() const
Compute convex hull.
Definition ogrgeometry.cpp:3917
const OGRCircularString * toCircularString() const
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:655
virtual void dumpReadable(FILE *, const char *=nullptr, char **papszOptions=nullptr) const
Dump geometry in well known text format to indicated output file.
Definition ogrgeometry.cpp:183
virtual OGRGeometry * Buffer(double dfDist, int nQuadSegs=30) const
Compute buffer of geometry.
Definition ogrgeometry.cpp:4159
OGRPolygon * toPolygon()
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:690
bool operator==(const OGRGeometry &other) const
Returns if two geometries are equal.
Definition ogr_geometry.h:390
virtual void segmentize(double dfMaxLength)
Modify the geometry such it has no segment longer then the given distance.
Definition ogrgeometry.cpp:806
virtual OGRErr Centroid(OGRPoint *poPoint) const
Compute the geometry centroid.
Definition ogrgeometry.cpp:5366
OGRLinearRing * toLinearRing()
Down-cast to OGRLinearRing*.
Definition ogr_geometry.h:634
virtual OGRGeometry * UnionCascaded() const
Compute union using cascading.
Definition ogrgeometry.cpp:4496
OGRBoolean IsMeasured() const
Definition ogr_geometry.h:407
virtual OGRBoolean Within(const OGRGeometry *) const
Test for containment.
Definition ogrgeometry.cpp:5101
OGRGeometry & operator=(const OGRGeometry &other)
Assignment operator.
Definition ogrgeometry.cpp:152
virtual OGRGeometry * Union(const OGRGeometry *) const
Compute union.
Definition ogrgeometry.cpp:4382
virtual OGRGeometry * Polygonize() const
Polygonizes a set of sparse edges.
Definition ogrgeometry.cpp:5891
virtual void accept(IOGRGeometryVisitor *visitor)=0
Accept a visitor.
virtual double Distance3D(const OGRGeometry *poOtherGeom) const
Returns the 3D distance between two geometries.
Definition ogrgeometry.cpp:3423
virtual OGRGeometry * Normalize() const
Attempts to bring geometry into normalized/canonical form.
Definition ogrgeometry.cpp:3834
OGRMultiCurve * toMultiCurve()
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:788
const OGRCompoundCurve * toCompoundCurve() const
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:669
virtual OGRBoolean Disjoint(const OGRGeometry *) const
Test for disjointness.
Definition ogrgeometry.cpp:4845
virtual OGRGeometry * SymDifference(const OGRGeometry *) const
Compute symmetric difference.
Definition ogrgeometry.cpp:4705
virtual OGRwkbGeometryType getGeometryType() const =0
Fetch geometry type.
virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc) const =0
Convert a geometry into well known binary format.
OGRGeometryCollection * toGeometryCollection()
Down-cast to OGRGeometryCollection*.
Definition ogr_geometry.h:732
virtual char * exportToKML() const
Convert a geometry into KML format.
Definition ogrgeometry.cpp:2933
virtual OGRGeometry * Boundary() const
Compute boundary.
Definition ogrgeometry.cpp:4032
virtual char * exportToGML(const char *const *papszOptions=nullptr) const
Convert a geometry into GML format.
Definition ogrgeometry.cpp:2910
virtual OGRBoolean Touches(const OGRGeometry *) const
Test for touching.
Definition ogrgeometry.cpp:4919
OGRMultiPolygon * toMultiPolygon()
Down-cast to OGRMultiPolygon*.
Definition ogr_geometry.h:774
const OGRPolygon * toPolygon() const
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:697
OGRCompoundCurve * toCompoundCurve()
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:662
OGRwkbGeometryType getIsoGeometryType() const
Get the geometry type that conforms with ISO SQL/MM Part3.
Definition ogrgeometry.cpp:774
OGRErr importFromWkt(char **ppszInput)
Deprecated.
Definition ogr_geometry.h:430
const OGRLineString * toLineString() const
Down-cast to OGRLineString*.
Definition ogr_geometry.h:627
OGRErr exportToWkt(char **ppszDstText, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known text format.
Definition ogrgeometry.cpp:1829
virtual void set3D(OGRBoolean bIs3D)
Add or remove the Z coordinate dimension.
Definition ogrgeometry.cpp:1047
virtual size_t WkbSize() const =0
Returns size of related binary representation.
OGRCircularString * toCircularString()
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:648
const OGRCurve * toCurve() const
Down-cast to OGRCurve*.
Definition ogr_geometry.h:599
virtual OGRGeometry * getLinearGeometry(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const
Return, possibly approximate, non-curve version of this geometry.
Definition ogrgeometry.cpp:3226
OGRCurvePolygon * toCurvePolygon()
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:718
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:613
static GEOSContextHandle_t createGEOSContext()
Create a new GEOS context.
Definition ogrgeometry.cpp:3004
virtual OGRBoolean Crosses(const OGRGeometry *) const
Test for crossing.
Definition ogrgeometry.cpp:4993
OGRErr importFromWkb(const GByte *, size_t=static_cast< size_t >(-1), OGRwkbVariant=wkbVariantOldOgc)
Assign geometry from well known binary data.
Definition ogrgeometry.cpp:1427
virtual OGRGeometry * Intersection(const OGRGeometry *) const
Compute intersection.
Definition ogrgeometry.cpp:4263
OGRErr transformTo(OGRSpatialReference *poSR)
Transform geometry to new spatial reference system.
Definition ogrgeometry.cpp:628
static OGRGeometryH ToHandle(OGRGeometry *poGeom)
Convert a OGRGeometry* to a OGRGeometryH.
Definition ogr_geometry.h:565
virtual OGRBoolean Contains(const OGRGeometry *) const
Test for containment.
Definition ogrgeometry.cpp:5175
OGRBoolean Is3D() const
Definition ogr_geometry.h:405
OGRMultiPoint * toMultiPoint()
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:746
virtual const char * getGeometryName() const =0
Fetch WKT name for geometry type.
virtual void closeRings()
Force rings to be closed.
Definition ogrgeometry.cpp:5311
const OGRTriangulatedSurface * toTriangulatedSurface() const
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:837
const OGRTriangle * toTriangle() const
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:711
OGRSurface * toSurface()
Down-cast to OGRSurface*.
Definition ogr_geometry.h:676
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:606
OGRTriangulatedSurface * toTriangulatedSurface()
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:830
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const =0
Export a WKT geometry.
OGRCurve * toCurve()
Down-cast to OGRCurve*.
Definition ogr_geometry.h:592
virtual OGRBoolean IsSimple() const
Test if the geometry is simple.
Definition ogrgeometry.cpp:2258
Concrete representation of a multi-vertex line.
Definition ogr_geometry.h:1407
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:1447
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1452
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition ogrlinestring.cpp:2764
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1451
OGRLineString & operator=(const OGRLineString &other)
Assignment operator.
Definition ogrlinestring.cpp:2734
OGRLineString(const OGRLineString &other)
Copy constructor.
virtual OGRLineString * CurveToLine(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const override
Return a linestring from a curve geometry.
Definition ogrlinestring.cpp:2774
virtual OGRwkbGeometryType getGeometryType() const override
Fetch geometry type.
Definition ogrlinestring.cpp:2747
OGRLineString()
Create an empty line string.
virtual OGRGeometry * getCurveGeometry(const char *const *papszOptions=nullptr) const override
Return curve version of this geometry.
Definition ogrlinestring.cpp:2827
virtual double get_Area() const override
Get the area of the (closed) curve.
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1449
static OGRLinearRing * CastToLinearRing(OGRLineString *poLS)
Cast to linear ring.
Definition ogrlinestring.cpp:2871
virtual OGRLineString * clone() const override
Make a copy of this object.
Definition ogrlinestring.cpp:2889
Concrete representation of a closed ring.
Definition ogr_geometry.h:1483
OGRLineString * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:1540
static OGRLineString * CastToLineString(OGRLinearRing *poLR)
Cast to line string.
Definition ogrlinearring.cpp:793
virtual OGRLinearRing * clone() const override
Make a copy of this object.
Definition ogrlinearring.cpp:415
virtual void reverseWindingOrder()
Reverse order of points.
Definition ogrlinearring.cpp:549
const OGRLineString * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1542
virtual int isClockwise() const
Returns TRUE if the ring has clockwise winding (or less than 2 points)
Definition ogrlinearring.cpp:448
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1545
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition ogrlinearring.cpp:128
OGRLinearRing(const OGRLinearRing &other)
Copy constructor.
OGRLinearRing & operator=(const OGRLinearRing &other)
Assignment operator.
Definition ogrlinearring.cpp:115
OGRLinearRing()
Constructor.
virtual OGRErr transform(OGRCoordinateTransformation *poCT) override
Apply arbitrary coordinate transformation to geometry.
Definition ogrlinearring.cpp:757
virtual void closeRings() override
Force rings to be closed.
Definition ogrlinearring.cpp:569
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1544
OGRBoolean isPointOnRingBoundary(const OGRPoint *pt, int bTestEnvelope=TRUE) const
Returns whether the point is on the ring boundary.
Definition ogrlinearring.cpp:676
OGRBoolean isPointInRing(const OGRPoint *pt, int bTestEnvelope=TRUE) const
Returns whether the point is inside the ring.
Definition ogrlinearring.cpp:595
A collection of OGRCurve.
Definition ogr_geometry.h:3023
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3051
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3053
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3096
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3047
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3093
const OGRCurve * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3059
OGRCurve * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3057
OGRMultiCurve()
Create an empty multi curve collection.
OGRMultiCurve(const OGRMultiCurve &other)
Copy constructor.
OGRMultiCurve & operator=(const OGRMultiCurve &other)
Assignment operator.
Definition ogrmulticurve.cpp:85
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:3040
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3045
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3091
virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override
Returns whether a geometry of the specified geometry type can be a member of this collection.
Definition ogrmulticurve.cpp:145
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3095
A collection of OGRLineString.
Definition ogr_geometry.h:3128
OGRMultiLineString & operator=(const OGRMultiLineString &other)
Assignment operator.
Definition ogrmultilinestring.cpp:86
OGRLineString ChildType
Type of child elements.
Definition ogr_geometry.h:3141
OGRLineString * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3158
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3183
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3148
virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override
Returns whether a geometry of the specified geometry type can be a member of this collection.
Definition ogrmultilinestring.cpp:137
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3154
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3188
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3152
OGRMultiLineString()
Create an empty multi line string collection.
const OGRLineString * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3160
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3187
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3146
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3185
OGRMultiLineString(const OGRMultiLineString &other)
Copy constructor.
A collection of OGRPoint.
Definition ogr_geometry.h:2918
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2981
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2985
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2947
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2939
OGRMultiPoint()
Create an empty multi point collection.
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2986
OGRMultiPoint(const OGRMultiPoint &other)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2945
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2983
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:2934
const OGRPoint * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:2953
OGRMultiPoint & operator=(const OGRMultiPoint &other)
Assignment operator.
Definition ogrmultipoint.cpp:90
OGRPoint * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:2951
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2941
virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override
Returns whether a geometry of the specified geometry type can be a member of this collection.
Definition ogrmultipoint.cpp:151
A collection of non-overlapping OGRPolygon.
Definition ogr_geometry.h:2597
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:2623
OGRMultiPolygon(const OGRMultiPolygon &other)
Copy constructor.
OGRPolygon * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:2640
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2670
const OGRPolygon * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:2642
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2636
OGRMultiPolygon & operator=(const OGRMultiPolygon &other)
Assignment operator.
Definition ogrmultipolygon.cpp:83
virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override
Returns whether a geometry of the specified geometry type can be a member of this collection.
Definition ogrmultipolygon.cpp:134
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2630
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2669
OGRMultiPolygon()
Create an empty multi polygon collection.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2628
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2665
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2634
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2667
A collection of non-overlapping OGRSurface.
Definition ogr_geometry.h:2493
OGRMultiSurface()
Create an empty multi surface collection.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2564
const OGRSurface * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:2553
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2511
OGRSurface ChildType
Type of child elements.
Definition ogr_geometry.h:2506
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2562
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2517
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2519
virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override
Returns whether a geometry of the specified geometry type can be a member of this collection.
Definition ogrmultisurface.cpp:147
OGRMultiSurface(const OGRMultiSurface &other)
Copy constructor.
OGRMultiSurface & operator=(const OGRMultiSurface &other)
Assignment operator.
Definition ogrmultisurface.cpp:86
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2513
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2565
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2560
OGRSurface * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:2551
Interface for a point iterator.
Definition ogr_geometry.h:1052
virtual OGRBoolean getNextPoint(OGRPoint *p)=0
Returns the next point followed by the iterator.
static void destroy(OGRPointIterator *)
Destroys a point iterator.
Definition ogrcurve.cpp:448
Point class.
Definition ogr_geometry.h:936
OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc) const override
Convert a geometry into well known binary format.
Definition ogrpoint.cpp:396
double getM() const
Return m.
Definition ogr_geometry.h:997
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1030
void setX(double xIn)
Set x.
Definition ogr_geometry.h:1004
OGRPoint & operator=(const OGRPoint &other)
Assignment operator.
Definition ogrpoint.cpp:185
OGRErr importFromWkt(const char **) override
deprecated
Definition ogrpoint.cpp:502
static OGRPoint * createXYM(double x, double y, double m)
Create a XYM point.
Definition ogrpoint.cpp:144
OGRPoint(const OGRPoint &other)
Copy constructor.
void setZ(double zIn)
Set z.
Definition ogr_geometry.h:1012
void setM(double mIn)
Set m.
Definition ogr_geometry.h:1017
virtual int getDimension() const override
Get the dimension of this object.
Definition ogrpoint.cpp:228
double getX() const
Return x.
Definition ogr_geometry.h:991
virtual void empty() override
Clear geometry information.
Definition ogrpoint.cpp:214
virtual OGRPoint * clone() const override
Make a copy of this object.
Definition ogrpoint.cpp:205
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1031
OGRPoint()
Create an empty point.
Definition ogrpoint.cpp:66
size_t WkbSize() const override
Returns size of related binary representation.
Definition ogrpoint.cpp:296
void setY(double yIn)
Set y.
Definition ogr_geometry.h:1008
virtual OGRBoolean IsEmpty() const override
Returns TRUE (non-zero) if the object has no points.
Definition ogr_geometry.h:986
double getZ() const
Return z.
Definition ogr_geometry.h:995
virtual void getEnvelope(OGREnvelope *psEnvelope) const override
Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
Definition ogrpoint.cpp:613
double getY() const
Return y.
Definition ogr_geometry.h:993
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const override
Export a point to WKT.
Definition ogrpoint.cpp:587
OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override
Assign geometry from well known binary data.
Definition ogrpoint.cpp:314
Concrete class representing polygons.
Definition ogr_geometry.h:2139
OGRLinearRing ChildType
Type of child elements.
Definition ogr_geometry.h:2171
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2176
const OGRCurvePolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2243
OGRPolygon()
Create an empty polygon.
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2178
OGRPolygon(const OGRPolygon &other)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2182
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2246
OGRPolygon & operator=(const OGRPolygon &other)
Assignment operator.
Definition ogrpolygon.cpp:92
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2184
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2245
OGRCurvePolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2241
PolyhedralSurface class.
Definition ogr_geometry.h:2701
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2734
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2740
OGRPolygon * getGeometryRef(int i)
Fetch geometry from container.
Definition ogrpolyhedralsurface.cpp:820
OGRPolyhedralSurface & operator=(const OGRPolyhedralSurface &other)
Assignment operator.
Definition ogrpolyhedralsurface.cpp:82
OGRPolyhedralSurface(const OGRPolyhedralSurface &poGeom)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2738
~OGRPolyhedralSurface() override
Destructor.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2732
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2802
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:2727
OGRPolyhedralSurface()
Create an empty PolyhedralSurface.
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2803
Simple container for a position.
Definition ogr_geometry.h:104
OGRRawPoint(double xIn, double yIn)
Constructor.
Definition ogr_geometry.h:110
double x
x
Definition ogr_geometry.h:113
double y
y
Definition ogr_geometry.h:115
OGRRawPoint()
Constructor.
Definition ogr_geometry.h:107
Abstract curve base class for OGRLineString and OGRCircularString.
Definition ogr_geometry.h:1187
double getY(int i) const
Get Y at vertex.
Definition ogr_geometry.h:1324
double getX(int i) const
Get X at vertex.
Definition ogr_geometry.h:1323
virtual size_t WkbSize() const override
Returns size of related binary representation.
Definition ogrlinestring.cpp:189
virtual double get_LinearArea() const
Compute area of ring / closed linestring.
Definition ogrlinestring.cpp:2796
virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc) const override
Convert a geometry into well known binary format.
Definition ogrlinestring.cpp:1633
virtual double Project(const OGRPoint *) const
Project point on linestring.
Definition ogrlinestring.cpp:2022
virtual OGRLineString * getSubLine(double, double, int) const
Get the portion of linestring.
Definition ogrlinestring.cpp:2076
OGRErr importFromWkt(const char **) override
deprecated
Definition ogrlinestring.cpp:1732
virtual void Value(double, OGRPoint *) const override
Fetch point at given distance along curve.
Definition ogrlinestring.cpp:1949
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:1253
virtual void EndPoint(OGRPoint *) const override
Return the curve end point.
Definition ogrlinestring.cpp:1937
OGRSimpleCurve & operator=(const OGRSimpleCurve &other)
Assignment operator.
Definition ogrlinestring.cpp:116
virtual void getEnvelope(OGREnvelope *psEnvelope) const override
Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
Definition ogrlinestring.cpp:2250
virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override
Assign geometry from well known binary data.
Definition ogrlinestring.cpp:1516
virtual double get_Length() const override
Returns the length of the curve.
Definition ogrlinestring.cpp:1907
virtual void StartPoint(OGRPoint *) const override
Return the curve start point.
Definition ogrlinestring.cpp:1927
virtual int getNumPoints() const override
Fetch vertex count.
Definition ogr_geometry.h:1321
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const override
Export a simple curve to WKT.
Definition ogrlinestring.cpp:1851
virtual void empty() override
Clear geometry information.
Definition ogrlinestring.cpp:144
OGRSimpleCurve()
Constructor.
Definition ogrlinestring.cpp:60
virtual OGRSimpleCurve * clone() const override=0
Make a copy of this object.
virtual OGRBoolean IsEmpty() const override
Returns TRUE (non-zero) if the object has no points.
Definition ogrlinestring.cpp:2465
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:158
Abstract base class for 2 dimensional objects like polygons or curve polygons.
Definition ogr_geometry.h:1931
virtual double get_Area() const =0
Get the area of the surface object.
virtual OGRSurface * clone() const override=0
Make a copy of this object.
virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
This method relates to the SFCOM ISurface::get_PointOnSurface() method.
Definition ogr_geometry.h:1940
Triangle class.
Definition ogr_geometry.h:2277
virtual OGRwkbGeometryType getGeometryType() const override
Fetch geometry type.
Definition ogrtriangle.cpp:170
const OGRPolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2316
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2318
virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override
Assign geometry from well known binary data.
Definition ogrtriangle.cpp:198
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2319
OGRTriangle()
Constructor.
~OGRTriangle() override
Destructor.
virtual OGRErr addRingDirectly(OGRCurve *poNewRing) override
Add a ring to a polygon.
Definition ogrtriangle.cpp:256
OGRPolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2314
OGRTriangle(const OGRTriangle &other)
Copy constructor.
virtual OGRTriangle * clone() const override
Make a copy of this object.
Definition ogrtriangle.cpp:151
OGRTriangle & operator=(const OGRTriangle &other)
Assignment operator.
Definition ogrtriangle.cpp:138
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition ogrtriangle.cpp:161
TriangulatedSurface class.
Definition ogr_geometry.h:2834
const OGRTriangle * getGeometryRef(int i) const
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:2877
~OGRTriangulatedSurface()
Destructor.
OGRTriangle * getGeometryRef(int i)
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:2875
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2867
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2865
OGRPolyhedralSurface * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2883
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2887
const OGRPolyhedralSurface * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2885
OGRTriangle ChildType
Type of child elements.
Definition ogr_geometry.h:2854
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2888
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2859
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2861
OGRTriangulatedSurface()
Constructor.
Various convenience functions for CPL.
To down_cast(From *f)
Use cpl::down_cast<Derived*>(pointer_to_base) as equivalent of static_cast<Derived*>(pointer_to_base)...
Definition cpl_conv.h:382
Interface for read and write JSON documents.
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1169
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition cpl_port.h:894
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:215
void * OGRGeometryH
Opaque type for a geometry.
Definition ogr_api.h:65
Core portability services for cross-platform OGR code.
int OGRBoolean
Type for a OGR boolean.
Definition ogr_core.h:357
OGRwkbByteOrder
Enumeration to describe byte order.
Definition ogr_core.h:551
OGRwkbVariant
Output variants of WKB we support.
Definition ogr_core.h:485
@ wkbVariantOldOgc
Old-style 99-402 extended dimension (Z) WKB types.
Definition ogr_core.h:486
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:369
int OGRErr
Type for a OGR error.
Definition ogr_core.h:341
OGRWktFormat
WKT Output formatting options.
Definition ogr_geometry.h:62
@ Default
Format as F when abs(value) < 1, otherwise as G.
Definition ogr_geometry.h:65
@ F
F-type formatting.
Definition ogr_geometry.h:63
@ G
G-type formatting.
Definition ogr_geometry.h:64
std::unique_ptr< OGRPreparedGeometry, OGRPreparedGeometryUniquePtrDeleter > OGRPreparedGeometryUniquePtr
Unique pointer type for OGRPreparedGeometry.
Definition ogr_geometry.h:3339
struct GEOSContextHandle_HS * GEOSContextHandle_t
GEOS context handle type.
Definition ogr_geometry.h:121
OGRwkbGeometryType OGRFromOGCGeomType(const char *pszGeomType)
Map OGCgeometry format type to corresponding OGR constants.
Definition ogrgeometry.cpp:2392
const char * OGRToOGCGeomType(OGRwkbGeometryType eGeomType)
Map OGR geometry format constants to corresponding OGC geometry type.
Definition ogrgeometry.cpp:2465
std::unique_ptr< OGRGeometry, OGRGeometryUniquePtrDeleter > OGRGeometryUniquePtr
Unique pointer type for OGRGeometry.
Definition ogr_geometry.h:852
struct GEOSGeom_t * GEOSGeom
GEOS geometry type.
Definition ogr_geometry.h:119
void sfcgal_geometry_t
SFCGAL geometry type.
Definition ogr_geometry.h:123
Coordinate systems services.
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition ogrsf_frmts.h:287
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition ogrsf_frmts.h:292
Options for formatting WKT output.
Definition ogr_geometry.h:70
OGRwkbVariant variant
Type of WKT output to produce.
Definition ogr_geometry.h:73
OGRWktOptions()
Constructor.
Definition ogr_geometry.h:82
OGRWktOptions(const OGRWktOptions &)=default
Copy constructor.
bool round
Whether GDAL-special rounding should be applied.
Definition ogr_geometry.h:77
int precision
Precision of output. Interpretation depends on format.
Definition ogr_geometry.h:75
OGRWktFormat format
Formatting type.
Definition ogr_geometry.h:79