GDAL

ogr_geometry.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Project: OpenGIS Simple Features Reference Implementation
4 * Purpose: Classes for manipulating simple features that is not specific
5 * to a particular interface technology.
6 * Author: Frank Warmerdam, warmerdam@pobox.com
7 *
8 ******************************************************************************
9 * Copyright (c) 1999, Frank Warmerdam
10 * Copyright (c) 2008-2014, Even Rouault <even dot rouault at spatialys.com>
11 *
12 * SPDX-License-Identifier: MIT
13 ****************************************************************************/
14
15#ifndef OGR_GEOMETRY_H_INCLUDED
16#define OGR_GEOMETRY_H_INCLUDED
17
18#include "cpl_conv.h"
19#include "cpl_json.h"
20#include "gdal_fwd.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#include <utility>
29
37 enum class OGRWktFormat
38{
39 F,
40 G,
41 Default
42};
43
45 class CPL_DLL OGRWktOptions
46{
47 public:
49 OGRwkbVariant variant = wkbVariantOldOgc;
51 int xyPrecision;
53 int zPrecision;
55 int mPrecision;
57 bool round;
59 OGRWktFormat format = OGRWktFormat::Default;
60
62 OGRWktOptions()
63 : xyPrecision(getDefaultPrecision()), zPrecision(xyPrecision),
64 mPrecision(zPrecision), round(getDefaultRound())
65 {
66 }
67
69 OGRWktOptions(int xyPrecisionIn, bool roundIn)
70 : xyPrecision(xyPrecisionIn), zPrecision(xyPrecision),
71 mPrecision(zPrecision), round(roundIn)
72 {
73 }
74
76 OGRWktOptions(const OGRWktOptions &) = default;
77
79 static int getDefaultPrecision();
80
82 static bool getDefaultRound();
83};
84
88 class OGRRawPoint
89{
90 public:
92 OGRRawPoint() : x(0.0), y(0.0)
93 {
94 }
95
97 OGRRawPoint(double xIn, double yIn) : x(xIn), y(yIn)
98 {
99 }
100
102 double x;
104 double y;
105};
106
108 typedef struct GEOSGeom_t *GEOSGeom;
110 typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
112 typedef void sfcgal_geometry_t;
113
114 class OGRPoint;
115 class OGRCurve;
116 class OGRCompoundCurve;
117 class OGRSimpleCurve;
118 class OGRLinearRing;
119 class OGRLineString;
120 class OGRCircularString;
121 class OGRSurface;
122 class OGRCurvePolygon;
123 class OGRPolygon;
124 class OGRMultiPoint;
125 class OGRMultiSurface;
126 class OGRMultiPolygon;
127 class OGRMultiCurve;
128 class OGRMultiLineString;
129 class OGRGeometryCollection;
130 class OGRTriangle;
131 class OGRPolyhedralSurface;
132 class OGRTriangulatedSurface;
133
135 typedef OGRLineString *(*OGRCurveCasterToLineString)(OGRCurve *);
136 typedef OGRLinearRing *(*OGRCurveCasterToLinearRing)(OGRCurve *);
137
138 typedef OGRPolygon *(*OGRSurfaceCasterToPolygon)(OGRSurface *);
139 typedef OGRCurvePolygon *(*OGRSurfaceCasterToCurvePolygon)(OGRSurface *);
140 typedef OGRMultiPolygon *(*OGRPolyhedralSurfaceCastToMultiPolygon)(
141 OGRPolyhedralSurface *);
142
144
147 class CPL_DLL IOGRGeometryVisitor
148{
149 public:
151 virtual ~IOGRGeometryVisitor();
152
154 virtual void visit(OGRPoint *) = 0;
156 virtual void visit(OGRLineString *) = 0;
158 virtual void visit(OGRLinearRing *) = 0;
160 virtual void visit(OGRPolygon *) = 0;
162 virtual void visit(OGRMultiPoint *) = 0;
164 virtual void visit(OGRMultiLineString *) = 0;
166 virtual void visit(OGRMultiPolygon *) = 0;
168 virtual void visit(OGRGeometryCollection *) = 0;
170 virtual void visit(OGRCircularString *) = 0;
172 virtual void visit(OGRCompoundCurve *) = 0;
174 virtual void visit(OGRCurvePolygon *) = 0;
176 virtual void visit(OGRMultiCurve *) = 0;
178 virtual void visit(OGRMultiSurface *) = 0;
180 virtual void visit(OGRTriangle *) = 0;
182 virtual void visit(OGRPolyhedralSurface *) = 0;
184 virtual void visit(OGRTriangulatedSurface *) = 0;
185};
186
193 class CPL_DLL OGRDefaultGeometryVisitor : public IOGRGeometryVisitor
194{
195 void _visit(OGRSimpleCurve *poGeom);
196
197 public:
198 void visit(OGRPoint *) override
199 {
200 }
201
202 void visit(OGRLineString *) override;
203 void visit(OGRLinearRing *) override;
204 void visit(OGRPolygon *) override;
205 void visit(OGRMultiPoint *) override;
206 void visit(OGRMultiLineString *) override;
207 void visit(OGRMultiPolygon *) override;
208 void visit(OGRGeometryCollection *) override;
209 void visit(OGRCircularString *) override;
210 void visit(OGRCompoundCurve *) override;
211 void visit(OGRCurvePolygon *) override;
212 void visit(OGRMultiCurve *) override;
213 void visit(OGRMultiSurface *) override;
214 void visit(OGRTriangle *) override;
215 void visit(OGRPolyhedralSurface *) override;
216 void visit(OGRTriangulatedSurface *) override;
217};
218
221 class CPL_DLL IOGRConstGeometryVisitor
222{
223 public:
225 virtual ~IOGRConstGeometryVisitor();
226
228 virtual void visit(const OGRPoint *) = 0;
230 virtual void visit(const OGRLineString *) = 0;
232 virtual void visit(const OGRLinearRing *) = 0;
234 virtual void visit(const OGRPolygon *) = 0;
236 virtual void visit(const OGRMultiPoint *) = 0;
238 virtual void visit(const OGRMultiLineString *) = 0;
240 virtual void visit(const OGRMultiPolygon *) = 0;
242 virtual void visit(const OGRGeometryCollection *) = 0;
244 virtual void visit(const OGRCircularString *) = 0;
246 virtual void visit(const OGRCompoundCurve *) = 0;
248 virtual void visit(const OGRCurvePolygon *) = 0;
250 virtual void visit(const OGRMultiCurve *) = 0;
252 virtual void visit(const OGRMultiSurface *) = 0;
254 virtual void visit(const OGRTriangle *) = 0;
256 virtual void visit(const OGRPolyhedralSurface *) = 0;
258 virtual void visit(const OGRTriangulatedSurface *) = 0;
259};
260
267 class CPL_DLL OGRDefaultConstGeometryVisitor : public IOGRConstGeometryVisitor
268{
269 void _visit(const OGRSimpleCurve *poGeom);
270
271 public:
272 void visit(const OGRPoint *) override
273 {
274 }
275
276 void visit(const OGRLineString *) override;
277 void visit(const OGRLinearRing *) override;
278 void visit(const OGRPolygon *) override;
279 void visit(const OGRMultiPoint *) override;
280 void visit(const OGRMultiLineString *) override;
281 void visit(const OGRMultiPolygon *) override;
282 void visit(const OGRGeometryCollection *) override;
283 void visit(const OGRCircularString *) override;
284 void visit(const OGRCompoundCurve *) override;
285 void visit(const OGRCurvePolygon *) override;
286 void visit(const OGRMultiCurve *) override;
287 void visit(const OGRMultiSurface *) override;
288 void visit(const OGRTriangle *) override;
289 void visit(const OGRPolyhedralSurface *) override;
290 void visit(const OGRTriangulatedSurface *) override;
291};
292
293/************************************************************************/
294/* OGRGeomCoordinateBinaryPrecision */
295/************************************************************************/
296
301 class CPL_DLL OGRGeomCoordinateBinaryPrecision
302{
303 public:
304 int nXYBitPrecision =
305 INT_MIN;
307 int nZBitPrecision =
308 INT_MIN;
310 int nMBitPrecision =
311 INT_MIN;
314 void SetFrom(const OGRGeomCoordinatePrecision &);
315};
316
317/************************************************************************/
318/* OGRwkbExportOptions */
319/************************************************************************/
320
325 struct CPL_DLL OGRwkbExportOptions
326{
327 OGRwkbByteOrder eByteOrder = wkbNDR;
328 OGRwkbVariant eWkbVariant = wkbVariantOldOgc;
329 OGRGeomCoordinateBinaryPrecision sPrecision{};
330};
331
332/************************************************************************/
333/* OGRGeometry */
334/************************************************************************/
335
356 class CPL_DLL OGRGeometry
357{
358 private:
359 const OGRSpatialReference *poSRS = nullptr; // may be NULL
360
361 protected:
363 friend class OGRCurveCollection;
364
365 unsigned int flags = 0;
366
367 OGRErr importPreambleFromWkt(const char **ppszInput, int *pbHasZ,
368 int *pbHasM, bool *pbIsEmpty);
369 OGRErr importCurveCollectionFromWkt(
370 const char **ppszInput, int bAllowEmptyComponent, int bAllowLineString,
371 int bAllowCurve, int bAllowCompoundCurve,
372 OGRErr (*pfnAddCurveDirectly)(OGRGeometry *poSelf, OGRCurve *poCurve));
373 OGRErr importPreambleFromWkb(const unsigned char *pabyData, size_t nSize,
374 OGRwkbByteOrder &eByteOrder,
375 OGRwkbVariant eWkbVariant);
376 OGRErr importPreambleOfCollectionFromWkb(const unsigned char *pabyData,
377 size_t &nSize, size_t &nDataOffset,
378 OGRwkbByteOrder &eByteOrder,
379 size_t nMinSubGeomSize,
380 int &nGeomCount,
381 OGRwkbVariant eWkbVariant);
382 OGRErr PointOnSurfaceInternal(OGRPoint *poPoint) const;
383 OGRBoolean IsSFCGALCompatible() const;
384
385 void HomogenizeDimensionalityWith(OGRGeometry *poOtherGeom);
386 std::string wktTypeString(OGRwkbVariant variant) const;
387
389
390 public:
391 /************************************************************************/
392 /* Bit flags for OGRGeometry */
393 /* The OGR_G_NOT_EMPTY_POINT is used *only* for points. */
394 /* Do not use these outside of the core. */
395 /* Use Is3D, IsMeasured, set3D, and setMeasured instead */
396 /************************************************************************/
397
399 static const unsigned int OGR_G_NOT_EMPTY_POINT = 0x1;
400 static const unsigned int OGR_G_3D = 0x2;
401 static const unsigned int OGR_G_MEASURED = 0x4;
403
404 OGRGeometry();
405 OGRGeometry(const OGRGeometry &other);
406 OGRGeometry(OGRGeometry &&other);
407 virtual ~OGRGeometry();
408
409 OGRGeometry &operator=(const OGRGeometry &other);
410 OGRGeometry &operator=(OGRGeometry &&other);
411
413 bool operator==(const OGRGeometry &other) const
414 {
415 return CPL_TO_BOOL(Equals(&other));
416 }
417
419 bool operator!=(const OGRGeometry &other) const
420 {
421 return !CPL_TO_BOOL(Equals(&other));
422 }
423
424 // Standard IGeometry.
425 virtual int getDimension() const = 0;
426 virtual int getCoordinateDimension() const;
427 int CoordinateDimension() const;
428 virtual OGRBoolean IsEmpty() const = 0;
429 virtual OGRBoolean IsValid() const;
430 virtual OGRGeometry *MakeValid(CSLConstList papszOptions = nullptr) const;
431 virtual OGRGeometry *Normalize() const;
432 virtual OGRBoolean IsSimple() const;
433
435 OGRBoolean Is3D() const
436 {
437 return (flags & OGR_G_3D) != 0;
438 }
439
441 OGRBoolean IsMeasured() const
442 {
443 return (flags & OGR_G_MEASURED) != 0;
444 }
445
446 virtual OGRBoolean IsRing() const;
447 virtual void empty() = 0;
448 virtual OGRGeometry *clone() const CPL_WARN_UNUSED_RESULT = 0;
449 virtual void getEnvelope(OGREnvelope *psEnvelope) const = 0;
450 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const = 0;
451
452 // IWks Interface.
453 virtual size_t WkbSize() const = 0;
454 OGRErr importFromWkb(const GByte *, size_t = static_cast<size_t>(-1),
455 OGRwkbVariant = wkbVariantOldOgc);
456 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
457 size_t &nBytesConsumedOut) = 0;
458 OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
459 OGRwkbVariant = wkbVariantOldOgc) const;
460 virtual OGRErr exportToWkb(unsigned char *,
461 const OGRwkbExportOptions * = nullptr) const = 0;
462 virtual OGRErr importFromWkt(const char **ppszInput) = 0;
463
464#ifndef DOXYGEN_XML
468 OGRErr importFromWkt(char **ppszInput)
470 CPL_WARN_DEPRECATED("Use importFromWkt(const char**) instead")
472 {
473 return importFromWkt(const_cast<const char **>(ppszInput));
474 }
475#endif
476
477 OGRErr exportToWkt(char **ppszDstText,
478 OGRwkbVariant = wkbVariantOldOgc) const;
479
484 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
485 OGRErr *err = nullptr) const = 0;
486
487 // Non-standard.
488 virtual OGRwkbGeometryType getGeometryType() const = 0;
489 OGRwkbGeometryType getIsoGeometryType() const;
490 virtual const char *getGeometryName() const = 0;
491 void dumpReadable(FILE *, const char * = nullptr,
492 CSLConstList papszOptions = nullptr) const;
493 std::string dumpReadable(const char * = nullptr,
494 CSLConstList papszOptions = nullptr) const;
495 virtual void flattenTo2D() = 0;
496 virtual char *exportToGML(const char *const *papszOptions = nullptr) const;
497 virtual char *exportToKML() const;
498 virtual char *exportToJson(CSLConstList papszOptions = nullptr) const;
499
501 virtual void accept(IOGRGeometryVisitor *visitor) = 0;
502
504 virtual void accept(IOGRConstGeometryVisitor *visitor) const = 0;
505
506 static GEOSContextHandle_t createGEOSContext();
507 static void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt);
508 GEOSGeom
509 exportToGEOS(GEOSContextHandle_t hGEOSCtxt,
510 bool bRemoveEmptyParts = false) const CPL_WARN_UNUSED_RESULT;
511 virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
512 virtual OGRGeometry *getCurveGeometry(
513 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
514 virtual OGRGeometry *getLinearGeometry(
515 double dfMaxAngleStepSizeDegrees = 0,
516 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
517
518 void roundCoordinates(const OGRGeomCoordinatePrecision &sPrecision);
519 void
520 roundCoordinatesIEEE754(const OGRGeomCoordinateBinaryPrecision &options);
521
522 // SFCGAL interfacing methods.
524 static sfcgal_geometry_t *OGRexportToSFCGAL(const OGRGeometry *poGeom);
525 static OGRGeometry *SFCGALexportToOGR(const sfcgal_geometry_t *_geometry);
527 virtual void closeRings();
528
529 virtual bool setCoordinateDimension(int nDimension);
530 virtual bool set3D(OGRBoolean bIs3D);
531 virtual bool setMeasured(OGRBoolean bIsMeasured);
532
533 virtual void assignSpatialReference(const OGRSpatialReference *poSR);
534
535 const OGRSpatialReference *getSpatialReference(void) const
536 {
537 return poSRS;
538 }
539
540 virtual OGRErr transform(OGRCoordinateTransformation *poCT) = 0;
541 OGRErr transformTo(const OGRSpatialReference *poSR);
542
543 virtual bool segmentize(double dfMaxLength);
544
545 // ISpatialRelation
546 virtual OGRBoolean Intersects(const OGRGeometry *) const;
547 virtual OGRBoolean Equals(const OGRGeometry *) const = 0;
548 virtual OGRBoolean Disjoint(const OGRGeometry *) const;
549 virtual OGRBoolean Touches(const OGRGeometry *) const;
550 virtual OGRBoolean Crosses(const OGRGeometry *) const;
551 virtual OGRBoolean Within(const OGRGeometry *) const;
552 virtual OGRBoolean Contains(const OGRGeometry *) const;
553 virtual OGRBoolean Overlaps(const OGRGeometry *) const;
554 // virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
555 // virtual OGRGeometry *LocateAlong( double mValue ) const;
556 // virtual OGRGeometry *LocateBetween( double mStart, double mEnd )
557 // const;
558
559 virtual OGRGeometry *Boundary() const CPL_WARN_UNUSED_RESULT;
560 virtual double Distance(const OGRGeometry *) const;
561 virtual OGRGeometry *ConvexHull() const CPL_WARN_UNUSED_RESULT;
562 virtual OGRGeometry *
563 ConcaveHull(double dfRatio, bool bAllowHoles) const CPL_WARN_UNUSED_RESULT;
564 virtual OGRGeometry *
565 Buffer(double dfDist, int nQuadSegs = 30) const CPL_WARN_UNUSED_RESULT;
566 virtual OGRGeometry *
567 BufferEx(double dfDist,
568 CSLConstList papszOptions) const CPL_WARN_UNUSED_RESULT;
569 virtual OGRGeometry *
570 Intersection(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
571 virtual OGRGeometry *
572 Union(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
573 virtual OGRGeometry *UnionCascaded() const CPL_WARN_UNUSED_RESULT;
574 OGRGeometry *UnaryUnion() const CPL_WARN_UNUSED_RESULT;
575 virtual OGRGeometry *
576 Difference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
577 virtual OGRGeometry *
578 SymDifference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
579 virtual OGRErr Centroid(OGRPoint *poPoint) const;
580 virtual OGRGeometry *
581 Simplify(double dTolerance) const CPL_WARN_UNUSED_RESULT;
582 OGRGeometry *
583 SimplifyPreserveTopology(double dTolerance) const CPL_WARN_UNUSED_RESULT;
584 virtual OGRGeometry *
585 DelaunayTriangulation(double dfTolerance,
586 int bOnlyEdges) const CPL_WARN_UNUSED_RESULT;
587 virtual OGRGeometry *
588 ConstrainedDelaunayTriangulation() const CPL_WARN_UNUSED_RESULT;
589
590 virtual OGRGeometry *Polygonize() const CPL_WARN_UNUSED_RESULT;
591 virtual OGRGeometry *BuildArea() const CPL_WARN_UNUSED_RESULT;
592
593 virtual double Distance3D(const OGRGeometry *poOtherGeom) const;
594
595 OGRGeometry *SetPrecision(double dfGridSize, int nFlags) const;
596
597 virtual bool hasEmptyParts() const;
598 virtual void removeEmptyParts();
599
601 // backward compatibility to non-standard method names.
602 OGRBoolean Intersect(OGRGeometry *) const
603 CPL_WARN_DEPRECATED("Non standard method. "
604 "Use Intersects() instead");
605 OGRBoolean Equal(OGRGeometry *) const
606 CPL_WARN_DEPRECATED("Non standard method. "
607 "Use Equals() instead");
608 OGRGeometry *SymmetricDifference(const OGRGeometry *) const
609 CPL_WARN_DEPRECATED("Non standard method. "
610 "Use SymDifference() instead");
611 OGRGeometry *getBoundary() const
612 CPL_WARN_DEPRECATED("Non standard method. "
613 "Use Boundary() instead");
615
617 // Special HACK for DB2 7.2 support
618 static int bGenerate_DB2_V72_BYTE_ORDER;
620
621 virtual void swapXY();
622
623 bool IsRectangle() const;
624
626 static OGRGeometry *CastToIdentity(OGRGeometry *poGeom)
627 {
628 return poGeom;
629 }
630
631 static OGRGeometry *CastToError(OGRGeometry *poGeom);
632
634
637 static inline OGRGeometryH ToHandle(OGRGeometry *poGeom)
638 {
639 return reinterpret_cast<OGRGeometryH>(poGeom);
640 }
641
644 static inline OGRGeometry *FromHandle(OGRGeometryH hGeom)
645 {
646 return reinterpret_cast<OGRGeometry *>(hGeom);
647 }
648
652 inline OGRPoint *toPoint()
653 {
654 return cpl::down_cast<OGRPoint *>(this);
655 }
656
660 inline const OGRPoint *toPoint() const
661 {
662 return cpl::down_cast<const OGRPoint *>(this);
663 }
664
669 inline OGRCurve *toCurve()
670 {
671 return cpl::down_cast<OGRCurve *>(this);
672 }
673
678 inline const OGRCurve *toCurve() const
679 {
680 return cpl::down_cast<const OGRCurve *>(this);
681 }
682
687 inline OGRSimpleCurve *toSimpleCurve()
688 {
689 return cpl::down_cast<OGRSimpleCurve *>(this);
690 }
691
696 inline const OGRSimpleCurve *toSimpleCurve() const
697 {
698 return cpl::down_cast<const OGRSimpleCurve *>(this);
699 }
700
705 inline OGRLineString *toLineString()
706 {
707 return cpl::down_cast<OGRLineString *>(this);
708 }
709
714 inline const OGRLineString *toLineString() const
715 {
716 return cpl::down_cast<const OGRLineString *>(this);
717 }
718
722 inline OGRLinearRing *toLinearRing()
723 {
724 return cpl::down_cast<OGRLinearRing *>(this);
725 }
726
730 inline const OGRLinearRing *toLinearRing() const
731 {
732 return cpl::down_cast<const OGRLinearRing *>(this);
733 }
734
739 inline OGRCircularString *toCircularString()
740 {
741 return cpl::down_cast<OGRCircularString *>(this);
742 }
743
748 inline const OGRCircularString *toCircularString() const
749 {
750 return cpl::down_cast<const OGRCircularString *>(this);
751 }
752
757 inline OGRCompoundCurve *toCompoundCurve()
758 {
759 return cpl::down_cast<OGRCompoundCurve *>(this);
760 }
761
766 inline const OGRCompoundCurve *toCompoundCurve() const
767 {
768 return cpl::down_cast<const OGRCompoundCurve *>(this);
769 }
770
775 inline OGRSurface *toSurface()
776 {
777 return cpl::down_cast<OGRSurface *>(this);
778 }
779
784 inline const OGRSurface *toSurface() const
785 {
786 return cpl::down_cast<const OGRSurface *>(this);
787 }
788
793 inline OGRPolygon *toPolygon()
794 {
795 return cpl::down_cast<OGRPolygon *>(this);
796 }
797
802 inline const OGRPolygon *toPolygon() const
803 {
804 return cpl::down_cast<const OGRPolygon *>(this);
805 }
806
810 inline OGRTriangle *toTriangle()
811 {
812 return cpl::down_cast<OGRTriangle *>(this);
813 }
814
818 inline const OGRTriangle *toTriangle() const
819 {
820 return cpl::down_cast<const OGRTriangle *>(this);
821 }
822
827 inline OGRCurvePolygon *toCurvePolygon()
828 {
829 return cpl::down_cast<OGRCurvePolygon *>(this);
830 }
831
836 inline const OGRCurvePolygon *toCurvePolygon() const
837 {
838 return cpl::down_cast<const OGRCurvePolygon *>(this);
839 }
840
845 inline OGRGeometryCollection *toGeometryCollection()
846 {
847 return cpl::down_cast<OGRGeometryCollection *>(this);
848 }
849
854 inline const OGRGeometryCollection *toGeometryCollection() const
855 {
856 return cpl::down_cast<const OGRGeometryCollection *>(this);
857 }
858
863 inline OGRMultiPoint *toMultiPoint()
864 {
865 return cpl::down_cast<OGRMultiPoint *>(this);
866 }
867
872 inline const OGRMultiPoint *toMultiPoint() const
873 {
874 return cpl::down_cast<const OGRMultiPoint *>(this);
875 }
876
881 inline OGRMultiLineString *toMultiLineString()
882 {
883 return cpl::down_cast<OGRMultiLineString *>(this);
884 }
885
890 inline const OGRMultiLineString *toMultiLineString() const
891 {
892 return cpl::down_cast<const OGRMultiLineString *>(this);
893 }
894
899 inline OGRMultiPolygon *toMultiPolygon()
900 {
901 return cpl::down_cast<OGRMultiPolygon *>(this);
902 }
903
908 inline const OGRMultiPolygon *toMultiPolygon() const
909 {
910 return cpl::down_cast<const OGRMultiPolygon *>(this);
911 }
912
917 inline OGRMultiCurve *toMultiCurve()
918 {
919 return cpl::down_cast<OGRMultiCurve *>(this);
920 }
921
926 inline const OGRMultiCurve *toMultiCurve() const
927 {
928 return cpl::down_cast<const OGRMultiCurve *>(this);
929 }
930
935 inline OGRMultiSurface *toMultiSurface()
936 {
937 return cpl::down_cast<OGRMultiSurface *>(this);
938 }
939
944 inline const OGRMultiSurface *toMultiSurface() const
945 {
946 return cpl::down_cast<const OGRMultiSurface *>(this);
947 }
948
953 inline OGRPolyhedralSurface *toPolyhedralSurface()
954 {
955 return cpl::down_cast<OGRPolyhedralSurface *>(this);
956 }
957
962 inline const OGRPolyhedralSurface *toPolyhedralSurface() const
963 {
964 return cpl::down_cast<const OGRPolyhedralSurface *>(this);
965 }
966
970 inline OGRTriangulatedSurface *toTriangulatedSurface()
971 {
972 return cpl::down_cast<OGRTriangulatedSurface *>(this);
973 }
974
978 inline const OGRTriangulatedSurface *toTriangulatedSurface() const
979 {
980 return cpl::down_cast<const OGRTriangulatedSurface *>(this);
981 }
982};
983
985 struct CPL_DLL OGRGeometryUniquePtrDeleter
986{
987 void operator()(OGRGeometry *) const;
988};
989
991
994 typedef std::unique_ptr<OGRGeometry, OGRGeometryUniquePtrDeleter>
995 OGRGeometryUniquePtr;
996
998#define OGR_FORBID_DOWNCAST_TO(name) \
999 inline OGR##name *to##name() = delete; \
1000 inline const OGR##name *to##name() const = delete;
1001
1002#define OGR_FORBID_DOWNCAST_TO_POINT OGR_FORBID_DOWNCAST_TO(Point)
1003#define OGR_FORBID_DOWNCAST_TO_CURVE OGR_FORBID_DOWNCAST_TO(Curve)
1004#define OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE OGR_FORBID_DOWNCAST_TO(SimpleCurve)
1005#define OGR_FORBID_DOWNCAST_TO_LINESTRING OGR_FORBID_DOWNCAST_TO(LineString)
1006#define OGR_FORBID_DOWNCAST_TO_LINEARRING OGR_FORBID_DOWNCAST_TO(LinearRing)
1007#define OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1008 OGR_FORBID_DOWNCAST_TO(CircularString)
1009#define OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE \
1010 OGR_FORBID_DOWNCAST_TO(CompoundCurve)
1011#define OGR_FORBID_DOWNCAST_TO_SURFACE OGR_FORBID_DOWNCAST_TO(Surface)
1012#define OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON OGR_FORBID_DOWNCAST_TO(CurvePolygon)
1013#define OGR_FORBID_DOWNCAST_TO_POLYGON OGR_FORBID_DOWNCAST_TO(Polygon)
1014#define OGR_FORBID_DOWNCAST_TO_TRIANGLE OGR_FORBID_DOWNCAST_TO(Triangle)
1015#define OGR_FORBID_DOWNCAST_TO_MULTIPOINT OGR_FORBID_DOWNCAST_TO(MultiPoint)
1016#define OGR_FORBID_DOWNCAST_TO_MULTICURVE OGR_FORBID_DOWNCAST_TO(MultiCurve)
1017#define OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1018 OGR_FORBID_DOWNCAST_TO(MultiLineString)
1019#define OGR_FORBID_DOWNCAST_TO_MULTISURFACE OGR_FORBID_DOWNCAST_TO(MultiSurface)
1020#define OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON OGR_FORBID_DOWNCAST_TO(MultiPolygon)
1021#define OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1022 OGR_FORBID_DOWNCAST_TO(GeometryCollection)
1023#define OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1024 OGR_FORBID_DOWNCAST_TO(PolyhedralSurface)
1025#define OGR_FORBID_DOWNCAST_TO_TIN OGR_FORBID_DOWNCAST_TO(TriangulatedSurface)
1026
1027#define OGR_ALLOW_UPCAST_TO(name) \
1028 inline OGR##name *to##name() \
1029 { \
1030 return this; \
1031 } \
1032 inline const OGR##name *to##name() const \
1033 { \
1034 return this; \
1035 }
1036
1037#ifndef SUPPRESS_OGR_ALLOW_CAST_TO_THIS_WARNING
1038#define CAST_TO_THIS_WARNING CPL_WARN_DEPRECATED("Casting to this is useless")
1039#else
1040#define CAST_TO_THIS_WARNING
1041#endif
1042
1043#define OGR_ALLOW_CAST_TO_THIS(name) \
1044 inline OGR##name *to##name() CAST_TO_THIS_WARNING \
1045 { \
1046 return this; \
1047 } \
1048 inline const OGR##name *to##name() const CAST_TO_THIS_WARNING \
1049 { \
1050 return this; \
1051 }
1052
1053#define OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1054 OGR_FORBID_DOWNCAST_TO_CURVE \
1055 OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE \
1056 OGR_FORBID_DOWNCAST_TO_LINESTRING \
1057 OGR_FORBID_DOWNCAST_TO_LINEARRING \
1058 OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1059 OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE
1060
1061#define OGR_FORBID_DOWNCAST_TO_ALL_SURFACES \
1062 OGR_FORBID_DOWNCAST_TO_SURFACE \
1063 OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON \
1064 OGR_FORBID_DOWNCAST_TO_POLYGON \
1065 OGR_FORBID_DOWNCAST_TO_TRIANGLE \
1066 OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1067 OGR_FORBID_DOWNCAST_TO_TIN
1068
1069#define OGR_FORBID_DOWNCAST_TO_ALL_SINGLES \
1070 OGR_FORBID_DOWNCAST_TO_POINT \
1071 OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1072 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1073
1074#define OGR_FORBID_DOWNCAST_TO_ALL_MULTI \
1075 OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1076 OGR_FORBID_DOWNCAST_TO_MULTIPOINT \
1077 OGR_FORBID_DOWNCAST_TO_MULTICURVE \
1078 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1079 OGR_FORBID_DOWNCAST_TO_MULTISURFACE \
1080 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
1081
1083
1084/************************************************************************/
1085/* OGRPoint */
1086/************************************************************************/
1087
1094 class CPL_DLL OGRPoint : public OGRGeometry
1095{
1096 double x;
1097 double y;
1098 double z;
1099 double m;
1100
1101 public:
1102 OGRPoint();
1103 OGRPoint(double x, double y);
1104 OGRPoint(double x, double y, double z);
1105 OGRPoint(double x, double y, double z, double m);
1106 OGRPoint(const OGRPoint &other);
1108 OGRPoint(OGRPoint &&other) = default;
1109 static OGRPoint *createXYM(double x, double y, double m);
1110
1111 OGRPoint &operator=(const OGRPoint &other);
1113 OGRPoint &operator=(OGRPoint &&other) = default;
1114
1115 // IWks Interface
1116 size_t WkbSize() const override;
1117 OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1118 size_t &nBytesConsumedOut) override;
1119 OGRErr exportToWkb(unsigned char *,
1120 const OGRwkbExportOptions * = nullptr) const override;
1121
1122#ifndef DOXYGEN_XML
1123 using OGRGeometry::importFromWkt;
1124#endif
1125
1126 OGRErr importFromWkt(const char **) override;
1127
1128#ifndef DOXYGEN_XML
1129 using OGRGeometry::exportToWkt;
1130#endif
1131
1136 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1137 OGRErr *err = nullptr) const override;
1138
1139 // IGeometry
1140 int getDimension() const override;
1141 OGRPoint *clone() const override;
1142 void empty() override;
1143 void getEnvelope(OGREnvelope *psEnvelope) const override;
1144 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1145
1146 OGRBoolean IsEmpty() const override
1147 {
1148 return !(flags & OGR_G_NOT_EMPTY_POINT);
1149 }
1150
1151 // IPoint
1153 double getX() const
1154 {
1155 return x;
1156 }
1157
1159 double getY() const
1160 {
1161 return y;
1162 }
1163
1165 double getZ() const
1166 {
1167 return z;
1168 }
1169
1171 double getM() const
1172 {
1173 return m;
1174 }
1175
1176 // Non standard
1177 bool setCoordinateDimension(int nDimension) override;
1178
1182 void setX(double xIn)
1183 {
1184 x = xIn;
1185 if (std::isnan(x) || std::isnan(y))
1186 flags &= ~OGR_G_NOT_EMPTY_POINT;
1187 else
1188 flags |= OGR_G_NOT_EMPTY_POINT;
1189 }
1190
1194 void setY(double yIn)
1195 {
1196 y = yIn;
1197 if (std::isnan(x) || std::isnan(y))
1198 flags &= ~OGR_G_NOT_EMPTY_POINT;
1199 else
1200 flags |= OGR_G_NOT_EMPTY_POINT;
1201 }
1202
1206 void setZ(double zIn)
1207 {
1208 z = zIn;
1209 flags |= OGR_G_3D;
1210 }
1211
1215 void setM(double mIn)
1216 {
1217 m = mIn;
1218 flags |= OGR_G_MEASURED;
1219 }
1220
1221 // ISpatialRelation
1222 OGRBoolean Equals(const OGRGeometry *) const override;
1223 OGRBoolean Intersects(const OGRGeometry *) const override;
1224 OGRBoolean Within(const OGRGeometry *) const override;
1225
1226 // Non standard from OGRGeometry
1227 const char *getGeometryName() const override;
1228 OGRwkbGeometryType getGeometryType() const override;
1229 OGRErr transform(OGRCoordinateTransformation *poCT) override;
1230 void flattenTo2D() override;
1231
1232 void accept(IOGRGeometryVisitor *visitor) override
1233 {
1234 visitor->visit(this);
1235 }
1236
1237 void accept(IOGRConstGeometryVisitor *visitor) const override
1238 {
1239 visitor->visit(this);
1240 }
1241
1242 void swapXY() override;
1243
1244 OGR_ALLOW_CAST_TO_THIS(Point)
1245 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
1246 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1247 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1248};
1249
1250/************************************************************************/
1251/* OGRPointIterator */
1252/************************************************************************/
1253
1259 class CPL_DLL OGRPointIterator
1260{
1261 public:
1262 virtual ~OGRPointIterator();
1263 virtual OGRBoolean getNextPoint(OGRPoint *p) = 0;
1264
1265 static void destroy(OGRPointIterator *);
1266};
1267
1268/************************************************************************/
1269/* OGRCurve */
1270/************************************************************************/
1271
1277 class CPL_DLL OGRCurve : public OGRGeometry
1278{
1279 protected:
1281 OGRCurve() = default;
1282 OGRCurve(const OGRCurve &other) = default;
1283 OGRCurve(OGRCurve &&other) = default;
1284
1285 virtual OGRCurveCasterToLineString GetCasterToLineString() const = 0;
1286 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const = 0;
1287
1288 friend class OGRCurvePolygon;
1289 friend class OGRCompoundCurve;
1291 virtual int ContainsPoint(const OGRPoint *p) const;
1292 virtual int IntersectsPoint(const OGRPoint *p) const;
1293 virtual double get_AreaOfCurveSegments() const = 0;
1294
1295 private:
1296 class CPL_DLL ConstIterator
1297 {
1298 struct Private;
1299 std::unique_ptr<Private> m_poPrivate;
1300
1301 public:
1302 ConstIterator(const OGRCurve *poSelf, bool bStart);
1303 ConstIterator(ConstIterator &&oOther) noexcept;
1304 ConstIterator &operator=(ConstIterator &&oOther);
1305 ~ConstIterator();
1306 const OGRPoint &operator*() const;
1307 ConstIterator &operator++();
1308 bool operator!=(const ConstIterator &it) const;
1309 };
1310
1311 friend inline ConstIterator begin(const OGRCurve *);
1312 friend inline ConstIterator end(const OGRCurve *);
1313
1314 public:
1316 OGRCurve &operator=(const OGRCurve &other);
1317 OGRCurve &operator=(OGRCurve &&other) = default;
1319
1321 typedef OGRPoint ChildType;
1322
1330 ConstIterator begin() const;
1332 ConstIterator end() const;
1333
1334 // IGeometry
1335 OGRCurve *clone() const override = 0;
1336
1337 // ICurve methods
1338 virtual double get_Length() const = 0;
1339 virtual void StartPoint(OGRPoint *) const = 0;
1340 virtual void EndPoint(OGRPoint *) const = 0;
1341 virtual int get_IsClosed() const;
1342 virtual void Value(double, OGRPoint *) const = 0;
1343 virtual OGRLineString *
1344 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1345 const char *const *papszOptions = nullptr) const = 0;
1346 int getDimension() const override;
1347
1348 // non standard
1349 virtual int getNumPoints() const = 0;
1350 virtual OGRPointIterator *getPointIterator() const = 0;
1351 virtual OGRBoolean IsConvex() const;
1352 virtual double get_Area() const = 0;
1353 virtual double get_GeodesicArea(
1354 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
1355 virtual double get_GeodesicLength(
1356 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
1357 virtual int isClockwise() const;
1358 virtual void reversePoints() = 0;
1359
1363 inline OGRSimpleCurve *toSimpleCurve()
1364 {
1365 return cpl::down_cast<OGRSimpleCurve *>(this);
1366 }
1367
1371 inline const OGRSimpleCurve *toSimpleCurve() const
1372 {
1373 return cpl::down_cast<const OGRSimpleCurve *>(this);
1374 }
1375
1376 static OGRCompoundCurve *CastToCompoundCurve(OGRCurve *puCurve);
1377 static OGRLineString *CastToLineString(OGRCurve *poCurve);
1378 static OGRLinearRing *CastToLinearRing(OGRCurve *poCurve);
1379
1380 OGR_FORBID_DOWNCAST_TO_POINT
1381 OGR_ALLOW_CAST_TO_THIS(Curve)
1382 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1383 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1384};
1385
1387
1388 inline OGRCurve::ConstIterator begin(const OGRCurve *poCurve)
1389{
1390 return poCurve->begin();
1391}
1392
1394 inline OGRCurve::ConstIterator end(const OGRCurve *poCurve)
1395{
1396 return poCurve->end();
1397}
1398
1400
1401/************************************************************************/
1402/* OGRIteratedPoint */
1403/************************************************************************/
1404
1426 class CPL_DLL OGRIteratedPoint : public OGRPoint
1427{
1428 private:
1429 friend class OGRSimpleCurve;
1430
1431 OGRSimpleCurve *m_poCurve = nullptr;
1432 int m_nPos = 0;
1433
1434 OGRIteratedPoint() = default;
1435
1436 CPL_DISALLOW_COPY_ASSIGN(OGRIteratedPoint)
1437
1438 public:
1442 void setX(double xIn);
1446 void setY(double yIn);
1450 void setZ(double zIn);
1454 void setM(double mIn);
1455
1457 ~OGRIteratedPoint() override;
1458};
1459
1460/************************************************************************/
1461/* OGRSimpleCurve */
1462/************************************************************************/
1463
1472 class CPL_DLL OGRSimpleCurve : public OGRCurve
1473{
1474 protected:
1476 friend class OGRGeometry;
1477
1478 int nPointCount = 0;
1479 int m_nPointCapacity = 0;
1480 OGRRawPoint *paoPoints = nullptr;
1481 double *padfZ = nullptr;
1482 double *padfM = nullptr;
1483
1484 bool Make3D();
1485 void Make2D();
1486 void RemoveM();
1487 bool AddM();
1488
1489 OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ, int bHasM,
1490 OGRRawPoint *&paoPointsIn, int &nMaxPoints,
1491 double *&padfZIn);
1493
1494 virtual double get_LinearArea() const;
1495
1497 OGRSimpleCurve() = default;
1498
1499 OGRSimpleCurve(const OGRSimpleCurve &other);
1500
1501 OGRSimpleCurve(OGRSimpleCurve &&other);
1502
1503 private:
1504 class CPL_DLL Iterator
1505 {
1506 struct Private;
1507 std::unique_ptr<Private> m_poPrivate;
1508 void update();
1509
1510 public:
1511 Iterator(OGRSimpleCurve *poSelf, int nPos);
1512 Iterator(Iterator &&oOther) noexcept; // declared but not defined.
1513 // Needed for gcc 5.4 at least
1514 ~Iterator();
1515 OGRIteratedPoint &operator*();
1516 Iterator &operator++();
1517 bool operator!=(const Iterator &it) const;
1518 };
1519
1520 friend inline Iterator begin(OGRSimpleCurve *);
1521 friend inline Iterator end(OGRSimpleCurve *);
1522
1523 class CPL_DLL ConstIterator
1524 {
1525 struct Private;
1526 std::unique_ptr<Private> m_poPrivate;
1527
1528 public:
1529 ConstIterator(const OGRSimpleCurve *poSelf, int nPos);
1530 ConstIterator(
1531 ConstIterator &&oOther) noexcept; // declared but not defined.
1532 // Needed for gcc 5.4 at least
1533 ~ConstIterator();
1534 const OGRPoint &operator*() const;
1535 ConstIterator &operator++();
1536 bool operator!=(const ConstIterator &it) const;
1537 };
1538
1539 friend inline ConstIterator begin(const OGRSimpleCurve *);
1540 friend inline ConstIterator end(const OGRSimpleCurve *);
1541
1542 public:
1543 ~OGRSimpleCurve() override;
1544
1545 OGRSimpleCurve &operator=(const OGRSimpleCurve &other);
1546
1547 OGRSimpleCurve &operator=(OGRSimpleCurve &&other);
1548
1550 typedef OGRPoint ChildType;
1551
1559 Iterator begin();
1561 Iterator end();
1569 ConstIterator begin() const;
1571 ConstIterator end() const;
1572
1573 // IWks Interface.
1574 size_t WkbSize() const override;
1575 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1576 size_t &nBytesConsumedOut) override;
1577 virtual OGRErr
1578 exportToWkb(unsigned char *,
1579 const OGRwkbExportOptions * = nullptr) const override;
1580
1581#ifndef DOXYGEN_XML
1582 using OGRGeometry::importFromWkt;
1583#endif
1584
1585 OGRErr importFromWkt(const char **) override;
1586
1587#ifndef DOXYGEN_XML
1588 using OGRGeometry::exportToWkt;
1589#endif
1590
1595 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1596 OGRErr *err = nullptr) const override;
1597
1598 // IGeometry interface.
1599 void empty() override;
1600 void getEnvelope(OGREnvelope *psEnvelope) const override;
1601 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1602 OGRBoolean IsEmpty() const override;
1603 OGRSimpleCurve *clone() const override = 0;
1604
1605 // ICurve methods.
1606 double get_Length() const override;
1607 void StartPoint(OGRPoint *) const override;
1608 void EndPoint(OGRPoint *) const override;
1609 void Value(double, OGRPoint *) const override;
1610 virtual double Project(const OGRPoint *) const;
1611 virtual OGRLineString *getSubLine(double, double, int) const;
1612
1613 // ILineString methods.
1614 int getNumPoints() const override
1615 {
1616 return nPointCount;
1617 }
1618
1619 void getPoint(int, OGRPoint *) const;
1620
1621 double getX(int i) const
1622 {
1623 return paoPoints[i].x;
1624 }
1625
1626 double getY(int i) const
1627 {
1628 return paoPoints[i].y;
1629 }
1630
1631 double getZ(int i) const;
1632 double getM(int i) const;
1633
1634 // ISpatialRelation
1635 OGRBoolean Equals(const OGRGeometry *) const override;
1636
1637 // non standard.
1638 bool setCoordinateDimension(int nDimension) override;
1639 bool set3D(OGRBoolean bIs3D) override;
1640 bool setMeasured(OGRBoolean bIsMeasured) override;
1641 bool setNumPoints(int nNewPointCount, int bZeroizeNewContent = TRUE);
1642 bool setPoint(int, OGRPoint *);
1643 bool setPoint(int, double, double);
1644 bool setZ(int, double);
1645 bool setM(int, double);
1646 bool setPoint(int, double, double, double);
1647 bool setPointM(int, double, double, double);
1648 bool setPoint(int, double, double, double, double);
1649 bool setPoints(int, const OGRRawPoint *, const double * = nullptr);
1650 bool setPointsM(int, const OGRRawPoint *, const double *);
1651 bool setPoints(int, const OGRRawPoint *, const double *, const double *);
1652 bool setPoints(int, const double *padfX, const double *padfY,
1653 const double *padfZIn = nullptr);
1654 bool setPointsM(int, const double *padfX, const double *padfY,
1655 const double *padfMIn = nullptr);
1656 bool setPoints(int, const double *padfX, const double *padfY,
1657 const double *padfZIn, const double *padfMIn);
1658 bool addPoint(const OGRPoint *);
1659 bool addPoint(double, double);
1660 bool addPoint(double, double, double);
1661 bool addPointM(double, double, double);
1662 bool addPoint(double, double, double, double);
1663
1664 bool removePoint(int);
1665
1666 void getPoints(OGRRawPoint *, double * = nullptr) const;
1667 void getPoints(void *pabyX, int nXStride, void *pabyY, int nYStride,
1668 void *pabyZ = nullptr, int nZStride = 0,
1669 void *pabyM = nullptr, int nMStride = 0) const;
1670
1671 void addSubLineString(const OGRLineString *, int nStartVertex = 0,
1672 int nEndVertex = -1);
1673 void reversePoints() override;
1674 OGRPointIterator *getPointIterator() const override;
1675
1676 // non-standard from OGRGeometry
1677 OGRErr transform(OGRCoordinateTransformation *poCT) override;
1678 void flattenTo2D() override;
1679 bool segmentize(double dfMaxLength) override;
1680
1681 void swapXY() override;
1682
1683 OGR_ALLOW_UPCAST_TO(Curve)
1684 OGR_ALLOW_CAST_TO_THIS(SimpleCurve)
1685};
1686
1688
1689 inline OGRSimpleCurve::Iterator begin(OGRSimpleCurve *poCurve)
1690{
1691 return poCurve->begin();
1692}
1693
1695 inline OGRSimpleCurve::Iterator end(OGRSimpleCurve *poCurve)
1696{
1697 return poCurve->end();
1698}
1699
1701 inline OGRSimpleCurve::ConstIterator begin(const OGRSimpleCurve *poCurve)
1702{
1703 return poCurve->begin();
1704}
1705
1707 inline OGRSimpleCurve::ConstIterator end(const OGRSimpleCurve *poCurve)
1708{
1709 return poCurve->end();
1710}
1711
1713
1714/************************************************************************/
1715/* OGRLineString */
1716/************************************************************************/
1717
1725 class CPL_DLL OGRLineString : public OGRSimpleCurve
1726{
1727 // cppcheck-suppress unusedPrivateFunction
1728 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
1729
1730 protected:
1732 static OGRLineString *TransferMembersAndDestroy(OGRLineString *poSrc,
1733 OGRLineString *poDst);
1734
1735 OGRCurveCasterToLineString GetCasterToLineString() const override;
1736 OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1737
1738 double get_AreaOfCurveSegments() const override;
1740
1741 static OGRLinearRing *CastToLinearRing(OGRLineString *poLS);
1742
1743 public:
1745 OGRLineString() = default;
1746 OGRLineString(const OGRLineString &other);
1747 OGRLineString(OGRLineString &&other);
1748
1749 OGRLineString &operator=(const OGRLineString &other);
1750 OGRLineString &operator=(OGRLineString &&other);
1751
1752 OGRLineString *clone() const override;
1753 virtual OGRLineString *
1754 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1755 const char *const *papszOptions = nullptr) const override;
1756 virtual OGRGeometry *
1757 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
1758 double get_Area() const override;
1759 virtual double get_GeodesicArea(
1760 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1761 virtual double get_GeodesicLength(
1762 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1763
1764 // Non-standard from OGRGeometry.
1765 OGRwkbGeometryType getGeometryType() const override;
1766 const char *getGeometryName() const override;
1767 int isClockwise() const override;
1768
1770 inline OGRSimpleCurve *toUpperClass()
1771 {
1772 return this;
1773 }
1774
1776 inline const OGRSimpleCurve *toUpperClass() const
1777 {
1778 return this;
1779 }
1780
1781 void accept(IOGRGeometryVisitor *visitor) override
1782 {
1783 visitor->visit(this);
1784 }
1785
1786 void accept(IOGRConstGeometryVisitor *visitor) const override
1787 {
1788 visitor->visit(this);
1789 }
1790
1791 OGR_ALLOW_UPCAST_TO(SimpleCurve)
1792 OGR_ALLOW_CAST_TO_THIS(LineString)
1793};
1794
1795/************************************************************************/
1796/* OGRLinearRing */
1797/************************************************************************/
1798
1819 class CPL_DLL OGRLinearRing : public OGRLineString
1820{
1821 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
1822
1823 // IWks Interface - Note this isn't really a first class object
1824 // for the purposes of WKB form. These methods always fail since this
1825 // object can't be serialized on its own.
1826 size_t WkbSize() const override;
1827 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1828 size_t &nBytesConsumedOut) override;
1829 OGRErr exportToWkb(unsigned char *,
1830 const OGRwkbExportOptions * = nullptr) const override;
1831
1832 protected:
1834 friend class OGRPolygon;
1835 friend class OGRTriangle;
1836
1837 // These are not IWks compatible ... just a convenience for OGRPolygon.
1838 virtual size_t _WkbSize(int _flags) const;
1839 virtual OGRErr _importFromWkb(OGRwkbByteOrder, int _flags,
1840 const unsigned char *, size_t,
1841 size_t &nBytesConsumedOut);
1842 virtual OGRErr _exportToWkb(int _flags, unsigned char *,
1843 const OGRwkbExportOptions *) const;
1844
1845 OGRCurveCasterToLineString GetCasterToLineString() const override;
1846 OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1848
1849 static OGRLineString *CastToLineString(OGRLinearRing *poLR);
1850
1851 public:
1853 OGRLinearRing() = default;
1854 OGRLinearRing(const OGRLinearRing &other);
1856 OGRLinearRing(OGRLinearRing &&other) = default;
1857 explicit OGRLinearRing(const OGRLinearRing *);
1858
1859 OGRLinearRing &operator=(const OGRLinearRing &other);
1861 OGRLinearRing &operator=(OGRLinearRing &&other) = default;
1862
1863 // Non standard.
1864 const char *getGeometryName() const override;
1865 OGRLinearRing *clone() const override;
1866
1868 void reverseWindingOrder()
1869 CPL_WARN_DEPRECATED("Use reversePoints() instead");
1871
1872 void closeRings() override;
1873 OGRBoolean isPointInRing(const OGRPoint *pt,
1874 int bTestEnvelope = TRUE) const;
1875 OGRBoolean isPointOnRingBoundary(const OGRPoint *pt,
1876 int bTestEnvelope = TRUE) const;
1877 OGRErr transform(OGRCoordinateTransformation *poCT) override;
1878
1880 inline OGRLineString *toUpperClass()
1881 {
1882 return this;
1883 }
1884
1886 inline const OGRLineString *toUpperClass() const
1887 {
1888 return this;
1889 }
1890
1891 void accept(IOGRGeometryVisitor *visitor) override
1892 {
1893 visitor->visit(this);
1894 }
1895
1896 void accept(IOGRConstGeometryVisitor *visitor) const override
1897 {
1898 visitor->visit(this);
1899 }
1900
1901 OGR_ALLOW_UPCAST_TO(LineString)
1902 OGR_ALLOW_CAST_TO_THIS(LinearRing)
1903};
1904
1905/************************************************************************/
1906/* OGRCircularString */
1907/************************************************************************/
1908
1920 class CPL_DLL OGRCircularString : public OGRSimpleCurve
1921{
1922 private:
1923 void ExtendEnvelopeWithCircular(OGREnvelope *psEnvelope) const;
1924 OGRBoolean IsValidFast() const;
1925 int IsFullCircle(double &cx, double &cy, double &square_R) const;
1926
1927 protected:
1929 OGRCurveCasterToLineString GetCasterToLineString() const override;
1930 OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1931 int IntersectsPoint(const OGRPoint *p) const override;
1932 int ContainsPoint(const OGRPoint *p) const override;
1933 double get_AreaOfCurveSegments() const override;
1935
1936 public:
1938 OGRCircularString() = default;
1939
1940 OGRCircularString(const OGRCircularString &other);
1942 OGRCircularString(OGRCircularString &&other) = default;
1943
1944 OGRCircularString &operator=(const OGRCircularString &other);
1946 OGRCircularString &operator=(OGRCircularString &&other) = default;
1947
1948 // IWks Interface.
1949 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1950 size_t &nBytesConsumedOut) override;
1951 OGRErr exportToWkb(unsigned char *,
1952 const OGRwkbExportOptions * = nullptr) const override;
1953
1954#ifndef DOXYGEN_XML
1955 using OGRGeometry::importFromWkt;
1956#endif
1957
1958 OGRErr importFromWkt(const char **) override;
1959
1960#ifndef DOXYGEN_XML
1961 using OGRGeometry::exportToWkt;
1962#endif
1963
1968 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1969 OGRErr *err = nullptr) const override;
1970
1971 // IGeometry interface.
1972 OGRBoolean IsValid() const override;
1973 void getEnvelope(OGREnvelope *psEnvelope) const override;
1974 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1975 OGRCircularString *clone() const override;
1976
1977 // ICurve methods.
1978 double get_Length() const override;
1979 virtual OGRLineString *
1980 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1981 const char *const *papszOptions = nullptr) const override;
1982 void Value(double, OGRPoint *) const override;
1983 double get_Area() const override;
1984 virtual double get_GeodesicArea(
1985 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1986 virtual double get_GeodesicLength(
1987 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1988
1989 // Non-standard from OGRGeometry.
1990 OGRwkbGeometryType getGeometryType() const override;
1991 const char *getGeometryName() const override;
1992 bool segmentize(double dfMaxLength) override;
1993 virtual OGRBoolean
1994 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
1995 virtual OGRGeometry *
1996 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
1997 const char *const *papszOptions = nullptr) const override;
1998
2000 inline OGRSimpleCurve *toUpperClass()
2001 {
2002 return this;
2003 }
2004
2006 inline const OGRSimpleCurve *toUpperClass() const
2007 {
2008 return this;
2009 }
2010
2011 void accept(IOGRGeometryVisitor *visitor) override
2012 {
2013 visitor->visit(this);
2014 }
2015
2016 void accept(IOGRConstGeometryVisitor *visitor) const override
2017 {
2018 visitor->visit(this);
2019 }
2020
2021 OGR_ALLOW_UPCAST_TO(SimpleCurve)
2022 OGR_ALLOW_CAST_TO_THIS(CircularString)
2023};
2024
2025/************************************************************************/
2026/* OGRCurveCollection */
2027/************************************************************************/
2028
2039 class CPL_DLL OGRCurveCollection
2040{
2041 protected:
2042 friend class OGRCompoundCurve;
2043 friend class OGRCurvePolygon;
2044 friend class OGRPolygon;
2045 friend class OGRTriangle;
2046
2047 int nCurveCount = 0;
2048 OGRCurve **papoCurves = nullptr;
2049
2050 public:
2051 OGRCurveCollection() = default;
2052 OGRCurveCollection(const OGRCurveCollection &other);
2053 OGRCurveCollection(OGRCurveCollection &&other);
2054 ~OGRCurveCollection();
2055
2056 OGRCurveCollection &operator=(const OGRCurveCollection &other);
2057 OGRCurveCollection &operator=(OGRCurveCollection &&other);
2058
2060 typedef OGRCurve ChildType;
2061
2064 OGRCurve **begin()
2065 {
2066 return papoCurves;
2067 }
2068
2070 OGRCurve **end()
2071 {
2072 return papoCurves + nCurveCount;
2073 }
2074
2077 const OGRCurve *const *begin() const
2078 {
2079 return papoCurves;
2080 }
2081
2083 const OGRCurve *const *end() const
2084 {
2085 return papoCurves + nCurveCount;
2086 }
2087
2088 void empty(OGRGeometry *poGeom);
2089 OGRBoolean IsEmpty() const;
2090 void getEnvelope(OGREnvelope *psEnvelope) const;
2091 void getEnvelope(OGREnvelope3D *psEnvelope) const;
2092
2093 OGRErr addCurveDirectly(OGRGeometry *poGeom, OGRCurve *poCurve,
2094 int bNeedRealloc);
2095 size_t WkbSize() const;
2096 OGRErr importPreambleFromWkb(OGRGeometry *poGeom,
2097 const unsigned char *pabyData, size_t &nSize,
2098 size_t &nDataOffset,
2099 OGRwkbByteOrder &eByteOrder,
2100 size_t nMinSubGeomSize,
2101 OGRwkbVariant eWkbVariant);
2102 OGRErr
2103 importBodyFromWkb(OGRGeometry *poGeom, const unsigned char *pabyData,
2104 size_t nSize, bool bAcceptCompoundCurve,
2105 OGRErr (*pfnAddCurveDirectlyFromWkb)(OGRGeometry *poGeom,
2106 OGRCurve *poCurve),
2107 OGRwkbVariant eWkbVariant, size_t &nBytesConsumedOut);
2108 std::string exportToWkt(const OGRGeometry *geom, const OGRWktOptions &opts,
2109 OGRErr *err) const;
2110 OGRErr exportToWkb(const OGRGeometry *poGeom, unsigned char *,
2111 const OGRwkbExportOptions * = nullptr) const;
2112 OGRBoolean Equals(const OGRCurveCollection *poOCC) const;
2113 bool setCoordinateDimension(OGRGeometry *poGeom, int nNewDimension);
2114 bool set3D(OGRGeometry *poGeom, OGRBoolean bIs3D);
2115 bool setMeasured(OGRGeometry *poGeom, OGRBoolean bIsMeasured);
2116 void assignSpatialReference(OGRGeometry *poGeom,
2117 const OGRSpatialReference *poSR);
2118 int getNumCurves() const;
2119 OGRCurve *getCurve(int);
2120 const OGRCurve *getCurve(int) const;
2121 OGRCurve *stealCurve(int);
2122
2123 OGRErr removeCurve(int iIndex, bool bDelete = true);
2124
2125 bool hasEmptyParts() const;
2126 void removeEmptyParts();
2127
2128 void reversePoints();
2129
2130 OGRErr transform(OGRGeometry *poGeom, OGRCoordinateTransformation *poCT);
2131 void flattenTo2D(OGRGeometry *poGeom);
2132 bool segmentize(double dfMaxLength);
2133 void swapXY();
2134 OGRBoolean hasCurveGeometry(int bLookForNonLinear) const;
2135};
2136
2138
2139/************************************************************************/
2140/* OGRCompoundCurve */
2141/************************************************************************/
2142
2152 class CPL_DLL OGRCompoundCurve : public OGRCurve
2153{
2154 private:
2155 OGRCurveCollection oCC{};
2156
2157 OGRErr addCurveDirectlyInternal(OGRCurve *poCurve, double dfToleranceEps,
2158 int bNeedRealloc);
2159 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2160 OGRCurve *poCurve);
2161 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2162 OGRCurve *poCurve);
2163 OGRLineString *CurveToLineInternal(double dfMaxAngleStepSizeDegrees,
2164 const char *const *papszOptions,
2165 int bIsLinearRing) const;
2166 // cppcheck-suppress unusedPrivateFunction
2167 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
2168 // cppcheck-suppress unusedPrivateFunction
2169 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
2170
2171 protected:
2173 static OGRLineString *CastToLineString(OGRCompoundCurve *poCC);
2174 static OGRLinearRing *CastToLinearRing(OGRCompoundCurve *poCC);
2175
2176 OGRCurveCasterToLineString GetCasterToLineString() const override;
2177 OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
2179
2180 public:
2182 OGRCompoundCurve() = default;
2183
2184 OGRCompoundCurve(const OGRCompoundCurve &other);
2186 OGRCompoundCurve(OGRCompoundCurve &&other) = default;
2187
2188 OGRCompoundCurve &operator=(const OGRCompoundCurve &other);
2190 OGRCompoundCurve &operator=(OGRCompoundCurve &&other) = default;
2191
2193 typedef OGRCurve ChildType;
2194
2197 ChildType **begin()
2198 {
2199 return oCC.begin();
2200 }
2201
2203 ChildType **end()
2204 {
2205 return oCC.end();
2206 }
2207
2210 const ChildType *const *begin() const
2211 {
2212 return oCC.begin();
2213 }
2214
2216 const ChildType *const *end() const
2217 {
2218 return oCC.end();
2219 }
2220
2221 // IWks Interface
2222 size_t WkbSize() const override;
2223 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2224 size_t &nBytesConsumedOut) override;
2225 OGRErr exportToWkb(unsigned char *,
2226 const OGRwkbExportOptions * = nullptr) const override;
2227
2228#ifndef DOXYGEN_XML
2229 using OGRGeometry::importFromWkt;
2230#endif
2231
2232 OGRErr importFromWkt(const char **) override;
2233
2234#ifndef DOXYGEN_XML
2235 using OGRGeometry::exportToWkt;
2236#endif
2237
2242 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2243 OGRErr *err = nullptr) const override;
2244
2245 // IGeometry interface.
2246 OGRCompoundCurve *clone() const override;
2247 void empty() override;
2248 void getEnvelope(OGREnvelope *psEnvelope) const override;
2249 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2250 OGRBoolean IsEmpty() const override;
2251
2252 // ICurve methods.
2253 double get_Length() const override;
2254 void StartPoint(OGRPoint *) const override;
2255 void EndPoint(OGRPoint *) const override;
2256 void Value(double, OGRPoint *) const override;
2257 virtual OGRLineString *
2258 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
2259 const char *const *papszOptions = nullptr) const override;
2260
2261 int getNumPoints() const override;
2262 double get_AreaOfCurveSegments() const override;
2263 double get_Area() const override;
2264 virtual double get_GeodesicArea(
2265 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2266 virtual double get_GeodesicLength(
2267 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2268
2269 // ISpatialRelation.
2270 OGRBoolean Equals(const OGRGeometry *) const override;
2271
2272 // ICompoundCurve method.
2273 int getNumCurves() const;
2274 OGRCurve *getCurve(int);
2275 const OGRCurve *getCurve(int) const;
2276
2277 // Non-standard.
2278 bool setCoordinateDimension(int nDimension) override;
2279 bool set3D(OGRBoolean bIs3D) override;
2280 bool setMeasured(OGRBoolean bIsMeasured) override;
2281
2282 virtual void
2283 assignSpatialReference(const OGRSpatialReference *poSR) override;
2284
2288 static constexpr double DEFAULT_TOLERANCE_EPSILON = 1e-14;
2289
2290 OGRErr addCurve(const OGRCurve *,
2291 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2292 OGRErr addCurveDirectly(OGRCurve *,
2293 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2294 OGRErr addCurve(std::unique_ptr<OGRCurve>,
2295 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2296 OGRCurve *stealCurve(int);
2297 OGRPointIterator *getPointIterator() const override;
2298 void reversePoints() override;
2299
2300 // Non-standard from OGRGeometry.
2301 OGRwkbGeometryType getGeometryType() const override;
2302 const char *getGeometryName() const override;
2303 OGRErr transform(OGRCoordinateTransformation *poCT) override;
2304 void flattenTo2D() override;
2305 bool segmentize(double dfMaxLength) override;
2306 virtual OGRBoolean
2307 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2308 virtual OGRGeometry *
2309 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2310 const char *const *papszOptions = nullptr) const override;
2311
2312 void accept(IOGRGeometryVisitor *visitor) override
2313 {
2314 visitor->visit(this);
2315 }
2316
2317 void accept(IOGRConstGeometryVisitor *visitor) const override
2318 {
2319 visitor->visit(this);
2320 }
2321
2322 void swapXY() override;
2323
2324 bool hasEmptyParts() const override;
2325 void removeEmptyParts() override;
2326
2327 OGR_ALLOW_UPCAST_TO(Curve)
2328 OGR_ALLOW_CAST_TO_THIS(CompoundCurve)
2329};
2330
2332
2333 inline const OGRCompoundCurve::ChildType *const *
2334 begin(const OGRCompoundCurve *poCurve)
2335{
2336 return poCurve->begin();
2337}
2338
2340 inline const OGRCompoundCurve::ChildType *const *
2341 end(const OGRCompoundCurve *poCurve)
2342{
2343 return poCurve->end();
2344}
2345
2347 inline OGRCompoundCurve::ChildType **begin(OGRCompoundCurve *poCurve)
2348{
2349 return poCurve->begin();
2350}
2351
2353 inline OGRCompoundCurve::ChildType **end(OGRCompoundCurve *poCurve)
2354{
2355 return poCurve->end();
2356}
2357
2359
2360/************************************************************************/
2361/* OGRSurface */
2362/************************************************************************/
2363
2369 class CPL_DLL OGRSurface : public OGRGeometry
2370{
2371 protected:
2373 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const = 0;
2374 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const = 0;
2376
2377 public:
2378 virtual double get_Area() const = 0;
2379 virtual double get_GeodesicArea(
2380 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
2381 virtual double get_Length() const = 0;
2382 virtual double get_GeodesicLength(
2383 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
2384
2385 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const;
2386
2387 OGRSurface *clone() const override = 0;
2388
2390 static OGRPolygon *CastToPolygon(OGRSurface *poSurface);
2391 static OGRCurvePolygon *CastToCurvePolygon(OGRSurface *poSurface);
2393
2394 OGR_FORBID_DOWNCAST_TO_POINT
2395 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
2396 OGR_ALLOW_CAST_TO_THIS(Surface)
2397 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
2398};
2399
2400/************************************************************************/
2401/* OGRCurvePolygon */
2402/************************************************************************/
2403
2416 class CPL_DLL OGRCurvePolygon : public OGRSurface
2417{
2418 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2419
2420 private:
2421 OGRBoolean IntersectsPoint(const OGRPoint *p) const;
2422 OGRBoolean ContainsPoint(const OGRPoint *p) const;
2423
2424 virtual bool isRingCorrectType(const OGRCurve *poRing) const;
2425
2426 virtual bool checkRing(const OGRCurve *poNewRing) const;
2427 OGRErr addRingDirectlyInternal(OGRCurve *poCurve, int bNeedRealloc);
2428 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2429 OGRCurve *poCurve);
2430 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2431 OGRCurve *poCurve);
2432
2433 protected:
2435 friend class OGRPolygon;
2436 friend class OGRTriangle;
2437 OGRCurveCollection oCC{};
2438
2439 OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2440 virtual OGRSurfaceCasterToCurvePolygon
2441 GetCasterToCurvePolygon() const override;
2442
2444
2445 static OGRPolygon *CastToPolygon(OGRCurvePolygon *poCP);
2446
2447 public:
2449 OGRCurvePolygon() = default;
2450
2451 OGRCurvePolygon(const OGRCurvePolygon &);
2453 OGRCurvePolygon(OGRCurvePolygon &&) = default;
2454
2455 OGRCurvePolygon &operator=(const OGRCurvePolygon &other);
2457 OGRCurvePolygon &operator=(OGRCurvePolygon &&other) = default;
2458
2460 typedef OGRCurve ChildType;
2461
2464 ChildType **begin()
2465 {
2466 return oCC.begin();
2467 }
2468
2470 ChildType **end()
2471 {
2472 return oCC.end();
2473 }
2474
2477 const ChildType *const *begin() const
2478 {
2479 return oCC.begin();
2480 }
2481
2483 const ChildType *const *end() const
2484 {
2485 return oCC.end();
2486 }
2487
2488 // Non standard (OGRGeometry).
2489 const char *getGeometryName() const override;
2490 OGRwkbGeometryType getGeometryType() const override;
2491 OGRCurvePolygon *clone() const override;
2492 void empty() override;
2493 OGRErr transform(OGRCoordinateTransformation *poCT) override;
2494 void flattenTo2D() override;
2495 OGRBoolean IsEmpty() const override;
2496 bool segmentize(double dfMaxLength) override;
2497 virtual OGRBoolean
2498 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2499 virtual OGRGeometry *
2500 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2501 const char *const *papszOptions = nullptr) const override;
2502 virtual double get_GeodesicArea(
2503 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2504 virtual double get_GeodesicLength(
2505 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2506
2507 // ISurface Interface
2508 double get_Area() const override;
2509
2510 double get_Length() const override;
2511
2512 // IWks Interface
2513 size_t WkbSize() const override;
2514 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2515 size_t &nBytesConsumedOut) override;
2516 OGRErr exportToWkb(unsigned char *,
2517 const OGRwkbExportOptions * = nullptr) const override;
2518
2519#ifndef DOXYGEN_XML
2520 using OGRGeometry::importFromWkt;
2521#endif
2522
2523 OGRErr importFromWkt(const char **) override;
2524
2525#ifndef DOXYGEN_XML
2526 using OGRGeometry::exportToWkt;
2527#endif
2528
2533 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2534 OGRErr *err = nullptr) const override;
2535
2536 // IGeometry
2537 int getDimension() const override;
2538 void getEnvelope(OGREnvelope *psEnvelope) const override;
2539 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2540
2541 // ICurvePolygon
2542 virtual OGRPolygon *
2543 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2544 const char *const *papszOptions = nullptr) const;
2545
2546 // ISpatialRelation
2547 OGRBoolean Equals(const OGRGeometry *) const override;
2548 OGRBoolean Intersects(const OGRGeometry *) const override;
2549 OGRBoolean Contains(const OGRGeometry *) const override;
2550
2551 // Non standard
2552 bool setCoordinateDimension(int nDimension) override;
2553 bool set3D(OGRBoolean bIs3D) override;
2554 bool setMeasured(OGRBoolean bIsMeasured) override;
2555
2556 virtual void
2557 assignSpatialReference(const OGRSpatialReference *poSR) override;
2558
2559 virtual OGRErr addRing(const OGRCurve *);
2560 virtual OGRErr addRingDirectly(OGRCurve *);
2561 OGRErr addRing(std::unique_ptr<OGRCurve>);
2562
2563 OGRCurve *getExteriorRingCurve();
2564 const OGRCurve *getExteriorRingCurve() const;
2565 int getNumInteriorRings() const;
2566 OGRCurve *getInteriorRingCurve(int);
2567 const OGRCurve *getInteriorRingCurve(int) const;
2568
2569 OGRCurve *stealExteriorRingCurve();
2570
2571 OGRErr removeRing(int iIndex, bool bDelete = true);
2572
2573 void accept(IOGRGeometryVisitor *visitor) override
2574 {
2575 visitor->visit(this);
2576 }
2577
2578 void accept(IOGRConstGeometryVisitor *visitor) const override
2579 {
2580 visitor->visit(this);
2581 }
2582
2583 void swapXY() override;
2584
2585 bool hasEmptyParts() const override;
2586 void removeEmptyParts() override;
2587
2588 OGR_ALLOW_UPCAST_TO(Surface)
2589 OGR_ALLOW_CAST_TO_THIS(CurvePolygon)
2590};
2591
2593
2594 inline const OGRCurvePolygon::ChildType *const *
2595 begin(const OGRCurvePolygon *poGeom)
2596{
2597 return poGeom->begin();
2598}
2599
2601 inline const OGRCurvePolygon::ChildType *const *
2602 end(const OGRCurvePolygon *poGeom)
2603{
2604 return poGeom->end();
2605}
2606
2608 inline OGRCurvePolygon::ChildType **begin(OGRCurvePolygon *poGeom)
2609{
2610 return poGeom->begin();
2611}
2612
2614 inline OGRCurvePolygon::ChildType **end(OGRCurvePolygon *poGeom)
2615{
2616 return poGeom->end();
2617}
2618
2620
2621/************************************************************************/
2622/* OGRPolygon */
2623/************************************************************************/
2624
2634 class CPL_DLL OGRPolygon : public OGRCurvePolygon
2635{
2636 static OGRCurvePolygon *CasterToCurvePolygon(OGRSurface *poSurface);
2637
2638 protected:
2640 friend class OGRMultiSurface;
2641 friend class OGRPolyhedralSurface;
2642 friend class OGRTriangulatedSurface;
2643
2644 bool isRingCorrectType(const OGRCurve *poRing) const override;
2645
2646 bool checkRing(const OGRCurve *poNewRing) const override;
2647 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2648 int bHasM, OGRRawPoint *&paoPoints,
2649 int &nMaxPoints, double *&padfZ);
2650
2651 static OGRCurvePolygon *CastToCurvePolygon(OGRPolygon *poPoly);
2652
2653 OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2654 virtual OGRSurfaceCasterToCurvePolygon
2655 GetCasterToCurvePolygon() const override;
2657
2658 public:
2660 OGRPolygon() = default;
2661
2662 OGRPolygon(double x1, double y1, double x2, double y2);
2663
2664 explicit OGRPolygon(const OGREnvelope &envelope);
2665
2666 OGRPolygon(const OGRPolygon &other);
2668 OGRPolygon(OGRPolygon &&other) = default;
2669
2670 OGRPolygon &operator=(const OGRPolygon &other);
2672 OGRPolygon &operator=(OGRPolygon &&other) = default;
2673
2675 typedef OGRLinearRing ChildType;
2676
2679 ChildType **begin()
2680 {
2681 return reinterpret_cast<ChildType **>(oCC.begin());
2682 }
2683
2685 ChildType **end()
2686 {
2687 return reinterpret_cast<ChildType **>(oCC.end());
2688 }
2689
2692 const ChildType *const *begin() const
2693 {
2694 return reinterpret_cast<const ChildType *const *>(oCC.begin());
2695 }
2696
2698 const ChildType *const *end() const
2699 {
2700 return reinterpret_cast<const ChildType *const *>(oCC.end());
2701 }
2702
2703 // Non-standard (OGRGeometry).
2704 const char *getGeometryName() const override;
2705 OGRwkbGeometryType getGeometryType() const override;
2706 OGRPolygon *clone() const override;
2707 virtual OGRBoolean
2708 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2709 virtual OGRGeometry *
2710 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2711 virtual OGRGeometry *
2712 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2713 const char *const *papszOptions = nullptr) const override;
2714
2715 // IWks Interface.
2716 size_t WkbSize() const override;
2717 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2718 size_t &nBytesConsumedOut) override;
2719 OGRErr exportToWkb(unsigned char *,
2720 const OGRwkbExportOptions * = nullptr) const override;
2721
2722#ifndef DOXYGEN_XML
2723 using OGRGeometry::importFromWkt;
2724#endif
2725
2726 OGRErr importFromWkt(const char **) override;
2727
2728#ifndef DOXYGEN_XML
2729 using OGRGeometry::exportToWkt;
2730#endif
2731
2736 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2737 OGRErr *err = nullptr) const override;
2738
2739 // ICurvePolygon.
2740 virtual OGRPolygon *
2741 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2742 const char *const *papszOptions = nullptr) const override;
2743
2744 OGRLinearRing *getExteriorRing();
2745 const OGRLinearRing *getExteriorRing() const;
2746 virtual OGRLinearRing *getInteriorRing(int);
2747 virtual const OGRLinearRing *getInteriorRing(int) const;
2748
2749 OGRLinearRing *stealExteriorRing();
2750 virtual OGRLinearRing *stealInteriorRing(int);
2751
2752 OGRBoolean IsPointOnSurface(const OGRPoint *) const;
2753
2755 inline OGRCurvePolygon *toUpperClass()
2756 {
2757 return this;
2758 }
2759
2761 inline const OGRCurvePolygon *toUpperClass() const
2762 {
2763 return this;
2764 }
2765
2766 void accept(IOGRGeometryVisitor *visitor) override
2767 {
2768 visitor->visit(this);
2769 }
2770
2771 void accept(IOGRConstGeometryVisitor *visitor) const override
2772 {
2773 visitor->visit(this);
2774 }
2775
2776 void closeRings() override;
2777
2778 OGR_ALLOW_UPCAST_TO(CurvePolygon)
2779 OGR_ALLOW_CAST_TO_THIS(Polygon)
2780};
2781
2783
2784 inline const OGRPolygon::ChildType *const *begin(const OGRPolygon *poGeom)
2785{
2786 return poGeom->begin();
2787}
2788
2790 inline const OGRPolygon::ChildType *const *end(const OGRPolygon *poGeom)
2791{
2792 return poGeom->end();
2793}
2794
2796 inline OGRPolygon::ChildType **begin(OGRPolygon *poGeom)
2797{
2798 return poGeom->begin();
2799}
2800
2802 inline OGRPolygon::ChildType **end(OGRPolygon *poGeom)
2803{
2804 return poGeom->end();
2805}
2806
2808
2809/************************************************************************/
2810/* OGRTriangle */
2811/************************************************************************/
2812
2818 class CPL_DLL OGRTriangle : public OGRPolygon
2819{
2820 private:
2821 // cppcheck-suppress unusedPrivateFunction
2822 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2823 bool quickValidityCheck() const;
2824
2825 protected:
2827 OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2828 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2829 int bHasM, OGRRawPoint *&paoPoints,
2830 int &nMaxPoints,
2831 double *&padfZ) override;
2833
2834 public:
2836 OGRTriangle() = default;
2837 OGRTriangle(const OGRPoint &p, const OGRPoint &q, const OGRPoint &r);
2838 OGRTriangle(const OGRTriangle &other);
2840 OGRTriangle(OGRTriangle &&other) = default;
2841 OGRTriangle(const OGRPolygon &other, OGRErr &eErr);
2842 OGRTriangle &operator=(const OGRTriangle &other);
2844 OGRTriangle &operator=(OGRTriangle &&other) = default;
2845
2846 const char *getGeometryName() const override;
2847 OGRwkbGeometryType getGeometryType() const override;
2848 OGRTriangle *clone() const override;
2849
2850 // IWks Interface.
2851 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2852 size_t &nBytesConsumedOut) override;
2853
2854 // New methods rewritten from OGRPolygon/OGRCurvePolygon/OGRGeometry.
2855 OGRErr addRingDirectly(OGRCurve *poNewRing) override;
2856
2858 inline OGRPolygon *toUpperClass()
2859 {
2860 return this;
2861 }
2862
2864 inline const OGRPolygon *toUpperClass() const
2865 {
2866 return this;
2867 }
2868
2869 void accept(IOGRGeometryVisitor *visitor) override
2870 {
2871 visitor->visit(this);
2872 }
2873
2874 void accept(IOGRConstGeometryVisitor *visitor) const override
2875 {
2876 visitor->visit(this);
2877 }
2878
2880 static OGRGeometry *CastToPolygon(OGRGeometry *poGeom);
2882
2883 OGR_ALLOW_UPCAST_TO(Polygon)
2884 OGR_ALLOW_CAST_TO_THIS(Triangle)
2885};
2886
2887/************************************************************************/
2888/* OGRGeometryCollection */
2889/************************************************************************/
2890
2898 class CPL_DLL OGRGeometryCollection : public OGRGeometry
2899{
2900 OGRErr importFromWktInternal(const char **ppszInput, int nRecLevel);
2901
2902 protected:
2904 int nGeomCount = 0;
2905 OGRGeometry **papoGeoms = nullptr;
2906
2907 std::string
2908 exportToWktInternal(const OGRWktOptions &opts, OGRErr *err,
2909 const std::string &exclude = std::string()) const;
2910 static OGRGeometryCollection *
2911 TransferMembersAndDestroy(OGRGeometryCollection *poSrc,
2912 OGRGeometryCollection *poDst);
2913
2914 OGRErr importFromWkbInternal(const unsigned char *pabyData, size_t nSize,
2915 int nRecLevel, OGRwkbVariant,
2916 size_t &nBytesConsumedOut);
2918 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
2919
2920 public:
2922 OGRGeometryCollection() = default;
2923
2924 OGRGeometryCollection(const OGRGeometryCollection &other);
2925 OGRGeometryCollection(OGRGeometryCollection &&other);
2926 ~OGRGeometryCollection() override;
2927
2928 OGRGeometryCollection &operator=(const OGRGeometryCollection &other);
2929 OGRGeometryCollection &operator=(OGRGeometryCollection &&other);
2930
2932 typedef OGRGeometry ChildType;
2933
2936 ChildType **begin()
2937 {
2938 return papoGeoms;
2939 }
2940
2942 ChildType **end()
2943 {
2944 return papoGeoms + nGeomCount;
2945 }
2946
2949 const ChildType *const *begin() const
2950 {
2951 return papoGeoms;
2952 }
2953
2955 const ChildType *const *end() const
2956 {
2957 return papoGeoms + nGeomCount;
2958 }
2959
2960 // Non standard (OGRGeometry).
2961 const char *getGeometryName() const override;
2962 OGRwkbGeometryType getGeometryType() const override;
2963 OGRGeometryCollection *clone() const override;
2964 void empty() override;
2965 OGRErr transform(OGRCoordinateTransformation *poCT) override;
2966 void flattenTo2D() override;
2967 OGRBoolean IsEmpty() const override;
2968 bool segmentize(double dfMaxLength) override;
2969 virtual OGRBoolean
2970 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2971 virtual OGRGeometry *
2972 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2973 virtual OGRGeometry *
2974 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2975 const char *const *papszOptions = nullptr) const override;
2976 virtual double
2977 get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const;
2978 virtual double get_GeodesicLength(
2979 const OGRSpatialReference *poSRSOverride = nullptr) const;
2980
2981 // IWks Interface
2982 size_t WkbSize() const override;
2983 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2984 size_t &nBytesConsumedOut) override;
2985 OGRErr exportToWkb(unsigned char *,
2986 const OGRwkbExportOptions * = nullptr) const override;
2987
2988#ifndef DOXYGEN_XML
2989 using OGRGeometry::importFromWkt;
2990#endif
2991
2992 OGRErr importFromWkt(const char **) override;
2993
2994#ifndef DOXYGEN_XML
2995 using OGRGeometry::exportToWkt;
2996#endif
2997
3002 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3003 OGRErr *err = nullptr) const override;
3004
3005 virtual double get_Length() const;
3006 virtual double get_Area() const;
3007
3008 // IGeometry methods
3009 int getDimension() const override;
3010 void getEnvelope(OGREnvelope *psEnvelope) const override;
3011 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3012
3013 // IGeometryCollection
3014 int getNumGeometries() const;
3015 OGRGeometry *getGeometryRef(int);
3016 const OGRGeometry *getGeometryRef(int) const;
3017
3018 // ISpatialRelation
3019 OGRBoolean Equals(const OGRGeometry *) const override;
3020
3021 // Non standard
3022 bool setCoordinateDimension(int nDimension) override;
3023 bool set3D(OGRBoolean bIs3D) override;
3024 bool setMeasured(OGRBoolean bIsMeasured) override;
3025 virtual OGRErr addGeometry(const OGRGeometry *);
3026 virtual OGRErr addGeometryDirectly(OGRGeometry *);
3027 OGRErr addGeometry(std::unique_ptr<OGRGeometry> geom);
3028 virtual OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3029 std::unique_ptr<OGRGeometry> stealGeometry(int iIndex);
3030
3031 bool hasEmptyParts() const override;
3032 void removeEmptyParts() override;
3033
3034 virtual void
3035 assignSpatialReference(const OGRSpatialReference *poSR) override;
3036
3037 void closeRings() override;
3038
3039 void swapXY() override;
3040
3041 void accept(IOGRGeometryVisitor *visitor) override
3042 {
3043 visitor->visit(this);
3044 }
3045
3046 void accept(IOGRConstGeometryVisitor *visitor) const override
3047 {
3048 visitor->visit(this);
3049 }
3050
3051 static OGRGeometryCollection *
3052 CastToGeometryCollection(OGRGeometryCollection *poSrc);
3053
3054 OGR_FORBID_DOWNCAST_TO_POINT
3055 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
3056 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
3057 OGR_ALLOW_CAST_TO_THIS(GeometryCollection)
3058};
3059
3061
3062 inline const OGRGeometryCollection::ChildType *const *
3063 begin(const OGRGeometryCollection *poGeom)
3064{
3065 return poGeom->begin();
3066}
3067
3069 inline const OGRGeometryCollection::ChildType *const *
3070 end(const OGRGeometryCollection *poGeom)
3071{
3072 return poGeom->end();
3073}
3074
3076 inline OGRGeometryCollection::ChildType **begin(OGRGeometryCollection *poGeom)
3077{
3078 return poGeom->begin();
3079}
3080
3082 inline OGRGeometryCollection::ChildType **end(OGRGeometryCollection *poGeom)
3083{
3084 return poGeom->end();
3085}
3086
3088
3089/************************************************************************/
3090/* OGRMultiSurface */
3091/************************************************************************/
3092
3098 class CPL_DLL OGRMultiSurface : public OGRGeometryCollection
3099{
3100 protected:
3101 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3102
3103 public:
3105 OGRMultiSurface() = default;
3106
3107 OGRMultiSurface(const OGRMultiSurface &other);
3109 OGRMultiSurface(OGRMultiSurface &&other) = default;
3110
3111 OGRMultiSurface &operator=(const OGRMultiSurface &other);
3113 OGRMultiSurface &operator=(OGRMultiSurface &&other) = default;
3114
3116 typedef OGRSurface ChildType;
3117
3120 ChildType **begin()
3121 {
3122 return reinterpret_cast<ChildType **>(papoGeoms);
3123 }
3124
3126 ChildType **end()
3127 {
3128 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3129 }
3130
3133 const ChildType *const *begin() const
3134 {
3135 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3136 }
3137
3139 const ChildType *const *end() const
3140 {
3141 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3142 nGeomCount);
3143 }
3144
3145 // Non standard (OGRGeometry).
3146 const char *getGeometryName() const override;
3147 OGRwkbGeometryType getGeometryType() const override;
3148 OGRMultiSurface *clone() const override;
3149
3150#ifndef DOXYGEN_XML
3151 using OGRGeometry::importFromWkt;
3152#endif
3153
3154 OGRErr importFromWkt(const char **) override;
3155
3156#ifndef DOXYGEN_XML
3157 using OGRGeometry::exportToWkt;
3158#endif
3159
3164 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3165 OGRErr *err = nullptr) const override;
3166
3167 // IMultiSurface methods
3168 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const;
3169
3170 // IGeometry methods
3171 int getDimension() const override;
3172
3173 // IGeometryCollection
3175 OGRSurface *getGeometryRef(int i)
3176 {
3177 return OGRGeometryCollection::getGeometryRef(i)->toSurface();
3178 }
3179
3181 const OGRSurface *getGeometryRef(int i) const
3182 {
3183 return OGRGeometryCollection::getGeometryRef(i)->toSurface();
3184 }
3185
3186 // Non standard
3187 virtual OGRBoolean
3188 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3189
3191 inline OGRGeometryCollection *toUpperClass()
3192 {
3193 return this;
3194 }
3195
3197 inline const OGRGeometryCollection *toUpperClass() const
3198 {
3199 return this;
3200 }
3201
3202 void accept(IOGRGeometryVisitor *visitor) override
3203 {
3204 visitor->visit(this);
3205 }
3206
3207 void accept(IOGRConstGeometryVisitor *visitor) const override
3208 {
3209 visitor->visit(this);
3210 }
3211
3212 static OGRMultiPolygon *CastToMultiPolygon(OGRMultiSurface *poMS);
3213
3214 OGR_ALLOW_CAST_TO_THIS(MultiSurface)
3215 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3216 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3217 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3218 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3219};
3220
3222
3223 inline const OGRMultiSurface::ChildType *const *
3224 begin(const OGRMultiSurface *poGeom)
3225{
3226 return poGeom->begin();
3227}
3228
3230 inline const OGRMultiSurface::ChildType *const *
3231 end(const OGRMultiSurface *poGeom)
3232{
3233 return poGeom->end();
3234}
3235
3237 inline OGRMultiSurface::ChildType **begin(OGRMultiSurface *poGeom)
3238{
3239 return poGeom->begin();
3240}
3241
3243 inline OGRMultiSurface::ChildType **end(OGRMultiSurface *poGeom)
3244{
3245 return poGeom->end();
3246}
3247
3249
3250/************************************************************************/
3251/* OGRMultiPolygon */
3252/************************************************************************/
3253
3258 class CPL_DLL OGRMultiPolygon : public OGRMultiSurface
3259{
3260 protected:
3261 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3262 friend class OGRPolyhedralSurface;
3263 friend class OGRTriangulatedSurface;
3264
3265 private:
3267 OGRErr _addGeometryWithExpectedSubGeometryType(
3268 const OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3269 OGRErr _addGeometryDirectlyWithExpectedSubGeometryType(
3270 OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3272
3273 public:
3275 OGRMultiPolygon() = default;
3276
3277 OGRMultiPolygon(const OGRMultiPolygon &other);
3279 OGRMultiPolygon(OGRMultiPolygon &&other) = default;
3280
3281 OGRMultiPolygon &operator=(const OGRMultiPolygon &other);
3283 OGRMultiPolygon &operator=(OGRMultiPolygon &&other) = default;
3284
3286 typedef OGRPolygon ChildType;
3287
3290 ChildType **begin()
3291 {
3292 return reinterpret_cast<ChildType **>(papoGeoms);
3293 }
3294
3296 ChildType **end()
3297 {
3298 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3299 }
3300
3303 const ChildType *const *begin() const
3304 {
3305 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3306 }
3307
3309 const ChildType *const *end() const
3310 {
3311 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3312 nGeomCount);
3313 }
3314
3315 // IGeometryCollection
3317 OGRPolygon *getGeometryRef(int i)
3318 {
3319 return OGRGeometryCollection::getGeometryRef(i)->toPolygon();
3320 }
3321
3323 const OGRPolygon *getGeometryRef(int i) const
3324 {
3325 return OGRGeometryCollection::getGeometryRef(i)->toPolygon();
3326 }
3327
3328 // Non-standard (OGRGeometry).
3329 const char *getGeometryName() const override;
3330 OGRwkbGeometryType getGeometryType() const override;
3331 OGRMultiPolygon *clone() const override;
3332
3333#ifndef DOXYGEN_XML
3334 using OGRGeometry::exportToWkt;
3335#endif
3336
3337 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3338 size_t &nBytesConsumedOut) override;
3339
3344 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3345 OGRErr *err = nullptr) const override;
3346
3347 // Non standard
3348 virtual OGRBoolean
3349 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3350
3352 inline OGRGeometryCollection *toUpperClass()
3353 {
3354 return this;
3355 }
3356
3358 inline const OGRGeometryCollection *toUpperClass() const
3359 {
3360 return this;
3361 }
3362
3363 void accept(IOGRGeometryVisitor *visitor) override
3364 {
3365 visitor->visit(this);
3366 }
3367
3368 void accept(IOGRConstGeometryVisitor *visitor) const override
3369 {
3370 visitor->visit(this);
3371 }
3372
3373 static OGRMultiSurface *CastToMultiSurface(OGRMultiPolygon *poMP);
3374
3375 OGR_ALLOW_CAST_TO_THIS(MultiPolygon)
3376 OGR_ALLOW_UPCAST_TO(MultiSurface)
3377};
3378
3380
3381 inline const OGRMultiPolygon::ChildType *const *
3382 begin(const OGRMultiPolygon *poGeom)
3383{
3384 return poGeom->begin();
3385}
3386
3388 inline const OGRMultiPolygon::ChildType *const *
3389 end(const OGRMultiPolygon *poGeom)
3390{
3391 return poGeom->end();
3392}
3393
3395 inline OGRMultiPolygon::ChildType **begin(OGRMultiPolygon *poGeom)
3396{
3397 return poGeom->begin();
3398}
3399
3401 inline OGRMultiPolygon::ChildType **end(OGRMultiPolygon *poGeom)
3402{
3403 return poGeom->end();
3404}
3405
3407
3408/************************************************************************/
3409/* OGRPolyhedralSurface */
3410/************************************************************************/
3411
3417 class CPL_DLL OGRPolyhedralSurface : public OGRSurface
3418{
3419 protected:
3421 friend class OGRTriangulatedSurface;
3422 OGRMultiPolygon oMP{};
3423 OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
3424 virtual OGRSurfaceCasterToCurvePolygon
3425 GetCasterToCurvePolygon() const override;
3426 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
3427 virtual const char *getSubGeometryName() const;
3428 virtual OGRwkbGeometryType getSubGeometryType() const;
3429 std::string exportToWktInternal(const OGRWktOptions &opts,
3430 OGRErr *err) const;
3431
3432 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3433 GetCasterToMultiPolygon() const;
3434 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3436
3437 public:
3439 OGRPolyhedralSurface() = default;
3440
3441 OGRPolyhedralSurface(const OGRPolyhedralSurface &other);
3443 OGRPolyhedralSurface(OGRPolyhedralSurface &&other) = default;
3444
3445 OGRPolyhedralSurface &operator=(const OGRPolyhedralSurface &other);
3447 OGRPolyhedralSurface &operator=(OGRPolyhedralSurface &&other) = default;
3448
3450 typedef OGRPolygon ChildType;
3451
3454 ChildType **begin()
3455 {
3456 return oMP.begin();
3457 }
3458
3460 ChildType **end()
3461 {
3462 return oMP.end();
3463 }
3464
3467 const ChildType *const *begin() const
3468 {
3469 return oMP.begin();
3470 }
3471
3473 const ChildType *const *end() const
3474 {
3475 return oMP.end();
3476 }
3477
3478 // IWks Interface.
3479 size_t WkbSize() const override;
3480 const char *getGeometryName() const override;
3481 OGRwkbGeometryType getGeometryType() const override;
3482 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3483 size_t &nBytesConsumedOut) override;
3484 OGRErr exportToWkb(unsigned char *,
3485 const OGRwkbExportOptions * = nullptr) const override;
3486
3487#ifndef DOXYGEN_XML
3488 using OGRGeometry::importFromWkt;
3489#endif
3490
3491 OGRErr importFromWkt(const char **) override;
3492
3493#ifndef DOXYGEN_XML
3494 using OGRGeometry::exportToWkt;
3495#endif
3496
3501 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3502 OGRErr *err = nullptr) const override;
3503
3504 // IGeometry methods.
3505 int getDimension() const override;
3506
3507 void empty() override;
3508
3509 OGRPolyhedralSurface *clone() const override;
3510 void getEnvelope(OGREnvelope *psEnvelope) const override;
3511 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3512
3513 void flattenTo2D() override;
3514 OGRErr transform(OGRCoordinateTransformation *) override;
3515 OGRBoolean Equals(const OGRGeometry *) const override;
3516 double get_Area() const override;
3517 virtual double get_GeodesicArea(
3518 const OGRSpatialReference *poSRSOverride = nullptr) const override;
3519 double get_Length() const override;
3520 virtual double get_GeodesicLength(
3521 const OGRSpatialReference *poSRSOverride = nullptr) const override;
3522
3523 OGRErr PointOnSurface(OGRPoint *) const override;
3524
3525 static OGRMultiPolygon *CastToMultiPolygon(OGRPolyhedralSurface *poPS);
3526 virtual OGRBoolean
3527 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3528 virtual OGRErr addGeometry(const OGRGeometry *);
3529 OGRErr addGeometryDirectly(OGRGeometry *poNewGeom);
3530 OGRErr addGeometry(std::unique_ptr<OGRGeometry> poNewGeom);
3531
3532 int getNumGeometries() const;
3533 OGRPolygon *getGeometryRef(int i);
3534 const OGRPolygon *getGeometryRef(int i) const;
3535
3536 OGRBoolean IsEmpty() const override;
3537 bool setCoordinateDimension(int nDimension) override;
3538 bool set3D(OGRBoolean bIs3D) override;
3539 bool setMeasured(OGRBoolean bIsMeasured) override;
3540 void swapXY() override;
3541 OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3542
3543 bool hasEmptyParts() const override;
3544 void removeEmptyParts() override;
3545
3546 void accept(IOGRGeometryVisitor *visitor) override
3547 {
3548 visitor->visit(this);
3549 }
3550
3551 void accept(IOGRConstGeometryVisitor *visitor) const override
3552 {
3553 visitor->visit(this);
3554 }
3555
3556 virtual void
3557 assignSpatialReference(const OGRSpatialReference *poSR) override;
3558
3559 OGR_ALLOW_CAST_TO_THIS(PolyhedralSurface)
3560 OGR_ALLOW_UPCAST_TO(Surface)
3561};
3562
3564
3565 inline const OGRPolyhedralSurface::ChildType *const *
3566 begin(const OGRPolyhedralSurface *poGeom)
3567{
3568 return poGeom->begin();
3569}
3570
3572 inline const OGRPolyhedralSurface::ChildType *const *
3573 end(const OGRPolyhedralSurface *poGeom)
3574{
3575 return poGeom->end();
3576}
3577
3579 inline OGRPolyhedralSurface::ChildType **begin(OGRPolyhedralSurface *poGeom)
3580{
3581 return poGeom->begin();
3582}
3583
3585 inline OGRPolyhedralSurface::ChildType **end(OGRPolyhedralSurface *poGeom)
3586{
3587 return poGeom->end();
3588}
3589
3591
3592/************************************************************************/
3593/* OGRTriangulatedSurface */
3594/************************************************************************/
3595
3601 class CPL_DLL OGRTriangulatedSurface : public OGRPolyhedralSurface
3602{
3603 protected:
3605 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3606 const char *getSubGeometryName() const override;
3607 OGRwkbGeometryType getSubGeometryType() const override;
3608
3609 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3610 GetCasterToMultiPolygon() const override;
3611 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3613
3614 public:
3616 OGRTriangulatedSurface() = default;
3617
3618 OGRTriangulatedSurface(const OGRTriangulatedSurface &other);
3620 OGRTriangulatedSurface(OGRTriangulatedSurface &&other) = default;
3621
3622 OGRTriangulatedSurface &operator=(const OGRTriangulatedSurface &other);
3624 OGRTriangulatedSurface &operator=(OGRTriangulatedSurface &&other) = default;
3625
3627 typedef OGRTriangle ChildType;
3628
3631 ChildType **begin()
3632 {
3633 return reinterpret_cast<ChildType **>(oMP.begin());
3634 }
3635
3637 ChildType **end()
3638 {
3639 return reinterpret_cast<ChildType **>(oMP.end());
3640 }
3641
3644 const ChildType *const *begin() const
3645 {
3646 return reinterpret_cast<const ChildType *const *>(oMP.begin());
3647 }
3648
3650 const ChildType *const *end() const
3651 {
3652 return reinterpret_cast<const ChildType *const *>(oMP.end());
3653 }
3654
3655 const char *getGeometryName() const override;
3656 OGRwkbGeometryType getGeometryType() const override;
3657 OGRTriangulatedSurface *clone() const override;
3658
3660 OGRTriangle *getGeometryRef(int i)
3661 {
3662 return OGRPolyhedralSurface::getGeometryRef(i)->toTriangle();
3663 }
3664
3666 const OGRTriangle *getGeometryRef(int i) const
3667 {
3668 return OGRPolyhedralSurface::getGeometryRef(i)->toTriangle();
3669 }
3670
3671 // IWks Interface.
3672 OGRErr addGeometry(const OGRGeometry *) override;
3673
3674#ifndef DOXYGEN_XML
3675 using OGRPolyhedralSurface::addGeometry;
3676#endif
3677
3679 inline OGRPolyhedralSurface *toUpperClass()
3680 {
3681 return this;
3682 }
3683
3685 inline const OGRPolyhedralSurface *toUpperClass() const
3686 {
3687 return this;
3688 }
3689
3690 void accept(IOGRGeometryVisitor *visitor) override
3691 {
3692 visitor->visit(this);
3693 }
3694
3695 void accept(IOGRConstGeometryVisitor *visitor) const override
3696 {
3697 visitor->visit(this);
3698 }
3699
3700 static OGRPolyhedralSurface *
3701 CastToPolyhedralSurface(OGRTriangulatedSurface *poTS);
3702
3703 OGR_ALLOW_CAST_TO_THIS(TriangulatedSurface)
3704 OGR_ALLOW_UPCAST_TO(PolyhedralSurface)
3705};
3706
3708
3709 inline const OGRTriangulatedSurface::ChildType *const *
3710 begin(const OGRTriangulatedSurface *poGeom)
3711{
3712 return poGeom->begin();
3713}
3714
3716 inline const OGRTriangulatedSurface::ChildType *const *
3717 end(const OGRTriangulatedSurface *poGeom)
3718{
3719 return poGeom->end();
3720}
3721
3723 inline OGRTriangulatedSurface::ChildType **begin(OGRTriangulatedSurface *poGeom)
3724{
3725 return poGeom->begin();
3726}
3727
3729 inline OGRTriangulatedSurface::ChildType **end(OGRTriangulatedSurface *poGeom)
3730{
3731 return poGeom->end();
3732}
3733
3735
3736/************************************************************************/
3737/* OGRMultiPoint */
3738/************************************************************************/
3739
3744 class CPL_DLL OGRMultiPoint : public OGRGeometryCollection
3745{
3746 private:
3747 OGRErr importFromWkt_Bracketed(const char **, int bHasM, int bHasZ);
3748
3749 protected:
3750 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3751
3752 public:
3754 OGRMultiPoint() = default;
3755
3756 OGRMultiPoint(const OGRMultiPoint &other);
3758 OGRMultiPoint(OGRMultiPoint &&other) = default;
3759
3760 OGRMultiPoint &operator=(const OGRMultiPoint &other);
3762 OGRMultiPoint &operator=(OGRMultiPoint &&other) = default;
3763
3765 typedef OGRPoint ChildType;
3766
3769 ChildType **begin()
3770 {
3771 return reinterpret_cast<ChildType **>(papoGeoms);
3772 }
3773
3775 ChildType **end()
3776 {
3777 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3778 }
3779
3782 const ChildType *const *begin() const
3783 {
3784 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3785 }
3786
3788 const ChildType *const *end() const
3789 {
3790 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3791 nGeomCount);
3792 }
3793
3794 // IGeometryCollection
3796 OGRPoint *getGeometryRef(int i)
3797 {
3798 return OGRGeometryCollection::getGeometryRef(i)->toPoint();
3799 }
3800
3802 const OGRPoint *getGeometryRef(int i) const
3803 {
3804 return OGRGeometryCollection::getGeometryRef(i)->toPoint();
3805 }
3806
3807 // Non-standard (OGRGeometry).
3808 const char *getGeometryName() const override;
3809 OGRwkbGeometryType getGeometryType() const override;
3810 OGRMultiPoint *clone() const override;
3811
3812#ifndef DOXYGEN_XML
3813 using OGRGeometry::importFromWkt;
3814#endif
3815
3816 OGRErr importFromWkt(const char **) override;
3817
3818#ifndef DOXYGEN_XML
3819 using OGRGeometry::exportToWkt;
3820#endif
3821
3826 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3827 OGRErr *err = nullptr) const override;
3828
3829 // IGeometry methods.
3830 int getDimension() const override;
3831
3833 inline OGRGeometryCollection *toUpperClass()
3834 {
3835 return this;
3836 }
3837
3839 inline const OGRGeometryCollection *toUpperClass() const
3840 {
3841 return this;
3842 }
3843
3844 void accept(IOGRGeometryVisitor *visitor) override
3845 {
3846 visitor->visit(this);
3847 }
3848
3849 void accept(IOGRConstGeometryVisitor *visitor) const override
3850 {
3851 visitor->visit(this);
3852 }
3853
3854 // Non-standard.
3855 virtual OGRBoolean
3856 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3857
3858 OGR_ALLOW_CAST_TO_THIS(MultiPoint)
3859 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3860 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3861 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3862 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3863 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3864};
3865
3867
3868 inline const OGRMultiPoint::ChildType *const *begin(const OGRMultiPoint *poGeom)
3869{
3870 return poGeom->begin();
3871}
3872
3874 inline const OGRMultiPoint::ChildType *const *end(const OGRMultiPoint *poGeom)
3875{
3876 return poGeom->end();
3877}
3878
3880 inline OGRMultiPoint::ChildType **begin(OGRMultiPoint *poGeom)
3881{
3882 return poGeom->begin();
3883}
3884
3886 inline OGRMultiPoint::ChildType **end(OGRMultiPoint *poGeom)
3887{
3888 return poGeom->end();
3889}
3890
3892
3893/************************************************************************/
3894/* OGRMultiCurve */
3895/************************************************************************/
3896
3902 class CPL_DLL OGRMultiCurve : public OGRGeometryCollection
3903{
3904 protected:
3906 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
3907 OGRCurve *poCurve);
3909 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3910
3911 public:
3913 OGRMultiCurve() = default;
3914
3915 OGRMultiCurve(const OGRMultiCurve &other);
3917 OGRMultiCurve(OGRMultiCurve &&other) = default;
3918
3919 OGRMultiCurve &operator=(const OGRMultiCurve &other);
3921 OGRMultiCurve &operator=(OGRMultiCurve &&other) = default;
3922
3924 typedef OGRCurve ChildType;
3925
3928 ChildType **begin()
3929 {
3930 return reinterpret_cast<ChildType **>(papoGeoms);
3931 }
3932
3934 ChildType **end()
3935 {
3936 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3937 }
3938
3941 const ChildType *const *begin() const
3942 {
3943 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3944 }
3945
3947 const ChildType *const *end() const
3948 {
3949 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3950 nGeomCount);
3951 }
3952
3953 // IGeometryCollection
3955 OGRCurve *getGeometryRef(int i)
3956 {
3957 return OGRGeometryCollection::getGeometryRef(i)->toCurve();
3958 }
3959
3961 const OGRCurve *getGeometryRef(int i) const
3962 {
3963 return OGRGeometryCollection::getGeometryRef(i)->toCurve();
3964 }
3965
3966 // Non standard (OGRGeometry).
3967 const char *getGeometryName() const override;
3968 OGRwkbGeometryType getGeometryType() const override;
3969 OGRMultiCurve *clone() const override;
3970
3971#ifndef DOXYGEN_XML
3972 using OGRGeometry::importFromWkt;
3973#endif
3974
3975 OGRErr importFromWkt(const char **) override;
3976
3977#ifndef DOXYGEN_XML
3978 using OGRGeometry::exportToWkt;
3979#endif
3980
3985 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3986 OGRErr *err = nullptr) const override;
3987
3988 // IGeometry methods.
3989 int getDimension() const override;
3990
3991 // Non-standard.
3992 virtual OGRBoolean
3993 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3994
3996 inline OGRGeometryCollection *toUpperClass()
3997 {
3998 return this;
3999 }
4000
4002 inline const OGRGeometryCollection *toUpperClass() const
4003 {
4004 return this;
4005 }
4006
4007 void accept(IOGRGeometryVisitor *visitor) override
4008 {
4009 visitor->visit(this);
4010 }
4011
4012 void accept(IOGRConstGeometryVisitor *visitor) const override
4013 {
4014 visitor->visit(this);
4015 }
4016
4017 static OGRMultiLineString *CastToMultiLineString(OGRMultiCurve *poMC);
4018
4019 OGR_ALLOW_CAST_TO_THIS(MultiCurve)
4020 OGR_ALLOW_UPCAST_TO(GeometryCollection)
4021 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
4022 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
4023 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
4024};
4025
4027
4028 inline const OGRMultiCurve::ChildType *const *begin(const OGRMultiCurve *poGeom)
4029{
4030 return poGeom->begin();
4031}
4032
4034 inline const OGRMultiCurve::ChildType *const *end(const OGRMultiCurve *poGeom)
4035{
4036 return poGeom->end();
4037}
4038
4040 inline OGRMultiCurve::ChildType **begin(OGRMultiCurve *poGeom)
4041{
4042 return poGeom->begin();
4043}
4044
4046 inline OGRMultiCurve::ChildType **end(OGRMultiCurve *poGeom)
4047{
4048 return poGeom->end();
4049}
4050
4052
4053/************************************************************************/
4054/* OGRMultiLineString */
4055/************************************************************************/
4056
4061 class CPL_DLL OGRMultiLineString : public OGRMultiCurve
4062{
4063 protected:
4064 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
4065
4066 public:
4068 OGRMultiLineString() = default;
4069
4070 OGRMultiLineString(const OGRMultiLineString &other);
4072 OGRMultiLineString(OGRMultiLineString &&other) = default;
4073
4074 OGRMultiLineString &operator=(const OGRMultiLineString &other);
4076 OGRMultiLineString &operator=(OGRMultiLineString &&other) = default;
4077
4079 typedef OGRLineString ChildType;
4080
4083 ChildType **begin()
4084 {
4085 return reinterpret_cast<ChildType **>(papoGeoms);
4086 }
4087
4089 ChildType **end()
4090 {
4091 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
4092 }
4093
4096 const ChildType *const *begin() const
4097 {
4098 return reinterpret_cast<const ChildType *const *>(papoGeoms);
4099 }
4100
4102 const ChildType *const *end() const
4103 {
4104 return reinterpret_cast<const ChildType *const *>(papoGeoms +
4105 nGeomCount);
4106 }
4107
4108 // IGeometryCollection
4110 OGRLineString *getGeometryRef(int i)
4111 {
4112 return OGRGeometryCollection::getGeometryRef(i)->toLineString();
4113 }
4114
4116 const OGRLineString *getGeometryRef(int i) const
4117 {
4118 return OGRGeometryCollection::getGeometryRef(i)->toLineString();
4119 }
4120
4121 // Non standard (OGRGeometry).
4122 const char *getGeometryName() const override;
4123 OGRwkbGeometryType getGeometryType() const override;
4124 OGRMultiLineString *clone() const override;
4125
4126#ifndef DOXYGEN_XML
4127 using OGRGeometry::exportToWkt;
4128#endif
4129
4130 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
4131 size_t &nBytesConsumedOut) override;
4132
4137 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
4138 OGRErr *err = nullptr) const override;
4139
4140 // Non standard
4141 virtual OGRBoolean
4142 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
4143
4145 inline OGRGeometryCollection *toUpperClass()
4146 {
4147 return this;
4148 }
4149
4151 inline const OGRGeometryCollection *toUpperClass() const
4152 {
4153 return this;
4154 }
4155
4156 void accept(IOGRGeometryVisitor *visitor) override
4157 {
4158 visitor->visit(this);
4159 }
4160
4161 void accept(IOGRConstGeometryVisitor *visitor) const override
4162 {
4163 visitor->visit(this);
4164 }
4165
4166 static OGRMultiCurve *CastToMultiCurve(OGRMultiLineString *poMLS);
4167
4168 OGR_ALLOW_CAST_TO_THIS(MultiLineString)
4169 OGR_ALLOW_UPCAST_TO(MultiCurve)
4170 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
4171 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
4172 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
4173};
4174
4176
4177 inline const OGRMultiLineString::ChildType *const *
4178 begin(const OGRMultiLineString *poGeom)
4179{
4180 return poGeom->begin();
4181}
4182
4184 inline const OGRMultiLineString::ChildType *const *
4185 end(const OGRMultiLineString *poGeom)
4186{
4187 return poGeom->end();
4188}
4189
4191 inline OGRMultiLineString::ChildType **begin(OGRMultiLineString *poGeom)
4192{
4193 return poGeom->begin();
4194}
4195
4197 inline OGRMultiLineString::ChildType **end(OGRMultiLineString *poGeom)
4198{
4199 return poGeom->end();
4200}
4201
4203
4204/************************************************************************/
4205/* OGRGeometryFactory */
4206/************************************************************************/
4207
4212 class CPL_DLL OGRGeometryFactory
4213{
4214 static OGRErr createFromFgfInternal(const unsigned char *pabyData,
4215 OGRSpatialReference *poSR,
4216 OGRGeometry **ppoReturn, int nBytes,
4217 int *pnBytesConsumed, int nRecLevel);
4218
4219 public:
4220 static OGRErr createFromWkb(const void *, const OGRSpatialReference *,
4221 OGRGeometry **,
4222 size_t = static_cast<size_t>(-1),
4223 OGRwkbVariant = wkbVariantOldOgc);
4224 static OGRErr createFromWkb(const void *pabyData,
4225 const OGRSpatialReference *, OGRGeometry **,
4226 size_t nSize, OGRwkbVariant eVariant,
4227 size_t &nBytesConsumedOut);
4228 static OGRErr createFromWkt(const char *, const OGRSpatialReference *,
4229 OGRGeometry **);
4230 static OGRErr createFromWkt(const char **, const OGRSpatialReference *,
4231 OGRGeometry **);
4232 static std::pair<std::unique_ptr<OGRGeometry>, OGRErr>
4233 createFromWkt(const char *, const OGRSpatialReference * = nullptr);
4234
4238 static OGRErr createFromWkt(char **ppszInput,
4239 const OGRSpatialReference *poSRS,
4240 OGRGeometry **ppoGeom)
4241 CPL_WARN_DEPRECATED("Use createFromWkt(const char**, ...) instead")
4242 {
4243 return createFromWkt(const_cast<const char **>(ppszInput), poSRS,
4244 ppoGeom);
4245 }
4246
4247 static OGRErr createFromFgf(const void *, OGRSpatialReference *,
4248 OGRGeometry **, int = -1, int * = nullptr);
4249 static OGRGeometry *createFromGML(const char *);
4250 static OGRGeometry *createFromGEOS(GEOSContextHandle_t hGEOSCtxt, GEOSGeom);
4251 static OGRGeometry *createFromGeoJson(const char *, int = -1);
4252 static OGRGeometry *createFromGeoJson(const CPLJSONObject &oJSONObject);
4253
4254 static void destroyGeometry(OGRGeometry *);
4255 static OGRGeometry *createGeometry(OGRwkbGeometryType);
4256
4257 static OGRGeometry *forceToPolygon(OGRGeometry *);
4258 static OGRGeometry *forceToLineString(OGRGeometry *,
4259 bool bOnlyInOrder = true);
4260 static OGRGeometry *forceToMultiPolygon(OGRGeometry *);
4261 static OGRGeometry *forceToMultiPoint(OGRGeometry *);
4262 static OGRGeometry *forceToMultiLineString(OGRGeometry *);
4263
4264 static OGRGeometry *forceTo(OGRGeometry *poGeom,
4265 OGRwkbGeometryType eTargetType,
4266 const char *const *papszOptions = nullptr);
4267
4268 static std::unique_ptr<OGRGeometry>
4269 makeCompatibleWith(std::unique_ptr<OGRGeometry>,
4270 OGRwkbGeometryType eTargetType);
4271
4272 static OGRGeometry *removeLowerDimensionSubGeoms(const OGRGeometry *poGeom);
4273
4274 static OGRGeometry *organizePolygons(OGRGeometry **papoPolygons,
4275 int nPolygonCount,
4276 int *pbResultValidGeometry,
4277 const char **papszOptions = nullptr);
4278 static bool haveGEOS();
4279
4281 class CPL_DLL TransformWithOptionsCache
4282 {
4283 friend class OGRGeometryFactory;
4284 struct Private;
4285 std::unique_ptr<Private> d;
4286
4287 public:
4288 TransformWithOptionsCache();
4289 ~TransformWithOptionsCache();
4290 };
4291
4293 static bool isTransformWithOptionsRegularTransform(
4294 const OGRSpatialReference *poSourceCRS,
4295 const OGRSpatialReference *poTargetCRS, CSLConstList papszOptions);
4297
4298 static OGRGeometry *transformWithOptions(
4299 const OGRGeometry *poSrcGeom, OGRCoordinateTransformation *poCT,
4300 char **papszOptions,
4301 const TransformWithOptionsCache &cache = TransformWithOptionsCache());
4302
4303 static double GetDefaultArcStepSize();
4304
4305 static OGRGeometry *
4306 approximateArcAngles(double dfX, double dfY, double dfZ,
4307 double dfPrimaryRadius, double dfSecondaryAxis,
4308 double dfRotation, double dfStartAngle,
4309 double dfEndAngle, double dfMaxAngleStepSizeDegrees,
4310 const bool bUseMaxGap = false);
4311
4312 static int GetCurveParameters(double x0, double y0, double x1, double y1,
4313 double x2, double y2, double &R, double &cx,
4314 double &cy, double &alpha0, double &alpha1,
4315 double &alpha2);
4316 static OGRLineString *
4317 curveToLineString(double x0, double y0, double z0, double x1, double y1,
4318 double z1, double x2, double y2, double z2, int bHasZ,
4319 double dfMaxAngleStepSizeDegrees,
4320 const char *const *papszOptions = nullptr);
4321 static OGRCurve *
4322 curveFromLineString(const OGRLineString *poLS,
4323 const char *const *papszOptions = nullptr);
4324};
4325
4326 OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType(const char *pszGeomType);
4327 const char CPL_DLL *OGRToOGCGeomType(OGRwkbGeometryType eGeomType,
4328 bool bCamelCase = false,
4329 bool bAddZM = false,
4330 bool bSpaceBeforeZM = false);
4331
4333 typedef struct _OGRPreparedGeometry OGRPreparedGeometry;
4334
4335 struct CPL_DLL OGRPreparedGeometryUniquePtrDeleter
4336{
4337 void operator()(OGRPreparedGeometry *) const;
4338};
4339
4341
4344 typedef std::unique_ptr<OGRPreparedGeometry,
4345 OGRPreparedGeometryUniquePtrDeleter>
4346 OGRPreparedGeometryUniquePtr;
4347
4348#endif /* ndef OGR_GEOMETRY_H_INCLUDED */
CPLJSONObject
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition cpl_json.h:56
IOGRConstGeometryVisitor
OGRGeometry visitor interface.
Definition ogr_geometry.h:222
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::~IOGRConstGeometryVisitor
virtual ~IOGRConstGeometryVisitor()
Destructor/.
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::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:148
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()
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:1921
OGRCircularString::OGRCircularString
OGRCircularString()=default
Create an empty circular string.
OGRCircularString::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2016
OGRCircularString::toUpperClass
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2006
OGRCircularString::OGRCircularString
OGRCircularString(const OGRCircularString &other)
Copy constructor.
OGRCircularString::toUpperClass
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2000
OGRCircularString::operator=
OGRCircularString & operator=(OGRCircularString &&other)=default
Move assignment operator.
OGRCircularString::OGRCircularString
OGRCircularString(OGRCircularString &&other)=default
Move constructor.
OGRCircularString::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2011
OGRCompoundCurve
Utility class to store a collection of curves.
Definition ogr_geometry.h:2153
OGRCompoundCurve::end
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:2216
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:2210
OGRCompoundCurve::OGRCompoundCurve
OGRCompoundCurve(const OGRCompoundCurve &other)
Copy constructor.
OGRCompoundCurve::ChildType
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:2193
OGRCompoundCurve::OGRCompoundCurve
OGRCompoundCurve(OGRCompoundCurve &&other)=default
Move constructor.
OGRCompoundCurve::end
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:2203
OGRCompoundCurve::operator=
OGRCompoundCurve & operator=(OGRCompoundCurve &&other)=default
Move assignment operator.
OGRCompoundCurve::begin
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:2197
OGRCompoundCurve::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2317
OGRCompoundCurve::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2312
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition ogr_spatialref.h:772
OGRCurvePolygon
Concrete class representing curve polygons.
Definition ogr_geometry.h:2417
OGRCurvePolygon::OGRCurvePolygon
OGRCurvePolygon()=default
Create an empty curve polygon.
OGRCurvePolygon::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2573
OGRCurvePolygon::operator=
OGRCurvePolygon & operator=(OGRCurvePolygon &&other)=default
Move assignment operator.
OGRCurvePolygon::ChildType
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:2460
OGRCurvePolygon::OGRCurvePolygon
OGRCurvePolygon(OGRCurvePolygon &&)=default
Move constructor.
OGRCurvePolygon::end
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:2483
OGRCurvePolygon::begin
const ChildType *const * begin() const
Return begin of curve iterator.
Definition ogr_geometry.h:2477
OGRCurvePolygon::begin
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:2464
OGRCurvePolygon::end
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:2470
OGRCurvePolygon::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2578
OGRCurvePolygon::OGRCurvePolygon
OGRCurvePolygon(const OGRCurvePolygon &)
Copy constructor.
OGRCurve
Abstract curve base class for OGRLineString, OGRCircularString and OGRCompoundCurve.
Definition ogr_geometry.h:1278
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::clone
OGRCurve * clone() const override=0
Make a copy of this object.
OGRCurve::toSimpleCurve
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:1371
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:1321
OGRCurve::toSimpleCurve
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:1363
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::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:268
OGRDefaultConstGeometryVisitor::visit
void visit(const OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:272
OGRDefaultGeometryVisitor
OGRGeometry visitor default implementation.
Definition ogr_geometry.h:194
OGRDefaultGeometryVisitor::visit
void visit(OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:198
OGREnvelope3D
Simple container for a bounding region in 3D.
Definition ogr_core.h:199
OGREnvelope
Simple container for a bounding region (rectangle)
Definition ogr_core.h:44
OGRGeomCoordinateBinaryPrecision
Geometry coordinate precision for a binary representation.
Definition ogr_geometry.h:302
OGRGeometryCollection
A collection of 1 or more geometry objects.
Definition ogr_geometry.h:2899
OGRGeometryCollection::end
ChildType ** end()
Return end of sub-geometry iterator.
Definition ogr_geometry.h:2942
OGRGeometryCollection::OGRGeometryCollection
OGRGeometryCollection()=default
Create an empty geometry collection.
OGRGeometryCollection::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3041
OGRGeometryCollection::begin
const ChildType *const * begin() const
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:2949
OGRGeometryCollection::end
const ChildType *const * end() const
Return end of sub-geometry iterator.
Definition ogr_geometry.h:2955
OGRGeometryCollection::begin
ChildType ** begin()
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:2936
OGRGeometryCollection::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3046
OGRGeometryCollection::getGeometryRef
OGRGeometry * getGeometryRef(int)
Fetch geometry from container.
Definition ogrgeometrycollection.cpp:293
OGRGeometryCollection::ChildType
OGRGeometry ChildType
Type of child elements.
Definition ogr_geometry.h:2932
OGRGeometryFactory::TransformWithOptionsCache
Opaque class used as argument to transformWithOptions()
Definition ogr_geometry.h:4282
OGRGeometryFactory
Create geometry objects from well known text/binary.
Definition ogr_geometry.h:4213
OGRGeometryFactory::createFromWkt
static OGRErr createFromWkt(char **ppszInput, const OGRSpatialReference *poSRS, OGRGeometry **ppoGeom)
Deprecated.
Definition ogr_geometry.h:4238
OGRGeometry
Abstract base class for all geometry classes.
Definition ogr_geometry.h:357
OGRGeometry::toSurface
const OGRSurface * toSurface() const
Down-cast to OGRSurface*.
Definition ogr_geometry.h:784
OGRGeometry::toCurvePolygon
const OGRCurvePolygon * toCurvePolygon() const
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:836
OGRGeometry::toMultiCurve
const OGRMultiCurve * toMultiCurve() const
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:926
OGRGeometry::toPolyhedralSurface
const OGRPolyhedralSurface * toPolyhedralSurface() const
Down-cast to OGRPolyhedralSurface*.
Definition ogr_geometry.h:962
OGRGeometry::toMultiPoint
const OGRMultiPoint * toMultiPoint() const
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:872
OGRGeometry::empty
virtual void empty()=0
Clear geometry information.
OGRGeometry::toMultiPolygon
const OGRMultiPolygon * toMultiPolygon() const
Down-cast to OGRMultiPolygon*.
Definition ogr_geometry.h:908
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:953
OGRGeometry::toMultiSurface
const OGRMultiSurface * toMultiSurface() const
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:944
OGRGeometry::toPoint
OGRPoint * toPoint()
Down-cast to OGRPoint*.
Definition ogr_geometry.h:652
OGRGeometry::operator!=
bool operator!=(const OGRGeometry &other) const
Returns if two geometries are different.
Definition ogr_geometry.h:419
OGRGeometry::toTriangle
OGRTriangle * toTriangle()
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:810
OGRGeometry::toLineString
OGRLineString * toLineString()
Down-cast to OGRLineString*.
Definition ogr_geometry.h:705
OGRGeometry::toLinearRing
const OGRLinearRing * toLinearRing() const
Down-cast to OGRLinearRing*.
Definition ogr_geometry.h:730
OGRGeometry::toPoint
const OGRPoint * toPoint() const
Down-cast to OGRPoint*.
Definition ogr_geometry.h:660
OGRGeometry::toMultiLineString
OGRMultiLineString * toMultiLineString()
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:881
OGRGeometry::toMultiSurface
OGRMultiSurface * toMultiSurface()
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:935
OGRGeometry::FromHandle
static OGRGeometry * FromHandle(OGRGeometryH hGeom)
Convert a OGRGeometryH to a OGRGeometry*.
Definition ogr_geometry.h:644
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:854
OGRGeometry::toMultiLineString
const OGRMultiLineString * toMultiLineString() const
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:890
OGRGeometry::toCircularString
const OGRCircularString * toCircularString() const
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:748
OGRGeometry::toPolygon
OGRPolygon * toPolygon()
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:793
OGRGeometry::operator==
bool operator==(const OGRGeometry &other) const
Returns if two geometries are equal.
Definition ogr_geometry.h:413
OGRGeometry::toLinearRing
OGRLinearRing * toLinearRing()
Down-cast to OGRLinearRing*.
Definition ogr_geometry.h:722
OGRGeometry::IsMeasured
OGRBoolean IsMeasured() const
Definition ogr_geometry.h:441
OGRGeometry::accept
virtual void accept(IOGRGeometryVisitor *visitor)=0
Accept a visitor.
OGRGeometry::toMultiCurve
OGRMultiCurve * toMultiCurve()
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:917
OGRGeometry::toCompoundCurve
const OGRCompoundCurve * toCompoundCurve() const
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:766
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:845
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:899
OGRGeometry::toPolygon
const OGRPolygon * toPolygon() const
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:802
OGRGeometry::toCompoundCurve
OGRCompoundCurve * toCompoundCurve()
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:757
OGRGeometry::importFromWkt
OGRErr importFromWkt(char **ppszInput)
Deprecated.
Definition ogr_geometry.h:468
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:714
OGRGeometry::exportToWkt
OGRErr exportToWkt(char **ppszDstText, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known text format.
Definition ogrgeometry.cpp:1961
OGRGeometry::toCircularString
OGRCircularString * toCircularString()
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:739
OGRGeometry::toCurve
const OGRCurve * toCurve() const
Down-cast to OGRCurve*.
Definition ogr_geometry.h:678
OGRGeometry::toCurvePolygon
OGRCurvePolygon * toCurvePolygon()
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:827
OGRGeometry::toSimpleCurve
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:696
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:435
OGRGeometry::toMultiPoint
OGRMultiPoint * toMultiPoint()
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:863
OGRGeometry::toTriangulatedSurface
const OGRTriangulatedSurface * toTriangulatedSurface() const
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:978
OGRGeometry::toTriangle
const OGRTriangle * toTriangle() const
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:818
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:775
OGRGeometry::toSimpleCurve
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:687
OGRGeometry::toTriangulatedSurface
OGRTriangulatedSurface * toTriangulatedSurface()
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:970
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:669
OGRIteratedPoint
Definition ogr_geometry.h:1427
OGRIteratedPoint::~OGRIteratedPoint
~OGRIteratedPoint() override
Destructor.
OGRLineString
Concrete representation of a multi-vertex line.
Definition ogr_geometry.h:1726
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:1770
OGRLineString::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1786
OGRLineString::OGRLineString
OGRLineString(const OGRLineString &other)
Copy constructor.
OGRLineString::get_Area
double get_Area() const override
Get the area of the (closed) curve.
OGRLineString::OGRLineString
OGRLineString(OGRLineString &&other)
Move 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
int isClockwise() const override
Returns TRUE if the ring has clockwise winding (or less than 2 points)
OGRLineString::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1781
OGRLineString::toUpperClass
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1776
OGRLineString::OGRLineString
OGRLineString()=default
Create an empty line string.
OGRLinearRing
Concrete representation of a closed ring.
Definition ogr_geometry.h:1820
OGRLinearRing::OGRLinearRing
OGRLinearRing()=default
Constructor.
OGRLinearRing::operator=
OGRLinearRing & operator=(OGRLinearRing &&other)=default
Move assignment operator.
OGRLinearRing::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1896
OGRLinearRing::toUpperClass
const OGRLineString * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1886
OGRLinearRing::OGRLinearRing
OGRLinearRing(const OGRLinearRing &other)
Copy constructor.
OGRLinearRing::OGRLinearRing
OGRLinearRing(OGRLinearRing &&other)=default
Move constructor.
OGRLinearRing::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1891
OGRMultiCurve
A collection of OGRCurve.
Definition ogr_geometry.h:3903
OGRMultiCurve::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3941
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:3947
OGRMultiCurve::end
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3934
OGRMultiCurve::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:4012
OGRMultiCurve::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:4002
OGRMultiCurve::operator=
OGRMultiCurve & operator=(OGRMultiCurve &&other)=default
Move assignment operator.
OGRMultiCurve::getGeometryRef
const OGRCurve * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3961
OGRMultiCurve::getGeometryRef
OGRCurve * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3955
OGRMultiCurve::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:4007
OGRMultiCurve::OGRMultiCurve
OGRMultiCurve(const OGRMultiCurve &other)
Copy constructor.
OGRMultiCurve::ChildType
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:3924
OGRMultiCurve::begin
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3928
OGRMultiCurve::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3996
OGRMultiCurve::OGRMultiCurve
OGRMultiCurve(OGRMultiCurve &&other)=default
Move constructor.
OGRMultiLineString
A collection of OGRLineString.
Definition ogr_geometry.h:4062
OGRMultiLineString::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:4161
OGRMultiLineString::ChildType
OGRLineString ChildType
Type of child elements.
Definition ogr_geometry.h:4079
OGRMultiLineString::getGeometryRef
OGRLineString * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:4110
OGRMultiLineString::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:4145
OGRMultiLineString::end
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:4089
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:4102
OGRMultiLineString::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:4096
OGRMultiLineString::OGRMultiLineString
OGRMultiLineString(OGRMultiLineString &&other)=default
Move constructor.
OGRMultiLineString::getGeometryRef
const OGRLineString * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:4116
OGRMultiLineString::begin
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:4083
OGRMultiLineString::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:4151
OGRMultiLineString::operator=
OGRMultiLineString & operator=(OGRMultiLineString &&other)=default
Move assignment operator.
OGRMultiLineString::OGRMultiLineString
OGRMultiLineString(const OGRMultiLineString &other)
Copy constructor.
OGRMultiLineString::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:4156
OGRMultiPoint
A collection of OGRPoint.
Definition ogr_geometry.h:3745
OGRMultiPoint::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3833
OGRMultiPoint::operator=
OGRMultiPoint & operator=(OGRMultiPoint &&other)=default
Move assignment operator.
OGRMultiPoint::OGRMultiPoint
OGRMultiPoint()=default
Create an empty multi point collection.
OGRMultiPoint::end
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3788
OGRMultiPoint::begin
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3769
OGRMultiPoint::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3849
OGRMultiPoint::OGRMultiPoint
OGRMultiPoint(const OGRMultiPoint &other)
Copy constructor.
OGRMultiPoint::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3782
OGRMultiPoint::OGRMultiPoint
OGRMultiPoint(OGRMultiPoint &&other)=default
Move constructor.
OGRMultiPoint::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3839
OGRMultiPoint::ChildType
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:3765
OGRMultiPoint::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3844
OGRMultiPoint::getGeometryRef
const OGRPoint * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3802
OGRMultiPoint::getGeometryRef
OGRPoint * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3796
OGRMultiPoint::end
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3775
OGRMultiPolygon
A collection of non-overlapping OGRPolygon.
Definition ogr_geometry.h:3259
OGRMultiPolygon::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3363
OGRMultiPolygon::ChildType
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:3286
OGRMultiPolygon::OGRMultiPolygon
OGRMultiPolygon(const OGRMultiPolygon &other)
Copy constructor.
OGRMultiPolygon::operator=
OGRMultiPolygon & operator=(OGRMultiPolygon &&other)=default
Move assignment operator.
OGRMultiPolygon::getGeometryRef
OGRPolygon * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3317
OGRMultiPolygon::OGRMultiPolygon
OGRMultiPolygon()=default
Create an empty multi polygon collection.
OGRMultiPolygon::getGeometryRef
const OGRPolygon * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3323
OGRMultiPolygon::end
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3309
OGRMultiPolygon::end
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3296
OGRMultiPolygon::OGRMultiPolygon
OGRMultiPolygon(OGRMultiPolygon &&other)=default
Move constructor.
OGRMultiPolygon::begin
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3290
OGRMultiPolygon::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3352
OGRMultiPolygon::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3303
OGRMultiPolygon::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3368
OGRMultiPolygon::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3358
OGRMultiSurface
A collection of non-overlapping OGRSurface.
Definition ogr_geometry.h:3099
OGRMultiSurface::getGeometryRef
const OGRSurface * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3181
OGRMultiSurface::operator=
OGRMultiSurface & operator=(OGRMultiSurface &&other)=default
Move assignment operator.
OGRMultiSurface::begin
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3120
OGRMultiSurface::ChildType
OGRSurface ChildType
Type of child elements.
Definition ogr_geometry.h:3116
OGRMultiSurface::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3197
OGRMultiSurface::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3133
OGRMultiSurface::end
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3139
OGRMultiSurface::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3207
OGRMultiSurface::OGRMultiSurface
OGRMultiSurface(const OGRMultiSurface &other)
Copy constructor.
OGRMultiSurface::OGRMultiSurface
OGRMultiSurface()=default
Create an empty multi surface collection.
OGRMultiSurface::OGRMultiSurface
OGRMultiSurface(OGRMultiSurface &&other)=default
Move constructor.
OGRMultiSurface::end
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3126
OGRMultiSurface::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3202
OGRMultiSurface::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3191
OGRMultiSurface::getGeometryRef
OGRSurface * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3175
OGRPointIterator
Interface for a point iterator.
Definition ogr_geometry.h:1260
OGRPointIterator::getNextPoint
virtual OGRBoolean getNextPoint(OGRPoint *p)=0
Returns the next point followed by the iterator.
OGRPoint
Point class.
Definition ogr_geometry.h:1095
OGRPoint::getM
double getM() const
Return m.
Definition ogr_geometry.h:1171
OGRPoint::setX
void setX(double xIn)
Set x.
Definition ogr_geometry.h:1182
OGRPoint::OGRPoint
OGRPoint(const OGRPoint &other)
Copy constructor.
OGRPoint::operator=
OGRPoint & operator=(OGRPoint &&other)=default
Move assignment operator.
OGRPoint::setZ
void setZ(double zIn)
Set z.
Definition ogr_geometry.h:1206
OGRPoint::setM
void setM(double mIn)
Set m.
Definition ogr_geometry.h:1215
OGRPoint::getX
double getX() const
Return x.
Definition ogr_geometry.h:1153
OGRPoint::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1232
OGRPoint::IsEmpty
OGRBoolean IsEmpty() const override
Returns TRUE (non-zero) if the object has no points.
Definition ogr_geometry.h:1146
OGRPoint::setY
void setY(double yIn)
Set y.
Definition ogr_geometry.h:1194
OGRPoint::getZ
double getZ() const
Return z.
Definition ogr_geometry.h:1165
OGRPoint::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1237
OGRPoint::getY
double getY() const
Return y.
Definition ogr_geometry.h:1159
OGRPoint::OGRPoint
OGRPoint(OGRPoint &&other)=default
Move constructor.
OGRPolygon
Concrete class representing polygons.
Definition ogr_geometry.h:2635
OGRPolygon::operator=
OGRPolygon & operator=(OGRPolygon &&other)=default
Move assignment operator.
OGRPolygon::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2771
OGRPolygon::ChildType
OGRLinearRing ChildType
Type of child elements.
Definition ogr_geometry.h:2675
OGRPolygon::begin
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2679
OGRPolygon::OGRPolygon
OGRPolygon(OGRPolygon &&other)=default
Move constructor.
OGRPolygon::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2766
OGRPolygon::toUpperClass
const OGRCurvePolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2761
OGRPolygon::end
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2685
OGRPolygon::OGRPolygon
OGRPolygon(const OGRPolygon &other)
Copy constructor.
OGRPolygon::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2692
OGRPolygon::OGRPolygon
OGRPolygon()=default
Create an empty polygon.
OGRPolygon::end
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2698
OGRPolygon::toUpperClass
OGRCurvePolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2755
OGRPolyhedralSurface
PolyhedralSurface class.
Definition ogr_geometry.h:3418
OGRPolyhedralSurface::end
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3460
OGRPolyhedralSurface::end
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3473
OGRPolyhedralSurface::OGRPolyhedralSurface
OGRPolyhedralSurface(const OGRPolyhedralSurface &other)
Copy constructor.
OGRPolyhedralSurface::getGeometryRef
OGRPolygon * getGeometryRef(int i)
Fetch geometry from container.
Definition ogrpolyhedralsurface.cpp:862
OGRPolyhedralSurface::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3467
OGRPolyhedralSurface::OGRPolyhedralSurface
OGRPolyhedralSurface(OGRPolyhedralSurface &&other)=default
Move constructor.
OGRPolyhedralSurface::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3546
OGRPolyhedralSurface::begin
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3454
OGRPolyhedralSurface::OGRPolyhedralSurface
OGRPolyhedralSurface()=default
Create an empty PolyhedralSurface.
OGRPolyhedralSurface::addGeometry
virtual OGRErr addGeometry(const OGRGeometry *)
Add a new geometry to a collection.
Definition ogrpolyhedralsurface.cpp:744
OGRPolyhedralSurface::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3551
OGRPolyhedralSurface::ChildType
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:3450
OGRPolyhedralSurface::operator=
OGRPolyhedralSurface & operator=(OGRPolyhedralSurface &&other)=default
Move assignment operator.
OGRRawPoint
Simple container for a position.
Definition ogr_geometry.h:89
OGRRawPoint::OGRRawPoint
OGRRawPoint(double xIn, double yIn)
Constructor.
Definition ogr_geometry.h:97
OGRRawPoint::x
double x
x
Definition ogr_geometry.h:102
OGRRawPoint::y
double y
y
Definition ogr_geometry.h:104
OGRRawPoint::OGRRawPoint
OGRRawPoint()
Constructor.
Definition ogr_geometry.h:92
OGRSimpleCurve
Abstract curve base class for OGRLineString and OGRCircularString.
Definition ogr_geometry.h:1473
OGRSimpleCurve::getY
double getY(int i) const
Get Y at vertex.
Definition ogr_geometry.h:1626
OGRSimpleCurve::getX
double getX(int i) const
Get X at vertex.
Definition ogr_geometry.h:1621
OGRSimpleCurve::OGRSimpleCurve
OGRSimpleCurve()=default
Constructor.
OGRSimpleCurve::clone
OGRSimpleCurve * clone() const override=0
Make a copy of this object.
OGRSimpleCurve::ChildType
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:1550
OGRSimpleCurve::getNumPoints
int getNumPoints() const override
Fetch vertex count.
Definition ogr_geometry.h:1614
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
OGRSurface
Abstract base class for 2 dimensional objects like polygons or curve polygons.
Definition ogr_geometry.h:2370
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::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::clone
OGRSurface * clone() const override=0
Make a copy of this object.
OGRTriangle
Triangle class.
Definition ogr_geometry.h:2819
OGRTriangle::OGRTriangle
OGRTriangle()=default
Constructor.
OGRTriangle::toUpperClass
const OGRPolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2864
OGRTriangle::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2874
OGRTriangle::OGRTriangle
OGRTriangle(OGRTriangle &&other)=default
Move constructor.
OGRTriangle::toUpperClass
OGRPolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2858
OGRTriangle::operator=
OGRTriangle & operator=(OGRTriangle &&other)=default
Move assignment operator.
OGRTriangle::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2869
OGRTriangle::OGRTriangle
OGRTriangle(const OGRTriangle &other)
Copy constructor.
OGRTriangulatedSurface
TriangulatedSurface class.
Definition ogr_geometry.h:3602
OGRTriangulatedSurface::getGeometryRef
const OGRTriangle * getGeometryRef(int i) const
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:3666
OGRTriangulatedSurface::getGeometryRef
OGRTriangle * getGeometryRef(int i)
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:3660
OGRTriangulatedSurface::OGRTriangulatedSurface
OGRTriangulatedSurface(OGRTriangulatedSurface &&other)=default
Move constructor.
OGRTriangulatedSurface::end
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3650
OGRTriangulatedSurface::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3644
OGRTriangulatedSurface::toUpperClass
OGRPolyhedralSurface * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3679
OGRTriangulatedSurface::toUpperClass
const OGRPolyhedralSurface * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3685
OGRTriangulatedSurface::accept
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3695
OGRTriangulatedSurface::operator=
OGRTriangulatedSurface & operator=(OGRTriangulatedSurface &&other)=default
Move assignment operator.
OGRTriangulatedSurface::ChildType
OGRTriangle ChildType
Type of child elements.
Definition ogr_geometry.h:3627
OGRTriangulatedSurface::OGRTriangulatedSurface
OGRTriangulatedSurface()=default
Constructor.
OGRTriangulatedSurface::begin
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3631
OGRTriangulatedSurface::end
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3637
OGRTriangulatedSurface::accept
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3690
OGRWktOptions
Options for formatting WKT output.
Definition ogr_geometry.h:46
OGRWktOptions::mPrecision
int mPrecision
Precision of output for M coordinates. Interpretation depends on format.
Definition ogr_geometry.h:55
OGRWktOptions::zPrecision
int zPrecision
Precision of output for Z coordinates. Interpretation depends on format.
Definition ogr_geometry.h:53
OGRWktOptions::OGRWktOptions
OGRWktOptions()
Constructor.
Definition ogr_geometry.h:62
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:51
OGRWktOptions::round
bool round
Whether GDAL-special rounding should be applied.
Definition ogr_geometry.h:57
OGRWktOptions::OGRWktOptions
OGRWktOptions(int xyPrecisionIn, bool roundIn)
Constructor.
Definition ogr_geometry.h:69
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:936
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
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:870
GByte
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175
gdal_fwd.h
Forward definitions of GDAL/OGR/OSR C handle types.
OGRGeometryH
void * OGRGeometryH
Opaque type for a geometry.
Definition gdal_fwd.h:96
ogr_core.h
Core portability services for cross-platform OGR code.
OGRBoolean
int OGRBoolean
Type for a OGR boolean.
Definition ogr_core.h:386
OGRwkbByteOrder
OGRwkbByteOrder
Enumeration to describe byte order.
Definition ogr_core.h:607
wkbNDR
@ wkbNDR
LSB/Intel/Vax: Least Significant Byte First
Definition ogr_core.h:609
OGRwkbVariant
OGRwkbVariant
Output variants of WKB we support.
Definition ogr_core.h:540
wkbVariantOldOgc
@ wkbVariantOldOgc
Old-style 99-402 extended dimension (Z) WKB types.
Definition ogr_core.h:541
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:405
OGRErr
int OGRErr
Type for a OGR error.
Definition ogr_core.h:370
ogr_geomcoordinateprecision.h
Geometry coordinate precision class.
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:2605
OGRWktFormat
OGRWktFormat
WKT Output formatting options.
Definition ogr_geometry.h:38
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:4346
GEOSContextHandle_t
struct GEOSContextHandle_HS * GEOSContextHandle_t
GEOS context handle type.
Definition ogr_geometry.h:110
OGRFromOGCGeomType
OGRwkbGeometryType OGRFromOGCGeomType(const char *pszGeomType)
Map OGC geometry format type to corresponding OGR constants.
Definition ogrgeometry.cpp:2526
OGRGeometryUniquePtr
std::unique_ptr< OGRGeometry, OGRGeometryUniquePtrDeleter > OGRGeometryUniquePtr
Unique pointer type for OGRGeometry.
Definition ogr_geometry.h:995
GEOSGeom
struct GEOSGeom_t * GEOSGeom
GEOS geometry type.
Definition ogr_geometry.h:108
sfcgal_geometry_t
void sfcgal_geometry_t
SFCGAL geometry type.
Definition ogr_geometry.h:112
ogr_spatialref.h
Coordinate systems services.
begin
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition ogrsf_frmts.h:470
end
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition ogrsf_frmts.h:478
OGRGeomCoordinatePrecision
Geometry coordinate precision.
Definition ogr_geomcoordinateprecision.h:40
OGRwkbExportOptions
WKB export options.
Definition ogr_geometry.h:326