GDAL

ogr_geometry.h
Go to the documentation of this file.
1/******************************************************************************
2 * $Id$
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 * SPDX-License-Identifier: MIT
14 ****************************************************************************/
15
16#ifndef OGR_GEOMETRY_H_INCLUDED
17#define OGR_GEOMETRY_H_INCLUDED
18
19#include "cpl_conv.h"
20#include "cpl_json.h"
21#include "ogr_core.h"
22#include "ogr_geomcoordinateprecision.h"
23#include "ogr_spatialref.h"
24
25#include <climits>
26#include <cmath>
27#include <memory>
28
36#ifndef DEFINEH_OGRGeometryH
37#define DEFINEH_OGRGeometryH
38#ifdef DEBUG
39 typedef struct OGRGeometryHS *OGRGeometryH;
40#else
41 typedef void *OGRGeometryH;
42#endif
43#endif /* DEFINEH_OGRGeometryH */
47 enum class OGRWktFormat
48{
49 F,
50 G,
51 Default
52};
53
55 struct CPL_DLL OGRWktOptions
56{
57 public:
59 OGRwkbVariant variant = wkbVariantOldOgc;
61 int xyPrecision;
63 int zPrecision;
65 int mPrecision;
67 bool round = getDefaultRound();
69 OGRWktFormat format = OGRWktFormat::Default;
70
72 OGRWktOptions()
73 : xyPrecision(getDefaultPrecision()), zPrecision(xyPrecision),
74 mPrecision(zPrecision)
75 {
76 }
77
79 OGRWktOptions(const OGRWktOptions &) = default;
80
81 private:
82 static int getDefaultPrecision();
83 static bool getDefaultRound();
84};
85
89 class OGRRawPoint
90{
91 public:
93 OGRRawPoint() : x(0.0), y(0.0)
94 {
95 }
96
98 OGRRawPoint(double xIn, double yIn) : x(xIn), y(yIn)
99 {
100 }
101
103 double x;
105 double y;
106};
107
109 typedef struct GEOSGeom_t *GEOSGeom;
111 typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
113 typedef void sfcgal_geometry_t;
114
115 class OGRPoint;
116 class OGRCurve;
117 class OGRCompoundCurve;
118 class OGRSimpleCurve;
119 class OGRLinearRing;
120 class OGRLineString;
121 class OGRCircularString;
122 class OGRSurface;
123 class OGRCurvePolygon;
124 class OGRPolygon;
125 class OGRMultiPoint;
126 class OGRMultiSurface;
127 class OGRMultiPolygon;
128 class OGRMultiCurve;
129 class OGRMultiLineString;
130 class OGRGeometryCollection;
131 class OGRTriangle;
132 class OGRPolyhedralSurface;
133 class OGRTriangulatedSurface;
134
136 typedef OGRLineString *(*OGRCurveCasterToLineString)(OGRCurve *);
137 typedef OGRLinearRing *(*OGRCurveCasterToLinearRing)(OGRCurve *);
138
139 typedef OGRPolygon *(*OGRSurfaceCasterToPolygon)(OGRSurface *);
140 typedef OGRCurvePolygon *(*OGRSurfaceCasterToCurvePolygon)(OGRSurface *);
141 typedef OGRMultiPolygon *(*OGRPolyhedralSurfaceCastToMultiPolygon)(
142 OGRPolyhedralSurface *);
143
145
149 class CPL_DLL IOGRGeometryVisitor
150{
151 public:
153 virtual ~IOGRGeometryVisitor() = default;
154
156 virtual void visit(OGRPoint *) = 0;
158 virtual void visit(OGRLineString *) = 0;
160 virtual void visit(OGRLinearRing *) = 0;
162 virtual void visit(OGRPolygon *) = 0;
164 virtual void visit(OGRMultiPoint *) = 0;
166 virtual void visit(OGRMultiLineString *) = 0;
168 virtual void visit(OGRMultiPolygon *) = 0;
170 virtual void visit(OGRGeometryCollection *) = 0;
172 virtual void visit(OGRCircularString *) = 0;
174 virtual void visit(OGRCompoundCurve *) = 0;
176 virtual void visit(OGRCurvePolygon *) = 0;
178 virtual void visit(OGRMultiCurve *) = 0;
180 virtual void visit(OGRMultiSurface *) = 0;
182 virtual void visit(OGRTriangle *) = 0;
184 virtual void visit(OGRPolyhedralSurface *) = 0;
186 virtual void visit(OGRTriangulatedSurface *) = 0;
187};
188
196 class CPL_DLL OGRDefaultGeometryVisitor : public IOGRGeometryVisitor
197{
198 void _visit(OGRSimpleCurve *poGeom);
199
200 public:
201 void visit(OGRPoint *) override
202 {
203 }
204
205 void visit(OGRLineString *) override;
206 void visit(OGRLinearRing *) override;
207 void visit(OGRPolygon *) override;
208 void visit(OGRMultiPoint *) override;
209 void visit(OGRMultiLineString *) override;
210 void visit(OGRMultiPolygon *) override;
211 void visit(OGRGeometryCollection *) override;
212 void visit(OGRCircularString *) override;
213 void visit(OGRCompoundCurve *) override;
214 void visit(OGRCurvePolygon *) override;
215 void visit(OGRMultiCurve *) override;
216 void visit(OGRMultiSurface *) override;
217 void visit(OGRTriangle *) override;
218 void visit(OGRPolyhedralSurface *) override;
219 void visit(OGRTriangulatedSurface *) override;
220};
221
225 class CPL_DLL IOGRConstGeometryVisitor
226{
227 public:
229 virtual ~IOGRConstGeometryVisitor() = default;
230
232 virtual void visit(const OGRPoint *) = 0;
234 virtual void visit(const OGRLineString *) = 0;
236 virtual void visit(const OGRLinearRing *) = 0;
238 virtual void visit(const OGRPolygon *) = 0;
240 virtual void visit(const OGRMultiPoint *) = 0;
242 virtual void visit(const OGRMultiLineString *) = 0;
244 virtual void visit(const OGRMultiPolygon *) = 0;
246 virtual void visit(const OGRGeometryCollection *) = 0;
248 virtual void visit(const OGRCircularString *) = 0;
250 virtual void visit(const OGRCompoundCurve *) = 0;
252 virtual void visit(const OGRCurvePolygon *) = 0;
254 virtual void visit(const OGRMultiCurve *) = 0;
256 virtual void visit(const OGRMultiSurface *) = 0;
258 virtual void visit(const OGRTriangle *) = 0;
260 virtual void visit(const OGRPolyhedralSurface *) = 0;
262 virtual void visit(const OGRTriangulatedSurface *) = 0;
263};
264
272 class CPL_DLL OGRDefaultConstGeometryVisitor : public IOGRConstGeometryVisitor
273{
274 void _visit(const OGRSimpleCurve *poGeom);
275
276 public:
277 void visit(const OGRPoint *) override
278 {
279 }
280
281 void visit(const OGRLineString *) override;
282 void visit(const OGRLinearRing *) override;
283 void visit(const OGRPolygon *) override;
284 void visit(const OGRMultiPoint *) override;
285 void visit(const OGRMultiLineString *) override;
286 void visit(const OGRMultiPolygon *) override;
287 void visit(const OGRGeometryCollection *) override;
288 void visit(const OGRCircularString *) override;
289 void visit(const OGRCompoundCurve *) override;
290 void visit(const OGRCurvePolygon *) override;
291 void visit(const OGRMultiCurve *) override;
292 void visit(const OGRMultiSurface *) override;
293 void visit(const OGRTriangle *) override;
294 void visit(const OGRPolyhedralSurface *) override;
295 void visit(const OGRTriangulatedSurface *) override;
296};
297
298/************************************************************************/
299/* OGRGeomCoordinateBinaryPrecision */
300/************************************************************************/
301
306 struct CPL_DLL OGRGeomCoordinateBinaryPrecision
307{
308 int nXYBitPrecision =
309 INT_MIN;
311 int nZBitPrecision =
312 INT_MIN;
314 int nMBitPrecision =
315 INT_MIN;
318 void SetFrom(const OGRGeomCoordinatePrecision &);
319};
320
321/************************************************************************/
322/* OGRwkbExportOptions */
323/************************************************************************/
324
329 struct CPL_DLL OGRwkbExportOptions
330{
331 OGRwkbByteOrder eByteOrder = wkbNDR;
332 OGRwkbVariant eWkbVariant = wkbVariantOldOgc;
333 OGRGeomCoordinateBinaryPrecision sPrecision{};
334};
335
336/************************************************************************/
337/* OGRGeometry */
338/************************************************************************/
339
360 class CPL_DLL OGRGeometry
361{
362 private:
363 const OGRSpatialReference *poSRS = nullptr; // may be NULL
364
365 protected:
367 friend class OGRCurveCollection;
368
369 unsigned int flags = 0;
370
371 OGRErr importPreambleFromWkt(const char **ppszInput, int *pbHasZ,
372 int *pbHasM, bool *pbIsEmpty);
373 OGRErr importCurveCollectionFromWkt(
374 const char **ppszInput, int bAllowEmptyComponent, int bAllowLineString,
375 int bAllowCurve, int bAllowCompoundCurve,
376 OGRErr (*pfnAddCurveDirectly)(OGRGeometry *poSelf, OGRCurve *poCurve));
377 OGRErr importPreambleFromWkb(const unsigned char *pabyData, size_t nSize,
378 OGRwkbByteOrder &eByteOrder,
379 OGRwkbVariant eWkbVariant);
380 OGRErr importPreambleOfCollectionFromWkb(const unsigned char *pabyData,
381 size_t &nSize, size_t &nDataOffset,
382 OGRwkbByteOrder &eByteOrder,
383 size_t nMinSubGeomSize,
384 int &nGeomCount,
385 OGRwkbVariant eWkbVariant);
386 OGRErr PointOnSurfaceInternal(OGRPoint *poPoint) const;
387 OGRBoolean IsSFCGALCompatible() const;
388
389 void HomogenizeDimensionalityWith(OGRGeometry *poOtherGeom);
390 std::string wktTypeString(OGRwkbVariant variant) const;
391
393
394 public:
395 /************************************************************************/
396 /* Bit flags for OGRGeometry */
397 /* The OGR_G_NOT_EMPTY_POINT is used *only* for points. */
398 /* Do not use these outside of the core. */
399 /* Use Is3D, IsMeasured, set3D, and setMeasured instead */
400 /************************************************************************/
401
403 static const unsigned int OGR_G_NOT_EMPTY_POINT = 0x1;
404 static const unsigned int OGR_G_3D = 0x2;
405 static const unsigned int OGR_G_MEASURED = 0x4;
407
408 OGRGeometry();
409 OGRGeometry(const OGRGeometry &other);
410 virtual ~OGRGeometry();
411
412 OGRGeometry &operator=(const OGRGeometry &other);
413
415 bool operator==(const OGRGeometry &other) const
416 {
417 return CPL_TO_BOOL(Equals(&other));
418 }
419
421 bool operator!=(const OGRGeometry &other) const
422 {
423 return !CPL_TO_BOOL(Equals(&other));
424 }
425
426 // Standard IGeometry.
427 virtual int getDimension() const = 0;
428 virtual int getCoordinateDimension() const;
429 int CoordinateDimension() const;
430 virtual OGRBoolean IsEmpty() const = 0;
431 virtual OGRBoolean IsValid() const;
432 virtual OGRGeometry *MakeValid(CSLConstList papszOptions = nullptr) const;
433 virtual OGRGeometry *Normalize() const;
434 virtual OGRBoolean IsSimple() const;
435
437 OGRBoolean Is3D() const
438 {
439 return (flags & OGR_G_3D) != 0;
440 }
441
443 OGRBoolean IsMeasured() const
444 {
445 return (flags & OGR_G_MEASURED) != 0;
446 }
447
448 virtual OGRBoolean IsRing() const;
449 virtual void empty() = 0;
450 virtual OGRGeometry *clone() const CPL_WARN_UNUSED_RESULT = 0;
451 virtual void getEnvelope(OGREnvelope *psEnvelope) const = 0;
452 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const = 0;
453
454 // IWks Interface.
455 virtual size_t WkbSize() const = 0;
456 OGRErr importFromWkb(const GByte *, size_t = static_cast<size_t>(-1),
457 OGRwkbVariant = wkbVariantOldOgc);
458 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
459 size_t &nBytesConsumedOut) = 0;
460 OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
461 OGRwkbVariant = wkbVariantOldOgc) const;
462 virtual OGRErr exportToWkb(unsigned char *,
463 const OGRwkbExportOptions * = nullptr) const = 0;
464 virtual OGRErr importFromWkt(const char **ppszInput) = 0;
465
466#ifndef DOXYGEN_XML
470 OGRErr importFromWkt(char **ppszInput)
472 CPL_WARN_DEPRECATED("Use importFromWkt(const char**) instead")
474 {
475 return importFromWkt(const_cast<const char **>(ppszInput));
476 }
477#endif
478
479 OGRErr exportToWkt(char **ppszDstText,
480 OGRwkbVariant = wkbVariantOldOgc) const;
481
486 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
487 OGRErr *err = nullptr) const = 0;
488
489 // Non-standard.
490 virtual OGRwkbGeometryType getGeometryType() const = 0;
491 OGRwkbGeometryType getIsoGeometryType() const;
492 virtual const char *getGeometryName() const = 0;
493 void dumpReadable(FILE *, const char * = nullptr,
494 CSLConstList papszOptions = nullptr) const;
495 std::string dumpReadable(const char * = nullptr,
496 CSLConstList papszOptions = nullptr) const;
497 virtual void flattenTo2D() = 0;
498 virtual char *exportToGML(const char *const *papszOptions = nullptr) const;
499 virtual char *exportToKML() const;
500 virtual char *exportToJson(CSLConstList papszOptions = nullptr) const;
501
503 virtual void accept(IOGRGeometryVisitor *visitor) = 0;
504
506 virtual void accept(IOGRConstGeometryVisitor *visitor) const = 0;
507
508 static GEOSContextHandle_t createGEOSContext();
509 static void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt);
510 GEOSGeom
511 exportToGEOS(GEOSContextHandle_t hGEOSCtxt,
512 bool bRemoveEmptyParts = false) const CPL_WARN_UNUSED_RESULT;
513 virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
514 virtual OGRGeometry *getCurveGeometry(
515 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
516 virtual OGRGeometry *getLinearGeometry(
517 double dfMaxAngleStepSizeDegrees = 0,
518 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
519
520 void roundCoordinates(const OGRGeomCoordinatePrecision &sPrecision);
521 void
522 roundCoordinatesIEEE754(const OGRGeomCoordinateBinaryPrecision &options);
523
524 // SFCGAL interfacing methods.
526 static sfcgal_geometry_t *OGRexportToSFCGAL(const OGRGeometry *poGeom);
527 static OGRGeometry *SFCGALexportToOGR(const sfcgal_geometry_t *_geometry);
529 virtual void closeRings();
530
531 virtual bool setCoordinateDimension(int nDimension);
532 virtual bool set3D(OGRBoolean bIs3D);
533 virtual bool setMeasured(OGRBoolean bIsMeasured);
534
535 virtual void assignSpatialReference(const OGRSpatialReference *poSR);
536
537 const OGRSpatialReference *getSpatialReference(void) const
538 {
539 return poSRS;
540 }
541
542 virtual OGRErr transform(OGRCoordinateTransformation *poCT) = 0;
543 OGRErr transformTo(const OGRSpatialReference *poSR);
544
545 virtual bool segmentize(double dfMaxLength);
546
547 // ISpatialRelation
548 virtual OGRBoolean Intersects(const OGRGeometry *) const;
549 virtual OGRBoolean Equals(const OGRGeometry *) const = 0;
550 virtual OGRBoolean Disjoint(const OGRGeometry *) const;
551 virtual OGRBoolean Touches(const OGRGeometry *) const;
552 virtual OGRBoolean Crosses(const OGRGeometry *) const;
553 virtual OGRBoolean Within(const OGRGeometry *) const;
554 virtual OGRBoolean Contains(const OGRGeometry *) const;
555 virtual OGRBoolean Overlaps(const OGRGeometry *) const;
556 // virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
557 // virtual OGRGeometry *LocateAlong( double mValue ) const;
558 // virtual OGRGeometry *LocateBetween( double mStart, double mEnd )
559 // const;
560
561 virtual OGRGeometry *Boundary() const CPL_WARN_UNUSED_RESULT;
562 virtual double Distance(const OGRGeometry *) const;
563 virtual OGRGeometry *ConvexHull() const CPL_WARN_UNUSED_RESULT;
564 virtual OGRGeometry *
565 ConcaveHull(double dfRatio, bool bAllowHoles) const CPL_WARN_UNUSED_RESULT;
566 virtual OGRGeometry *
567 Buffer(double dfDist, int nQuadSegs = 30) const CPL_WARN_UNUSED_RESULT;
568 virtual OGRGeometry *
569 BufferEx(double dfDistance,
570 CSLConstList papszOptions) const CPL_WARN_UNUSED_RESULT;
571 virtual OGRGeometry *
572 Intersection(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
573 virtual OGRGeometry *
574 Union(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
575 virtual OGRGeometry *UnionCascaded() const CPL_WARN_UNUSED_RESULT;
576 OGRGeometry *UnaryUnion() const CPL_WARN_UNUSED_RESULT;
577 virtual OGRGeometry *
578 Difference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
579 virtual OGRGeometry *
580 SymDifference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
581 virtual OGRErr Centroid(OGRPoint *poPoint) const;
582 virtual OGRGeometry *
583 Simplify(double dTolerance) const CPL_WARN_UNUSED_RESULT;
584 OGRGeometry *
585 SimplifyPreserveTopology(double dTolerance) const CPL_WARN_UNUSED_RESULT;
586 virtual OGRGeometry *
587 DelaunayTriangulation(double dfTolerance,
588 int bOnlyEdges) const CPL_WARN_UNUSED_RESULT;
589
590 virtual OGRGeometry *Polygonize() const CPL_WARN_UNUSED_RESULT;
591
592 virtual double Distance3D(const OGRGeometry *poOtherGeom) const;
593
594 OGRGeometry *SetPrecision(double dfGridSize, int nFlags) const;
595
596 virtual bool hasEmptyParts() const;
597 virtual void removeEmptyParts();
598
600 // backward compatibility to non-standard method names.
601 OGRBoolean Intersect(OGRGeometry *) const
602 CPL_WARN_DEPRECATED("Non standard method. "
603 "Use Intersects() instead");
604 OGRBoolean Equal(OGRGeometry *) const
605 CPL_WARN_DEPRECATED("Non standard method. "
606 "Use Equals() instead");
607 OGRGeometry *SymmetricDifference(const OGRGeometry *) const
608 CPL_WARN_DEPRECATED("Non standard method. "
609 "Use SymDifference() instead");
610 OGRGeometry *getBoundary() const
611 CPL_WARN_DEPRECATED("Non standard method. "
612 "Use Boundary() instead");
614
616 // Special HACK for DB2 7.2 support
617 static int bGenerate_DB2_V72_BYTE_ORDER;
619
620 virtual void swapXY();
621
622 bool IsRectangle() const;
623
625 static OGRGeometry *CastToIdentity(OGRGeometry *poGeom)
626 {
627 return poGeom;
628 }
629
630 static OGRGeometry *CastToError(OGRGeometry *poGeom);
631
633
637 static inline OGRGeometryH ToHandle(OGRGeometry *poGeom)
638 {
639 return reinterpret_cast<OGRGeometryH>(poGeom);
640 }
641
645 static inline OGRGeometry *FromHandle(OGRGeometryH hGeom)
646 {
647 return reinterpret_cast<OGRGeometry *>(hGeom);
648 }
649
654 inline OGRPoint *toPoint()
655 {
656 return cpl::down_cast<OGRPoint *>(this);
657 }
658
663 inline const OGRPoint *toPoint() const
664 {
665 return cpl::down_cast<const OGRPoint *>(this);
666 }
667
673 inline OGRCurve *toCurve()
674 {
675 return cpl::down_cast<OGRCurve *>(this);
676 }
677
683 inline const OGRCurve *toCurve() const
684 {
685 return cpl::down_cast<const OGRCurve *>(this);
686 }
687
693 inline OGRSimpleCurve *toSimpleCurve()
694 {
695 return cpl::down_cast<OGRSimpleCurve *>(this);
696 }
697
703 inline const OGRSimpleCurve *toSimpleCurve() const
704 {
705 return cpl::down_cast<const OGRSimpleCurve *>(this);
706 }
707
713 inline OGRLineString *toLineString()
714 {
715 return cpl::down_cast<OGRLineString *>(this);
716 }
717
723 inline const OGRLineString *toLineString() const
724 {
725 return cpl::down_cast<const OGRLineString *>(this);
726 }
727
732 inline OGRLinearRing *toLinearRing()
733 {
734 return cpl::down_cast<OGRLinearRing *>(this);
735 }
736
741 inline const OGRLinearRing *toLinearRing() const
742 {
743 return cpl::down_cast<const OGRLinearRing *>(this);
744 }
745
751 inline OGRCircularString *toCircularString()
752 {
753 return cpl::down_cast<OGRCircularString *>(this);
754 }
755
761 inline const OGRCircularString *toCircularString() const
762 {
763 return cpl::down_cast<const OGRCircularString *>(this);
764 }
765
771 inline OGRCompoundCurve *toCompoundCurve()
772 {
773 return cpl::down_cast<OGRCompoundCurve *>(this);
774 }
775
781 inline const OGRCompoundCurve *toCompoundCurve() const
782 {
783 return cpl::down_cast<const OGRCompoundCurve *>(this);
784 }
785
791 inline OGRSurface *toSurface()
792 {
793 return cpl::down_cast<OGRSurface *>(this);
794 }
795
801 inline const OGRSurface *toSurface() const
802 {
803 return cpl::down_cast<const OGRSurface *>(this);
804 }
805
811 inline OGRPolygon *toPolygon()
812 {
813 return cpl::down_cast<OGRPolygon *>(this);
814 }
815
821 inline const OGRPolygon *toPolygon() const
822 {
823 return cpl::down_cast<const OGRPolygon *>(this);
824 }
825
830 inline OGRTriangle *toTriangle()
831 {
832 return cpl::down_cast<OGRTriangle *>(this);
833 }
834
839 inline const OGRTriangle *toTriangle() const
840 {
841 return cpl::down_cast<const OGRTriangle *>(this);
842 }
843
849 inline OGRCurvePolygon *toCurvePolygon()
850 {
851 return cpl::down_cast<OGRCurvePolygon *>(this);
852 }
853
859 inline const OGRCurvePolygon *toCurvePolygon() const
860 {
861 return cpl::down_cast<const OGRCurvePolygon *>(this);
862 }
863
869 inline OGRGeometryCollection *toGeometryCollection()
870 {
871 return cpl::down_cast<OGRGeometryCollection *>(this);
872 }
873
879 inline const OGRGeometryCollection *toGeometryCollection() const
880 {
881 return cpl::down_cast<const OGRGeometryCollection *>(this);
882 }
883
889 inline OGRMultiPoint *toMultiPoint()
890 {
891 return cpl::down_cast<OGRMultiPoint *>(this);
892 }
893
899 inline const OGRMultiPoint *toMultiPoint() const
900 {
901 return cpl::down_cast<const OGRMultiPoint *>(this);
902 }
903
909 inline OGRMultiLineString *toMultiLineString()
910 {
911 return cpl::down_cast<OGRMultiLineString *>(this);
912 }
913
919 inline const OGRMultiLineString *toMultiLineString() const
920 {
921 return cpl::down_cast<const OGRMultiLineString *>(this);
922 }
923
929 inline OGRMultiPolygon *toMultiPolygon()
930 {
931 return cpl::down_cast<OGRMultiPolygon *>(this);
932 }
933
939 inline const OGRMultiPolygon *toMultiPolygon() const
940 {
941 return cpl::down_cast<const OGRMultiPolygon *>(this);
942 }
943
949 inline OGRMultiCurve *toMultiCurve()
950 {
951 return cpl::down_cast<OGRMultiCurve *>(this);
952 }
953
959 inline const OGRMultiCurve *toMultiCurve() const
960 {
961 return cpl::down_cast<const OGRMultiCurve *>(this);
962 }
963
969 inline OGRMultiSurface *toMultiSurface()
970 {
971 return cpl::down_cast<OGRMultiSurface *>(this);
972 }
973
979 inline const OGRMultiSurface *toMultiSurface() const
980 {
981 return cpl::down_cast<const OGRMultiSurface *>(this);
982 }
983
989 inline OGRPolyhedralSurface *toPolyhedralSurface()
990 {
991 return cpl::down_cast<OGRPolyhedralSurface *>(this);
992 }
993
999 inline const OGRPolyhedralSurface *toPolyhedralSurface() const
1000 {
1001 return cpl::down_cast<const OGRPolyhedralSurface *>(this);
1002 }
1003
1008 inline OGRTriangulatedSurface *toTriangulatedSurface()
1009 {
1010 return cpl::down_cast<OGRTriangulatedSurface *>(this);
1011 }
1012
1017 inline const OGRTriangulatedSurface *toTriangulatedSurface() const
1018 {
1019 return cpl::down_cast<const OGRTriangulatedSurface *>(this);
1020 }
1021};
1022
1024 struct CPL_DLL OGRGeometryUniquePtrDeleter
1025{
1026 void operator()(OGRGeometry *) const;
1027};
1028
1030
1034 typedef std::unique_ptr<OGRGeometry, OGRGeometryUniquePtrDeleter>
1035 OGRGeometryUniquePtr;
1036
1038#define OGR_FORBID_DOWNCAST_TO(name) \
1039 inline OGR##name *to##name() = delete; \
1040 inline const OGR##name *to##name() const = delete;
1041
1042#define OGR_FORBID_DOWNCAST_TO_POINT OGR_FORBID_DOWNCAST_TO(Point)
1043#define OGR_FORBID_DOWNCAST_TO_CURVE OGR_FORBID_DOWNCAST_TO(Curve)
1044#define OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE OGR_FORBID_DOWNCAST_TO(SimpleCurve)
1045#define OGR_FORBID_DOWNCAST_TO_LINESTRING OGR_FORBID_DOWNCAST_TO(LineString)
1046#define OGR_FORBID_DOWNCAST_TO_LINEARRING OGR_FORBID_DOWNCAST_TO(LinearRing)
1047#define OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1048 OGR_FORBID_DOWNCAST_TO(CircularString)
1049#define OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE \
1050 OGR_FORBID_DOWNCAST_TO(CompoundCurve)
1051#define OGR_FORBID_DOWNCAST_TO_SURFACE OGR_FORBID_DOWNCAST_TO(Surface)
1052#define OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON OGR_FORBID_DOWNCAST_TO(CurvePolygon)
1053#define OGR_FORBID_DOWNCAST_TO_POLYGON OGR_FORBID_DOWNCAST_TO(Polygon)
1054#define OGR_FORBID_DOWNCAST_TO_TRIANGLE OGR_FORBID_DOWNCAST_TO(Triangle)
1055#define OGR_FORBID_DOWNCAST_TO_MULTIPOINT OGR_FORBID_DOWNCAST_TO(MultiPoint)
1056#define OGR_FORBID_DOWNCAST_TO_MULTICURVE OGR_FORBID_DOWNCAST_TO(MultiCurve)
1057#define OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1058 OGR_FORBID_DOWNCAST_TO(MultiLineString)
1059#define OGR_FORBID_DOWNCAST_TO_MULTISURFACE OGR_FORBID_DOWNCAST_TO(MultiSurface)
1060#define OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON OGR_FORBID_DOWNCAST_TO(MultiPolygon)
1061#define OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1062 OGR_FORBID_DOWNCAST_TO(GeometryCollection)
1063#define OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1064 OGR_FORBID_DOWNCAST_TO(PolyhedralSurface)
1065#define OGR_FORBID_DOWNCAST_TO_TIN OGR_FORBID_DOWNCAST_TO(TriangulatedSurface)
1066
1067#define OGR_ALLOW_UPCAST_TO(name) \
1068 inline OGR##name *to##name() \
1069 { \
1070 return this; \
1071 } \
1072 inline const OGR##name *to##name() const \
1073 { \
1074 return this; \
1075 }
1076
1077#ifndef SUPPRESS_OGR_ALLOW_CAST_TO_THIS_WARNING
1078#define CAST_TO_THIS_WARNING CPL_WARN_DEPRECATED("Casting to this is useless")
1079#else
1080#define CAST_TO_THIS_WARNING
1081#endif
1082
1083#define OGR_ALLOW_CAST_TO_THIS(name) \
1084 inline OGR##name *to##name() CAST_TO_THIS_WARNING \
1085 { \
1086 return this; \
1087 } \
1088 inline const OGR##name *to##name() const CAST_TO_THIS_WARNING \
1089 { \
1090 return this; \
1091 }
1092
1093#define OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1094 OGR_FORBID_DOWNCAST_TO_CURVE \
1095 OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE \
1096 OGR_FORBID_DOWNCAST_TO_LINESTRING \
1097 OGR_FORBID_DOWNCAST_TO_LINEARRING \
1098 OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1099 OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE
1100
1101#define OGR_FORBID_DOWNCAST_TO_ALL_SURFACES \
1102 OGR_FORBID_DOWNCAST_TO_SURFACE \
1103 OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON \
1104 OGR_FORBID_DOWNCAST_TO_POLYGON \
1105 OGR_FORBID_DOWNCAST_TO_TRIANGLE \
1106 OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1107 OGR_FORBID_DOWNCAST_TO_TIN
1108
1109#define OGR_FORBID_DOWNCAST_TO_ALL_SINGLES \
1110 OGR_FORBID_DOWNCAST_TO_POINT \
1111 OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1112 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1113
1114#define OGR_FORBID_DOWNCAST_TO_ALL_MULTI \
1115 OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1116 OGR_FORBID_DOWNCAST_TO_MULTIPOINT \
1117 OGR_FORBID_DOWNCAST_TO_MULTICURVE \
1118 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1119 OGR_FORBID_DOWNCAST_TO_MULTISURFACE \
1120 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
1121
1123
1124/************************************************************************/
1125/* OGRPoint */
1126/************************************************************************/
1127
1134 class CPL_DLL OGRPoint : public OGRGeometry
1135{
1136 double x;
1137 double y;
1138 double z;
1139 double m;
1140
1141 public:
1142 OGRPoint();
1143 OGRPoint(double x, double y);
1144 OGRPoint(double x, double y, double z);
1145 OGRPoint(double x, double y, double z, double m);
1146 OGRPoint(const OGRPoint &other);
1147 static OGRPoint *createXYM(double x, double y, double m);
1148
1149 OGRPoint &operator=(const OGRPoint &other);
1150
1151 // IWks Interface
1152 size_t WkbSize() const override;
1153 OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1154 size_t &nBytesConsumedOut) override;
1155 OGRErr exportToWkb(unsigned char *,
1156 const OGRwkbExportOptions * = nullptr) const override;
1157
1158#ifndef DOXYGEN_XML
1159 using OGRGeometry::importFromWkt;
1160#endif
1161
1162 OGRErr importFromWkt(const char **) override;
1163
1164#ifndef DOXYGEN_XML
1165 using OGRGeometry::exportToWkt;
1166#endif
1167
1172 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1173 OGRErr *err = nullptr) const override;
1174
1175 // IGeometry
1176 virtual int getDimension() const override;
1177 virtual OGRPoint *clone() const override;
1178 virtual void empty() override;
1179 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1180 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1181
1182 virtual OGRBoolean IsEmpty() const override
1183 {
1184 return !(flags & OGR_G_NOT_EMPTY_POINT);
1185 }
1186
1187 // IPoint
1189 double getX() const
1190 {
1191 return x;
1192 }
1193
1195 double getY() const
1196 {
1197 return y;
1198 }
1199
1201 double getZ() const
1202 {
1203 return z;
1204 }
1205
1207 double getM() const
1208 {
1209 return m;
1210 }
1211
1212 // Non standard
1213 virtual bool setCoordinateDimension(int nDimension) override;
1214
1218 void setX(double xIn)
1219 {
1220 x = xIn;
1221 if (std::isnan(x) || std::isnan(y))
1222 flags &= ~OGR_G_NOT_EMPTY_POINT;
1223 else
1224 flags |= OGR_G_NOT_EMPTY_POINT;
1225 }
1226
1230 void setY(double yIn)
1231 {
1232 y = yIn;
1233 if (std::isnan(x) || std::isnan(y))
1234 flags &= ~OGR_G_NOT_EMPTY_POINT;
1235 else
1236 flags |= OGR_G_NOT_EMPTY_POINT;
1237 }
1238
1242 void setZ(double zIn)
1243 {
1244 z = zIn;
1245 flags |= OGR_G_3D;
1246 }
1247
1251 void setM(double mIn)
1252 {
1253 m = mIn;
1254 flags |= OGR_G_MEASURED;
1255 }
1256
1257 // ISpatialRelation
1258 virtual OGRBoolean Equals(const OGRGeometry *) const override;
1259 virtual OGRBoolean Intersects(const OGRGeometry *) const override;
1260 virtual OGRBoolean Within(const OGRGeometry *) const override;
1261
1262 // Non standard from OGRGeometry
1263 virtual const char *getGeometryName() const override;
1264 virtual OGRwkbGeometryType getGeometryType() const override;
1265 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1266 virtual void flattenTo2D() override;
1267
1268 virtual void accept(IOGRGeometryVisitor *visitor) override
1269 {
1270 visitor->visit(this);
1271 }
1272
1273 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1274 {
1275 visitor->visit(this);
1276 }
1277
1278 virtual void swapXY() override;
1279
1280 OGR_ALLOW_CAST_TO_THIS(Point)
1281 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
1282 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1283 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1284};
1285
1286/************************************************************************/
1287/* OGRPointIterator */
1288/************************************************************************/
1289
1296 class CPL_DLL OGRPointIterator
1297{
1298 public:
1299 virtual ~OGRPointIterator();
1300 virtual OGRBoolean getNextPoint(OGRPoint *p) = 0;
1301
1302 static void destroy(OGRPointIterator *);
1303};
1304
1305/************************************************************************/
1306/* OGRCurve */
1307/************************************************************************/
1308
1314 class CPL_DLL OGRCurve : public OGRGeometry
1315{
1316 protected:
1318 OGRCurve() = default;
1319 OGRCurve(const OGRCurve &other) = default;
1320
1321 virtual OGRCurveCasterToLineString GetCasterToLineString() const = 0;
1322 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const = 0;
1323
1324 friend class OGRCurvePolygon;
1325 friend class OGRCompoundCurve;
1327 virtual int ContainsPoint(const OGRPoint *p) const;
1328 virtual int IntersectsPoint(const OGRPoint *p) const;
1329 virtual double get_AreaOfCurveSegments() const = 0;
1330
1331 private:
1332 class CPL_DLL ConstIterator
1333 {
1334 struct Private;
1335 std::unique_ptr<Private> m_poPrivate;
1336
1337 public:
1338 ConstIterator(const OGRCurve *poSelf, bool bStart);
1339 ConstIterator(ConstIterator &&oOther) noexcept;
1340 ConstIterator &operator=(ConstIterator &&oOther);
1341 ~ConstIterator();
1342 const OGRPoint &operator*() const;
1343 ConstIterator &operator++();
1344 bool operator!=(const ConstIterator &it) const;
1345 };
1346
1347 friend inline ConstIterator begin(const OGRCurve *);
1348 friend inline ConstIterator end(const OGRCurve *);
1349
1350 public:
1352 OGRCurve &operator=(const OGRCurve &other);
1354
1356 typedef OGRPoint ChildType;
1357
1366 ConstIterator begin() const;
1368 ConstIterator end() const;
1369
1370 // IGeometry
1371 virtual OGRCurve *clone() const override = 0;
1372
1373 // ICurve methods
1374 virtual double get_Length() const = 0;
1375 virtual void StartPoint(OGRPoint *) const = 0;
1376 virtual void EndPoint(OGRPoint *) const = 0;
1377 virtual int get_IsClosed() const;
1378 virtual void Value(double, OGRPoint *) const = 0;
1379 virtual OGRLineString *
1380 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1381 const char *const *papszOptions = nullptr) const = 0;
1382 virtual int getDimension() const override;
1383
1384 // non standard
1385 virtual int getNumPoints() const = 0;
1386 virtual OGRPointIterator *getPointIterator() const = 0;
1387 virtual OGRBoolean IsConvex() const;
1388 virtual double get_Area() const = 0;
1389 virtual double get_GeodesicArea(
1390 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
1391 virtual double get_GeodesicLength(
1392 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
1393 virtual int isClockwise() const;
1394 virtual void reversePoints() = 0;
1395
1399 inline OGRSimpleCurve *toSimpleCurve()
1400 {
1401 return cpl::down_cast<OGRSimpleCurve *>(this);
1402 }
1403
1407 inline const OGRSimpleCurve *toSimpleCurve() const
1408 {
1409 return cpl::down_cast<const OGRSimpleCurve *>(this);
1410 }
1411
1412 static OGRCompoundCurve *CastToCompoundCurve(OGRCurve *puCurve);
1413 static OGRLineString *CastToLineString(OGRCurve *poCurve);
1414 static OGRLinearRing *CastToLinearRing(OGRCurve *poCurve);
1415
1416 OGR_FORBID_DOWNCAST_TO_POINT
1417 OGR_ALLOW_CAST_TO_THIS(Curve)
1418 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1419 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1420};
1421
1423
1424 inline OGRCurve::ConstIterator begin(const OGRCurve *poCurve)
1425{
1426 return poCurve->begin();
1427}
1428
1430 inline OGRCurve::ConstIterator end(const OGRCurve *poCurve)
1431{
1432 return poCurve->end();
1433}
1434
1436
1437/************************************************************************/
1438/* OGRIteratedPoint */
1439/************************************************************************/
1440
1462 class CPL_DLL OGRIteratedPoint : public OGRPoint
1463{
1464 private:
1465 friend class OGRSimpleCurve;
1466
1467 OGRSimpleCurve *m_poCurve = nullptr;
1468 int m_nPos = 0;
1469
1470 OGRIteratedPoint() = default;
1471
1472 CPL_DISALLOW_COPY_ASSIGN(OGRIteratedPoint)
1473
1474 public:
1478 void setX(double xIn);
1482 void setY(double yIn);
1486 void setZ(double zIn);
1490 void setM(double mIn);
1491};
1492
1493/************************************************************************/
1494/* OGRSimpleCurve */
1495/************************************************************************/
1496
1506 class CPL_DLL OGRSimpleCurve : public OGRCurve
1507{
1508 protected:
1510 friend class OGRGeometry;
1511
1512 int nPointCount = 0;
1513 int m_nPointCapacity = 0;
1514 OGRRawPoint *paoPoints = nullptr;
1515 double *padfZ = nullptr;
1516 double *padfM = nullptr;
1517
1518 bool Make3D();
1519 void Make2D();
1520 void RemoveM();
1521 bool AddM();
1522
1523 OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ, int bHasM,
1524 OGRRawPoint *&paoPointsIn, int &nMaxPoints,
1525 double *&padfZIn);
1527
1528 virtual double get_LinearArea() const;
1529
1531 OGRSimpleCurve() = default;
1532
1533 OGRSimpleCurve(const OGRSimpleCurve &other);
1534
1535 private:
1536 class CPL_DLL Iterator
1537 {
1538 struct Private;
1539 std::unique_ptr<Private> m_poPrivate;
1540 void update();
1541
1542 public:
1543 Iterator(OGRSimpleCurve *poSelf, int nPos);
1544 Iterator(Iterator &&oOther) noexcept; // declared but not defined.
1545 // Needed for gcc 5.4 at least
1546 ~Iterator();
1547 OGRIteratedPoint &operator*();
1548 Iterator &operator++();
1549 bool operator!=(const Iterator &it) const;
1550 };
1551
1552 friend inline Iterator begin(OGRSimpleCurve *);
1553 friend inline Iterator end(OGRSimpleCurve *);
1554
1555 class CPL_DLL ConstIterator
1556 {
1557 struct Private;
1558 std::unique_ptr<Private> m_poPrivate;
1559
1560 public:
1561 ConstIterator(const OGRSimpleCurve *poSelf, int nPos);
1562 ConstIterator(
1563 ConstIterator &&oOther) noexcept; // declared but not defined.
1564 // Needed for gcc 5.4 at least
1565 ~ConstIterator();
1566 const OGRPoint &operator*() const;
1567 ConstIterator &operator++();
1568 bool operator!=(const ConstIterator &it) const;
1569 };
1570
1571 friend inline ConstIterator begin(const OGRSimpleCurve *);
1572 friend inline ConstIterator end(const OGRSimpleCurve *);
1573
1574 public:
1575 ~OGRSimpleCurve() override;
1576
1577 OGRSimpleCurve &operator=(const OGRSimpleCurve &other);
1578
1580 typedef OGRPoint ChildType;
1581
1590 Iterator begin();
1592 Iterator end();
1601 ConstIterator begin() const;
1603 ConstIterator end() const;
1604
1605 // IWks Interface.
1606 virtual size_t WkbSize() const override;
1607 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1608 size_t &nBytesConsumedOut) override;
1609 virtual OGRErr
1610 exportToWkb(unsigned char *,
1611 const OGRwkbExportOptions * = nullptr) const override;
1612
1613#ifndef DOXYGEN_XML
1614 using OGRGeometry::importFromWkt;
1615#endif
1616
1617 OGRErr importFromWkt(const char **) override;
1618
1619#ifndef DOXYGEN_XML
1620 using OGRGeometry::exportToWkt;
1621#endif
1622
1627 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1628 OGRErr *err = nullptr) const override;
1629
1630 // IGeometry interface.
1631 virtual void empty() override;
1632 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1633 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1634 virtual OGRBoolean IsEmpty() const override;
1635 virtual OGRSimpleCurve *clone() const override = 0;
1636
1637 // ICurve methods.
1638 virtual double get_Length() const override;
1639 virtual void StartPoint(OGRPoint *) const override;
1640 virtual void EndPoint(OGRPoint *) const override;
1641 virtual void Value(double, OGRPoint *) const override;
1642 virtual double Project(const OGRPoint *) const;
1643 virtual OGRLineString *getSubLine(double, double, int) const;
1644
1645 // ILineString methods.
1646 virtual int getNumPoints() const override
1647 {
1648 return nPointCount;
1649 }
1650
1651 void getPoint(int, OGRPoint *) const;
1652
1653 double getX(int i) const
1654 {
1655 return paoPoints[i].x;
1656 }
1657
1658 double getY(int i) const
1659 {
1660 return paoPoints[i].y;
1661 }
1662
1663 double getZ(int i) const;
1664 double getM(int i) const;
1665
1666 // ISpatialRelation
1667 virtual OGRBoolean Equals(const OGRGeometry *) const override;
1668
1669 // non standard.
1670 virtual bool setCoordinateDimension(int nDimension) override;
1671 virtual bool set3D(OGRBoolean bIs3D) override;
1672 virtual bool setMeasured(OGRBoolean bIsMeasured) override;
1673 bool setNumPoints(int nNewPointCount, int bZeroizeNewContent = TRUE);
1674 bool setPoint(int, OGRPoint *);
1675 bool setPoint(int, double, double);
1676 bool setZ(int, double);
1677 bool setM(int, double);
1678 bool setPoint(int, double, double, double);
1679 bool setPointM(int, double, double, double);
1680 bool setPoint(int, double, double, double, double);
1681 bool setPoints(int, const OGRRawPoint *, const double * = nullptr);
1682 bool setPointsM(int, const OGRRawPoint *, const double *);
1683 bool setPoints(int, const OGRRawPoint *, const double *, const double *);
1684 bool setPoints(int, const double *padfX, const double *padfY,
1685 const double *padfZIn = nullptr);
1686 bool setPointsM(int, const double *padfX, const double *padfY,
1687 const double *padfMIn = nullptr);
1688 bool setPoints(int, const double *padfX, const double *padfY,
1689 const double *padfZIn, const double *padfMIn);
1690 bool addPoint(const OGRPoint *);
1691 bool addPoint(double, double);
1692 bool addPoint(double, double, double);
1693 bool addPointM(double, double, double);
1694 bool addPoint(double, double, double, double);
1695
1696 bool removePoint(int);
1697
1698 void getPoints(OGRRawPoint *, double * = nullptr) const;
1699 void getPoints(void *pabyX, int nXStride, void *pabyY, int nYStride,
1700 void *pabyZ = nullptr, int nZStride = 0,
1701 void *pabyM = nullptr, int nMStride = 0) const;
1702
1703 void addSubLineString(const OGRLineString *, int nStartVertex = 0,
1704 int nEndVertex = -1);
1705 void reversePoints() override;
1706 virtual OGRPointIterator *getPointIterator() const override;
1707
1708 // non-standard from OGRGeometry
1709 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1710 virtual void flattenTo2D() override;
1711 virtual bool segmentize(double dfMaxLength) override;
1712
1713 virtual void swapXY() override;
1714
1715 OGR_ALLOW_UPCAST_TO(Curve)
1716 OGR_ALLOW_CAST_TO_THIS(SimpleCurve)
1717};
1718
1720
1721 inline OGRSimpleCurve::Iterator begin(OGRSimpleCurve *poCurve)
1722{
1723 return poCurve->begin();
1724}
1725
1727 inline OGRSimpleCurve::Iterator end(OGRSimpleCurve *poCurve)
1728{
1729 return poCurve->end();
1730}
1731
1733 inline OGRSimpleCurve::ConstIterator begin(const OGRSimpleCurve *poCurve)
1734{
1735 return poCurve->begin();
1736}
1737
1739 inline OGRSimpleCurve::ConstIterator end(const OGRSimpleCurve *poCurve)
1740{
1741 return poCurve->end();
1742}
1743
1745
1746/************************************************************************/
1747/* OGRLineString */
1748/************************************************************************/
1749
1757 class CPL_DLL OGRLineString : public OGRSimpleCurve
1758{
1759 // cppcheck-suppress unusedPrivateFunction
1760 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
1761
1762 protected:
1764 static OGRLineString *TransferMembersAndDestroy(OGRLineString *poSrc,
1765 OGRLineString *poDst);
1766
1767 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1768 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1769
1770 virtual double get_AreaOfCurveSegments() const override;
1772
1773 static OGRLinearRing *CastToLinearRing(OGRLineString *poLS);
1774
1775 public:
1777 OGRLineString() = default;
1778 OGRLineString(const OGRLineString &other);
1779
1780 OGRLineString &operator=(const OGRLineString &other);
1781
1782 virtual OGRLineString *clone() const override;
1783 virtual OGRLineString *
1784 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1785 const char *const *papszOptions = nullptr) const override;
1786 virtual OGRGeometry *
1787 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
1788 virtual double get_Area() const override;
1789 virtual double get_GeodesicArea(
1790 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1791 virtual double get_GeodesicLength(
1792 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1793
1794 // Non-standard from OGRGeometry.
1795 virtual OGRwkbGeometryType getGeometryType() const override;
1796 virtual const char *getGeometryName() const override;
1797 virtual int isClockwise() const override;
1798
1800 inline OGRSimpleCurve *toUpperClass()
1801 {
1802 return this;
1803 }
1804
1806 inline const OGRSimpleCurve *toUpperClass() const
1807 {
1808 return this;
1809 }
1810
1811 virtual void accept(IOGRGeometryVisitor *visitor) override
1812 {
1813 visitor->visit(this);
1814 }
1815
1816 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1817 {
1818 visitor->visit(this);
1819 }
1820
1821 OGR_ALLOW_UPCAST_TO(SimpleCurve)
1822 OGR_ALLOW_CAST_TO_THIS(LineString)
1823};
1824
1825/************************************************************************/
1826/* OGRLinearRing */
1827/************************************************************************/
1828
1849 class CPL_DLL OGRLinearRing : public OGRLineString
1850{
1851 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
1852
1853 // IWks Interface - Note this isn't really a first class object
1854 // for the purposes of WKB form. These methods always fail since this
1855 // object can't be serialized on its own.
1856 virtual size_t WkbSize() const override;
1857 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1858 size_t &nBytesConsumedOut) override;
1859 OGRErr exportToWkb(unsigned char *,
1860 const OGRwkbExportOptions * = nullptr) const override;
1861
1862 protected:
1864 friend class OGRPolygon;
1865 friend class OGRTriangle;
1866
1867 // These are not IWks compatible ... just a convenience for OGRPolygon.
1868 virtual size_t _WkbSize(int _flags) const;
1869 virtual OGRErr _importFromWkb(OGRwkbByteOrder, int _flags,
1870 const unsigned char *, size_t,
1871 size_t &nBytesConsumedOut);
1872 virtual OGRErr _exportToWkb(int _flags, unsigned char *,
1873 const OGRwkbExportOptions *) const;
1874
1875 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1876 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1878
1879 static OGRLineString *CastToLineString(OGRLinearRing *poLR);
1880
1881 public:
1883 OGRLinearRing() = default;
1884 OGRLinearRing(const OGRLinearRing &other);
1885 explicit OGRLinearRing(const OGRLinearRing *);
1886
1887 OGRLinearRing &operator=(const OGRLinearRing &other);
1888
1889 // Non standard.
1890 virtual const char *getGeometryName() const override;
1891 virtual OGRLinearRing *clone() const override;
1892
1894 void reverseWindingOrder()
1895 CPL_WARN_DEPRECATED("Use reversePoints() instead");
1897
1898 virtual void closeRings() override;
1899 OGRBoolean isPointInRing(const OGRPoint *pt,
1900 int bTestEnvelope = TRUE) const;
1901 OGRBoolean isPointOnRingBoundary(const OGRPoint *pt,
1902 int bTestEnvelope = TRUE) const;
1903 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1904
1906 inline OGRLineString *toUpperClass()
1907 {
1908 return this;
1909 }
1910
1912 inline const OGRLineString *toUpperClass() const
1913 {
1914 return this;
1915 }
1916
1917 virtual void accept(IOGRGeometryVisitor *visitor) override
1918 {
1919 visitor->visit(this);
1920 }
1921
1922 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1923 {
1924 visitor->visit(this);
1925 }
1926
1927 OGR_ALLOW_UPCAST_TO(LineString)
1928 OGR_ALLOW_CAST_TO_THIS(LinearRing)
1929};
1930
1931/************************************************************************/
1932/* OGRCircularString */
1933/************************************************************************/
1934
1947 class CPL_DLL OGRCircularString : public OGRSimpleCurve
1948{
1949 private:
1950 void ExtendEnvelopeWithCircular(OGREnvelope *psEnvelope) const;
1951 OGRBoolean IsValidFast() const;
1952 int IsFullCircle(double &cx, double &cy, double &square_R) const;
1953
1954 protected:
1956 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1957 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1958 virtual int IntersectsPoint(const OGRPoint *p) const override;
1959 virtual int ContainsPoint(const OGRPoint *p) const override;
1960 virtual double get_AreaOfCurveSegments() const override;
1962
1963 public:
1965 OGRCircularString() = default;
1966
1967 OGRCircularString(const OGRCircularString &other);
1968
1969 OGRCircularString &operator=(const OGRCircularString &other);
1970
1971 // IWks Interface.
1972 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1973 size_t &nBytesConsumedOut) override;
1974 OGRErr exportToWkb(unsigned char *,
1975 const OGRwkbExportOptions * = nullptr) const override;
1976
1977#ifndef DOXYGEN_XML
1978 using OGRGeometry::importFromWkt;
1979#endif
1980
1981 OGRErr importFromWkt(const char **) override;
1982
1983#ifndef DOXYGEN_XML
1984 using OGRGeometry::exportToWkt;
1985#endif
1986
1991 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1992 OGRErr *err = nullptr) const override;
1993
1994 // IGeometry interface.
1995 virtual OGRBoolean IsValid() const override;
1996 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1997 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1998 virtual OGRCircularString *clone() const override;
1999
2000 // ICurve methods.
2001 virtual double get_Length() const override;
2002 virtual OGRLineString *
2003 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
2004 const char *const *papszOptions = nullptr) const override;
2005 virtual void Value(double, OGRPoint *) const override;
2006 virtual double get_Area() const override;
2007 virtual double get_GeodesicArea(
2008 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2009 virtual double get_GeodesicLength(
2010 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2011
2012 // Non-standard from OGRGeometry.
2013 virtual OGRwkbGeometryType getGeometryType() const override;
2014 virtual const char *getGeometryName() const override;
2015 virtual bool segmentize(double dfMaxLength) override;
2016 virtual OGRBoolean
2017 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2018 virtual OGRGeometry *
2019 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2020 const char *const *papszOptions = nullptr) const override;
2021
2023 inline OGRSimpleCurve *toUpperClass()
2024 {
2025 return this;
2026 }
2027
2029 inline const OGRSimpleCurve *toUpperClass() const
2030 {
2031 return this;
2032 }
2033
2034 virtual void accept(IOGRGeometryVisitor *visitor) override
2035 {
2036 visitor->visit(this);
2037 }
2038
2039 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2040 {
2041 visitor->visit(this);
2042 }
2043
2044 OGR_ALLOW_UPCAST_TO(SimpleCurve)
2045 OGR_ALLOW_CAST_TO_THIS(CircularString)
2046};
2047
2048/************************************************************************/
2049/* OGRCurveCollection */
2050/************************************************************************/
2051
2063 class CPL_DLL OGRCurveCollection
2064{
2065 protected:
2066 friend class OGRCompoundCurve;
2067 friend class OGRCurvePolygon;
2068 friend class OGRPolygon;
2069 friend class OGRTriangle;
2070
2071 int nCurveCount = 0;
2072 OGRCurve **papoCurves = nullptr;
2073
2074 public:
2075 OGRCurveCollection() = default;
2076 OGRCurveCollection(const OGRCurveCollection &other);
2077 ~OGRCurveCollection();
2078
2079 OGRCurveCollection &operator=(const OGRCurveCollection &other);
2080
2082 typedef OGRCurve ChildType;
2083
2087 OGRCurve **begin()
2088 {
2089 return papoCurves;
2090 }
2091
2093 OGRCurve **end()
2094 {
2095 return papoCurves + nCurveCount;
2096 }
2097
2101 const OGRCurve *const *begin() const
2102 {
2103 return papoCurves;
2104 }
2105
2107 const OGRCurve *const *end() const
2108 {
2109 return papoCurves + nCurveCount;
2110 }
2111
2112 void empty(OGRGeometry *poGeom);
2113 OGRBoolean IsEmpty() const;
2114 void getEnvelope(OGREnvelope *psEnvelope) const;
2115 void getEnvelope(OGREnvelope3D *psEnvelope) const;
2116
2117 OGRErr addCurveDirectly(OGRGeometry *poGeom, OGRCurve *poCurve,
2118 int bNeedRealloc);
2119 size_t WkbSize() const;
2120 OGRErr importPreambleFromWkb(OGRGeometry *poGeom,
2121 const unsigned char *pabyData, size_t &nSize,
2122 size_t &nDataOffset,
2123 OGRwkbByteOrder &eByteOrder,
2124 size_t nMinSubGeomSize,
2125 OGRwkbVariant eWkbVariant);
2126 OGRErr
2127 importBodyFromWkb(OGRGeometry *poGeom, const unsigned char *pabyData,
2128 size_t nSize, bool bAcceptCompoundCurve,
2129 OGRErr (*pfnAddCurveDirectlyFromWkb)(OGRGeometry *poGeom,
2130 OGRCurve *poCurve),
2131 OGRwkbVariant eWkbVariant, size_t &nBytesConsumedOut);
2132 std::string exportToWkt(const OGRGeometry *geom, const OGRWktOptions &opts,
2133 OGRErr *err) const;
2134 OGRErr exportToWkb(const OGRGeometry *poGeom, unsigned char *,
2135 const OGRwkbExportOptions * = nullptr) const;
2136 OGRBoolean Equals(const OGRCurveCollection *poOCC) const;
2137 bool setCoordinateDimension(OGRGeometry *poGeom, int nNewDimension);
2138 bool set3D(OGRGeometry *poGeom, OGRBoolean bIs3D);
2139 bool setMeasured(OGRGeometry *poGeom, OGRBoolean bIsMeasured);
2140 void assignSpatialReference(OGRGeometry *poGeom,
2141 const OGRSpatialReference *poSR);
2142 int getNumCurves() const;
2143 OGRCurve *getCurve(int);
2144 const OGRCurve *getCurve(int) const;
2145 OGRCurve *stealCurve(int);
2146
2147 OGRErr removeCurve(int iIndex, bool bDelete = true);
2148
2149 bool hasEmptyParts() const;
2150 void removeEmptyParts();
2151
2152 void reversePoints();
2153
2154 OGRErr transform(OGRGeometry *poGeom, OGRCoordinateTransformation *poCT);
2155 void flattenTo2D(OGRGeometry *poGeom);
2156 bool segmentize(double dfMaxLength);
2157 void swapXY();
2158 OGRBoolean hasCurveGeometry(int bLookForNonLinear) const;
2159};
2160
2162
2163/************************************************************************/
2164/* OGRCompoundCurve */
2165/************************************************************************/
2166
2177 class CPL_DLL OGRCompoundCurve : public OGRCurve
2178{
2179 private:
2180 OGRCurveCollection oCC{};
2181
2182 OGRErr addCurveDirectlyInternal(OGRCurve *poCurve, double dfToleranceEps,
2183 int bNeedRealloc);
2184 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2185 OGRCurve *poCurve);
2186 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2187 OGRCurve *poCurve);
2188 OGRLineString *CurveToLineInternal(double dfMaxAngleStepSizeDegrees,
2189 const char *const *papszOptions,
2190 int bIsLinearRing) const;
2191 // cppcheck-suppress unusedPrivateFunction
2192 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
2193 // cppcheck-suppress unusedPrivateFunction
2194 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
2195
2196 protected:
2198 static OGRLineString *CastToLineString(OGRCompoundCurve *poCC);
2199 static OGRLinearRing *CastToLinearRing(OGRCompoundCurve *poCC);
2200
2201 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
2202 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
2204
2205 public:
2207 OGRCompoundCurve() = default;
2208
2209 OGRCompoundCurve(const OGRCompoundCurve &other);
2210
2211 OGRCompoundCurve &operator=(const OGRCompoundCurve &other);
2212
2214 typedef OGRCurve ChildType;
2215
2219 ChildType **begin()
2220 {
2221 return oCC.begin();
2222 }
2223
2225 ChildType **end()
2226 {
2227 return oCC.end();
2228 }
2229
2233 const ChildType *const *begin() const
2234 {
2235 return oCC.begin();
2236 }
2237
2239 const ChildType *const *end() const
2240 {
2241 return oCC.end();
2242 }
2243
2244 // IWks Interface
2245 virtual size_t WkbSize() const override;
2246 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2247 size_t &nBytesConsumedOut) override;
2248 OGRErr exportToWkb(unsigned char *,
2249 const OGRwkbExportOptions * = nullptr) const override;
2250
2251#ifndef DOXYGEN_XML
2252 using OGRGeometry::importFromWkt;
2253#endif
2254
2255 OGRErr importFromWkt(const char **) override;
2256
2257#ifndef DOXYGEN_XML
2258 using OGRGeometry::exportToWkt;
2259#endif
2260
2265 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2266 OGRErr *err = nullptr) const override;
2267
2268 // IGeometry interface.
2269 virtual OGRCompoundCurve *clone() const override;
2270 virtual void empty() override;
2271 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2272 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2273 virtual OGRBoolean IsEmpty() const override;
2274
2275 // ICurve methods.
2276 virtual double get_Length() const override;
2277 virtual void StartPoint(OGRPoint *) const override;
2278 virtual void EndPoint(OGRPoint *) const override;
2279 virtual void Value(double, OGRPoint *) const override;
2280 virtual OGRLineString *
2281 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
2282 const char *const *papszOptions = nullptr) const override;
2283
2284 virtual int getNumPoints() const override;
2285 virtual double get_AreaOfCurveSegments() const override;
2286 virtual double get_Area() const override;
2287 virtual double get_GeodesicArea(
2288 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2289 virtual double get_GeodesicLength(
2290 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2291
2292 // ISpatialRelation.
2293 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2294
2295 // ICompoundCurve method.
2296 int getNumCurves() const;
2297 OGRCurve *getCurve(int);
2298 const OGRCurve *getCurve(int) const;
2299
2300 // Non-standard.
2301 virtual bool setCoordinateDimension(int nDimension) override;
2302 virtual bool set3D(OGRBoolean bIs3D) override;
2303 virtual bool setMeasured(OGRBoolean bIsMeasured) override;
2304
2305 virtual void
2306 assignSpatialReference(const OGRSpatialReference *poSR) override;
2307
2311 static constexpr double DEFAULT_TOLERANCE_EPSILON = 1e-14;
2312
2313 OGRErr addCurve(const OGRCurve *,
2314 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2315 OGRErr addCurveDirectly(OGRCurve *,
2316 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2317 OGRErr addCurve(std::unique_ptr<OGRCurve>,
2318 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2319 OGRCurve *stealCurve(int);
2320 virtual OGRPointIterator *getPointIterator() const override;
2321 void reversePoints() override;
2322
2323 // Non-standard from OGRGeometry.
2324 virtual OGRwkbGeometryType getGeometryType() const override;
2325 virtual const char *getGeometryName() const override;
2326 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2327 virtual void flattenTo2D() override;
2328 virtual bool segmentize(double dfMaxLength) override;
2329 virtual OGRBoolean
2330 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2331 virtual OGRGeometry *
2332 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2333 const char *const *papszOptions = nullptr) const override;
2334
2335 virtual void accept(IOGRGeometryVisitor *visitor) override
2336 {
2337 visitor->visit(this);
2338 }
2339
2340 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2341 {
2342 visitor->visit(this);
2343 }
2344
2345 virtual void swapXY() override;
2346
2347 bool hasEmptyParts() const override;
2348 void removeEmptyParts() override;
2349
2350 OGR_ALLOW_UPCAST_TO(Curve)
2351 OGR_ALLOW_CAST_TO_THIS(CompoundCurve)
2352};
2353
2355
2356 inline const OGRCompoundCurve::ChildType *const *
2357 begin(const OGRCompoundCurve *poCurve)
2358{
2359 return poCurve->begin();
2360}
2361
2363 inline const OGRCompoundCurve::ChildType *const *
2364 end(const OGRCompoundCurve *poCurve)
2365{
2366 return poCurve->end();
2367}
2368
2370 inline OGRCompoundCurve::ChildType **begin(OGRCompoundCurve *poCurve)
2371{
2372 return poCurve->begin();
2373}
2374
2376 inline OGRCompoundCurve::ChildType **end(OGRCompoundCurve *poCurve)
2377{
2378 return poCurve->end();
2379}
2380
2382
2383/************************************************************************/
2384/* OGRSurface */
2385/************************************************************************/
2386
2392 class CPL_DLL OGRSurface : public OGRGeometry
2393{
2394 protected:
2396 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const = 0;
2397 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const = 0;
2399
2400 public:
2401 virtual double get_Area() const = 0;
2402 virtual double get_GeodesicArea(
2403 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
2404 virtual double get_Length() const = 0;
2405 virtual double get_GeodesicLength(
2406 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
2407
2408 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
2409 {
2410 return PointOnSurfaceInternal(poPoint);
2411 }
2412
2413 virtual OGRSurface *clone() const override = 0;
2414
2416 static OGRPolygon *CastToPolygon(OGRSurface *poSurface);
2417 static OGRCurvePolygon *CastToCurvePolygon(OGRSurface *poSurface);
2419
2420 OGR_FORBID_DOWNCAST_TO_POINT
2421 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
2422 OGR_ALLOW_CAST_TO_THIS(Surface)
2423 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
2424};
2425
2426/************************************************************************/
2427/* OGRCurvePolygon */
2428/************************************************************************/
2429
2443 class CPL_DLL OGRCurvePolygon : public OGRSurface
2444{
2445 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2446
2447 private:
2448 OGRBoolean IntersectsPoint(const OGRPoint *p) const;
2449 OGRBoolean ContainsPoint(const OGRPoint *p) const;
2450
2451 virtual bool isRingCorrectType(const OGRCurve *poRing) const;
2452
2453 virtual bool checkRing(const OGRCurve *poNewRing) const;
2454 OGRErr addRingDirectlyInternal(OGRCurve *poCurve, int bNeedRealloc);
2455 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2456 OGRCurve *poCurve);
2457 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2458 OGRCurve *poCurve);
2459
2460 protected:
2462 friend class OGRPolygon;
2463 friend class OGRTriangle;
2464 OGRCurveCollection oCC{};
2465
2466 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2467 virtual OGRSurfaceCasterToCurvePolygon
2468 GetCasterToCurvePolygon() const override;
2469
2471
2472 static OGRPolygon *CastToPolygon(OGRCurvePolygon *poCP);
2473
2474 public:
2476 OGRCurvePolygon() = default;
2477
2478 OGRCurvePolygon(const OGRCurvePolygon &);
2479
2480 OGRCurvePolygon &operator=(const OGRCurvePolygon &other);
2481
2483 typedef OGRCurve ChildType;
2484
2488 ChildType **begin()
2489 {
2490 return oCC.begin();
2491 }
2492
2494 ChildType **end()
2495 {
2496 return oCC.end();
2497 }
2498
2502 const ChildType *const *begin() const
2503 {
2504 return oCC.begin();
2505 }
2506
2508 const ChildType *const *end() const
2509 {
2510 return oCC.end();
2511 }
2512
2513 // Non standard (OGRGeometry).
2514 virtual const char *getGeometryName() const override;
2515 virtual OGRwkbGeometryType getGeometryType() const override;
2516 virtual OGRCurvePolygon *clone() const override;
2517 virtual void empty() override;
2518 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2519 virtual void flattenTo2D() override;
2520 virtual OGRBoolean IsEmpty() const override;
2521 virtual bool segmentize(double dfMaxLength) override;
2522 virtual OGRBoolean
2523 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2524 virtual OGRGeometry *
2525 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2526 const char *const *papszOptions = nullptr) const override;
2527 virtual double get_GeodesicArea(
2528 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2529 virtual double get_GeodesicLength(
2530 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2531
2532 // ISurface Interface
2533 virtual double get_Area() const override;
2534
2535 virtual double get_Length() const override;
2536
2537 // IWks Interface
2538 virtual size_t WkbSize() const override;
2539 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2540 size_t &nBytesConsumedOut) override;
2541 OGRErr exportToWkb(unsigned char *,
2542 const OGRwkbExportOptions * = nullptr) const override;
2543
2544#ifndef DOXYGEN_XML
2545 using OGRGeometry::importFromWkt;
2546#endif
2547
2548 OGRErr importFromWkt(const char **) override;
2549
2550#ifndef DOXYGEN_XML
2551 using OGRGeometry::exportToWkt;
2552#endif
2553
2558 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2559 OGRErr *err = nullptr) const override;
2560
2561 // IGeometry
2562 virtual int getDimension() const override;
2563 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2564 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2565
2566 // ICurvePolygon
2567 virtual OGRPolygon *
2568 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2569 const char *const *papszOptions = nullptr) const;
2570
2571 // ISpatialRelation
2572 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2573 virtual OGRBoolean Intersects(const OGRGeometry *) const override;
2574 virtual OGRBoolean Contains(const OGRGeometry *) const override;
2575
2576 // Non standard
2577 virtual bool setCoordinateDimension(int nDimension) override;
2578 virtual bool set3D(OGRBoolean bIs3D) override;
2579 virtual bool setMeasured(OGRBoolean bIsMeasured) override;
2580
2581 virtual void
2582 assignSpatialReference(const OGRSpatialReference *poSR) override;
2583
2584 virtual OGRErr addRing(const OGRCurve *);
2585 virtual OGRErr addRingDirectly(OGRCurve *);
2586 OGRErr addRing(std::unique_ptr<OGRCurve>);
2587
2588 OGRCurve *getExteriorRingCurve();
2589 const OGRCurve *getExteriorRingCurve() const;
2590 int getNumInteriorRings() const;
2591 OGRCurve *getInteriorRingCurve(int);
2592 const OGRCurve *getInteriorRingCurve(int) const;
2593
2594 OGRCurve *stealExteriorRingCurve();
2595
2596 OGRErr removeRing(int iIndex, bool bDelete = true);
2597
2598 virtual void accept(IOGRGeometryVisitor *visitor) override
2599 {
2600 visitor->visit(this);
2601 }
2602
2603 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2604 {
2605 visitor->visit(this);
2606 }
2607
2608 virtual void swapXY() override;
2609
2610 bool hasEmptyParts() const override;
2611 void removeEmptyParts() override;
2612
2613 OGR_ALLOW_UPCAST_TO(Surface)
2614 OGR_ALLOW_CAST_TO_THIS(CurvePolygon)
2615};
2616
2618
2619 inline const OGRCurvePolygon::ChildType *const *
2620 begin(const OGRCurvePolygon *poGeom)
2621{
2622 return poGeom->begin();
2623}
2624
2626 inline const OGRCurvePolygon::ChildType *const *
2627 end(const OGRCurvePolygon *poGeom)
2628{
2629 return poGeom->end();
2630}
2631
2633 inline OGRCurvePolygon::ChildType **begin(OGRCurvePolygon *poGeom)
2634{
2635 return poGeom->begin();
2636}
2637
2639 inline OGRCurvePolygon::ChildType **end(OGRCurvePolygon *poGeom)
2640{
2641 return poGeom->end();
2642}
2643
2645
2646/************************************************************************/
2647/* OGRPolygon */
2648/************************************************************************/
2649
2659 class CPL_DLL OGRPolygon : public OGRCurvePolygon
2660{
2661 static OGRCurvePolygon *CasterToCurvePolygon(OGRSurface *poSurface);
2662
2663 protected:
2665 friend class OGRMultiSurface;
2666 friend class OGRPolyhedralSurface;
2667 friend class OGRTriangulatedSurface;
2668
2669 virtual bool isRingCorrectType(const OGRCurve *poRing) const override;
2670
2671 virtual bool checkRing(const OGRCurve *poNewRing) const override;
2672 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2673 int bHasM, OGRRawPoint *&paoPoints,
2674 int &nMaxPoints, double *&padfZ);
2675
2676 static OGRCurvePolygon *CastToCurvePolygon(OGRPolygon *poPoly);
2677
2678 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2679 virtual OGRSurfaceCasterToCurvePolygon
2680 GetCasterToCurvePolygon() const override;
2682
2683 public:
2685 OGRPolygon() = default;
2686
2687 OGRPolygon(const OGRPolygon &other);
2688
2689 OGRPolygon &operator=(const OGRPolygon &other);
2690
2692 typedef OGRLinearRing ChildType;
2693
2697 ChildType **begin()
2698 {
2699 return reinterpret_cast<ChildType **>(oCC.begin());
2700 }
2701
2703 ChildType **end()
2704 {
2705 return reinterpret_cast<ChildType **>(oCC.end());
2706 }
2707
2711 const ChildType *const *begin() const
2712 {
2713 return reinterpret_cast<const ChildType *const *>(oCC.begin());
2714 }
2715
2717 const ChildType *const *end() const
2718 {
2719 return reinterpret_cast<const ChildType *const *>(oCC.end());
2720 }
2721
2722 // Non-standard (OGRGeometry).
2723 virtual const char *getGeometryName() const override;
2724 virtual OGRwkbGeometryType getGeometryType() const override;
2725 virtual OGRPolygon *clone() const override;
2726 virtual OGRBoolean
2727 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2728 virtual OGRGeometry *
2729 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2730 virtual OGRGeometry *
2731 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2732 const char *const *papszOptions = nullptr) const override;
2733
2734 // IWks Interface.
2735 virtual size_t WkbSize() const override;
2736 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2737 size_t &nBytesConsumedOut) override;
2738 OGRErr exportToWkb(unsigned char *,
2739 const OGRwkbExportOptions * = nullptr) const override;
2740
2741#ifndef DOXYGEN_XML
2742 using OGRGeometry::importFromWkt;
2743#endif
2744
2745 OGRErr importFromWkt(const char **) override;
2746
2747#ifndef DOXYGEN_XML
2748 using OGRGeometry::exportToWkt;
2749#endif
2750
2755 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2756 OGRErr *err = nullptr) const override;
2757
2758 // ICurvePolygon.
2759 virtual OGRPolygon *
2760 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2761 const char *const *papszOptions = nullptr) const override;
2762
2763 OGRLinearRing *getExteriorRing();
2764 const OGRLinearRing *getExteriorRing() const;
2765 virtual OGRLinearRing *getInteriorRing(int);
2766 virtual const OGRLinearRing *getInteriorRing(int) const;
2767
2768 OGRLinearRing *stealExteriorRing();
2769 virtual OGRLinearRing *stealInteriorRing(int);
2770
2771 OGRBoolean IsPointOnSurface(const OGRPoint *) const;
2772
2774 inline OGRCurvePolygon *toUpperClass()
2775 {
2776 return this;
2777 }
2778
2780 inline const OGRCurvePolygon *toUpperClass() const
2781 {
2782 return this;
2783 }
2784
2785 virtual void accept(IOGRGeometryVisitor *visitor) override
2786 {
2787 visitor->visit(this);
2788 }
2789
2790 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2791 {
2792 visitor->visit(this);
2793 }
2794
2795 virtual void closeRings() override;
2796
2797 OGR_ALLOW_UPCAST_TO(CurvePolygon)
2798 OGR_ALLOW_CAST_TO_THIS(Polygon)
2799};
2800
2802
2803 inline const OGRPolygon::ChildType *const *begin(const OGRPolygon *poGeom)
2804{
2805 return poGeom->begin();
2806}
2807
2809 inline const OGRPolygon::ChildType *const *end(const OGRPolygon *poGeom)
2810{
2811 return poGeom->end();
2812}
2813
2815 inline OGRPolygon::ChildType **begin(OGRPolygon *poGeom)
2816{
2817 return poGeom->begin();
2818}
2819
2821 inline OGRPolygon::ChildType **end(OGRPolygon *poGeom)
2822{
2823 return poGeom->end();
2824}
2825
2827
2828/************************************************************************/
2829/* OGRTriangle */
2830/************************************************************************/
2831
2838 class CPL_DLL OGRTriangle : public OGRPolygon
2839{
2840 private:
2841 // cppcheck-suppress unusedPrivateFunction
2842 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2843 bool quickValidityCheck() const;
2844
2845 protected:
2847 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2848 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2849 int bHasM, OGRRawPoint *&paoPoints,
2850 int &nMaxPoints,
2851 double *&padfZ) override;
2853
2854 public:
2856 OGRTriangle() = default;
2857 OGRTriangle(const OGRPoint &p, const OGRPoint &q, const OGRPoint &r);
2858 OGRTriangle(const OGRTriangle &other);
2859 OGRTriangle(const OGRPolygon &other, OGRErr &eErr);
2860 OGRTriangle &operator=(const OGRTriangle &other);
2861
2862 virtual const char *getGeometryName() const override;
2863 virtual OGRwkbGeometryType getGeometryType() const override;
2864 virtual OGRTriangle *clone() const override;
2865
2866 // IWks Interface.
2867 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2868 size_t &nBytesConsumedOut) override;
2869
2870 // New methods rewritten from OGRPolygon/OGRCurvePolygon/OGRGeometry.
2871 virtual OGRErr addRingDirectly(OGRCurve *poNewRing) override;
2872
2874 inline OGRPolygon *toUpperClass()
2875 {
2876 return this;
2877 }
2878
2880 inline const OGRPolygon *toUpperClass() const
2881 {
2882 return this;
2883 }
2884
2885 virtual void accept(IOGRGeometryVisitor *visitor) override
2886 {
2887 visitor->visit(this);
2888 }
2889
2890 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2891 {
2892 visitor->visit(this);
2893 }
2894
2896 static OGRGeometry *CastToPolygon(OGRGeometry *poGeom);
2898
2899 OGR_ALLOW_UPCAST_TO(Polygon)
2900 OGR_ALLOW_CAST_TO_THIS(Triangle)
2901};
2902
2903/************************************************************************/
2904/* OGRGeometryCollection */
2905/************************************************************************/
2906
2914 class CPL_DLL OGRGeometryCollection : public OGRGeometry
2915{
2916 OGRErr importFromWktInternal(const char **ppszInput, int nRecLevel);
2917
2918 protected:
2920 int nGeomCount = 0;
2921 OGRGeometry **papoGeoms = nullptr;
2922
2923 std::string
2924 exportToWktInternal(const OGRWktOptions &opts, OGRErr *err,
2925 const std::string &exclude = std::string()) const;
2926 static OGRGeometryCollection *
2927 TransferMembersAndDestroy(OGRGeometryCollection *poSrc,
2928 OGRGeometryCollection *poDst);
2929
2930 OGRErr importFromWkbInternal(const unsigned char *pabyData, size_t nSize,
2931 int nRecLevel, OGRwkbVariant,
2932 size_t &nBytesConsumedOut);
2934 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
2935
2936 public:
2938 OGRGeometryCollection() = default;
2939
2940 OGRGeometryCollection(const OGRGeometryCollection &other);
2941 ~OGRGeometryCollection() override;
2942
2943 OGRGeometryCollection &operator=(const OGRGeometryCollection &other);
2944
2946 typedef OGRGeometry ChildType;
2947
2951 ChildType **begin()
2952 {
2953 return papoGeoms;
2954 }
2955
2957 ChildType **end()
2958 {
2959 return papoGeoms + nGeomCount;
2960 }
2961
2965 const ChildType *const *begin() const
2966 {
2967 return papoGeoms;
2968 }
2969
2971 const ChildType *const *end() const
2972 {
2973 return papoGeoms + nGeomCount;
2974 }
2975
2976 // Non standard (OGRGeometry).
2977 virtual const char *getGeometryName() const override;
2978 virtual OGRwkbGeometryType getGeometryType() const override;
2979 virtual OGRGeometryCollection *clone() const override;
2980 virtual void empty() override;
2981 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2982 virtual void flattenTo2D() override;
2983 virtual OGRBoolean IsEmpty() const override;
2984 virtual bool segmentize(double dfMaxLength) override;
2985 virtual OGRBoolean
2986 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2987 virtual OGRGeometry *
2988 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2989 virtual OGRGeometry *
2990 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2991 const char *const *papszOptions = nullptr) const override;
2992 virtual double
2993 get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const;
2994 virtual double get_GeodesicLength(
2995 const OGRSpatialReference *poSRSOverride = nullptr) const;
2996
2997 // IWks Interface
2998 virtual size_t WkbSize() const override;
2999 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3000 size_t &nBytesConsumedOut) override;
3001 OGRErr exportToWkb(unsigned char *,
3002 const OGRwkbExportOptions * = nullptr) const override;
3003
3004#ifndef DOXYGEN_XML
3005 using OGRGeometry::importFromWkt;
3006#endif
3007
3008 OGRErr importFromWkt(const char **) override;
3009
3010#ifndef DOXYGEN_XML
3011 using OGRGeometry::exportToWkt;
3012#endif
3013
3018 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3019 OGRErr *err = nullptr) const override;
3020
3021 virtual double get_Length() const;
3022 virtual double get_Area() const;
3023
3024 // IGeometry methods
3025 virtual int getDimension() const override;
3026 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
3027 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3028
3029 // IGeometryCollection
3030 int getNumGeometries() const;
3031 OGRGeometry *getGeometryRef(int);
3032 const OGRGeometry *getGeometryRef(int) const;
3033
3034 // ISpatialRelation
3035 virtual OGRBoolean Equals(const OGRGeometry *) const override;
3036
3037 // Non standard
3038 virtual bool setCoordinateDimension(int nDimension) override;
3039 virtual bool set3D(OGRBoolean bIs3D) override;
3040 virtual bool setMeasured(OGRBoolean bIsMeasured) override;
3041 virtual OGRErr addGeometry(const OGRGeometry *);
3042 virtual OGRErr addGeometryDirectly(OGRGeometry *);
3043 OGRErr addGeometry(std::unique_ptr<OGRGeometry> geom);
3044 virtual OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3045 std::unique_ptr<OGRGeometry> stealGeometry(int iIndex);
3046
3047 bool hasEmptyParts() const override;
3048 void removeEmptyParts() override;
3049
3050 virtual void
3051 assignSpatialReference(const OGRSpatialReference *poSR) override;
3052
3053 void closeRings() override;
3054
3055 virtual void swapXY() override;
3056
3057 virtual void accept(IOGRGeometryVisitor *visitor) override
3058 {
3059 visitor->visit(this);
3060 }
3061
3062 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3063 {
3064 visitor->visit(this);
3065 }
3066
3067 static OGRGeometryCollection *
3068 CastToGeometryCollection(OGRGeometryCollection *poSrc);
3069
3070 OGR_FORBID_DOWNCAST_TO_POINT
3071 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
3072 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
3073 OGR_ALLOW_CAST_TO_THIS(GeometryCollection)
3074};
3075
3077
3078 inline const OGRGeometryCollection::ChildType *const *
3079 begin(const OGRGeometryCollection *poGeom)
3080{
3081 return poGeom->begin();
3082}
3083
3085 inline const OGRGeometryCollection::ChildType *const *
3086 end(const OGRGeometryCollection *poGeom)
3087{
3088 return poGeom->end();
3089}
3090
3092 inline OGRGeometryCollection::ChildType **begin(OGRGeometryCollection *poGeom)
3093{
3094 return poGeom->begin();
3095}
3096
3098 inline OGRGeometryCollection::ChildType **end(OGRGeometryCollection *poGeom)
3099{
3100 return poGeom->end();
3101}
3102
3104
3105/************************************************************************/
3106/* OGRMultiSurface */
3107/************************************************************************/
3108
3115 class CPL_DLL OGRMultiSurface : public OGRGeometryCollection
3116{
3117 protected:
3118 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3119
3120 public:
3122 OGRMultiSurface() = default;
3123
3124 OGRMultiSurface(const OGRMultiSurface &other);
3125
3126 OGRMultiSurface &operator=(const OGRMultiSurface &other);
3127
3129 typedef OGRSurface ChildType;
3130
3134 ChildType **begin()
3135 {
3136 return reinterpret_cast<ChildType **>(papoGeoms);
3137 }
3138
3140 ChildType **end()
3141 {
3142 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3143 }
3144
3148 const ChildType *const *begin() const
3149 {
3150 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3151 }
3152
3154 const ChildType *const *end() const
3155 {
3156 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3157 nGeomCount);
3158 }
3159
3160 // Non standard (OGRGeometry).
3161 virtual const char *getGeometryName() const override;
3162 virtual OGRwkbGeometryType getGeometryType() const override;
3163 virtual OGRMultiSurface *clone() const override;
3164
3165#ifndef DOXYGEN_XML
3166 using OGRGeometry::importFromWkt;
3167#endif
3168
3169 OGRErr importFromWkt(const char **) override;
3170
3171#ifndef DOXYGEN_XML
3172 using OGRGeometry::exportToWkt;
3173#endif
3174
3179 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3180 OGRErr *err = nullptr) const override;
3181
3182 // IMultiSurface methods
3183 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const;
3184
3185 // IGeometry methods
3186 virtual int getDimension() const override;
3187
3188 // IGeometryCollection
3190 OGRSurface *getGeometryRef(int i)
3191 {
3192 return OGRGeometryCollection::getGeometryRef(i)->toSurface();
3193 }
3194
3196 const OGRSurface *getGeometryRef(int i) const
3197 {
3198 return OGRGeometryCollection::getGeometryRef(i)->toSurface();
3199 }
3200
3201 // Non standard
3202 virtual OGRBoolean
3203 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3204
3206 inline OGRGeometryCollection *toUpperClass()
3207 {
3208 return this;
3209 }
3210
3212 inline const OGRGeometryCollection *toUpperClass() const
3213 {
3214 return this;
3215 }
3216
3217 virtual void accept(IOGRGeometryVisitor *visitor) override
3218 {
3219 visitor->visit(this);
3220 }
3221
3222 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3223 {
3224 visitor->visit(this);
3225 }
3226
3227 static OGRMultiPolygon *CastToMultiPolygon(OGRMultiSurface *poMS);
3228
3229 OGR_ALLOW_CAST_TO_THIS(MultiSurface)
3230 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3231 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3232 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3233 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3234};
3235
3237
3238 inline const OGRMultiSurface::ChildType *const *
3239 begin(const OGRMultiSurface *poGeom)
3240{
3241 return poGeom->begin();
3242}
3243
3245 inline const OGRMultiSurface::ChildType *const *
3246 end(const OGRMultiSurface *poGeom)
3247{
3248 return poGeom->end();
3249}
3250
3252 inline OGRMultiSurface::ChildType **begin(OGRMultiSurface *poGeom)
3253{
3254 return poGeom->begin();
3255}
3256
3258 inline OGRMultiSurface::ChildType **end(OGRMultiSurface *poGeom)
3259{
3260 return poGeom->end();
3261}
3262
3264
3265/************************************************************************/
3266/* OGRMultiPolygon */
3267/************************************************************************/
3268
3273 class CPL_DLL OGRMultiPolygon : public OGRMultiSurface
3274{
3275 protected:
3276 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3277 friend class OGRPolyhedralSurface;
3278 friend class OGRTriangulatedSurface;
3279
3280 private:
3282 OGRErr _addGeometryWithExpectedSubGeometryType(
3283 const OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3284 OGRErr _addGeometryDirectlyWithExpectedSubGeometryType(
3285 OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3287
3288 public:
3290 OGRMultiPolygon() = default;
3291
3292 OGRMultiPolygon(const OGRMultiPolygon &other);
3293
3294 OGRMultiPolygon &operator=(const OGRMultiPolygon &other);
3295
3297 typedef OGRPolygon ChildType;
3298
3302 ChildType **begin()
3303 {
3304 return reinterpret_cast<ChildType **>(papoGeoms);
3305 }
3306
3308 ChildType **end()
3309 {
3310 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3311 }
3312
3316 const ChildType *const *begin() const
3317 {
3318 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3319 }
3320
3322 const ChildType *const *end() const
3323 {
3324 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3325 nGeomCount);
3326 }
3327
3328 // IGeometryCollection
3330 OGRPolygon *getGeometryRef(int i)
3331 {
3332 return OGRGeometryCollection::getGeometryRef(i)->toPolygon();
3333 }
3334
3336 const OGRPolygon *getGeometryRef(int i) const
3337 {
3338 return OGRGeometryCollection::getGeometryRef(i)->toPolygon();
3339 }
3340
3341 // Non-standard (OGRGeometry).
3342 virtual const char *getGeometryName() const override;
3343 virtual OGRwkbGeometryType getGeometryType() const override;
3344 virtual OGRMultiPolygon *clone() const override;
3345
3346#ifndef DOXYGEN_XML
3347 using OGRGeometry::exportToWkt;
3348#endif
3349
3350 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3351 size_t &nBytesConsumedOut) override;
3352
3357 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3358 OGRErr *err = nullptr) const override;
3359
3360 // Non standard
3361 virtual OGRBoolean
3362 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3363
3365 inline OGRGeometryCollection *toUpperClass()
3366 {
3367 return this;
3368 }
3369
3371 inline const OGRGeometryCollection *toUpperClass() const
3372 {
3373 return this;
3374 }
3375
3376 virtual void accept(IOGRGeometryVisitor *visitor) override
3377 {
3378 visitor->visit(this);
3379 }
3380
3381 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3382 {
3383 visitor->visit(this);
3384 }
3385
3386 static OGRMultiSurface *CastToMultiSurface(OGRMultiPolygon *poMP);
3387
3388 OGR_ALLOW_CAST_TO_THIS(MultiPolygon)
3389 OGR_ALLOW_UPCAST_TO(MultiSurface)
3390};
3391
3393
3394 inline const OGRMultiPolygon::ChildType *const *
3395 begin(const OGRMultiPolygon *poGeom)
3396{
3397 return poGeom->begin();
3398}
3399
3401 inline const OGRMultiPolygon::ChildType *const *
3402 end(const OGRMultiPolygon *poGeom)
3403{
3404 return poGeom->end();
3405}
3406
3408 inline OGRMultiPolygon::ChildType **begin(OGRMultiPolygon *poGeom)
3409{
3410 return poGeom->begin();
3411}
3412
3414 inline OGRMultiPolygon::ChildType **end(OGRMultiPolygon *poGeom)
3415{
3416 return poGeom->end();
3417}
3418
3420
3421/************************************************************************/
3422/* OGRPolyhedralSurface */
3423/************************************************************************/
3424
3431 class CPL_DLL OGRPolyhedralSurface : public OGRSurface
3432{
3433 protected:
3435 friend class OGRTriangulatedSurface;
3436 OGRMultiPolygon oMP{};
3437 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
3438 virtual OGRSurfaceCasterToCurvePolygon
3439 GetCasterToCurvePolygon() const override;
3440 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
3441 virtual const char *getSubGeometryName() const;
3442 virtual OGRwkbGeometryType getSubGeometryType() const;
3443 std::string exportToWktInternal(const OGRWktOptions &opts,
3444 OGRErr *err) const;
3445
3446 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3447 GetCasterToMultiPolygon() const;
3448 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3450
3451 public:
3453 OGRPolyhedralSurface() = default;
3454
3455 OGRPolyhedralSurface(const OGRPolyhedralSurface &poGeom);
3456
3457 OGRPolyhedralSurface &operator=(const OGRPolyhedralSurface &other);
3458
3460 typedef OGRPolygon ChildType;
3461
3465 ChildType **begin()
3466 {
3467 return oMP.begin();
3468 }
3469
3471 ChildType **end()
3472 {
3473 return oMP.end();
3474 }
3475
3479 const ChildType *const *begin() const
3480 {
3481 return oMP.begin();
3482 }
3483
3485 const ChildType *const *end() const
3486 {
3487 return oMP.end();
3488 }
3489
3490 // IWks Interface.
3491 virtual size_t WkbSize() const override;
3492 virtual const char *getGeometryName() const override;
3493 virtual OGRwkbGeometryType getGeometryType() const override;
3494 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3495 size_t &nBytesConsumedOut) override;
3496 OGRErr exportToWkb(unsigned char *,
3497 const OGRwkbExportOptions * = nullptr) const override;
3498
3499#ifndef DOXYGEN_XML
3500 using OGRGeometry::importFromWkt;
3501#endif
3502
3503 OGRErr importFromWkt(const char **) override;
3504
3505#ifndef DOXYGEN_XML
3506 using OGRGeometry::exportToWkt;
3507#endif
3508
3513 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3514 OGRErr *err = nullptr) const override;
3515
3516 // IGeometry methods.
3517 virtual int getDimension() const override;
3518
3519 virtual void empty() override;
3520
3521 virtual OGRPolyhedralSurface *clone() const override;
3522 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
3523 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3524
3525 virtual void flattenTo2D() override;
3526 virtual OGRErr transform(OGRCoordinateTransformation *) override;
3527 virtual OGRBoolean Equals(const OGRGeometry *) const override;
3528 virtual double get_Area() const override;
3529 virtual double get_GeodesicArea(
3530 const OGRSpatialReference *poSRSOverride = nullptr) const override;
3531 virtual double get_Length() const override;
3532 virtual double get_GeodesicLength(
3533 const OGRSpatialReference *poSRSOverride = nullptr) const override;
3534
3535 virtual OGRErr PointOnSurface(OGRPoint *) const override;
3536
3537 static OGRMultiPolygon *CastToMultiPolygon(OGRPolyhedralSurface *poPS);
3538 virtual OGRBoolean
3539 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3540 virtual OGRErr addGeometry(const OGRGeometry *);
3541 OGRErr addGeometryDirectly(OGRGeometry *poNewGeom);
3542 OGRErr addGeometry(std::unique_ptr<OGRGeometry> poNewGeom);
3543
3544 int getNumGeometries() const;
3545 OGRPolygon *getGeometryRef(int i);
3546 const OGRPolygon *getGeometryRef(int i) const;
3547
3548 virtual OGRBoolean IsEmpty() const override;
3549 virtual bool setCoordinateDimension(int nDimension) override;
3550 virtual bool set3D(OGRBoolean bIs3D) override;
3551 virtual bool setMeasured(OGRBoolean bIsMeasured) override;
3552 virtual void swapXY() override;
3553 OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3554
3555 bool hasEmptyParts() const override;
3556 void removeEmptyParts() override;
3557
3558 virtual void accept(IOGRGeometryVisitor *visitor) override
3559 {
3560 visitor->visit(this);
3561 }
3562
3563 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3564 {
3565 visitor->visit(this);
3566 }
3567
3568 virtual void
3569 assignSpatialReference(const OGRSpatialReference *poSR) override;
3570
3571 OGR_ALLOW_CAST_TO_THIS(PolyhedralSurface)
3572 OGR_ALLOW_UPCAST_TO(Surface)
3573};
3574
3576
3577 inline const OGRPolyhedralSurface::ChildType *const *
3578 begin(const OGRPolyhedralSurface *poGeom)
3579{
3580 return poGeom->begin();
3581}
3582
3584 inline const OGRPolyhedralSurface::ChildType *const *
3585 end(const OGRPolyhedralSurface *poGeom)
3586{
3587 return poGeom->end();
3588}
3589
3591 inline OGRPolyhedralSurface::ChildType **begin(OGRPolyhedralSurface *poGeom)
3592{
3593 return poGeom->begin();
3594}
3595
3597 inline OGRPolyhedralSurface::ChildType **end(OGRPolyhedralSurface *poGeom)
3598{
3599 return poGeom->end();
3600}
3601
3603
3604/************************************************************************/
3605/* OGRTriangulatedSurface */
3606/************************************************************************/
3607
3614 class CPL_DLL OGRTriangulatedSurface : public OGRPolyhedralSurface
3615{
3616 protected:
3618 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3619 virtual const char *getSubGeometryName() const override;
3620 virtual OGRwkbGeometryType getSubGeometryType() const override;
3621
3622 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3623 GetCasterToMultiPolygon() const override;
3624 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3626
3627 public:
3629 OGRTriangulatedSurface() = default;
3630
3631 OGRTriangulatedSurface(const OGRTriangulatedSurface &other);
3632
3634 typedef OGRTriangle ChildType;
3635
3639 ChildType **begin()
3640 {
3641 return reinterpret_cast<ChildType **>(oMP.begin());
3642 }
3643
3645 ChildType **end()
3646 {
3647 return reinterpret_cast<ChildType **>(oMP.end());
3648 }
3649
3653 const ChildType *const *begin() const
3654 {
3655 return reinterpret_cast<const ChildType *const *>(oMP.begin());
3656 }
3657
3659 const ChildType *const *end() const
3660 {
3661 return reinterpret_cast<const ChildType *const *>(oMP.end());
3662 }
3663
3664 OGRTriangulatedSurface &operator=(const OGRTriangulatedSurface &other);
3665 virtual const char *getGeometryName() const override;
3666 virtual OGRwkbGeometryType getGeometryType() const override;
3667 virtual OGRTriangulatedSurface *clone() const override;
3668
3670 OGRTriangle *getGeometryRef(int i)
3671 {
3672 return OGRPolyhedralSurface::getGeometryRef(i)->toTriangle();
3673 }
3674
3676 const OGRTriangle *getGeometryRef(int i) const
3677 {
3678 return OGRPolyhedralSurface::getGeometryRef(i)->toTriangle();
3679 }
3680
3681 // IWks Interface.
3682 virtual OGRErr addGeometry(const OGRGeometry *) override;
3683
3684#ifndef DOXYGEN_XML
3685 using OGRPolyhedralSurface::addGeometry;
3686#endif
3687
3689 inline OGRPolyhedralSurface *toUpperClass()
3690 {
3691 return this;
3692 }
3693
3695 inline const OGRPolyhedralSurface *toUpperClass() const
3696 {
3697 return this;
3698 }
3699
3700 virtual void accept(IOGRGeometryVisitor *visitor) override
3701 {
3702 visitor->visit(this);
3703 }
3704
3705 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3706 {
3707 visitor->visit(this);
3708 }
3709
3710 static OGRPolyhedralSurface *
3711 CastToPolyhedralSurface(OGRTriangulatedSurface *poTS);
3712
3713 OGR_ALLOW_CAST_TO_THIS(TriangulatedSurface)
3714 OGR_ALLOW_UPCAST_TO(PolyhedralSurface)
3715};
3716
3718
3719 inline const OGRTriangulatedSurface::ChildType *const *
3720 begin(const OGRTriangulatedSurface *poGeom)
3721{
3722 return poGeom->begin();
3723}
3724
3726 inline const OGRTriangulatedSurface::ChildType *const *
3727 end(const OGRTriangulatedSurface *poGeom)
3728{
3729 return poGeom->end();
3730}
3731
3733 inline OGRTriangulatedSurface::ChildType **begin(OGRTriangulatedSurface *poGeom)
3734{
3735 return poGeom->begin();
3736}
3737
3739 inline OGRTriangulatedSurface::ChildType **end(OGRTriangulatedSurface *poGeom)
3740{
3741 return poGeom->end();
3742}
3743
3745
3746/************************************************************************/
3747/* OGRMultiPoint */
3748/************************************************************************/
3749
3754 class CPL_DLL OGRMultiPoint : public OGRGeometryCollection
3755{
3756 private:
3757 OGRErr importFromWkt_Bracketed(const char **, int bHasM, int bHasZ);
3758
3759 protected:
3760 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3761
3762 public:
3764 OGRMultiPoint() = default;
3765
3766 OGRMultiPoint(const OGRMultiPoint &other);
3767
3768 OGRMultiPoint &operator=(const OGRMultiPoint &other);
3769
3771 typedef OGRPoint ChildType;
3772
3776 ChildType **begin()
3777 {
3778 return reinterpret_cast<ChildType **>(papoGeoms);
3779 }
3780
3782 ChildType **end()
3783 {
3784 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3785 }
3786
3790 const ChildType *const *begin() const
3791 {
3792 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3793 }
3794
3796 const ChildType *const *end() const
3797 {
3798 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3799 nGeomCount);
3800 }
3801
3802 // IGeometryCollection
3804 OGRPoint *getGeometryRef(int i)
3805 {
3806 return OGRGeometryCollection::getGeometryRef(i)->toPoint();
3807 }
3808
3810 const OGRPoint *getGeometryRef(int i) const
3811 {
3812 return OGRGeometryCollection::getGeometryRef(i)->toPoint();
3813 }
3814
3815 // Non-standard (OGRGeometry).
3816 virtual const char *getGeometryName() const override;
3817 virtual OGRwkbGeometryType getGeometryType() const override;
3818 virtual OGRMultiPoint *clone() const override;
3819
3820#ifndef DOXYGEN_XML
3821 using OGRGeometry::importFromWkt;
3822#endif
3823
3824 OGRErr importFromWkt(const char **) override;
3825
3826#ifndef DOXYGEN_XML
3827 using OGRGeometry::exportToWkt;
3828#endif
3829
3834 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3835 OGRErr *err = nullptr) const override;
3836
3837 // IGeometry methods.
3838 virtual int getDimension() const override;
3839
3841 inline OGRGeometryCollection *toUpperClass()
3842 {
3843 return this;
3844 }
3845
3847 inline const OGRGeometryCollection *toUpperClass() const
3848 {
3849 return this;
3850 }
3851
3852 virtual void accept(IOGRGeometryVisitor *visitor) override
3853 {
3854 visitor->visit(this);
3855 }
3856
3857 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3858 {
3859 visitor->visit(this);
3860 }
3861
3862 // Non-standard.
3863 virtual OGRBoolean
3864 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3865
3866 OGR_ALLOW_CAST_TO_THIS(MultiPoint)
3867 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3868 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3869 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3870 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3871 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3872};
3873
3875
3876 inline const OGRMultiPoint::ChildType *const *begin(const OGRMultiPoint *poGeom)
3877{
3878 return poGeom->begin();
3879}
3880
3882 inline const OGRMultiPoint::ChildType *const *end(const OGRMultiPoint *poGeom)
3883{
3884 return poGeom->end();
3885}
3886
3888 inline OGRMultiPoint::ChildType **begin(OGRMultiPoint *poGeom)
3889{
3890 return poGeom->begin();
3891}
3892
3894 inline OGRMultiPoint::ChildType **end(OGRMultiPoint *poGeom)
3895{
3896 return poGeom->end();
3897}
3898
3900
3901/************************************************************************/
3902/* OGRMultiCurve */
3903/************************************************************************/
3904
3911 class CPL_DLL OGRMultiCurve : public OGRGeometryCollection
3912{
3913 protected:
3915 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
3916 OGRCurve *poCurve);
3918 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3919
3920 public:
3922 OGRMultiCurve() = default;
3923
3924 OGRMultiCurve(const OGRMultiCurve &other);
3925
3926 OGRMultiCurve &operator=(const OGRMultiCurve &other);
3927
3929 typedef OGRCurve ChildType;
3930
3934 ChildType **begin()
3935 {
3936 return reinterpret_cast<ChildType **>(papoGeoms);
3937 }
3938
3940 ChildType **end()
3941 {
3942 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3943 }
3944
3948 const ChildType *const *begin() const
3949 {
3950 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3951 }
3952
3954 const ChildType *const *end() const
3955 {
3956 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3957 nGeomCount);
3958 }
3959
3960 // IGeometryCollection
3962 OGRCurve *getGeometryRef(int i)
3963 {
3964 return OGRGeometryCollection::getGeometryRef(i)->toCurve();
3965 }
3966
3968 const OGRCurve *getGeometryRef(int i) const
3969 {
3970 return OGRGeometryCollection::getGeometryRef(i)->toCurve();
3971 }
3972
3973 // Non standard (OGRGeometry).
3974 virtual const char *getGeometryName() const override;
3975 virtual OGRwkbGeometryType getGeometryType() const override;
3976 virtual OGRMultiCurve *clone() const override;
3977
3978#ifndef DOXYGEN_XML
3979 using OGRGeometry::importFromWkt;
3980#endif
3981
3982 OGRErr importFromWkt(const char **) override;
3983
3984#ifndef DOXYGEN_XML
3985 using OGRGeometry::exportToWkt;
3986#endif
3987
3992 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3993 OGRErr *err = nullptr) const override;
3994
3995 // IGeometry methods.
3996 virtual int getDimension() const override;
3997
3998 // Non-standard.
3999 virtual OGRBoolean
4000 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
4001
4003 inline OGRGeometryCollection *toUpperClass()
4004 {
4005 return this;
4006 }
4007
4009 inline const OGRGeometryCollection *toUpperClass() const
4010 {
4011 return this;
4012 }
4013
4014 virtual void accept(IOGRGeometryVisitor *visitor) override
4015 {
4016 visitor->visit(this);
4017 }
4018
4019 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
4020 {
4021 visitor->visit(this);
4022 }
4023
4024 static OGRMultiLineString *CastToMultiLineString(OGRMultiCurve *poMC);
4025
4026 OGR_ALLOW_CAST_TO_THIS(MultiCurve)
4027 OGR_ALLOW_UPCAST_TO(GeometryCollection)
4028 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
4029 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
4030 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
4031};
4032
4034
4035 inline const OGRMultiCurve::ChildType *const *begin(const OGRMultiCurve *poGeom)
4036{
4037 return poGeom->begin();
4038}
4039
4041 inline const OGRMultiCurve::ChildType *const *end(const OGRMultiCurve *poGeom)
4042{
4043 return poGeom->end();
4044}
4045
4047 inline OGRMultiCurve::ChildType **begin(OGRMultiCurve *poGeom)
4048{
4049 return poGeom->begin();
4050}
4051
4053 inline OGRMultiCurve::ChildType **end(OGRMultiCurve *poGeom)
4054{
4055 return poGeom->end();
4056}
4057
4059
4060/************************************************************************/
4061/* OGRMultiLineString */
4062/************************************************************************/
4063
4068 class CPL_DLL OGRMultiLineString : public OGRMultiCurve
4069{
4070 protected:
4071 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
4072
4073 public:
4075 OGRMultiLineString() = default;
4076
4077 OGRMultiLineString(const OGRMultiLineString &other);
4078
4079 OGRMultiLineString &operator=(const OGRMultiLineString &other);
4080
4082 typedef OGRLineString ChildType;
4083
4087 ChildType **begin()
4088 {
4089 return reinterpret_cast<ChildType **>(papoGeoms);
4090 }
4091
4093 ChildType **end()
4094 {
4095 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
4096 }
4097
4101 const ChildType *const *begin() const
4102 {
4103 return reinterpret_cast<const ChildType *const *>(papoGeoms);
4104 }
4105
4107 const ChildType *const *end() const
4108 {
4109 return reinterpret_cast<const ChildType *const *>(papoGeoms +
4110 nGeomCount);
4111 }
4112
4113 // IGeometryCollection
4115 OGRLineString *getGeometryRef(int i)
4116 {
4117 return OGRGeometryCollection::getGeometryRef(i)->toLineString();
4118 }
4119
4121 const OGRLineString *getGeometryRef(int i) const
4122 {
4123 return OGRGeometryCollection::getGeometryRef(i)->toLineString();
4124 }
4125
4126 // Non standard (OGRGeometry).
4127 virtual const char *getGeometryName() const override;
4128 virtual OGRwkbGeometryType getGeometryType() const override;
4129 virtual OGRMultiLineString *clone() const override;
4130
4131#ifndef DOXYGEN_XML
4132 using OGRGeometry::exportToWkt;
4133#endif
4134
4135 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
4136 size_t &nBytesConsumedOut) override;
4137
4142 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
4143 OGRErr *err = nullptr) const override;
4144
4145 // Non standard
4146 virtual OGRBoolean
4147 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
4148
4150 inline OGRGeometryCollection *toUpperClass()
4151 {
4152 return this;
4153 }
4154
4156 inline const OGRGeometryCollection *toUpperClass() const
4157 {
4158 return this;
4159 }
4160
4161 virtual void accept(IOGRGeometryVisitor *visitor) override
4162 {
4163 visitor->visit(this);
4164 }
4165
4166 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
4167 {
4168 visitor->visit(this);
4169 }
4170
4171 static OGRMultiCurve *CastToMultiCurve(OGRMultiLineString *poMLS);
4172
4173 OGR_ALLOW_CAST_TO_THIS(MultiLineString)
4174 OGR_ALLOW_UPCAST_TO(MultiCurve)
4175 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
4176 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
4177 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
4178};
4179
4181
4182 inline const OGRMultiLineString::ChildType *const *
4183 begin(const OGRMultiLineString *poGeom)
4184{
4185 return poGeom->begin();
4186}
4187
4189 inline const OGRMultiLineString::ChildType *const *
4190 end(const OGRMultiLineString *poGeom)
4191{
4192 return poGeom->end();
4193}
4194
4196 inline OGRMultiLineString::ChildType **begin(OGRMultiLineString *poGeom)
4197{
4198 return poGeom->begin();
4199}
4200
4202 inline OGRMultiLineString::ChildType **end(OGRMultiLineString *poGeom)
4203{
4204 return poGeom->end();
4205}
4206
4208
4209/************************************************************************/
4210/* OGRGeometryFactory */
4211/************************************************************************/
4212
4217 class CPL_DLL OGRGeometryFactory
4218{
4219 static OGRErr createFromFgfInternal(const unsigned char *pabyData,
4220 OGRSpatialReference *poSR,
4221 OGRGeometry **ppoReturn, int nBytes,
4222 int *pnBytesConsumed, int nRecLevel);
4223
4224 public:
4225 static OGRErr createFromWkb(const void *, const OGRSpatialReference *,
4226 OGRGeometry **,
4227 size_t = static_cast<size_t>(-1),
4228 OGRwkbVariant = wkbVariantOldOgc);
4229 static OGRErr createFromWkb(const void *pabyData,
4230 const OGRSpatialReference *, OGRGeometry **,
4231 size_t nSize, OGRwkbVariant eVariant,
4232 size_t &nBytesConsumedOut);
4233 static OGRErr createFromWkt(const char *, const OGRSpatialReference *,
4234 OGRGeometry **);
4235 static OGRErr createFromWkt(const char **, const OGRSpatialReference *,
4236 OGRGeometry **);
4237
4241 static OGRErr createFromWkt(char **ppszInput,
4242 const OGRSpatialReference *poSRS,
4243 OGRGeometry **ppoGeom)
4244 CPL_WARN_DEPRECATED("Use createFromWkt(const char**, ...) instead")
4245 {
4246 return createFromWkt(const_cast<const char **>(ppszInput), poSRS,
4247 ppoGeom);
4248 }
4249
4250 static OGRErr createFromFgf(const void *, OGRSpatialReference *,
4251 OGRGeometry **, int = -1, int * = nullptr);
4252 static OGRGeometry *createFromGML(const char *);
4253 static OGRGeometry *createFromGEOS(GEOSContextHandle_t hGEOSCtxt, GEOSGeom);
4254 static OGRGeometry *createFromGeoJson(const char *, int = -1);
4255 static OGRGeometry *createFromGeoJson(const CPLJSONObject &oJSONObject);
4256
4257 static void destroyGeometry(OGRGeometry *);
4258 static OGRGeometry *createGeometry(OGRwkbGeometryType);
4259
4260 static OGRGeometry *forceToPolygon(OGRGeometry *);
4261 static OGRGeometry *forceToLineString(OGRGeometry *,
4262 bool bOnlyInOrder = true);
4263 static OGRGeometry *forceToMultiPolygon(OGRGeometry *);
4264 static OGRGeometry *forceToMultiPoint(OGRGeometry *);
4265 static OGRGeometry *forceToMultiLineString(OGRGeometry *);
4266
4267 static OGRGeometry *forceTo(OGRGeometry *poGeom,
4268 OGRwkbGeometryType eTargetType,
4269 const char *const *papszOptions = nullptr);
4270
4271 static OGRGeometry *removeLowerDimensionSubGeoms(const OGRGeometry *poGeom);
4272
4273 static OGRGeometry *organizePolygons(OGRGeometry **papoPolygons,
4274 int nPolygonCount,
4275 int *pbResultValidGeometry,
4276 const char **papszOptions = nullptr);
4277 static bool haveGEOS();
4278
4280 class CPL_DLL TransformWithOptionsCache
4281 {
4282 friend class OGRGeometryFactory;
4283 struct Private;
4284 std::unique_ptr<Private> d;
4285
4286 public:
4287 TransformWithOptionsCache();
4288 ~TransformWithOptionsCache();
4289 };
4290
4292 static bool isTransformWithOptionsRegularTransform(
4293 const OGRSpatialReference *poSourceCRS,
4294 const OGRSpatialReference *poTargetCRS, CSLConstList papszOptions);
4296
4297 static OGRGeometry *transformWithOptions(
4298 const OGRGeometry *poSrcGeom, OGRCoordinateTransformation *poCT,
4299 char **papszOptions,
4300 const TransformWithOptionsCache &cache = TransformWithOptionsCache());
4301
4302 static OGRGeometry *
4303 approximateArcAngles(double dfX, double dfY, double dfZ,
4304 double dfPrimaryRadius, double dfSecondaryAxis,
4305 double dfRotation, double dfStartAngle,
4306 double dfEndAngle, double dfMaxAngleStepSizeDegrees,
4307 const bool bUseMaxGap = false);
4308
4309 static int GetCurveParameters(double x0, double y0, double x1, double y1,
4310 double x2, double y2, double &R, double &cx,
4311 double &cy, double &alpha0, double &alpha1,
4312 double &alpha2);
4313 static OGRLineString *
4314 curveToLineString(double x0, double y0, double z0, double x1, double y1,
4315 double z1, double x2, double y2, double z2, int bHasZ,
4316 double dfMaxAngleStepSizeDegrees,
4317 const char *const *papszOptions = nullptr);
4318 static OGRCurve *
4319 curveFromLineString(const OGRLineString *poLS,
4320 const char *const *papszOptions = nullptr);
4321};
4322
4323 OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType(const char *pszGeomType);
4324 const char CPL_DLL *OGRToOGCGeomType(OGRwkbGeometryType eGeomType,
4325 bool bCamelCase = false,
4326 bool bAddZM = false,
4327 bool bSpaceBeforeZM = false);
4328
4330 typedef struct _OGRPreparedGeometry OGRPreparedGeometry;
4331
4332 struct CPL_DLL OGRPreparedGeometryUniquePtrDeleter
4333{
4334 void operator()(OGRPreparedGeometry *) const;
4335};
4336
4338
4342 typedef std::unique_ptr<OGRPreparedGeometry,
4343 OGRPreparedGeometryUniquePtrDeleter>
4344 OGRPreparedGeometryUniquePtr;
4345
4346#endif /* ndef OGR_GEOMETRY_H_INCLUDED */
CPLJSONObject
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition: cpl_json.h:41
IOGRConstGeometryVisitor
OGRGeometry visitor interface.
Definition: ogr_geometry.h:226
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRCurvePolygon *)=0
Visit OGRCurvePolygon.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRPolyhedralSurface *)=0
Visit OGRPolyhedralSurface.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRCompoundCurve *)=0
Visit OGRCompoundCurve.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRMultiLineString *)=0
Visit OGRMultiLineString.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRTriangulatedSurface *)=0
Visit OGRTriangulatedSurface.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRPolygon *)=0
Visit OGRPolygon.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRMultiPolygon *)=0
Visit OGRMultiPolygon.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRTriangle *)=0
Visit OGRTriangle.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRLineString *)=0
Visit OGRLineString.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRMultiPoint *)=0
Visit OGRMultiPoint.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRMultiCurve *)=0
Visit OGRMultiCurve.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRGeometryCollection *)=0
Visit OGRGeometryCollection.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRPoint *)=0
Visit OGRPoint.
IOGRConstGeometryVisitor::~IOGRConstGeometryVisitor
virtual ~IOGRConstGeometryVisitor()=default
Destructor/.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRMultiSurface *)=0
Visit OGRMultiSurface.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRLinearRing *)=0
Visit OGRLinearRing.
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRCircularString *)=0
Visit OGRCircularString.
IOGRGeometryVisitor
OGRGeometry visitor interface.
Definition: ogr_geometry.h:150
IOGRGeometryVisitor::visit
virtual void visit(OGRMultiSurface *)=0
Visit OGRMultiSurface.
IOGRGeometryVisitor::visit
virtual void visit(OGRLinearRing *)=0
Visit OGRLinearRing.
IOGRGeometryVisitor::visit
virtual void visit(OGRTriangle *)=0
Visit OGRTriangle.
IOGRGeometryVisitor::visit
virtual void visit(OGRCircularString *)=0
Visit OGRCircularString.
IOGRGeometryVisitor::visit
virtual void visit(OGRPolygon *)=0
Visit OGRPolygon.
IOGRGeometryVisitor::visit
virtual void visit(OGRLineString *)=0
Visit OGRLineString.
IOGRGeometryVisitor::visit
virtual void visit(OGRCompoundCurve *)=0
Visit OGRCompoundCurve.
IOGRGeometryVisitor::visit
virtual void visit(OGRTriangulatedSurface *)=0
Visit OGRTriangulatedSurface.
IOGRGeometryVisitor::visit
virtual void visit(OGRPoint *)=0
Visit OGRPoint.
IOGRGeometryVisitor::visit
virtual void visit(OGRCurvePolygon *)=0
Visit OGRCurvePolygon.
IOGRGeometryVisitor::visit
virtual void visit(OGRGeometryCollection *)=0
Visit OGRGeometryCollection.
IOGRGeometryVisitor::visit
virtual void visit(OGRPolyhedralSurface *)=0
Visit OGRPolyhedralSurface.
IOGRGeometryVisitor::visit
virtual void visit(OGRMultiPolygon *)=0
Visit OGRMultiPolygon.
IOGRGeometryVisitor::~IOGRGeometryVisitor
virtual ~IOGRGeometryVisitor()=default
Destructor/.
IOGRGeometryVisitor::visit
virtual void visit(OGRMultiLineString *)=0
Visit OGRMultiLineString.
IOGRGeometryVisitor::visit
virtual void visit(OGRMultiPoint *)=0
Visit OGRMultiPoint.
IOGRGeometryVisitor::visit
virtual void visit(OGRMultiCurve *)=0
Visit OGRMultiCurve.
OGRCircularString
Concrete representation of a circular string, that is to say a curve made of one or several arc circl...
Definition: ogr_geometry.h:1948
OGRCircularString::OGRCircularString
OGRCircularString()=default
Create an empty circular string.
OGRCircularString::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:2034
OGRCircularString::toUpperClass
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:2029
OGRCircularString::OGRCircularString
OGRCircularString(const OGRCircularString &other)
Copy constructor.
OGRCircularString::toUpperClass
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:2023
OGRCircularString::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:2039
OGRCompoundCurve
Utility class to store a collection of curves.
Definition: ogr_geometry.h:2178
OGRCompoundCurve::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:2340
OGRCompoundCurve::end
const ChildType *const * end() const
Return end of curve iterator.
Definition: ogr_geometry.h:2239
OGRCompoundCurve::OGRCompoundCurve
OGRCompoundCurve()=default
Create an empty compound curve.
OGRCompoundCurve::begin
const ChildType *const * begin() const
Return begin of curve iterator.
Definition: ogr_geometry.h:2233
OGRCompoundCurve::OGRCompoundCurve
OGRCompoundCurve(const OGRCompoundCurve &other)
Copy constructor.
OGRCompoundCurve::ChildType
OGRCurve ChildType
Type of child elements.
Definition: ogr_geometry.h:2214
OGRCompoundCurve::end
ChildType ** end()
Return end of curve iterator.
Definition: ogr_geometry.h:2225
OGRCompoundCurve::begin
ChildType ** begin()
Return begin of curve iterator.
Definition: ogr_geometry.h:2219
OGRCompoundCurve::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:2335
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:773
OGRCurvePolygon
Concrete class representing curve polygons.
Definition: ogr_geometry.h:2444
OGRCurvePolygon::stealExteriorRingCurve
OGRCurve * stealExteriorRingCurve()
"Steal" reference to external ring.
Definition: ogrcurvepolygon.cpp:269
OGRCurvePolygon::get_GeodesicLength
virtual double get_GeodesicLength(const OGRSpatialReference *poSRSOverride=nullptr) const override
Get the length of the surface, where curve edges are geodesic lines on the underlying ellipsoid of th...
Definition: ogrcurvepolygon.cpp:693
OGRCurvePolygon::assignSpatialReference
virtual void assignSpatialReference(const OGRSpatialReference *poSR) override
Assign spatial reference to this object.
Definition: ogrcurvepolygon.cpp:783
OGRCurvePolygon::getExteriorRingCurve
OGRCurve * getExteriorRingCurve()
Fetch reference to external polygon ring.
Definition: ogrcurvepolygon.cpp:163
OGRCurvePolygon::setMeasured
virtual bool setMeasured(OGRBoolean bIsMeasured) override
Add or remove the M coordinate dimension.
Definition: ogrcurvepolygon.cpp:774
OGRCurvePolygon::addRing
virtual OGRErr addRing(const OGRCurve *)
Add a ring to a polygon.
Definition: ogrcurvepolygon.cpp:324
OGRCurvePolygon::getInteriorRingCurve
OGRCurve * getInteriorRingCurve(int)
Fetch reference to indicated internal ring.
Definition: ogrcurvepolygon.cpp:228
OGRCurvePolygon::OGRCurvePolygon
OGRCurvePolygon()=default
Create an empty curve polygon.
OGRCurvePolygon::Contains
virtual OGRBoolean Contains(const OGRGeometry *) const override
Test for containment.
Definition: ogrcurvepolygon.cpp:857
OGRCurvePolygon::flattenTo2D
virtual void flattenTo2D() override
Convert geometry to strictly 2D.
Definition: ogrcurvepolygon.cpp:127
OGRCurvePolygon::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:2598
OGRCurvePolygon::empty
virtual void empty() override
Clear geometry information.
Definition: ogrcurvepolygon.cpp:90
OGRCurvePolygon::getEnvelope
virtual void getEnvelope(OGREnvelope *psEnvelope) const override
Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
Definition: ogrcurvepolygon.cpp:628
OGRCurvePolygon::CastToPolygon
static OGRPolygon * CastToPolygon(OGRCurvePolygon *poCP)
Convert to polygon.
Definition: ogrcurvepolygon.cpp:904
OGRCurvePolygon::get_Area
virtual double get_Area() const override
Get the area of the surface object.
Definition: ogrcurvepolygon.cpp:716
OGRCurvePolygon::set3D
virtual bool set3D(OGRBoolean bIs3D) override
Add or remove the Z coordinate dimension.
Definition: ogrcurvepolygon.cpp:769
OGRCurvePolygon::transform
virtual OGRErr transform(OGRCoordinateTransformation *poCT) override
Apply arbitrary coordinate transformation to geometry.
Definition: ogrcurvepolygon.cpp:667
OGRCurvePolygon::getDimension
virtual int getDimension() const override
Get the dimension of this object.
Definition: ogrcurvepolygon.cpp:117
OGRCurvePolygon::Intersects
virtual OGRBoolean Intersects(const OGRGeometry *) const override
Do these features intersect?
Definition: ogrcurvepolygon.cpp:873
OGRCurvePolygon::get_GeodesicArea
virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride=nullptr) const override
Get the area of the surface object, considered as a surface on the underlying ellipsoid of the SRS at...
Definition: ogrcurvepolygon.cpp:736
OGRCurvePolygon::swapXY
virtual void swapXY() override
Swap x and y coordinates.
Definition: ogrcurvepolygon.cpp:816
OGRCurvePolygon::Equals
virtual OGRBoolean Equals(const OGRGeometry *) const override
Returns TRUE if two geometries are equivalent.
Definition: ogrcurvepolygon.cpp:648
OGRCurvePolygon::ChildType
OGRCurve ChildType
Type of child elements.
Definition: ogr_geometry.h:2483
OGRCurvePolygon::IsEmpty
virtual OGRBoolean IsEmpty() const override
Returns TRUE (non-zero) if the object has no points.
Definition: ogrcurvepolygon.cpp:792
OGRCurvePolygon::hasEmptyParts
bool hasEmptyParts() const override
Returns whether a geometry has empty parts/rings.
Definition: ogrcurvepolygon.cpp:963
OGRCurvePolygon::setCoordinateDimension
virtual bool setCoordinateDimension(int nDimension) override
Set the coordinate dimension.
Definition: ogrcurvepolygon.cpp:763
OGRCurvePolygon::end
const ChildType *const * end() const
Return end of curve iterator.
Definition: ogr_geometry.h:2508
OGRCurvePolygon::begin
const ChildType *const * begin() const
Return begin of curve iterator.
Definition: ogr_geometry.h:2502
OGRCurvePolygon::get_Length
virtual double get_Length() const override
Get the length of the surface.
Definition: ogrcurvepolygon.cpp:677
OGRCurvePolygon::begin
ChildType ** begin()
Return begin of curve iterator.
Definition: ogr_geometry.h:2488
OGRCurvePolygon::segmentize
virtual bool segmentize(double dfMaxLength) override
Modify the geometry such it has no segment longer then the given distance.
Definition: ogrcurvepolygon.cpp:801
OGRCurvePolygon::end
ChildType ** end()
Return end of curve iterator.
Definition: ogr_geometry.h:2494
OGRCurvePolygon::getNumInteriorRings
int getNumInteriorRings() const
Fetch the number of internal rings.
Definition: ogrcurvepolygon.cpp:200
OGRCurvePolygon::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:2603
OGRCurvePolygon::removeRing
OGRErr removeRing(int iIndex, bool bDelete=true)
Remove a geometry from the container.
Definition: ogrcurvepolygon.cpp:301
OGRCurvePolygon::OGRCurvePolygon
OGRCurvePolygon(const OGRCurvePolygon &)
Copy constructor.
OGRCurvePolygon::removeEmptyParts
void removeEmptyParts() override
Remove empty parts/rings from this geometry.
Definition: ogrcurvepolygon.cpp:972
OGRCurve
Abstract curve base class for OGRLineString, OGRCircularString and OGRCompoundCurve.
Definition: ogr_geometry.h:1315
OGRCurve::CurveToLine
virtual OGRLineString * CurveToLine(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const =0
Return a linestring from a curve geometry.
OGRCurve::get_Length
virtual double get_Length() const =0
Returns the length of the curve.
OGRCurve::IntersectsPoint
virtual int IntersectsPoint(const OGRPoint *p) const
Returns if a point intersects a (closed) curve.
Definition: ogrcurve.cpp:450
OGRCurve::toSimpleCurve
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition: ogr_geometry.h:1407
OGRCurve::StartPoint
virtual void StartPoint(OGRPoint *) const =0
Return the curve start point.
OGRCurve::EndPoint
virtual void EndPoint(OGRPoint *) const =0
Return the curve end point.
OGRCurve::getNumPoints
virtual int getNumPoints() const =0
Return the number of points of a curve geometry.
OGRCurve::ChildType
OGRPoint ChildType
Type of child elements.
Definition: ogr_geometry.h:1356
OGRCurve::toSimpleCurve
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition: ogr_geometry.h:1399
OGRCurve::ContainsPoint
virtual int ContainsPoint(const OGRPoint *p) const
Returns if a point is contained in a (closed) curve.
Definition: ogrcurve.cpp:430
OGRCurve::Value
virtual void Value(double, OGRPoint *) const =0
Fetch point at given distance along curve.
OGRCurve::getPointIterator
virtual OGRPointIterator * getPointIterator() const =0
Returns a point iterator over the curve.
OGRCurve::get_GeodesicArea
virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride=nullptr) const =0
Get the area of the (closed) curve, considered as a surface on the underlying ellipsoid of the SRS at...
OGRCurve::get_AreaOfCurveSegments
virtual double get_AreaOfCurveSegments() const =0
Get the area of the purely curve portions of a (closed) curve.
OGRCurve::get_Area
virtual double get_Area() const =0
Get the area of the (closed) curve.
OGRCurve::reversePoints
virtual void reversePoints()=0
Reverse point order.
OGRCurve::clone
virtual OGRCurve * clone() const override=0
Make a copy of this object.
OGRCurve::get_GeodesicLength
virtual double get_GeodesicLength(const OGRSpatialReference *poSRSOverride=nullptr) const =0
Get the length of the curve, considered as a geodesic line on the underlying ellipsoid of the SRS att...
OGRDefaultConstGeometryVisitor
OGRGeometry visitor default implementation.
Definition: ogr_geometry.h:273
OGRDefaultConstGeometryVisitor::visit
void visit(const OGRPoint *) override
Visit OGRPoint.
Definition: ogr_geometry.h:277
OGRDefaultGeometryVisitor
OGRGeometry visitor default implementation.
Definition: ogr_geometry.h:197
OGRDefaultGeometryVisitor::visit
void visit(OGRPoint *) override
Visit OGRPoint.
Definition: ogr_geometry.h:201
OGREnvelope3D
Simple container for a bounding region in 3D.
Definition: ogr_core.h:200
OGREnvelope
Simple container for a bounding region (rectangle)
Definition: ogr_core.h:45
OGRGeometryCollection
A collection of 1 or more geometry objects.
Definition: ogr_geometry.h:2915
OGRGeometryCollection::end
ChildType ** end()
Return end of sub-geometry iterator.
Definition: ogr_geometry.h:2957
OGRGeometryCollection::OGRGeometryCollection
OGRGeometryCollection()=default
Create an empty geometry collection.
OGRGeometryCollection::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3057
OGRGeometryCollection::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3062
OGRGeometryCollection::begin
const ChildType *const * begin() const
Return begin of sub-geometry iterator.
Definition: ogr_geometry.h:2965
OGRGeometryCollection::end
const ChildType *const * end() const
Return end of sub-geometry iterator.
Definition: ogr_geometry.h:2971
OGRGeometryCollection::begin
ChildType ** begin()
Return begin of sub-geometry iterator.
Definition: ogr_geometry.h:2951
OGRGeometryCollection::getGeometryRef
OGRGeometry * getGeometryRef(int)
Fetch geometry from container.
Definition: ogrgeometrycollection.cpp:249
OGRGeometryCollection::ChildType
OGRGeometry ChildType
Type of child elements.
Definition: ogr_geometry.h:2946
OGRGeometryFactory::TransformWithOptionsCache
Opaque class used as argument to transformWithOptions()
Definition: ogr_geometry.h:4281
OGRGeometryFactory
Create geometry objects from well known text/binary.
Definition: ogr_geometry.h:4218
OGRGeometryFactory::createFromWkt
static OGRErr createFromWkt(char **ppszInput, const OGRSpatialReference *poSRS, OGRGeometry **ppoGeom)
Deprecated.
Definition: ogr_geometry.h:4241
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:361
OGRGeometry::toSurface
const OGRSurface * toSurface() const
Down-cast to OGRSurface*.
Definition: ogr_geometry.h:801
OGRGeometry::toCurvePolygon
const OGRCurvePolygon * toCurvePolygon() const
Down-cast to OGRCurvePolygon*.
Definition: ogr_geometry.h:859
OGRGeometry::toMultiCurve
const OGRMultiCurve * toMultiCurve() const
Down-cast to OGRMultiCurve*.
Definition: ogr_geometry.h:959
OGRGeometry::getCurveGeometry
virtual OGRGeometry * getCurveGeometry(const char *const *papszOptions=nullptr) const
Return curve version of this geometry.
Definition: ogrgeometry.cpp:3498
OGRGeometry::toPolyhedralSurface
const OGRPolyhedralSurface * toPolyhedralSurface() const
Down-cast to OGRPolyhedralSurface*.
Definition: ogr_geometry.h:999
OGRGeometry::toMultiPoint
const OGRMultiPoint * toMultiPoint() const
Down-cast to OGRMultiPoint*.
Definition: ogr_geometry.h:899
OGRGeometry::empty
virtual void empty()=0
Clear geometry information.
OGRGeometry::toMultiPolygon
const OGRMultiPolygon * toMultiPolygon() const
Down-cast to OGRMultiPolygon*.
Definition: ogr_geometry.h:939
OGRGeometry::Equals
virtual OGRBoolean Equals(const OGRGeometry *) const =0
Returns TRUE if two geometries are equivalent.
OGRGeometry::toPolyhedralSurface
OGRPolyhedralSurface * toPolyhedralSurface()
Down-cast to OGRPolyhedralSurface*.
Definition: ogr_geometry.h:989
OGRGeometry::toMultiSurface
const OGRMultiSurface * toMultiSurface() const
Down-cast to OGRMultiSurface*.
Definition: ogr_geometry.h:979
OGRGeometry::toPoint
OGRPoint * toPoint()
Down-cast to OGRPoint*.
Definition: ogr_geometry.h:654
OGRGeometry::operator!=
bool operator!=(const OGRGeometry &other) const
Returns if two geometries are different.
Definition: ogr_geometry.h:421
OGRGeometry::toTriangle
OGRTriangle * toTriangle()
Down-cast to OGRTriangle*.
Definition: ogr_geometry.h:830
OGRGeometry::toLineString
OGRLineString * toLineString()
Down-cast to OGRLineString*.
Definition: ogr_geometry.h:713
OGRGeometry::toLinearRing
const OGRLinearRing * toLinearRing() const
Down-cast to OGRLinearRing*.
Definition: ogr_geometry.h:741
OGRGeometry::toPoint
const OGRPoint * toPoint() const
Down-cast to OGRPoint*.
Definition: ogr_geometry.h:663
OGRGeometry::toMultiLineString
OGRMultiLineString * toMultiLineString()
Down-cast to OGRMultiLineString*.
Definition: ogr_geometry.h:909
OGRGeometry::toMultiSurface
OGRMultiSurface * toMultiSurface()
Down-cast to OGRMultiSurface*.
Definition: ogr_geometry.h:969
OGRGeometry::FromHandle
static OGRGeometry * FromHandle(OGRGeometryH hGeom)
Convert a OGRGeometryH to a OGRGeometry*.
Definition: ogr_geometry.h:645
OGRGeometry::getGeometryType
virtual OGRwkbGeometryType getGeometryType() const =0
Fetch geometry type.
OGRGeometry::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const =0
Accept a visitor.
OGRGeometry::toGeometryCollection
const OGRGeometryCollection * toGeometryCollection() const
Down-cast to OGRGeometryCollection*.
Definition: ogr_geometry.h:879
OGRGeometry::toMultiLineString
const OGRMultiLineString * toMultiLineString() const
Down-cast to OGRMultiLineString*.
Definition: ogr_geometry.h:919
OGRGeometry::toCircularString
const OGRCircularString * toCircularString() const
Down-cast to OGRCircularString*.
Definition: ogr_geometry.h:761
OGRGeometry::toPolygon
OGRPolygon * toPolygon()
Down-cast to OGRPolygon*.
Definition: ogr_geometry.h:811
OGRGeometry::operator==
bool operator==(const OGRGeometry &other) const
Returns if two geometries are equal.
Definition: ogr_geometry.h:415
OGRGeometry::toLinearRing
OGRLinearRing * toLinearRing()
Down-cast to OGRLinearRing*.
Definition: ogr_geometry.h:732
OGRGeometry::IsMeasured
OGRBoolean IsMeasured() const
Definition: ogr_geometry.h:443
OGRGeometry::accept
virtual void accept(IOGRGeometryVisitor *visitor)=0
Accept a visitor.
OGRGeometry::toMultiCurve
OGRMultiCurve * toMultiCurve()
Down-cast to OGRMultiCurve*.
Definition: ogr_geometry.h:949
OGRGeometry::toCompoundCurve
const OGRCompoundCurve * toCompoundCurve() const
Down-cast to OGRCompoundCurve*.
Definition: ogr_geometry.h:781
OGRGeometry::transform
virtual OGRErr transform(OGRCoordinateTransformation *poCT)=0
Apply arbitrary coordinate transformation to geometry.
OGRGeometry::flattenTo2D
virtual void flattenTo2D()=0
Convert geometry to strictly 2D.
OGRGeometry::getDimension
virtual int getDimension() const =0
Get the dimension of this object.
OGRGeometry::toGeometryCollection
OGRGeometryCollection * toGeometryCollection()
Down-cast to OGRGeometryCollection*.
Definition: ogr_geometry.h:869
OGRGeometry::getGeometryName
virtual const char * getGeometryName() const =0
Fetch WKT name for geometry type.
OGRGeometry::toMultiPolygon
OGRMultiPolygon * toMultiPolygon()
Down-cast to OGRMultiPolygon*.
Definition: ogr_geometry.h:929
OGRGeometry::toPolygon
const OGRPolygon * toPolygon() const
Down-cast to OGRPolygon*.
Definition: ogr_geometry.h:821
OGRGeometry::toCompoundCurve
OGRCompoundCurve * toCompoundCurve()
Down-cast to OGRCompoundCurve*.
Definition: ogr_geometry.h:771
OGRGeometry::importFromWkt
OGRErr importFromWkt(char **ppszInput)
Deprecated.
Definition: ogr_geometry.h:470
OGRGeometry::IsEmpty
virtual OGRBoolean IsEmpty() const =0
Returns TRUE (non-zero) if the object has no points.
OGRGeometry::toLineString
const OGRLineString * toLineString() const
Down-cast to OGRLineString*.
Definition: ogr_geometry.h:723
OGRGeometry::exportToWkt
OGRErr exportToWkt(char **ppszDstText, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known text format.
Definition: ogrgeometry.cpp:1946
OGRGeometry::toCircularString
OGRCircularString * toCircularString()
Down-cast to OGRCircularString*.
Definition: ogr_geometry.h:751
OGRGeometry::toCurve
const OGRCurve * toCurve() const
Down-cast to OGRCurve*.
Definition: ogr_geometry.h:683
OGRGeometry::getLinearGeometry
virtual OGRGeometry * getLinearGeometry(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const
Return, possibly approximate, non-curve version of this geometry.
Definition: ogrgeometry.cpp:3463
OGRGeometry::toCurvePolygon
OGRCurvePolygon * toCurvePolygon()
Down-cast to OGRCurvePolygon*.
Definition: ogr_geometry.h:849
OGRGeometry::toSimpleCurve
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition: ogr_geometry.h:703
OGRGeometry::ToHandle
static OGRGeometryH ToHandle(OGRGeometry *poGeom)
Convert a OGRGeometry* to a OGRGeometryH.
Definition: ogr_geometry.h:637
OGRGeometry::Is3D
OGRBoolean Is3D() const
Definition: ogr_geometry.h:437
OGRGeometry::toMultiPoint
OGRMultiPoint * toMultiPoint()
Down-cast to OGRMultiPoint*.
Definition: ogr_geometry.h:889
OGRGeometry::closeRings
virtual void closeRings()
Force rings to be closed.
Definition: ogrgeometry.cpp:6012
OGRGeometry::toTriangulatedSurface
const OGRTriangulatedSurface * toTriangulatedSurface() const
Down-cast to OGRTriangulatedSurface*.
Definition: ogr_geometry.h:1017
OGRGeometry::toTriangle
const OGRTriangle * toTriangle() const
Down-cast to OGRTriangle*.
Definition: ogr_geometry.h:839
OGRGeometry::importFromWkt
virtual OGRErr importFromWkt(const char **ppszInput)=0
Assign geometry from well known text data.
OGRGeometry::clone
virtual OGRGeometry * clone() const =0
Make a copy of this object.
OGRGeometry::toSurface
OGRSurface * toSurface()
Down-cast to OGRSurface*.
Definition: ogr_geometry.h:791
OGRGeometry::toSimpleCurve
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition: ogr_geometry.h:693
OGRGeometry::toTriangulatedSurface
OGRTriangulatedSurface * toTriangulatedSurface()
Down-cast to OGRTriangulatedSurface*.
Definition: ogr_geometry.h:1008
OGRGeometry::exportToWkt
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const =0
Export a WKT geometry.
OGRGeometry::toCurve
OGRCurve * toCurve()
Down-cast to OGRCurve*.
Definition: ogr_geometry.h:673
OGRIteratedPoint
Definition: ogr_geometry.h:1463
OGRLineString
Concrete representation of a multi-vertex line.
Definition: ogr_geometry.h:1758
OGRLineString::get_GeodesicLength
virtual double get_GeodesicLength(const OGRSpatialReference *poSRSOverride=nullptr) const override
Get the length of the curve, considered as a geodesic line on the underlying ellipsoid of the SRS att...
OGRLineString::toUpperClass
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:1800
OGRLineString::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:1816
OGRLineString::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:1811
OGRLineString::OGRLineString
OGRLineString(const OGRLineString &other)
Copy constructor.
OGRLineString::get_GeodesicArea
virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride=nullptr) const override
Get the area of the (closed) curve, considered as a surface on the underlying ellipsoid of the SRS at...
OGRLineString::isClockwise
virtual int isClockwise() const override
Returns TRUE if the ring has clockwise winding (or less than 2 points)
OGRLineString::get_Area
virtual double get_Area() const override
Get the area of the (closed) curve.
OGRLineString::toUpperClass
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:1806
OGRLineString::OGRLineString
OGRLineString()=default
Create an empty line string.
OGRLinearRing
Concrete representation of a closed ring.
Definition: ogr_geometry.h:1850
OGRLinearRing::OGRLinearRing
OGRLinearRing()=default
Constructor.
OGRLinearRing::toUpperClass
const OGRLineString * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:1912
OGRLinearRing::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:1922
OGRLinearRing::OGRLinearRing
OGRLinearRing(const OGRLinearRing &other)
Copy constructor.
OGRLinearRing::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:1917
OGRMultiCurve
A collection of OGRCurve.
Definition: ogr_geometry.h:3912
OGRMultiCurve::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3948
OGRMultiCurve::OGRMultiCurve
OGRMultiCurve()=default
Create an empty multi curve collection.
OGRMultiCurve::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3954
OGRMultiCurve::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:4019
OGRMultiCurve::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3940
OGRMultiCurve::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:4009
OGRMultiCurve::getGeometryRef
const OGRCurve * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3968
OGRMultiCurve::getGeometryRef
OGRCurve * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3962
OGRMultiCurve::OGRMultiCurve
OGRMultiCurve(const OGRMultiCurve &other)
Copy constructor.
OGRMultiCurve::ChildType
OGRCurve ChildType
Type of child elements.
Definition: ogr_geometry.h:3929
OGRMultiCurve::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3934
OGRMultiCurve::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:4003
OGRMultiCurve::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:4014
OGRMultiLineString
A collection of OGRLineString.
Definition: ogr_geometry.h:4069
OGRMultiLineString::ChildType
OGRLineString ChildType
Type of child elements.
Definition: ogr_geometry.h:4082
OGRMultiLineString::getGeometryRef
OGRLineString * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:4115
OGRMultiLineString::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:4150
OGRMultiLineString::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:4093
OGRMultiLineString::OGRMultiLineString
OGRMultiLineString()=default
Create an empty multi line string collection.
OGRMultiLineString::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:4107
OGRMultiLineString::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:4166
OGRMultiLineString::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:4101
OGRMultiLineString::getGeometryRef
const OGRLineString * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:4121
OGRMultiLineString::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:4161
OGRMultiLineString::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:4087
OGRMultiLineString::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:4156
OGRMultiLineString::OGRMultiLineString
OGRMultiLineString(const OGRMultiLineString &other)
Copy constructor.
OGRMultiPoint
A collection of OGRPoint.
Definition: ogr_geometry.h:3755
OGRMultiPoint::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:3841
OGRMultiPoint::OGRMultiPoint
OGRMultiPoint()=default
Create an empty multi point collection.
OGRMultiPoint::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3852
OGRMultiPoint::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3796
OGRMultiPoint::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3776
OGRMultiPoint::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3857
OGRMultiPoint::OGRMultiPoint
OGRMultiPoint(const OGRMultiPoint &other)
Copy constructor.
OGRMultiPoint::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3790
OGRMultiPoint::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:3847
OGRMultiPoint::ChildType
OGRPoint ChildType
Type of child elements.
Definition: ogr_geometry.h:3771
OGRMultiPoint::getGeometryRef
const OGRPoint * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3810
OGRMultiPoint::getGeometryRef
OGRPoint * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3804
OGRMultiPoint::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3782
OGRMultiPolygon
A collection of non-overlapping OGRPolygon.
Definition: ogr_geometry.h:3274
OGRMultiPolygon::ChildType
OGRPolygon ChildType
Type of child elements.
Definition: ogr_geometry.h:3297
OGRMultiPolygon::OGRMultiPolygon
OGRMultiPolygon(const OGRMultiPolygon &other)
Copy constructor.
OGRMultiPolygon::getGeometryRef
OGRPolygon * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3330
OGRMultiPolygon::OGRMultiPolygon
OGRMultiPolygon()=default
Create an empty multi polygon collection.
OGRMultiPolygon::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3381
OGRMultiPolygon::getGeometryRef
const OGRPolygon * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3336
OGRMultiPolygon::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3322
OGRMultiPolygon::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3308
OGRMultiPolygon::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3376
OGRMultiPolygon::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3302
OGRMultiPolygon::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:3365
OGRMultiPolygon::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3316
OGRMultiPolygon::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:3371
OGRMultiSurface
A collection of non-overlapping OGRSurface.
Definition: ogr_geometry.h:3116
OGRMultiSurface::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3217
OGRMultiSurface::getGeometryRef
const OGRSurface * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3196
OGRMultiSurface::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3134
OGRMultiSurface::ChildType
OGRSurface ChildType
Type of child elements.
Definition: ogr_geometry.h:3129
OGRMultiSurface::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:3212
OGRMultiSurface::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3148
OGRMultiSurface::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3154
OGRMultiSurface::OGRMultiSurface
OGRMultiSurface(const OGRMultiSurface &other)
Copy constructor.
OGRMultiSurface::OGRMultiSurface
OGRMultiSurface()=default
Create an empty multi surface collection.
OGRMultiSurface::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3140
OGRMultiSurface::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3222
OGRMultiSurface::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:3206
OGRMultiSurface::getGeometryRef
OGRSurface * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3190
OGRPointIterator
Interface for a point iterator.
Definition: ogr_geometry.h:1297
OGRPointIterator::getNextPoint
virtual OGRBoolean getNextPoint(OGRPoint *p)=0
Returns the next point followed by the iterator.
OGRPoint
Point class.
Definition: ogr_geometry.h:1135
OGRPoint::getM
double getM() const
Return m.
Definition: ogr_geometry.h:1207
OGRPoint::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:1268
OGRPoint::setX
void setX(double xIn)
Set x.
Definition: ogr_geometry.h:1218
OGRPoint::OGRPoint
OGRPoint(const OGRPoint &other)
Copy constructor.
OGRPoint::setZ
void setZ(double zIn)
Set z.
Definition: ogr_geometry.h:1242
OGRPoint::setM
void setM(double mIn)
Set m.
Definition: ogr_geometry.h:1251
OGRPoint::getX
double getX() const
Return x.
Definition: ogr_geometry.h:1189
OGRPoint::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:1273
OGRPoint::setY
void setY(double yIn)
Set y.
Definition: ogr_geometry.h:1230
OGRPoint::IsEmpty
virtual OGRBoolean IsEmpty() const override
Returns TRUE (non-zero) if the object has no points.
Definition: ogr_geometry.h:1182
OGRPoint::getZ
double getZ() const
Return z.
Definition: ogr_geometry.h:1201
OGRPoint::getY
double getY() const
Return y.
Definition: ogr_geometry.h:1195
OGRPolygon
Concrete class representing polygons.
Definition: ogr_geometry.h:2660
OGRPolygon::exportToWkt
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const override
Export a polygon to WKT.
Definition: ogrpolygon.cpp:668
OGRPolygon::getLinearGeometry
virtual OGRGeometry * getLinearGeometry(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const override
Return, possibly approximate, non-curve version of this geometry.
Definition: ogrpolygon.cpp:804
OGRPolygon::ChildType
OGRLinearRing ChildType
Type of child elements.
Definition: ogr_geometry.h:2692
OGRPolygon::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:2697
OGRPolygon::hasCurveGeometry
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const override
Returns if this geometry is or has curve geometry.
Definition: ogrpolygon.cpp:794
OGRPolygon::toUpperClass
const OGRCurvePolygon * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:2780
OGRPolygon::WkbSize
virtual size_t WkbSize() const override
Returns size of related binary representation.
Definition: ogrpolygon.cpp:306
OGRPolygon::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:2703
OGRPolygon::importFromWkt
OGRErr importFromWkt(const char **) override
deprecated
Definition: ogrpolygon.cpp:483
OGRPolygon::CurvePolyToPoly
virtual OGRPolygon * CurvePolyToPoly(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const override
Return a polygon from a curve polygon.
Definition: ogrpolygon.cpp:784
OGRPolygon::OGRPolygon
OGRPolygon(const OGRPolygon &other)
Copy constructor.
OGRPolygon::exportToWkb
OGRErr exportToWkb(unsigned char *, const OGRwkbExportOptions *=nullptr) const override
Convert a geometry into well known binary format.
Definition: ogrpolygon.cpp:407
OGRPolygon::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:2711
OGRPolygon::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:2790
OGRPolygon::OGRPolygon
OGRPolygon()=default
Create an empty polygon.
OGRPolygon::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:2717
OGRPolygon::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:2785
OGRPolygon::toUpperClass
OGRCurvePolygon * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:2774
OGRPolygon::closeRings
virtual void closeRings() override
Force rings to be closed.
Definition: ogrpolygon.cpp:772
OGRPolyhedralSurface
PolyhedralSurface class.
Definition: ogr_geometry.h:3432
OGRPolyhedralSurface::exportToWkb
OGRErr exportToWkb(unsigned char *, const OGRwkbExportOptions *=nullptr) const override
Convert a geometry into well known binary format.
Definition: ogrpolyhedralsurface.cpp:246
OGRPolyhedralSurface::set3D
virtual bool set3D(OGRBoolean bIs3D) override
Set the type as 3D geometry.
Definition: ogrpolyhedralsurface.cpp:913
OGRPolyhedralSurface::exportToWkt
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const override
Export a polyhedral surface to WKT.
Definition: ogrpolyhedralsurface.cpp:402
OGRPolyhedralSurface::IsEmpty
virtual OGRBoolean IsEmpty() const override
Checks if the PolyhedralSurface is empty.
Definition: ogrpolyhedralsurface.cpp:900
OGRPolyhedralSurface::hasEmptyParts
bool hasEmptyParts() const override
Returns whether a geometry has empty parts/rings.
Definition: ogrpolyhedralsurface.cpp:1005
OGRPolyhedralSurface::getNumGeometries
int getNumGeometries() const
Fetch number of geometries in PolyhedralSurface.
Definition: ogrpolyhedralsurface.cpp:841
OGRPolyhedralSurface::get_GeodesicLength
virtual double get_GeodesicLength(const OGRSpatialReference *poSRSOverride=nullptr) const override
Get the length of the surface, where curve edges are geodesic lines on the underlying ellipsoid of th...
Definition: ogrpolyhedralsurface.cpp:667
OGRPolyhedralSurface::importFromWkb
virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override
Assign geometry from well known binary data.
Definition: ogrpolyhedralsurface.cpp:158
OGRPolyhedralSurface::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3471
OGRPolyhedralSurface::get_GeodesicArea
virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride=nullptr) const override
Get the area of the surface object, considered as a surface on the underlying ellipsoid of the SRS at...
Definition: ogrpolyhedralsurface.cpp:638
OGRPolyhedralSurface::CastToMultiPolygon
static OGRMultiPolygon * CastToMultiPolygon(OGRPolyhedralSurface *poPS)
Casts the OGRPolyhedralSurface to an OGRMultiPolygon.
Definition: ogrpolyhedralsurface.cpp:726
OGRPolyhedralSurface::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3485
OGRPolyhedralSurface::getGeometryRef
OGRPolygon * getGeometryRef(int i)
Fetch geometry from container.
Definition: ogrpolyhedralsurface.cpp:863
OGRPolyhedralSurface::swapXY
virtual void swapXY() override
Swap x and y coordinates.
Definition: ogrpolyhedralsurface.cpp:961
OGRPolyhedralSurface::getEnvelope
virtual void getEnvelope(OGREnvelope *psEnvelope) const override
Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
Definition: ogrpolyhedralsurface.cpp:140
OGRPolyhedralSurface::flattenTo2D
virtual void flattenTo2D() override
Convert geometry to strictly 2D.
Definition: ogrpolyhedralsurface.cpp:471
OGRPolyhedralSurface::OGRPolyhedralSurface
OGRPolyhedralSurface(const OGRPolyhedralSurface &poGeom)
Copy constructor.
OGRPolyhedralSurface::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3479
OGRPolyhedralSurface::removeEmptyParts
void removeEmptyParts() override
Remove empty parts/rings from this geometry.
Definition: ogrpolyhedralsurface.cpp:1014
OGRPolyhedralSurface::hasCurveGeometry
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const override
Returns if this geometry is or has curve geometry.
Definition: ogrpolyhedralsurface.cpp:970
OGRPolyhedralSurface::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3465
OGRPolyhedralSurface::OGRPolyhedralSurface
OGRPolyhedralSurface()=default
Create an empty PolyhedralSurface.
OGRPolyhedralSurface::assignSpatialReference
virtual void assignSpatialReference(const OGRSpatialReference *poSR) override
Assign spatial reference to this object.
Definition: ogrpolyhedralsurface.cpp:1023
OGRPolyhedralSurface::addGeometry
virtual OGRErr addGeometry(const OGRGeometry *)
Add a new geometry to a collection.
Definition: ogrpolyhedralsurface.cpp:745
OGRPolyhedralSurface::addGeometryDirectly
OGRErr addGeometryDirectly(OGRGeometry *poNewGeom)
Add a geometry directly to the container.
Definition: ogrpolyhedralsurface.cpp:785
OGRPolyhedralSurface::importFromWkt
OGRErr importFromWkt(const char **) override
deprecated
Definition: ogrpolyhedralsurface.cpp:301
OGRPolyhedralSurface::Equals
virtual OGRBoolean Equals(const OGRGeometry *) const override
Returns TRUE if two geometries are equivalent.
Definition: ogrpolyhedralsurface.cpp:570
OGRPolyhedralSurface::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3558
OGRPolyhedralSurface::setCoordinateDimension
virtual bool setCoordinateDimension(int nDimension) override
Set the coordinate dimension.
Definition: ogrpolyhedralsurface.cpp:947
OGRPolyhedralSurface::ChildType
OGRPolygon ChildType
Type of child elements.
Definition: ogr_geometry.h:3460
OGRPolyhedralSurface::get_Area
virtual double get_Area() const override
Returns the area enclosed.
Definition: ogrpolyhedralsurface.cpp:611
OGRPolyhedralSurface::setMeasured
virtual bool setMeasured(OGRBoolean bIsMeasured) override
Set the type as Measured.
Definition: ogrpolyhedralsurface.cpp:926
OGRPolyhedralSurface::transform
virtual OGRErr transform(OGRCoordinateTransformation *) override
Apply arbitrary coordinate transformation to geometry.
Definition: ogrpolyhedralsurface.cpp:483
OGRPolyhedralSurface::get_Length
virtual double get_Length() const override
Get the length of the surface.
Definition: ogrpolyhedralsurface.cpp:652
OGRPolyhedralSurface::PointOnSurface
virtual OGRErr PointOnSurface(OGRPoint *) const override
This method relates to the SFCOM ISurface::get_PointOnSurface() method.
Definition: ogrpolyhedralsurface.cpp:681
OGRPolyhedralSurface::WkbSize
virtual size_t WkbSize() const override
Returns size of related binary representation.
Definition: ogrpolyhedralsurface.cpp:99
OGRPolyhedralSurface::getDimension
virtual int getDimension() const override
Get the dimension of this object.
Definition: ogrpolyhedralsurface.cpp:113
OGRPolyhedralSurface::empty
virtual void empty() override
Clear geometry information.
Definition: ogrpolyhedralsurface.cpp:122
OGRPolyhedralSurface::removeGeometry
OGRErr removeGeometry(int iIndex, int bDelete=TRUE)
Remove a geometry from the container.
Definition: ogrpolyhedralsurface.cpp:996
OGRPolyhedralSurface::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3563
OGRRawPoint
Simple container for a position.
Definition: ogr_geometry.h:90
OGRRawPoint::OGRRawPoint
OGRRawPoint(double xIn, double yIn)
Constructor.
Definition: ogr_geometry.h:98
OGRRawPoint::x
double x
x
Definition: ogr_geometry.h:103
OGRRawPoint::y
double y
y
Definition: ogr_geometry.h:105
OGRRawPoint::OGRRawPoint
OGRRawPoint()
Constructor.
Definition: ogr_geometry.h:93
OGRSimpleCurve
Abstract curve base class for OGRLineString and OGRCircularString.
Definition: ogr_geometry.h:1507
OGRSimpleCurve::getY
double getY(int i) const
Get Y at vertex.
Definition: ogr_geometry.h:1658
OGRSimpleCurve::getX
double getX(int i) const
Get X at vertex.
Definition: ogr_geometry.h:1653
OGRSimpleCurve::setM
bool setM(int, double)
Set the M of a vertex in line string.
Definition: ogrlinestring.cpp:770
OGRSimpleCurve::OGRSimpleCurve
OGRSimpleCurve()=default
Constructor.
OGRSimpleCurve::ChildType
OGRPoint ChildType
Type of child elements.
Definition: ogr_geometry.h:1580
OGRSimpleCurve::clone
virtual OGRSimpleCurve * clone() const override=0
Make a copy of this object.
OGRSimpleCurve::setZ
bool setZ(int, double)
Set the Z of a vertex in line string.
Definition: ogrlinestring.cpp:733
OGRSimpleCurve::getNumPoints
virtual int getNumPoints() const override
Fetch vertex count.
Definition: ogr_geometry.h:1646
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:153
OGRSurface
Abstract base class for 2 dimensional objects like polygons or curve polygons.
Definition: ogr_geometry.h:2393
OGRSurface::get_Area
virtual double get_Area() const =0
Get the area of the surface object.
OGRSurface::get_Length
virtual double get_Length() const =0
Get the length of the surface.
OGRSurface::get_GeodesicArea
virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride=nullptr) const =0
Get the area of the surface object, considered as a surface on the underlying ellipsoid of the SRS at...
OGRSurface::clone
virtual OGRSurface * clone() const override=0
Make a copy of this object.
OGRSurface::get_GeodesicLength
virtual double get_GeodesicLength(const OGRSpatialReference *poSRSOverride=nullptr) const =0
Get the length of the surface, where curve edges are geodesic lines on the underlying ellipsoid of th...
OGRSurface::PointOnSurface
virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
This method relates to the SFCOM ISurface::get_PointOnSurface() method.
Definition: ogr_geometry.h:2408
OGRTriangle
Triangle class.
Definition: ogr_geometry.h:2839
OGRTriangle::OGRTriangle
OGRTriangle()=default
Constructor.
OGRTriangle::getGeometryType
virtual OGRwkbGeometryType getGeometryType() const override
Fetch geometry type.
Definition: ogrtriangle.cpp:129
OGRTriangle::toUpperClass
const OGRPolygon * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:2880
OGRTriangle::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:2885
OGRTriangle::importFromWkb
virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override
Assign geometry from well known binary data.
Definition: ogrtriangle.cpp:156
OGRTriangle::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:2890
OGRTriangle::addRingDirectly
virtual OGRErr addRingDirectly(OGRCurve *poNewRing) override
Add a ring to a polygon.
Definition: ogrtriangle.cpp:209
OGRTriangle::toUpperClass
OGRPolygon * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:2874
OGRTriangle::OGRTriangle
OGRTriangle(const OGRTriangle &other)
Copy constructor.
OGRTriangle::clone
virtual OGRTriangle * clone() const override
Make a copy of this object.
Definition: ogrtriangle.cpp:110
OGRTriangle::operator=
OGRTriangle & operator=(const OGRTriangle &other)
Assignment operator.
Definition: ogrtriangle.cpp:97
OGRTriangle::getGeometryName
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition: ogrtriangle.cpp:120
OGRTriangulatedSurface
TriangulatedSurface class.
Definition: ogr_geometry.h:3615
OGRTriangulatedSurface::getGeometryRef
const OGRTriangle * getGeometryRef(int i) const
See OGRPolyhedralSurface::getGeometryRef()
Definition: ogr_geometry.h:3676
OGRTriangulatedSurface::getGeometryRef
OGRTriangle * getGeometryRef(int i)
See OGRPolyhedralSurface::getGeometryRef()
Definition: ogr_geometry.h:3670
OGRTriangulatedSurface::operator=
OGRTriangulatedSurface & operator=(const OGRTriangulatedSurface &other)
Assignment operator.
Definition: ogrtriangulatedsurface.cpp:45
OGRTriangulatedSurface::getGeometryName
virtual const char * getGeometryName() const override
Returns the geometry name of the TriangulatedSurface.
Definition: ogrtriangulatedsurface.cpp:82
OGRTriangulatedSurface::getGeometryType
virtual OGRwkbGeometryType getGeometryType() const override
Returns the WKB Type of TriangulatedSurface.
Definition: ogrtriangulatedsurface.cpp:96
OGRTriangulatedSurface::addGeometry
virtual OGRErr addGeometry(const OGRGeometry *) override
Add a new geometry to a collection.
Definition: ogrtriangulatedsurface.cpp:149
OGRTriangulatedSurface::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3659
OGRTriangulatedSurface::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3653
OGRTriangulatedSurface::toUpperClass
OGRPolyhedralSurface * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:3689
OGRTriangulatedSurface::clone
virtual OGRTriangulatedSurface * clone() const override
Make a copy of this object.
Definition: ogrtriangulatedsurface.cpp:65
OGRTriangulatedSurface::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3700
OGRTriangulatedSurface::toUpperClass
const OGRPolyhedralSurface * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:3695
OGRTriangulatedSurface::ChildType
OGRTriangle ChildType
Type of child elements.
Definition: ogr_geometry.h:3634
OGRTriangulatedSurface::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3705
OGRTriangulatedSurface::OGRTriangulatedSurface
OGRTriangulatedSurface()=default
Constructor.
OGRTriangulatedSurface::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3639
OGRTriangulatedSurface::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3645
cpl_conv.h
Various convenience functions for CPL.
cpl_json.h
Interface for read and write JSON documents.
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1030
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1179
CPL_WARN_UNUSED_RESULT
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:964
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:169
OGRGeometryH
void * OGRGeometryH
Opaque type for a geometry.
Definition: ogr_api.h:50
ogr_core.h
Core portability services for cross-platform OGR code.
OGRBoolean
int OGRBoolean
Type for a OGR boolean.
Definition: ogr_core.h:388
OGRwkbByteOrder
OGRwkbByteOrder
Enumeration to describe byte order.
Definition: ogr_core.h:615
wkbNDR
@ wkbNDR
LSB/Intel/Vax: Least Significant Byte First
Definition: ogr_core.h:617
OGRwkbVariant
OGRwkbVariant
Output variants of WKB we support.
Definition: ogr_core.h:545
wkbVariantOldOgc
@ wkbVariantOldOgc
Old-style 99-402 extended dimension (Z) WKB types.
Definition: ogr_core.h:546
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:407
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:371
OGRToOGCGeomType
const char * OGRToOGCGeomType(OGRwkbGeometryType eGeomType, bool bCamelCase=false, bool bAddZM=false, bool bSpaceBeforeZM=false)
Map OGR geometry format constants to corresponding OGC geometry type.
Definition: ogrgeometry.cpp:2589
OGRWktFormat
OGRWktFormat
WKT Output formatting options.
Definition: ogr_geometry.h:48
OGRWktFormat::Default
@ Default
Format as F when abs(value) < 1, otherwise as G.
OGRWktFormat::F
@ F
F-type formatting.
OGRWktFormat::G
@ G
G-type formatting.
OGRPreparedGeometryUniquePtr
std::unique_ptr< OGRPreparedGeometry, OGRPreparedGeometryUniquePtrDeleter > OGRPreparedGeometryUniquePtr
Unique pointer type for OGRPreparedGeometry.
Definition: ogr_geometry.h:4344
GEOSContextHandle_t
struct GEOSContextHandle_HS * GEOSContextHandle_t
GEOS context handle type.
Definition: ogr_geometry.h:111
OGRFromOGCGeomType
OGRwkbGeometryType OGRFromOGCGeomType(const char *pszGeomType)
Map OGCgeometry format type to corresponding OGR constants.
Definition: ogrgeometry.cpp:2510
OGRGeometryUniquePtr
std::unique_ptr< OGRGeometry, OGRGeometryUniquePtrDeleter > OGRGeometryUniquePtr
Unique pointer type for OGRGeometry.
Definition: ogr_geometry.h:1035
GEOSGeom
struct GEOSGeom_t * GEOSGeom
GEOS geometry type.
Definition: ogr_geometry.h:109
sfcgal_geometry_t
void sfcgal_geometry_t
SFCGAL geometry type.
Definition: ogr_geometry.h:113
ogr_spatialref.h
Coordinate systems services.
begin
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:421
end
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:429
OGRGeomCoordinateBinaryPrecision
Geometry coordinate precision for a binary representation.
Definition: ogr_geometry.h:307
OGRGeomCoordinatePrecision
Geometry coordinate precision.
Definition: ogr_geomcoordinateprecision.h:34
OGRWktOptions
Options for formatting WKT output.
Definition: ogr_geometry.h:56
OGRWktOptions::mPrecision
int mPrecision
Precision of output for M coordinates. Interpretation depends on format.
Definition: ogr_geometry.h:65
OGRWktOptions::zPrecision
int zPrecision
Precision of output for Z coordinates. Interpretation depends on format.
Definition: ogr_geometry.h:63
OGRWktOptions::OGRWktOptions
OGRWktOptions()
Constructor.
Definition: ogr_geometry.h:72
OGRWktOptions::OGRWktOptions
OGRWktOptions(const OGRWktOptions &)=default
Copy constructor.
OGRWktOptions::xyPrecision
int xyPrecision
Precision of output for X,Y coordinates. Interpretation depends on format.
Definition: ogr_geometry.h:61
OGRwkbExportOptions
WKB export options.
Definition: ogr_geometry.h:330