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"
23#include "ogr_spatialref.h"
24
25#include <climits>
26#include <cmath>
27#include <memory>
28#include <utility>
29
37enum class OGRWktFormat
38{
39 F,
40 G,
41 Default
42};
43
45struct CPL_DLL OGRWktOptions
46{
47 public:
57 bool round;
60
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
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
108typedef struct GEOSGeom_t *GEOSGeom;
110typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
112typedef void sfcgal_geometry_t;
113
114class OGRPoint;
115class OGRCurve;
116class OGRCompoundCurve;
117class OGRSimpleCurve;
118class OGRLinearRing;
119class OGRLineString;
121class OGRSurface;
122class OGRCurvePolygon;
123class OGRPolygon;
124class OGRMultiPoint;
125class OGRMultiSurface;
126class OGRMultiPolygon;
127class OGRMultiCurve;
130class OGRTriangle;
133
135typedef OGRLineString *(*OGRCurveCasterToLineString)(OGRCurve *);
136typedef OGRLinearRing *(*OGRCurveCasterToLinearRing)(OGRCurve *);
137
138typedef OGRPolygon *(*OGRSurfaceCasterToPolygon)(OGRSurface *);
139typedef OGRCurvePolygon *(*OGRSurfaceCasterToCurvePolygon)(OGRSurface *);
140typedef OGRMultiPolygon *(*OGRPolyhedralSurfaceCastToMultiPolygon)(
142
144
149{
150 public:
152 virtual ~IOGRGeometryVisitor() = default;
153
155 virtual void visit(OGRPoint *) = 0;
157 virtual void visit(OGRLineString *) = 0;
159 virtual void visit(OGRLinearRing *) = 0;
161 virtual void visit(OGRPolygon *) = 0;
163 virtual void visit(OGRMultiPoint *) = 0;
165 virtual void visit(OGRMultiLineString *) = 0;
167 virtual void visit(OGRMultiPolygon *) = 0;
169 virtual void visit(OGRGeometryCollection *) = 0;
171 virtual void visit(OGRCircularString *) = 0;
173 virtual void visit(OGRCompoundCurve *) = 0;
175 virtual void visit(OGRCurvePolygon *) = 0;
177 virtual void visit(OGRMultiCurve *) = 0;
179 virtual void visit(OGRMultiSurface *) = 0;
181 virtual void visit(OGRTriangle *) = 0;
183 virtual void visit(OGRPolyhedralSurface *) = 0;
185 virtual void visit(OGRTriangulatedSurface *) = 0;
186};
187
196{
197 void _visit(OGRSimpleCurve *poGeom);
198
199 public:
200 void visit(OGRPoint *) override
201 {
202 }
203
204 void visit(OGRLineString *) override;
205 void visit(OGRLinearRing *) override;
206 void visit(OGRPolygon *) override;
207 void visit(OGRMultiPoint *) override;
208 void visit(OGRMultiLineString *) override;
209 void visit(OGRMultiPolygon *) override;
210 void visit(OGRGeometryCollection *) override;
211 void visit(OGRCircularString *) override;
212 void visit(OGRCompoundCurve *) override;
213 void visit(OGRCurvePolygon *) override;
214 void visit(OGRMultiCurve *) override;
215 void visit(OGRMultiSurface *) override;
216 void visit(OGRTriangle *) override;
217 void visit(OGRPolyhedralSurface *) override;
218 void visit(OGRTriangulatedSurface *) override;
219};
220
225{
226 public:
228 virtual ~IOGRConstGeometryVisitor() = default;
229
231 virtual void visit(const OGRPoint *) = 0;
233 virtual void visit(const OGRLineString *) = 0;
235 virtual void visit(const OGRLinearRing *) = 0;
237 virtual void visit(const OGRPolygon *) = 0;
239 virtual void visit(const OGRMultiPoint *) = 0;
241 virtual void visit(const OGRMultiLineString *) = 0;
243 virtual void visit(const OGRMultiPolygon *) = 0;
245 virtual void visit(const OGRGeometryCollection *) = 0;
247 virtual void visit(const OGRCircularString *) = 0;
249 virtual void visit(const OGRCompoundCurve *) = 0;
251 virtual void visit(const OGRCurvePolygon *) = 0;
253 virtual void visit(const OGRMultiCurve *) = 0;
255 virtual void visit(const OGRMultiSurface *) = 0;
257 virtual void visit(const OGRTriangle *) = 0;
259 virtual void visit(const OGRPolyhedralSurface *) = 0;
261 virtual void visit(const OGRTriangulatedSurface *) = 0;
262};
263
272{
273 void _visit(const OGRSimpleCurve *poGeom);
274
275 public:
276 void visit(const OGRPoint *) override
277 {
278 }
279
280 void visit(const OGRLineString *) override;
281 void visit(const OGRLinearRing *) override;
282 void visit(const OGRPolygon *) override;
283 void visit(const OGRMultiPoint *) override;
284 void visit(const OGRMultiLineString *) override;
285 void visit(const OGRMultiPolygon *) override;
286 void visit(const OGRGeometryCollection *) override;
287 void visit(const OGRCircularString *) override;
288 void visit(const OGRCompoundCurve *) override;
289 void visit(const OGRCurvePolygon *) override;
290 void visit(const OGRMultiCurve *) override;
291 void visit(const OGRMultiSurface *) override;
292 void visit(const OGRTriangle *) override;
293 void visit(const OGRPolyhedralSurface *) override;
294 void visit(const OGRTriangulatedSurface *) override;
295};
296
297/************************************************************************/
298/* OGRGeomCoordinateBinaryPrecision */
299/************************************************************************/
300
306{
307 int nXYBitPrecision =
308 INT_MIN;
310 int nZBitPrecision =
311 INT_MIN;
313 int nMBitPrecision =
314 INT_MIN;
317 void SetFrom(const OGRGeomCoordinatePrecision &);
318};
319
320/************************************************************************/
321/* OGRwkbExportOptions */
322/************************************************************************/
323
334
335/************************************************************************/
336/* OGRGeometry */
337/************************************************************************/
338
359class CPL_DLL OGRGeometry
360{
361 private:
362 const OGRSpatialReference *poSRS = nullptr; // may be NULL
363
364 protected:
366 friend class OGRCurveCollection;
367
368 unsigned int flags = 0;
369
370 OGRErr importPreambleFromWkt(const char **ppszInput, int *pbHasZ,
371 int *pbHasM, bool *pbIsEmpty);
372 OGRErr importCurveCollectionFromWkt(
373 const char **ppszInput, int bAllowEmptyComponent, int bAllowLineString,
374 int bAllowCurve, int bAllowCompoundCurve,
375 OGRErr (*pfnAddCurveDirectly)(OGRGeometry *poSelf, OGRCurve *poCurve));
376 OGRErr importPreambleFromWkb(const unsigned char *pabyData, size_t nSize,
377 OGRwkbByteOrder &eByteOrder,
378 OGRwkbVariant eWkbVariant);
379 OGRErr importPreambleOfCollectionFromWkb(const unsigned char *pabyData,
380 size_t &nSize, size_t &nDataOffset,
381 OGRwkbByteOrder &eByteOrder,
382 size_t nMinSubGeomSize,
383 int &nGeomCount,
384 OGRwkbVariant eWkbVariant);
385 OGRErr PointOnSurfaceInternal(OGRPoint *poPoint) const;
386 OGRBoolean IsSFCGALCompatible() const;
387
388 void HomogenizeDimensionalityWith(OGRGeometry *poOtherGeom);
389 std::string wktTypeString(OGRwkbVariant variant) const;
390
392
393 public:
394 /************************************************************************/
395 /* Bit flags for OGRGeometry */
396 /* The OGR_G_NOT_EMPTY_POINT is used *only* for points. */
397 /* Do not use these outside of the core. */
398 /* Use Is3D, IsMeasured, set3D, and setMeasured instead */
399 /************************************************************************/
400
402 static const unsigned int OGR_G_NOT_EMPTY_POINT = 0x1;
403 static const unsigned int OGR_G_3D = 0x2;
404 static const unsigned int OGR_G_MEASURED = 0x4;
406
407 OGRGeometry();
408 OGRGeometry(const OGRGeometry &other);
409 OGRGeometry(OGRGeometry &&other);
410 virtual ~OGRGeometry();
411
412 OGRGeometry &operator=(const OGRGeometry &other);
413 OGRGeometry &operator=(OGRGeometry &&other);
414
416 bool operator==(const OGRGeometry &other) const
417 {
418 return CPL_TO_BOOL(Equals(&other));
419 }
420
422 bool operator!=(const OGRGeometry &other) const
423 {
424 return !CPL_TO_BOOL(Equals(&other));
425 }
426
427 // Standard IGeometry.
428 virtual int getDimension() const = 0;
429 virtual int getCoordinateDimension() const;
430 int CoordinateDimension() const;
431 virtual OGRBoolean IsEmpty() const = 0;
432 virtual OGRBoolean IsValid() const;
433 virtual OGRGeometry *MakeValid(CSLConstList papszOptions = nullptr) const;
434 virtual OGRGeometry *Normalize() const;
435 virtual OGRBoolean IsSimple() const;
436
439 {
440 return (flags & OGR_G_3D) != 0;
441 }
442
445 {
446 return (flags & OGR_G_MEASURED) != 0;
447 }
448
449 virtual OGRBoolean IsRing() const;
450 virtual void empty() = 0;
452 virtual void getEnvelope(OGREnvelope *psEnvelope) const = 0;
453 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const = 0;
454
455 // IWks Interface.
456 virtual size_t WkbSize() const = 0;
457 OGRErr importFromWkb(const GByte *, size_t = static_cast<size_t>(-1),
459 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
460 size_t &nBytesConsumedOut) = 0;
461 OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
463 virtual OGRErr exportToWkb(unsigned char *,
464 const OGRwkbExportOptions * = nullptr) const = 0;
465 virtual OGRErr importFromWkt(const char **ppszInput) = 0;
466
467#ifndef DOXYGEN_XML
471 OGRErr importFromWkt(char **ppszInput)
473 CPL_WARN_DEPRECATED("Use importFromWkt(const char**) instead")
475 {
476 return importFromWkt(const_cast<const char **>(ppszInput));
477 }
478#endif
479
480 OGRErr exportToWkt(char **ppszDstText,
482
487 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
488 OGRErr *err = nullptr) const = 0;
489
490 // Non-standard.
492 OGRwkbGeometryType getIsoGeometryType() const;
493 virtual const char *getGeometryName() const = 0;
494 void dumpReadable(FILE *, const char * = nullptr,
495 CSLConstList papszOptions = nullptr) const;
496 std::string dumpReadable(const char * = nullptr,
497 CSLConstList papszOptions = nullptr) const;
498 virtual void flattenTo2D() = 0;
499 virtual char *exportToGML(const char *const *papszOptions = nullptr) const;
500 virtual char *exportToKML() const;
501 virtual char *exportToJson(CSLConstList papszOptions = nullptr) const;
502
504 virtual void accept(IOGRGeometryVisitor *visitor) = 0;
505
507 virtual void accept(IOGRConstGeometryVisitor *visitor) const = 0;
508
509 static GEOSContextHandle_t createGEOSContext();
510 static void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt);
512 exportToGEOS(GEOSContextHandle_t hGEOSCtxt,
513 bool bRemoveEmptyParts = false) const CPL_WARN_UNUSED_RESULT;
514 virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
515 virtual OGRGeometry *getCurveGeometry(
516 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
517 virtual OGRGeometry *getLinearGeometry(
518 double dfMaxAngleStepSizeDegrees = 0,
519 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
520
521 void roundCoordinates(const OGRGeomCoordinatePrecision &sPrecision);
522 void
523 roundCoordinatesIEEE754(const OGRGeomCoordinateBinaryPrecision &options);
524
525 // SFCGAL interfacing methods.
527 static sfcgal_geometry_t *OGRexportToSFCGAL(const OGRGeometry *poGeom);
528 static OGRGeometry *SFCGALexportToOGR(const sfcgal_geometry_t *_geometry);
530 virtual void closeRings();
531
532 virtual bool setCoordinateDimension(int nDimension);
533 virtual bool set3D(OGRBoolean bIs3D);
534 virtual bool setMeasured(OGRBoolean bIsMeasured);
535
536 virtual void assignSpatialReference(const OGRSpatialReference *poSR);
537
538 const OGRSpatialReference *getSpatialReference(void) const
539 {
540 return poSRS;
541 }
542
544 OGRErr transformTo(const OGRSpatialReference *poSR);
545
546 virtual bool segmentize(double dfMaxLength);
547
548 // ISpatialRelation
549 virtual OGRBoolean Intersects(const OGRGeometry *) const;
550 virtual OGRBoolean Equals(const OGRGeometry *) const = 0;
551 virtual OGRBoolean Disjoint(const OGRGeometry *) const;
552 virtual OGRBoolean Touches(const OGRGeometry *) const;
553 virtual OGRBoolean Crosses(const OGRGeometry *) const;
554 virtual OGRBoolean Within(const OGRGeometry *) const;
555 virtual OGRBoolean Contains(const OGRGeometry *) const;
556 virtual OGRBoolean Overlaps(const OGRGeometry *) const;
557 // virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
558 // virtual OGRGeometry *LocateAlong( double mValue ) const;
559 // virtual OGRGeometry *LocateBetween( double mStart, double mEnd )
560 // const;
561
562 virtual OGRGeometry *Boundary() const CPL_WARN_UNUSED_RESULT;
563 virtual double Distance(const OGRGeometry *) const;
564 virtual OGRGeometry *ConvexHull() const CPL_WARN_UNUSED_RESULT;
565 virtual OGRGeometry *
566 ConcaveHull(double dfRatio, bool bAllowHoles) const CPL_WARN_UNUSED_RESULT;
567 virtual OGRGeometry *
568 Buffer(double dfDist, int nQuadSegs = 30) const CPL_WARN_UNUSED_RESULT;
569 virtual OGRGeometry *
570 BufferEx(double dfDistance,
571 CSLConstList papszOptions) const CPL_WARN_UNUSED_RESULT;
572 virtual OGRGeometry *
573 Intersection(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
574 virtual OGRGeometry *
575 Union(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
576 virtual OGRGeometry *UnionCascaded() const CPL_WARN_UNUSED_RESULT;
577 OGRGeometry *UnaryUnion() const CPL_WARN_UNUSED_RESULT;
578 virtual OGRGeometry *
579 Difference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
580 virtual OGRGeometry *
581 SymDifference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
582 virtual OGRErr Centroid(OGRPoint *poPoint) const;
583 virtual OGRGeometry *
584 Simplify(double dTolerance) const CPL_WARN_UNUSED_RESULT;
586 SimplifyPreserveTopology(double dTolerance) const CPL_WARN_UNUSED_RESULT;
587 virtual OGRGeometry *
588 DelaunayTriangulation(double dfTolerance,
589 int bOnlyEdges) const CPL_WARN_UNUSED_RESULT;
590
591 virtual OGRGeometry *Polygonize() const CPL_WARN_UNUSED_RESULT;
592 virtual OGRGeometry *BuildArea() const CPL_WARN_UNUSED_RESULT;
593
594 virtual double Distance3D(const OGRGeometry *poOtherGeom) const;
595
596 OGRGeometry *SetPrecision(double dfGridSize, int nFlags) const;
597
598 virtual bool hasEmptyParts() const;
599 virtual void removeEmptyParts();
600
602 // backward compatibility to non-standard method names.
603 OGRBoolean Intersect(OGRGeometry *) const
604 CPL_WARN_DEPRECATED("Non standard method. "
605 "Use Intersects() instead");
606 OGRBoolean Equal(OGRGeometry *) const
607 CPL_WARN_DEPRECATED("Non standard method. "
608 "Use Equals() instead");
609 OGRGeometry *SymmetricDifference(const OGRGeometry *) const
610 CPL_WARN_DEPRECATED("Non standard method. "
611 "Use SymDifference() instead");
612 OGRGeometry *getBoundary() const
613 CPL_WARN_DEPRECATED("Non standard method. "
614 "Use Boundary() instead");
616
618 // Special HACK for DB2 7.2 support
619 static int bGenerate_DB2_V72_BYTE_ORDER;
621
622 virtual void swapXY();
623
624 bool IsRectangle() const;
625
627 static OGRGeometry *CastToIdentity(OGRGeometry *poGeom)
628 {
629 return poGeom;
630 }
631
632 static OGRGeometry *CastToError(OGRGeometry *poGeom);
633
635
639 static inline OGRGeometryH ToHandle(OGRGeometry *poGeom)
640 {
641 return reinterpret_cast<OGRGeometryH>(poGeom);
642 }
643
647 static inline OGRGeometry *FromHandle(OGRGeometryH hGeom)
648 {
649 return reinterpret_cast<OGRGeometry *>(hGeom);
650 }
651
657 {
658 return cpl::down_cast<OGRPoint *>(this);
659 }
660
665 inline const OGRPoint *toPoint() const
666 {
667 return cpl::down_cast<const OGRPoint *>(this);
668 }
669
676 {
677 return cpl::down_cast<OGRCurve *>(this);
678 }
679
685 inline const OGRCurve *toCurve() const
686 {
687 return cpl::down_cast<const OGRCurve *>(this);
688 }
689
696 {
697 return cpl::down_cast<OGRSimpleCurve *>(this);
698 }
699
705 inline const OGRSimpleCurve *toSimpleCurve() const
706 {
707 return cpl::down_cast<const OGRSimpleCurve *>(this);
708 }
709
716 {
717 return cpl::down_cast<OGRLineString *>(this);
718 }
719
725 inline const OGRLineString *toLineString() const
726 {
727 return cpl::down_cast<const OGRLineString *>(this);
728 }
729
735 {
736 return cpl::down_cast<OGRLinearRing *>(this);
737 }
738
743 inline const OGRLinearRing *toLinearRing() const
744 {
745 return cpl::down_cast<const OGRLinearRing *>(this);
746 }
747
754 {
755 return cpl::down_cast<OGRCircularString *>(this);
756 }
757
764 {
765 return cpl::down_cast<const OGRCircularString *>(this);
766 }
767
774 {
775 return cpl::down_cast<OGRCompoundCurve *>(this);
776 }
777
783 inline const OGRCompoundCurve *toCompoundCurve() const
784 {
785 return cpl::down_cast<const OGRCompoundCurve *>(this);
786 }
787
794 {
795 return cpl::down_cast<OGRSurface *>(this);
796 }
797
803 inline const OGRSurface *toSurface() const
804 {
805 return cpl::down_cast<const OGRSurface *>(this);
806 }
807
814 {
815 return cpl::down_cast<OGRPolygon *>(this);
816 }
817
823 inline const OGRPolygon *toPolygon() const
824 {
825 return cpl::down_cast<const OGRPolygon *>(this);
826 }
827
833 {
834 return cpl::down_cast<OGRTriangle *>(this);
835 }
836
841 inline const OGRTriangle *toTriangle() const
842 {
843 return cpl::down_cast<const OGRTriangle *>(this);
844 }
845
852 {
853 return cpl::down_cast<OGRCurvePolygon *>(this);
854 }
855
861 inline const OGRCurvePolygon *toCurvePolygon() const
862 {
863 return cpl::down_cast<const OGRCurvePolygon *>(this);
864 }
865
872 {
873 return cpl::down_cast<OGRGeometryCollection *>(this);
874 }
875
882 {
883 return cpl::down_cast<const OGRGeometryCollection *>(this);
884 }
885
892 {
893 return cpl::down_cast<OGRMultiPoint *>(this);
894 }
895
901 inline const OGRMultiPoint *toMultiPoint() const
902 {
903 return cpl::down_cast<const OGRMultiPoint *>(this);
904 }
905
912 {
913 return cpl::down_cast<OGRMultiLineString *>(this);
914 }
915
922 {
923 return cpl::down_cast<const OGRMultiLineString *>(this);
924 }
925
932 {
933 return cpl::down_cast<OGRMultiPolygon *>(this);
934 }
935
941 inline const OGRMultiPolygon *toMultiPolygon() const
942 {
943 return cpl::down_cast<const OGRMultiPolygon *>(this);
944 }
945
952 {
953 return cpl::down_cast<OGRMultiCurve *>(this);
954 }
955
961 inline const OGRMultiCurve *toMultiCurve() const
962 {
963 return cpl::down_cast<const OGRMultiCurve *>(this);
964 }
965
972 {
973 return cpl::down_cast<OGRMultiSurface *>(this);
974 }
975
981 inline const OGRMultiSurface *toMultiSurface() const
982 {
983 return cpl::down_cast<const OGRMultiSurface *>(this);
984 }
985
992 {
993 return cpl::down_cast<OGRPolyhedralSurface *>(this);
994 }
995
1002 {
1003 return cpl::down_cast<const OGRPolyhedralSurface *>(this);
1004 }
1005
1011 {
1012 return cpl::down_cast<OGRTriangulatedSurface *>(this);
1013 }
1014
1020 {
1021 return cpl::down_cast<const OGRTriangulatedSurface *>(this);
1022 }
1023};
1024
1026struct CPL_DLL OGRGeometryUniquePtrDeleter
1027{
1028 void operator()(OGRGeometry *) const;
1029};
1030
1032
1036typedef std::unique_ptr<OGRGeometry, OGRGeometryUniquePtrDeleter>
1038
1040#define OGR_FORBID_DOWNCAST_TO(name) \
1041 inline OGR##name *to##name() = delete; \
1042 inline const OGR##name *to##name() const = delete;
1043
1044#define OGR_FORBID_DOWNCAST_TO_POINT OGR_FORBID_DOWNCAST_TO(Point)
1045#define OGR_FORBID_DOWNCAST_TO_CURVE OGR_FORBID_DOWNCAST_TO(Curve)
1046#define OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE OGR_FORBID_DOWNCAST_TO(SimpleCurve)
1047#define OGR_FORBID_DOWNCAST_TO_LINESTRING OGR_FORBID_DOWNCAST_TO(LineString)
1048#define OGR_FORBID_DOWNCAST_TO_LINEARRING OGR_FORBID_DOWNCAST_TO(LinearRing)
1049#define OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1050 OGR_FORBID_DOWNCAST_TO(CircularString)
1051#define OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE \
1052 OGR_FORBID_DOWNCAST_TO(CompoundCurve)
1053#define OGR_FORBID_DOWNCAST_TO_SURFACE OGR_FORBID_DOWNCAST_TO(Surface)
1054#define OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON OGR_FORBID_DOWNCAST_TO(CurvePolygon)
1055#define OGR_FORBID_DOWNCAST_TO_POLYGON OGR_FORBID_DOWNCAST_TO(Polygon)
1056#define OGR_FORBID_DOWNCAST_TO_TRIANGLE OGR_FORBID_DOWNCAST_TO(Triangle)
1057#define OGR_FORBID_DOWNCAST_TO_MULTIPOINT OGR_FORBID_DOWNCAST_TO(MultiPoint)
1058#define OGR_FORBID_DOWNCAST_TO_MULTICURVE OGR_FORBID_DOWNCAST_TO(MultiCurve)
1059#define OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1060 OGR_FORBID_DOWNCAST_TO(MultiLineString)
1061#define OGR_FORBID_DOWNCAST_TO_MULTISURFACE OGR_FORBID_DOWNCAST_TO(MultiSurface)
1062#define OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON OGR_FORBID_DOWNCAST_TO(MultiPolygon)
1063#define OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1064 OGR_FORBID_DOWNCAST_TO(GeometryCollection)
1065#define OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1066 OGR_FORBID_DOWNCAST_TO(PolyhedralSurface)
1067#define OGR_FORBID_DOWNCAST_TO_TIN OGR_FORBID_DOWNCAST_TO(TriangulatedSurface)
1068
1069#define OGR_ALLOW_UPCAST_TO(name) \
1070 inline OGR##name *to##name() \
1071 { \
1072 return this; \
1073 } \
1074 inline const OGR##name *to##name() const \
1075 { \
1076 return this; \
1077 }
1078
1079#ifndef SUPPRESS_OGR_ALLOW_CAST_TO_THIS_WARNING
1080#define CAST_TO_THIS_WARNING CPL_WARN_DEPRECATED("Casting to this is useless")
1081#else
1082#define CAST_TO_THIS_WARNING
1083#endif
1084
1085#define OGR_ALLOW_CAST_TO_THIS(name) \
1086 inline OGR##name *to##name() CAST_TO_THIS_WARNING \
1087 { \
1088 return this; \
1089 } \
1090 inline const OGR##name *to##name() const CAST_TO_THIS_WARNING \
1091 { \
1092 return this; \
1093 }
1094
1095#define OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1096 OGR_FORBID_DOWNCAST_TO_CURVE \
1097 OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE \
1098 OGR_FORBID_DOWNCAST_TO_LINESTRING \
1099 OGR_FORBID_DOWNCAST_TO_LINEARRING \
1100 OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1101 OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE
1102
1103#define OGR_FORBID_DOWNCAST_TO_ALL_SURFACES \
1104 OGR_FORBID_DOWNCAST_TO_SURFACE \
1105 OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON \
1106 OGR_FORBID_DOWNCAST_TO_POLYGON \
1107 OGR_FORBID_DOWNCAST_TO_TRIANGLE \
1108 OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1109 OGR_FORBID_DOWNCAST_TO_TIN
1110
1111#define OGR_FORBID_DOWNCAST_TO_ALL_SINGLES \
1112 OGR_FORBID_DOWNCAST_TO_POINT \
1113 OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1114 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1115
1116#define OGR_FORBID_DOWNCAST_TO_ALL_MULTI \
1117 OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1118 OGR_FORBID_DOWNCAST_TO_MULTIPOINT \
1119 OGR_FORBID_DOWNCAST_TO_MULTICURVE \
1120 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1121 OGR_FORBID_DOWNCAST_TO_MULTISURFACE \
1122 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
1123
1125
1126/************************************************************************/
1127/* OGRPoint */
1128/************************************************************************/
1129
1136class CPL_DLL OGRPoint : public OGRGeometry
1137{
1138 double x;
1139 double y;
1140 double z;
1141 double m;
1142
1143 public:
1144 OGRPoint();
1145 OGRPoint(double x, double y);
1146 OGRPoint(double x, double y, double z);
1147 OGRPoint(double x, double y, double z, double m);
1148 OGRPoint(const OGRPoint &other);
1150 OGRPoint(OGRPoint &&other) = default;
1151 static OGRPoint *createXYM(double x, double y, double m);
1152
1153 OGRPoint &operator=(const OGRPoint &other);
1155 OGRPoint &operator=(OGRPoint &&other) = default;
1156
1157 // IWks Interface
1158 size_t WkbSize() const override;
1159 OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1160 size_t &nBytesConsumedOut) override;
1161 OGRErr exportToWkb(unsigned char *,
1162 const OGRwkbExportOptions * = nullptr) const override;
1163
1164#ifndef DOXYGEN_XML
1166#endif
1167
1168 OGRErr importFromWkt(const char **) override;
1169
1170#ifndef DOXYGEN_XML
1172#endif
1173
1178 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1179 OGRErr *err = nullptr) const override;
1180
1181 // IGeometry
1182 virtual int getDimension() const override;
1183 virtual OGRPoint *clone() const override;
1184 virtual void empty() override;
1185 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1186 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1187
1188 virtual OGRBoolean IsEmpty() const override
1189 {
1190 return !(flags & OGR_G_NOT_EMPTY_POINT);
1191 }
1192
1193 // IPoint
1195 double getX() const
1196 {
1197 return x;
1198 }
1199
1201 double getY() const
1202 {
1203 return y;
1204 }
1205
1207 double getZ() const
1208 {
1209 return z;
1210 }
1211
1213 double getM() const
1214 {
1215 return m;
1216 }
1217
1218 // Non standard
1219 virtual bool setCoordinateDimension(int nDimension) override;
1220
1224 void setX(double xIn)
1225 {
1226 x = xIn;
1227 if (std::isnan(x) || std::isnan(y))
1228 flags &= ~OGR_G_NOT_EMPTY_POINT;
1229 else
1230 flags |= OGR_G_NOT_EMPTY_POINT;
1231 }
1232
1236 void setY(double yIn)
1237 {
1238 y = yIn;
1239 if (std::isnan(x) || std::isnan(y))
1240 flags &= ~OGR_G_NOT_EMPTY_POINT;
1241 else
1242 flags |= OGR_G_NOT_EMPTY_POINT;
1243 }
1244
1248 void setZ(double zIn)
1249 {
1250 z = zIn;
1251 flags |= OGR_G_3D;
1252 }
1253
1257 void setM(double mIn)
1258 {
1259 m = mIn;
1260 flags |= OGR_G_MEASURED;
1261 }
1262
1263 // ISpatialRelation
1264 virtual OGRBoolean Equals(const OGRGeometry *) const override;
1265 virtual OGRBoolean Intersects(const OGRGeometry *) const override;
1266 virtual OGRBoolean Within(const OGRGeometry *) const override;
1267
1268 // Non standard from OGRGeometry
1269 virtual const char *getGeometryName() const override;
1270 virtual OGRwkbGeometryType getGeometryType() const override;
1271 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1272 virtual void flattenTo2D() override;
1273
1274 virtual void accept(IOGRGeometryVisitor *visitor) override
1275 {
1276 visitor->visit(this);
1277 }
1278
1279 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1280 {
1281 visitor->visit(this);
1282 }
1283
1284 virtual void swapXY() override;
1285
1286 OGR_ALLOW_CAST_TO_THIS(Point)
1287 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
1288 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1289 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1290};
1291
1292/************************************************************************/
1293/* OGRPointIterator */
1294/************************************************************************/
1295
1302class CPL_DLL OGRPointIterator
1303{
1304 public:
1305 virtual ~OGRPointIterator();
1307
1308 static void destroy(OGRPointIterator *);
1309};
1310
1311/************************************************************************/
1312/* OGRCurve */
1313/************************************************************************/
1314
1320class CPL_DLL OGRCurve : public OGRGeometry
1321{
1322 protected:
1324 OGRCurve() = default;
1325 OGRCurve(const OGRCurve &other) = default;
1326 OGRCurve(OGRCurve &&other) = default;
1327
1328 virtual OGRCurveCasterToLineString GetCasterToLineString() const = 0;
1329 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const = 0;
1330
1331 friend class OGRCurvePolygon;
1332 friend class OGRCompoundCurve;
1334 virtual int ContainsPoint(const OGRPoint *p) const;
1335 virtual int IntersectsPoint(const OGRPoint *p) const;
1336 virtual double get_AreaOfCurveSegments() const = 0;
1337
1338 private:
1339 class CPL_DLL ConstIterator
1340 {
1341 struct Private;
1342 std::unique_ptr<Private> m_poPrivate;
1343
1344 public:
1345 ConstIterator(const OGRCurve *poSelf, bool bStart);
1346 ConstIterator(ConstIterator &&oOther) noexcept;
1347 ConstIterator &operator=(ConstIterator &&oOther);
1348 ~ConstIterator();
1349 const OGRPoint &operator*() const;
1350 ConstIterator &operator++();
1351 bool operator!=(const ConstIterator &it) const;
1352 };
1353
1354 friend inline ConstIterator begin(const OGRCurve *);
1355 friend inline ConstIterator end(const OGRCurve *);
1356
1357 public:
1359 OGRCurve &operator=(const OGRCurve &other);
1360 OGRCurve &operator=(OGRCurve &&other) = default;
1362
1365
1374 ConstIterator begin() const;
1376 ConstIterator end() const;
1377
1378 // IGeometry
1379 virtual OGRCurve *clone() const override = 0;
1380
1381 // ICurve methods
1382 virtual double get_Length() const = 0;
1383 virtual void StartPoint(OGRPoint *) const = 0;
1384 virtual void EndPoint(OGRPoint *) const = 0;
1385 virtual int get_IsClosed() const;
1386 virtual void Value(double, OGRPoint *) const = 0;
1387 virtual OGRLineString *
1388 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1389 const char *const *papszOptions = nullptr) const = 0;
1390 virtual int getDimension() const override;
1391
1392 // non standard
1393 virtual int getNumPoints() const = 0;
1395 virtual OGRBoolean IsConvex() const;
1396 virtual double get_Area() const = 0;
1397 virtual double get_GeodesicArea(
1398 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
1399 virtual double get_GeodesicLength(
1400 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
1401 virtual int isClockwise() const;
1402 virtual void reversePoints() = 0;
1403
1408 {
1409 return cpl::down_cast<OGRSimpleCurve *>(this);
1410 }
1411
1415 inline const OGRSimpleCurve *toSimpleCurve() const
1416 {
1417 return cpl::down_cast<const OGRSimpleCurve *>(this);
1418 }
1419
1420 static OGRCompoundCurve *CastToCompoundCurve(OGRCurve *puCurve);
1421 static OGRLineString *CastToLineString(OGRCurve *poCurve);
1422 static OGRLinearRing *CastToLinearRing(OGRCurve *poCurve);
1423
1424 OGR_FORBID_DOWNCAST_TO_POINT
1425 OGR_ALLOW_CAST_TO_THIS(Curve)
1426 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1427 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1428};
1429
1431
1432inline OGRCurve::ConstIterator begin(const OGRCurve *poCurve)
1433{
1434 return poCurve->begin();
1435}
1436
1438inline OGRCurve::ConstIterator end(const OGRCurve *poCurve)
1439{
1440 return poCurve->end();
1441}
1442
1444
1445/************************************************************************/
1446/* OGRIteratedPoint */
1447/************************************************************************/
1448
1470class CPL_DLL OGRIteratedPoint : public OGRPoint
1471{
1472 private:
1473 friend class OGRSimpleCurve;
1474
1475 OGRSimpleCurve *m_poCurve = nullptr;
1476 int m_nPos = 0;
1477
1478 OGRIteratedPoint() = default;
1479
1481
1482 public:
1486 void setX(double xIn);
1490 void setY(double yIn);
1494 void setZ(double zIn);
1498 void setM(double mIn);
1499};
1500
1501/************************************************************************/
1502/* OGRSimpleCurve */
1503/************************************************************************/
1504
1514class CPL_DLL OGRSimpleCurve : public OGRCurve
1515{
1516 protected:
1518 friend class OGRGeometry;
1519
1520 int nPointCount = 0;
1521 int m_nPointCapacity = 0;
1522 OGRRawPoint *paoPoints = nullptr;
1523 double *padfZ = nullptr;
1524 double *padfM = nullptr;
1525
1526 bool Make3D();
1527 void Make2D();
1528 void RemoveM();
1529 bool AddM();
1530
1531 OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ, int bHasM,
1532 OGRRawPoint *&paoPointsIn, int &nMaxPoints,
1533 double *&padfZIn);
1535
1536 virtual double get_LinearArea() const;
1537
1539 OGRSimpleCurve() = default;
1540
1541 OGRSimpleCurve(const OGRSimpleCurve &other);
1542
1544
1545 private:
1546 class CPL_DLL Iterator
1547 {
1548 struct Private;
1549 std::unique_ptr<Private> m_poPrivate;
1550 void update();
1551
1552 public:
1553 Iterator(OGRSimpleCurve *poSelf, int nPos);
1554 Iterator(Iterator &&oOther) noexcept; // declared but not defined.
1555 // Needed for gcc 5.4 at least
1556 ~Iterator();
1557 OGRIteratedPoint &operator*();
1558 Iterator &operator++();
1559 bool operator!=(const Iterator &it) const;
1560 };
1561
1562 friend inline Iterator begin(OGRSimpleCurve *);
1563 friend inline Iterator end(OGRSimpleCurve *);
1564
1565 class CPL_DLL ConstIterator
1566 {
1567 struct Private;
1568 std::unique_ptr<Private> m_poPrivate;
1569
1570 public:
1571 ConstIterator(const OGRSimpleCurve *poSelf, int nPos);
1572 ConstIterator(
1573 ConstIterator &&oOther) noexcept; // declared but not defined.
1574 // Needed for gcc 5.4 at least
1575 ~ConstIterator();
1576 const OGRPoint &operator*() const;
1577 ConstIterator &operator++();
1578 bool operator!=(const ConstIterator &it) const;
1579 };
1580
1581 friend inline ConstIterator begin(const OGRSimpleCurve *);
1582 friend inline ConstIterator end(const OGRSimpleCurve *);
1583
1584 public:
1585 ~OGRSimpleCurve() override;
1586
1587 OGRSimpleCurve &operator=(const OGRSimpleCurve &other);
1588
1589 OGRSimpleCurve &operator=(OGRSimpleCurve &&other);
1590
1593
1602 Iterator begin();
1604 Iterator end();
1613 ConstIterator begin() const;
1615 ConstIterator end() const;
1616
1617 // IWks Interface.
1618 virtual size_t WkbSize() const override;
1619 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1620 size_t &nBytesConsumedOut) override;
1621 virtual OGRErr
1622 exportToWkb(unsigned char *,
1623 const OGRwkbExportOptions * = nullptr) const override;
1624
1625#ifndef DOXYGEN_XML
1627#endif
1628
1629 OGRErr importFromWkt(const char **) override;
1630
1631#ifndef DOXYGEN_XML
1633#endif
1634
1639 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1640 OGRErr *err = nullptr) const override;
1641
1642 // IGeometry interface.
1643 virtual void empty() override;
1644 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1645 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1646 virtual OGRBoolean IsEmpty() const override;
1647 virtual OGRSimpleCurve *clone() const override = 0;
1648
1649 // ICurve methods.
1650 virtual double get_Length() const override;
1651 virtual void StartPoint(OGRPoint *) const override;
1652 virtual void EndPoint(OGRPoint *) const override;
1653 virtual void Value(double, OGRPoint *) const override;
1654 virtual double Project(const OGRPoint *) const;
1655 virtual OGRLineString *getSubLine(double, double, int) const;
1656
1657 // ILineString methods.
1658 virtual int getNumPoints() const override
1659 {
1660 return nPointCount;
1661 }
1662
1663 void getPoint(int, OGRPoint *) const;
1664
1665 double getX(int i) const
1666 {
1667 return paoPoints[i].x;
1668 }
1669
1670 double getY(int i) const
1671 {
1672 return paoPoints[i].y;
1673 }
1674
1675 double getZ(int i) const;
1676 double getM(int i) const;
1677
1678 // ISpatialRelation
1679 virtual OGRBoolean Equals(const OGRGeometry *) const override;
1680
1681 // non standard.
1682 virtual bool setCoordinateDimension(int nDimension) override;
1683 virtual bool set3D(OGRBoolean bIs3D) override;
1684 virtual bool setMeasured(OGRBoolean bIsMeasured) override;
1685 bool setNumPoints(int nNewPointCount, int bZeroizeNewContent = TRUE);
1686 bool setPoint(int, OGRPoint *);
1687 bool setPoint(int, double, double);
1688 bool setZ(int, double);
1689 bool setM(int, double);
1690 bool setPoint(int, double, double, double);
1691 bool setPointM(int, double, double, double);
1692 bool setPoint(int, double, double, double, double);
1693 bool setPoints(int, const OGRRawPoint *, const double * = nullptr);
1694 bool setPointsM(int, const OGRRawPoint *, const double *);
1695 bool setPoints(int, const OGRRawPoint *, const double *, const double *);
1696 bool setPoints(int, const double *padfX, const double *padfY,
1697 const double *padfZIn = nullptr);
1698 bool setPointsM(int, const double *padfX, const double *padfY,
1699 const double *padfMIn = nullptr);
1700 bool setPoints(int, const double *padfX, const double *padfY,
1701 const double *padfZIn, const double *padfMIn);
1702 bool addPoint(const OGRPoint *);
1703 bool addPoint(double, double);
1704 bool addPoint(double, double, double);
1705 bool addPointM(double, double, double);
1706 bool addPoint(double, double, double, double);
1707
1708 bool removePoint(int);
1709
1710 void getPoints(OGRRawPoint *, double * = nullptr) const;
1711 void getPoints(void *pabyX, int nXStride, void *pabyY, int nYStride,
1712 void *pabyZ = nullptr, int nZStride = 0,
1713 void *pabyM = nullptr, int nMStride = 0) const;
1714
1715 void addSubLineString(const OGRLineString *, int nStartVertex = 0,
1716 int nEndVertex = -1);
1717 void reversePoints() override;
1718 virtual OGRPointIterator *getPointIterator() const override;
1719
1720 // non-standard from OGRGeometry
1721 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1722 virtual void flattenTo2D() override;
1723 virtual bool segmentize(double dfMaxLength) override;
1724
1725 virtual void swapXY() override;
1726
1727 OGR_ALLOW_UPCAST_TO(Curve)
1728 OGR_ALLOW_CAST_TO_THIS(SimpleCurve)
1729};
1730
1732
1733inline OGRSimpleCurve::Iterator begin(OGRSimpleCurve *poCurve)
1734{
1735 return poCurve->begin();
1736}
1737
1739inline OGRSimpleCurve::Iterator end(OGRSimpleCurve *poCurve)
1740{
1741 return poCurve->end();
1742}
1743
1745inline OGRSimpleCurve::ConstIterator begin(const OGRSimpleCurve *poCurve)
1746{
1747 return poCurve->begin();
1748}
1749
1751inline OGRSimpleCurve::ConstIterator end(const OGRSimpleCurve *poCurve)
1752{
1753 return poCurve->end();
1754}
1755
1757
1758/************************************************************************/
1759/* OGRLineString */
1760/************************************************************************/
1761
1769class CPL_DLL OGRLineString : public OGRSimpleCurve
1770{
1771 // cppcheck-suppress unusedPrivateFunction
1772 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
1773
1774 protected:
1776 static OGRLineString *TransferMembersAndDestroy(OGRLineString *poSrc,
1777 OGRLineString *poDst);
1778
1779 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1780 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1781
1782 virtual double get_AreaOfCurveSegments() const override;
1784
1785 static OGRLinearRing *CastToLinearRing(OGRLineString *poLS);
1786
1787 public:
1789 OGRLineString() = default;
1792
1793 OGRLineString &operator=(const OGRLineString &other);
1794 OGRLineString &operator=(OGRLineString &&other);
1795
1796 virtual OGRLineString *clone() const override;
1797 virtual OGRLineString *
1798 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1799 const char *const *papszOptions = nullptr) const override;
1800 virtual OGRGeometry *
1801 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
1802 virtual double get_Area() const override;
1803 virtual double get_GeodesicArea(
1804 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1805 virtual double get_GeodesicLength(
1806 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1807
1808 // Non-standard from OGRGeometry.
1809 virtual OGRwkbGeometryType getGeometryType() const override;
1810 virtual const char *getGeometryName() const override;
1811 virtual int isClockwise() const override;
1812
1815 {
1816 return this;
1817 }
1818
1820 inline const OGRSimpleCurve *toUpperClass() const
1821 {
1822 return this;
1823 }
1824
1825 virtual void accept(IOGRGeometryVisitor *visitor) override
1826 {
1827 visitor->visit(this);
1828 }
1829
1830 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1831 {
1832 visitor->visit(this);
1833 }
1834
1835 OGR_ALLOW_UPCAST_TO(SimpleCurve)
1836 OGR_ALLOW_CAST_TO_THIS(LineString)
1837};
1838
1839/************************************************************************/
1840/* OGRLinearRing */
1841/************************************************************************/
1842
1863class CPL_DLL OGRLinearRing : public OGRLineString
1864{
1865 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
1866
1867 // IWks Interface - Note this isn't really a first class object
1868 // for the purposes of WKB form. These methods always fail since this
1869 // object can't be serialized on its own.
1870 virtual size_t WkbSize() const override;
1871 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1872 size_t &nBytesConsumedOut) override;
1873 OGRErr exportToWkb(unsigned char *,
1874 const OGRwkbExportOptions * = nullptr) const override;
1875
1876 protected:
1878 friend class OGRPolygon;
1879 friend class OGRTriangle;
1880
1881 // These are not IWks compatible ... just a convenience for OGRPolygon.
1882 virtual size_t _WkbSize(int _flags) const;
1883 virtual OGRErr _importFromWkb(OGRwkbByteOrder, int _flags,
1884 const unsigned char *, size_t,
1885 size_t &nBytesConsumedOut);
1886 virtual OGRErr _exportToWkb(int _flags, unsigned char *,
1887 const OGRwkbExportOptions *) const;
1888
1889 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1890 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1892
1893 static OGRLineString *CastToLineString(OGRLinearRing *poLR);
1894
1895 public:
1897 OGRLinearRing() = default;
1900 OGRLinearRing(OGRLinearRing &&other) = default;
1901 explicit OGRLinearRing(const OGRLinearRing *);
1902
1903 OGRLinearRing &operator=(const OGRLinearRing &other);
1906
1907 // Non standard.
1908 virtual const char *getGeometryName() const override;
1909 virtual OGRLinearRing *clone() const override;
1910
1912 void reverseWindingOrder()
1913 CPL_WARN_DEPRECATED("Use reversePoints() instead");
1915
1916 virtual void closeRings() override;
1917 OGRBoolean isPointInRing(const OGRPoint *pt,
1918 int bTestEnvelope = TRUE) const;
1919 OGRBoolean isPointOnRingBoundary(const OGRPoint *pt,
1920 int bTestEnvelope = TRUE) const;
1921 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1922
1924 inline OGRLineString *toUpperClass()
1925 {
1926 return this;
1927 }
1928
1930 inline const OGRLineString *toUpperClass() const
1931 {
1932 return this;
1933 }
1934
1935 virtual void accept(IOGRGeometryVisitor *visitor) override
1936 {
1937 visitor->visit(this);
1938 }
1939
1940 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1941 {
1942 visitor->visit(this);
1943 }
1944
1945 OGR_ALLOW_UPCAST_TO(LineString)
1946 OGR_ALLOW_CAST_TO_THIS(LinearRing)
1947};
1948
1949/************************************************************************/
1950/* OGRCircularString */
1951/************************************************************************/
1952
1965class CPL_DLL OGRCircularString : public OGRSimpleCurve
1966{
1967 private:
1968 void ExtendEnvelopeWithCircular(OGREnvelope *psEnvelope) const;
1969 OGRBoolean IsValidFast() const;
1970 int IsFullCircle(double &cx, double &cy, double &square_R) const;
1971
1972 protected:
1974 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1975 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1976 virtual int IntersectsPoint(const OGRPoint *p) const override;
1977 virtual int ContainsPoint(const OGRPoint *p) const override;
1978 virtual double get_AreaOfCurveSegments() const override;
1980
1981 public:
1984
1988
1989 OGRCircularString &operator=(const OGRCircularString &other);
1992
1993 // IWks Interface.
1994 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1995 size_t &nBytesConsumedOut) override;
1996 OGRErr exportToWkb(unsigned char *,
1997 const OGRwkbExportOptions * = nullptr) const override;
1998
1999#ifndef DOXYGEN_XML
2001#endif
2002
2003 OGRErr importFromWkt(const char **) override;
2004
2005#ifndef DOXYGEN_XML
2007#endif
2008
2013 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2014 OGRErr *err = nullptr) const override;
2015
2016 // IGeometry interface.
2017 virtual OGRBoolean IsValid() const override;
2018 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2019 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2020 virtual OGRCircularString *clone() const override;
2021
2022 // ICurve methods.
2023 virtual double get_Length() const override;
2024 virtual OGRLineString *
2025 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
2026 const char *const *papszOptions = nullptr) const override;
2027 virtual void Value(double, OGRPoint *) const override;
2028 virtual double get_Area() const override;
2029 virtual double get_GeodesicArea(
2030 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2031 virtual double get_GeodesicLength(
2032 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2033
2034 // Non-standard from OGRGeometry.
2035 virtual OGRwkbGeometryType getGeometryType() const override;
2036 virtual const char *getGeometryName() const override;
2037 virtual bool segmentize(double dfMaxLength) override;
2038 virtual OGRBoolean
2039 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2040 virtual OGRGeometry *
2041 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2042 const char *const *papszOptions = nullptr) const override;
2043
2046 {
2047 return this;
2048 }
2049
2051 inline const OGRSimpleCurve *toUpperClass() const
2052 {
2053 return this;
2054 }
2055
2056 virtual void accept(IOGRGeometryVisitor *visitor) override
2057 {
2058 visitor->visit(this);
2059 }
2060
2061 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2062 {
2063 visitor->visit(this);
2064 }
2065
2066 OGR_ALLOW_UPCAST_TO(SimpleCurve)
2067 OGR_ALLOW_CAST_TO_THIS(CircularString)
2068};
2069
2070/************************************************************************/
2071/* OGRCurveCollection */
2072/************************************************************************/
2073
2085class CPL_DLL OGRCurveCollection
2086{
2087 protected:
2088 friend class OGRCompoundCurve;
2089 friend class OGRCurvePolygon;
2090 friend class OGRPolygon;
2091 friend class OGRTriangle;
2092
2093 int nCurveCount = 0;
2094 OGRCurve **papoCurves = nullptr;
2095
2096 public:
2097 OGRCurveCollection() = default;
2098 OGRCurveCollection(const OGRCurveCollection &other);
2099 OGRCurveCollection(OGRCurveCollection &&other);
2100 ~OGRCurveCollection();
2101
2102 OGRCurveCollection &operator=(const OGRCurveCollection &other);
2103 OGRCurveCollection &operator=(OGRCurveCollection &&other);
2104
2106 typedef OGRCurve ChildType;
2107
2111 OGRCurve **begin()
2112 {
2113 return papoCurves;
2114 }
2115
2117 OGRCurve **end()
2118 {
2119 return papoCurves + nCurveCount;
2120 }
2121
2125 const OGRCurve *const *begin() const
2126 {
2127 return papoCurves;
2128 }
2129
2131 const OGRCurve *const *end() const
2132 {
2133 return papoCurves + nCurveCount;
2134 }
2135
2136 void empty(OGRGeometry *poGeom);
2137 OGRBoolean IsEmpty() const;
2138 void getEnvelope(OGREnvelope *psEnvelope) const;
2139 void getEnvelope(OGREnvelope3D *psEnvelope) const;
2140
2141 OGRErr addCurveDirectly(OGRGeometry *poGeom, OGRCurve *poCurve,
2142 int bNeedRealloc);
2143 size_t WkbSize() const;
2144 OGRErr importPreambleFromWkb(OGRGeometry *poGeom,
2145 const unsigned char *pabyData, size_t &nSize,
2146 size_t &nDataOffset,
2147 OGRwkbByteOrder &eByteOrder,
2148 size_t nMinSubGeomSize,
2149 OGRwkbVariant eWkbVariant);
2150 OGRErr
2151 importBodyFromWkb(OGRGeometry *poGeom, const unsigned char *pabyData,
2152 size_t nSize, bool bAcceptCompoundCurve,
2153 OGRErr (*pfnAddCurveDirectlyFromWkb)(OGRGeometry *poGeom,
2154 OGRCurve *poCurve),
2155 OGRwkbVariant eWkbVariant, size_t &nBytesConsumedOut);
2156 std::string exportToWkt(const OGRGeometry *geom, const OGRWktOptions &opts,
2157 OGRErr *err) const;
2158 OGRErr exportToWkb(const OGRGeometry *poGeom, unsigned char *,
2159 const OGRwkbExportOptions * = nullptr) const;
2160 OGRBoolean Equals(const OGRCurveCollection *poOCC) const;
2161 bool setCoordinateDimension(OGRGeometry *poGeom, int nNewDimension);
2162 bool set3D(OGRGeometry *poGeom, OGRBoolean bIs3D);
2163 bool setMeasured(OGRGeometry *poGeom, OGRBoolean bIsMeasured);
2164 void assignSpatialReference(OGRGeometry *poGeom,
2165 const OGRSpatialReference *poSR);
2166 int getNumCurves() const;
2167 OGRCurve *getCurve(int);
2168 const OGRCurve *getCurve(int) const;
2169 OGRCurve *stealCurve(int);
2170
2171 OGRErr removeCurve(int iIndex, bool bDelete = true);
2172
2173 bool hasEmptyParts() const;
2174 void removeEmptyParts();
2175
2176 void reversePoints();
2177
2178 OGRErr transform(OGRGeometry *poGeom, OGRCoordinateTransformation *poCT);
2179 void flattenTo2D(OGRGeometry *poGeom);
2180 bool segmentize(double dfMaxLength);
2181 void swapXY();
2182 OGRBoolean hasCurveGeometry(int bLookForNonLinear) const;
2183};
2184
2186
2187/************************************************************************/
2188/* OGRCompoundCurve */
2189/************************************************************************/
2190
2201class CPL_DLL OGRCompoundCurve : public OGRCurve
2202{
2203 private:
2204 OGRCurveCollection oCC{};
2205
2206 OGRErr addCurveDirectlyInternal(OGRCurve *poCurve, double dfToleranceEps,
2207 int bNeedRealloc);
2208 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2209 OGRCurve *poCurve);
2210 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2211 OGRCurve *poCurve);
2212 OGRLineString *CurveToLineInternal(double dfMaxAngleStepSizeDegrees,
2213 const char *const *papszOptions,
2214 int bIsLinearRing) const;
2215 // cppcheck-suppress unusedPrivateFunction
2216 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
2217 // cppcheck-suppress unusedPrivateFunction
2218 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
2219
2220 protected:
2222 static OGRLineString *CastToLineString(OGRCompoundCurve *poCC);
2223 static OGRLinearRing *CastToLinearRing(OGRCompoundCurve *poCC);
2224
2225 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
2226 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
2228
2229 public:
2231 OGRCompoundCurve() = default;
2232
2236
2237 OGRCompoundCurve &operator=(const OGRCompoundCurve &other);
2240
2243
2248 {
2249 return oCC.begin();
2250 }
2251
2254 {
2255 return oCC.end();
2256 }
2257
2261 const ChildType *const *begin() const
2262 {
2263 return oCC.begin();
2264 }
2265
2267 const ChildType *const *end() const
2268 {
2269 return oCC.end();
2270 }
2271
2272 // IWks Interface
2273 virtual size_t WkbSize() const override;
2274 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2275 size_t &nBytesConsumedOut) override;
2276 OGRErr exportToWkb(unsigned char *,
2277 const OGRwkbExportOptions * = nullptr) const override;
2278
2279#ifndef DOXYGEN_XML
2281#endif
2282
2283 OGRErr importFromWkt(const char **) override;
2284
2285#ifndef DOXYGEN_XML
2287#endif
2288
2293 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2294 OGRErr *err = nullptr) const override;
2295
2296 // IGeometry interface.
2297 virtual OGRCompoundCurve *clone() const override;
2298 virtual void empty() override;
2299 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2300 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2301 virtual OGRBoolean IsEmpty() const override;
2302
2303 // ICurve methods.
2304 virtual double get_Length() const override;
2305 virtual void StartPoint(OGRPoint *) const override;
2306 virtual void EndPoint(OGRPoint *) const override;
2307 virtual void Value(double, OGRPoint *) const override;
2308 virtual OGRLineString *
2309 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
2310 const char *const *papszOptions = nullptr) const override;
2311
2312 virtual int getNumPoints() const override;
2313 virtual double get_AreaOfCurveSegments() const override;
2314 virtual double get_Area() const override;
2315 virtual double get_GeodesicArea(
2316 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2317 virtual double get_GeodesicLength(
2318 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2319
2320 // ISpatialRelation.
2321 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2322
2323 // ICompoundCurve method.
2324 int getNumCurves() const;
2325 OGRCurve *getCurve(int);
2326 const OGRCurve *getCurve(int) const;
2327
2328 // Non-standard.
2329 virtual bool setCoordinateDimension(int nDimension) override;
2330 virtual bool set3D(OGRBoolean bIs3D) override;
2331 virtual bool setMeasured(OGRBoolean bIsMeasured) override;
2332
2333 virtual void
2334 assignSpatialReference(const OGRSpatialReference *poSR) override;
2335
2339 static constexpr double DEFAULT_TOLERANCE_EPSILON = 1e-14;
2340
2341 OGRErr addCurve(const OGRCurve *,
2342 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2343 OGRErr addCurveDirectly(OGRCurve *,
2344 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2345 OGRErr addCurve(std::unique_ptr<OGRCurve>,
2346 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2347 OGRCurve *stealCurve(int);
2348 virtual OGRPointIterator *getPointIterator() const override;
2349 void reversePoints() override;
2350
2351 // Non-standard from OGRGeometry.
2352 virtual OGRwkbGeometryType getGeometryType() const override;
2353 virtual const char *getGeometryName() const override;
2354 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2355 virtual void flattenTo2D() override;
2356 virtual bool segmentize(double dfMaxLength) override;
2357 virtual OGRBoolean
2358 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2359 virtual OGRGeometry *
2360 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2361 const char *const *papszOptions = nullptr) const override;
2362
2363 virtual void accept(IOGRGeometryVisitor *visitor) override
2364 {
2365 visitor->visit(this);
2366 }
2367
2368 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2369 {
2370 visitor->visit(this);
2371 }
2372
2373 virtual void swapXY() override;
2374
2375 bool hasEmptyParts() const override;
2376 void removeEmptyParts() override;
2377
2378 OGR_ALLOW_UPCAST_TO(Curve)
2379 OGR_ALLOW_CAST_TO_THIS(CompoundCurve)
2380};
2381
2383
2384inline const OGRCompoundCurve::ChildType *const *
2385begin(const OGRCompoundCurve *poCurve)
2386{
2387 return poCurve->begin();
2388}
2389
2391inline const OGRCompoundCurve::ChildType *const *
2392end(const OGRCompoundCurve *poCurve)
2393{
2394 return poCurve->end();
2395}
2396
2399{
2400 return poCurve->begin();
2401}
2402
2405{
2406 return poCurve->end();
2407}
2408
2410
2411/************************************************************************/
2412/* OGRSurface */
2413/************************************************************************/
2414
2420class CPL_DLL OGRSurface : public OGRGeometry
2421{
2422 protected:
2424 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const = 0;
2425 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const = 0;
2427
2428 public:
2429 virtual double get_Area() const = 0;
2430 virtual double get_GeodesicArea(
2431 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
2432 virtual double get_Length() const = 0;
2433 virtual double get_GeodesicLength(
2434 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
2435
2436 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
2437 {
2438 return PointOnSurfaceInternal(poPoint);
2439 }
2440
2441 virtual OGRSurface *clone() const override = 0;
2442
2444 static OGRPolygon *CastToPolygon(OGRSurface *poSurface);
2445 static OGRCurvePolygon *CastToCurvePolygon(OGRSurface *poSurface);
2447
2448 OGR_FORBID_DOWNCAST_TO_POINT
2449 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
2450 OGR_ALLOW_CAST_TO_THIS(Surface)
2451 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
2452};
2453
2454/************************************************************************/
2455/* OGRCurvePolygon */
2456/************************************************************************/
2457
2471class CPL_DLL OGRCurvePolygon : public OGRSurface
2472{
2473 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2474
2475 private:
2476 OGRBoolean IntersectsPoint(const OGRPoint *p) const;
2477 OGRBoolean ContainsPoint(const OGRPoint *p) const;
2478
2479 virtual bool isRingCorrectType(const OGRCurve *poRing) const;
2480
2481 virtual bool checkRing(const OGRCurve *poNewRing) const;
2482 OGRErr addRingDirectlyInternal(OGRCurve *poCurve, int bNeedRealloc);
2483 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2484 OGRCurve *poCurve);
2485 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2486 OGRCurve *poCurve);
2487
2488 protected:
2490 friend class OGRPolygon;
2491 friend class OGRTriangle;
2492 OGRCurveCollection oCC{};
2493
2494 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2495 virtual OGRSurfaceCasterToCurvePolygon
2496 GetCasterToCurvePolygon() const override;
2497
2499
2500 static OGRPolygon *CastToPolygon(OGRCurvePolygon *poCP);
2501
2502 public:
2504 OGRCurvePolygon() = default;
2505
2509
2510 OGRCurvePolygon &operator=(const OGRCurvePolygon &other);
2513
2516
2521 {
2522 return oCC.begin();
2523 }
2524
2527 {
2528 return oCC.end();
2529 }
2530
2534 const ChildType *const *begin() const
2535 {
2536 return oCC.begin();
2537 }
2538
2540 const ChildType *const *end() const
2541 {
2542 return oCC.end();
2543 }
2544
2545 // Non standard (OGRGeometry).
2546 virtual const char *getGeometryName() const override;
2547 virtual OGRwkbGeometryType getGeometryType() const override;
2548 virtual OGRCurvePolygon *clone() const override;
2549 virtual void empty() override;
2550 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2551 virtual void flattenTo2D() override;
2552 virtual OGRBoolean IsEmpty() const override;
2553 virtual bool segmentize(double dfMaxLength) override;
2554 virtual OGRBoolean
2555 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2556 virtual OGRGeometry *
2557 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2558 const char *const *papszOptions = nullptr) const override;
2559 virtual double get_GeodesicArea(
2560 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2561 virtual double get_GeodesicLength(
2562 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2563
2564 // ISurface Interface
2565 virtual double get_Area() const override;
2566
2567 virtual double get_Length() const override;
2568
2569 // IWks Interface
2570 virtual size_t WkbSize() const override;
2571 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2572 size_t &nBytesConsumedOut) override;
2573 OGRErr exportToWkb(unsigned char *,
2574 const OGRwkbExportOptions * = nullptr) const override;
2575
2576#ifndef DOXYGEN_XML
2578#endif
2579
2580 OGRErr importFromWkt(const char **) override;
2581
2582#ifndef DOXYGEN_XML
2584#endif
2585
2590 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2591 OGRErr *err = nullptr) const override;
2592
2593 // IGeometry
2594 virtual int getDimension() const override;
2595 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2596 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2597
2598 // ICurvePolygon
2599 virtual OGRPolygon *
2600 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2601 const char *const *papszOptions = nullptr) const;
2602
2603 // ISpatialRelation
2604 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2605 virtual OGRBoolean Intersects(const OGRGeometry *) const override;
2606 virtual OGRBoolean Contains(const OGRGeometry *) const override;
2607
2608 // Non standard
2609 virtual bool setCoordinateDimension(int nDimension) override;
2610 virtual bool set3D(OGRBoolean bIs3D) override;
2611 virtual bool setMeasured(OGRBoolean bIsMeasured) override;
2612
2613 virtual void
2614 assignSpatialReference(const OGRSpatialReference *poSR) override;
2615
2616 virtual OGRErr addRing(const OGRCurve *);
2617 virtual OGRErr addRingDirectly(OGRCurve *);
2618 OGRErr addRing(std::unique_ptr<OGRCurve>);
2619
2620 OGRCurve *getExteriorRingCurve();
2621 const OGRCurve *getExteriorRingCurve() const;
2622 int getNumInteriorRings() const;
2623 OGRCurve *getInteriorRingCurve(int);
2624 const OGRCurve *getInteriorRingCurve(int) const;
2625
2626 OGRCurve *stealExteriorRingCurve();
2627
2628 OGRErr removeRing(int iIndex, bool bDelete = true);
2629
2630 virtual void accept(IOGRGeometryVisitor *visitor) override
2631 {
2632 visitor->visit(this);
2633 }
2634
2635 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2636 {
2637 visitor->visit(this);
2638 }
2639
2640 virtual void swapXY() override;
2641
2642 bool hasEmptyParts() const override;
2643 void removeEmptyParts() override;
2644
2645 OGR_ALLOW_UPCAST_TO(Surface)
2646 OGR_ALLOW_CAST_TO_THIS(CurvePolygon)
2647};
2648
2650
2651inline const OGRCurvePolygon::ChildType *const *
2652begin(const OGRCurvePolygon *poGeom)
2653{
2654 return poGeom->begin();
2655}
2656
2658inline const OGRCurvePolygon::ChildType *const *
2659end(const OGRCurvePolygon *poGeom)
2660{
2661 return poGeom->end();
2662}
2663
2666{
2667 return poGeom->begin();
2668}
2669
2672{
2673 return poGeom->end();
2674}
2675
2677
2678/************************************************************************/
2679/* OGRPolygon */
2680/************************************************************************/
2681
2691class CPL_DLL OGRPolygon : public OGRCurvePolygon
2692{
2693 static OGRCurvePolygon *CasterToCurvePolygon(OGRSurface *poSurface);
2694
2695 protected:
2697 friend class OGRMultiSurface;
2698 friend class OGRPolyhedralSurface;
2699 friend class OGRTriangulatedSurface;
2700
2701 virtual bool isRingCorrectType(const OGRCurve *poRing) const override;
2702
2703 virtual bool checkRing(const OGRCurve *poNewRing) const override;
2704 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2705 int bHasM, OGRRawPoint *&paoPoints,
2706 int &nMaxPoints, double *&padfZ);
2707
2708 static OGRCurvePolygon *CastToCurvePolygon(OGRPolygon *poPoly);
2709
2710 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2711 virtual OGRSurfaceCasterToCurvePolygon
2712 GetCasterToCurvePolygon() const override;
2714
2715 public:
2717 OGRPolygon() = default;
2718
2719 OGRPolygon(double x1, double y1, double x2, double y2);
2720
2721 explicit OGRPolygon(const OGREnvelope &envelope);
2722
2723 OGRPolygon(const OGRPolygon &other);
2725 OGRPolygon(OGRPolygon &&other) = default;
2726
2727 OGRPolygon &operator=(const OGRPolygon &other);
2729 OGRPolygon &operator=(OGRPolygon &&other) = default;
2730
2733
2738 {
2739 return reinterpret_cast<ChildType **>(oCC.begin());
2740 }
2741
2744 {
2745 return reinterpret_cast<ChildType **>(oCC.end());
2746 }
2747
2751 const ChildType *const *begin() const
2752 {
2753 return reinterpret_cast<const ChildType *const *>(oCC.begin());
2754 }
2755
2757 const ChildType *const *end() const
2758 {
2759 return reinterpret_cast<const ChildType *const *>(oCC.end());
2760 }
2761
2762 // Non-standard (OGRGeometry).
2763 virtual const char *getGeometryName() const override;
2764 virtual OGRwkbGeometryType getGeometryType() const override;
2765 virtual OGRPolygon *clone() const override;
2766 virtual OGRBoolean
2767 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2768 virtual OGRGeometry *
2769 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2770 virtual OGRGeometry *
2771 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2772 const char *const *papszOptions = nullptr) const override;
2773
2774 // IWks Interface.
2775 virtual size_t WkbSize() const override;
2776 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2777 size_t &nBytesConsumedOut) override;
2778 OGRErr exportToWkb(unsigned char *,
2779 const OGRwkbExportOptions * = nullptr) const override;
2780
2781#ifndef DOXYGEN_XML
2783#endif
2784
2785 OGRErr importFromWkt(const char **) override;
2786
2787#ifndef DOXYGEN_XML
2789#endif
2790
2795 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2796 OGRErr *err = nullptr) const override;
2797
2798 // ICurvePolygon.
2799 virtual OGRPolygon *
2800 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2801 const char *const *papszOptions = nullptr) const override;
2802
2803 OGRLinearRing *getExteriorRing();
2804 const OGRLinearRing *getExteriorRing() const;
2805 virtual OGRLinearRing *getInteriorRing(int);
2806 virtual const OGRLinearRing *getInteriorRing(int) const;
2807
2808 OGRLinearRing *stealExteriorRing();
2809 virtual OGRLinearRing *stealInteriorRing(int);
2810
2811 OGRBoolean IsPointOnSurface(const OGRPoint *) const;
2812
2815 {
2816 return this;
2817 }
2818
2820 inline const OGRCurvePolygon *toUpperClass() const
2821 {
2822 return this;
2823 }
2824
2825 virtual void accept(IOGRGeometryVisitor *visitor) override
2826 {
2827 visitor->visit(this);
2828 }
2829
2830 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2831 {
2832 visitor->visit(this);
2833 }
2834
2835 virtual void closeRings() override;
2836
2837 OGR_ALLOW_UPCAST_TO(CurvePolygon)
2838 OGR_ALLOW_CAST_TO_THIS(Polygon)
2839};
2840
2842
2843inline const OGRPolygon::ChildType *const *begin(const OGRPolygon *poGeom)
2844{
2845 return poGeom->begin();
2846}
2847
2849inline const OGRPolygon::ChildType *const *end(const OGRPolygon *poGeom)
2850{
2851 return poGeom->end();
2852}
2853
2855inline OGRPolygon::ChildType **begin(OGRPolygon *poGeom)
2856{
2857 return poGeom->begin();
2858}
2859
2861inline OGRPolygon::ChildType **end(OGRPolygon *poGeom)
2862{
2863 return poGeom->end();
2864}
2865
2867
2868/************************************************************************/
2869/* OGRTriangle */
2870/************************************************************************/
2871
2878class CPL_DLL OGRTriangle : public OGRPolygon
2879{
2880 private:
2881 // cppcheck-suppress unusedPrivateFunction
2882 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2883 bool quickValidityCheck() const;
2884
2885 protected:
2887 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2888 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2889 int bHasM, OGRRawPoint *&paoPoints,
2890 int &nMaxPoints,
2891 double *&padfZ) override;
2893
2894 public:
2896 OGRTriangle() = default;
2897 OGRTriangle(const OGRPoint &p, const OGRPoint &q, const OGRPoint &r);
2900 OGRTriangle(OGRTriangle &&other) = default;
2901 OGRTriangle(const OGRPolygon &other, OGRErr &eErr);
2902 OGRTriangle &operator=(const OGRTriangle &other);
2904 OGRTriangle &operator=(OGRTriangle &&other) = default;
2905
2906 virtual const char *getGeometryName() const override;
2907 virtual OGRwkbGeometryType getGeometryType() const override;
2908 virtual OGRTriangle *clone() const override;
2909
2910 // IWks Interface.
2911 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2912 size_t &nBytesConsumedOut) override;
2913
2914 // New methods rewritten from OGRPolygon/OGRCurvePolygon/OGRGeometry.
2915 virtual OGRErr addRingDirectly(OGRCurve *poNewRing) override;
2916
2919 {
2920 return this;
2921 }
2922
2924 inline const OGRPolygon *toUpperClass() const
2925 {
2926 return this;
2927 }
2928
2929 virtual void accept(IOGRGeometryVisitor *visitor) override
2930 {
2931 visitor->visit(this);
2932 }
2933
2934 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2935 {
2936 visitor->visit(this);
2937 }
2938
2940 static OGRGeometry *CastToPolygon(OGRGeometry *poGeom);
2942
2943 OGR_ALLOW_UPCAST_TO(Polygon)
2944 OGR_ALLOW_CAST_TO_THIS(Triangle)
2945};
2946
2947/************************************************************************/
2948/* OGRGeometryCollection */
2949/************************************************************************/
2950
2959{
2960 OGRErr importFromWktInternal(const char **ppszInput, int nRecLevel);
2961
2962 protected:
2964 int nGeomCount = 0;
2965 OGRGeometry **papoGeoms = nullptr;
2966
2967 std::string
2968 exportToWktInternal(const OGRWktOptions &opts, OGRErr *err,
2969 const std::string &exclude = std::string()) const;
2970 static OGRGeometryCollection *
2971 TransferMembersAndDestroy(OGRGeometryCollection *poSrc,
2972 OGRGeometryCollection *poDst);
2973
2974 OGRErr importFromWkbInternal(const unsigned char *pabyData, size_t nSize,
2975 int nRecLevel, OGRwkbVariant,
2976 size_t &nBytesConsumedOut);
2978 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
2979
2980 public:
2983
2986 ~OGRGeometryCollection() override;
2987
2988 OGRGeometryCollection &operator=(const OGRGeometryCollection &other);
2989 OGRGeometryCollection &operator=(OGRGeometryCollection &&other);
2990
2993
2998 {
2999 return papoGeoms;
3000 }
3001
3004 {
3005 return papoGeoms + nGeomCount;
3006 }
3007
3011 const ChildType *const *begin() const
3012 {
3013 return papoGeoms;
3014 }
3015
3017 const ChildType *const *end() const
3018 {
3019 return papoGeoms + nGeomCount;
3020 }
3021
3022 // Non standard (OGRGeometry).
3023 virtual const char *getGeometryName() const override;
3024 virtual OGRwkbGeometryType getGeometryType() const override;
3025 virtual OGRGeometryCollection *clone() const override;
3026 virtual void empty() override;
3027 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
3028 virtual void flattenTo2D() override;
3029 virtual OGRBoolean IsEmpty() const override;
3030 virtual bool segmentize(double dfMaxLength) override;
3031 virtual OGRBoolean
3032 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3033 virtual OGRGeometry *
3034 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
3035 virtual OGRGeometry *
3036 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
3037 const char *const *papszOptions = nullptr) const override;
3038 virtual double
3039 get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const;
3040 virtual double get_GeodesicLength(
3041 const OGRSpatialReference *poSRSOverride = nullptr) const;
3042
3043 // IWks Interface
3044 virtual size_t WkbSize() const override;
3045 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3046 size_t &nBytesConsumedOut) override;
3047 OGRErr exportToWkb(unsigned char *,
3048 const OGRwkbExportOptions * = nullptr) const override;
3049
3050#ifndef DOXYGEN_XML
3052#endif
3053
3054 OGRErr importFromWkt(const char **) override;
3055
3056#ifndef DOXYGEN_XML
3058#endif
3059
3064 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3065 OGRErr *err = nullptr) const override;
3066
3067 virtual double get_Length() const;
3068 virtual double get_Area() const;
3069
3070 // IGeometry methods
3071 virtual int getDimension() const override;
3072 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
3073 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3074
3075 // IGeometryCollection
3076 int getNumGeometries() const;
3077 OGRGeometry *getGeometryRef(int);
3078 const OGRGeometry *getGeometryRef(int) const;
3079
3080 // ISpatialRelation
3081 virtual OGRBoolean Equals(const OGRGeometry *) const override;
3082
3083 // Non standard
3084 virtual bool setCoordinateDimension(int nDimension) override;
3085 virtual bool set3D(OGRBoolean bIs3D) override;
3086 virtual bool setMeasured(OGRBoolean bIsMeasured) override;
3087 virtual OGRErr addGeometry(const OGRGeometry *);
3088 virtual OGRErr addGeometryDirectly(OGRGeometry *);
3089 OGRErr addGeometry(std::unique_ptr<OGRGeometry> geom);
3090 virtual OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3091 std::unique_ptr<OGRGeometry> stealGeometry(int iIndex);
3092
3093 bool hasEmptyParts() const override;
3094 void removeEmptyParts() override;
3095
3096 virtual void
3097 assignSpatialReference(const OGRSpatialReference *poSR) override;
3098
3099 void closeRings() override;
3100
3101 virtual void swapXY() override;
3102
3103 virtual void accept(IOGRGeometryVisitor *visitor) override
3104 {
3105 visitor->visit(this);
3106 }
3107
3108 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3109 {
3110 visitor->visit(this);
3111 }
3112
3113 static OGRGeometryCollection *
3114 CastToGeometryCollection(OGRGeometryCollection *poSrc);
3115
3116 OGR_FORBID_DOWNCAST_TO_POINT
3117 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
3118 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
3119 OGR_ALLOW_CAST_TO_THIS(GeometryCollection)
3120};
3121
3123
3124inline const OGRGeometryCollection::ChildType *const *
3125begin(const OGRGeometryCollection *poGeom)
3126{
3127 return poGeom->begin();
3128}
3129
3131inline const OGRGeometryCollection::ChildType *const *
3132end(const OGRGeometryCollection *poGeom)
3133{
3134 return poGeom->end();
3135}
3136
3139{
3140 return poGeom->begin();
3141}
3142
3145{
3146 return poGeom->end();
3147}
3148
3150
3151/************************************************************************/
3152/* OGRMultiSurface */
3153/************************************************************************/
3154
3162{
3163 protected:
3164 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3165
3166 public:
3168 OGRMultiSurface() = default;
3169
3173
3174 OGRMultiSurface &operator=(const OGRMultiSurface &other);
3177
3180
3185 {
3186 return reinterpret_cast<ChildType **>(papoGeoms);
3187 }
3188
3191 {
3192 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3193 }
3194
3198 const ChildType *const *begin() const
3199 {
3200 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3201 }
3202
3204 const ChildType *const *end() const
3205 {
3206 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3207 nGeomCount);
3208 }
3209
3210 // Non standard (OGRGeometry).
3211 virtual const char *getGeometryName() const override;
3212 virtual OGRwkbGeometryType getGeometryType() const override;
3213 virtual OGRMultiSurface *clone() const override;
3214
3215#ifndef DOXYGEN_XML
3217#endif
3218
3219 OGRErr importFromWkt(const char **) override;
3220
3221#ifndef DOXYGEN_XML
3223#endif
3224
3229 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3230 OGRErr *err = nullptr) const override;
3231
3232 // IMultiSurface methods
3233 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const;
3234
3235 // IGeometry methods
3236 virtual int getDimension() const override;
3237
3238 // IGeometryCollection
3244
3246 const OGRSurface *getGeometryRef(int i) const
3247 {
3249 }
3250
3251 // Non standard
3252 virtual OGRBoolean
3253 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3254
3257 {
3258 return this;
3259 }
3260
3263 {
3264 return this;
3265 }
3266
3267 virtual void accept(IOGRGeometryVisitor *visitor) override
3268 {
3269 visitor->visit(this);
3270 }
3271
3272 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3273 {
3274 visitor->visit(this);
3275 }
3276
3277 static OGRMultiPolygon *CastToMultiPolygon(OGRMultiSurface *poMS);
3278
3279 OGR_ALLOW_CAST_TO_THIS(MultiSurface)
3280 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3281 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3282 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3283 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3284};
3285
3287
3288inline const OGRMultiSurface::ChildType *const *
3289begin(const OGRMultiSurface *poGeom)
3290{
3291 return poGeom->begin();
3292}
3293
3295inline const OGRMultiSurface::ChildType *const *
3296end(const OGRMultiSurface *poGeom)
3297{
3298 return poGeom->end();
3299}
3300
3303{
3304 return poGeom->begin();
3305}
3306
3309{
3310 return poGeom->end();
3311}
3312
3314
3315/************************************************************************/
3316/* OGRMultiPolygon */
3317/************************************************************************/
3318
3323class CPL_DLL OGRMultiPolygon : public OGRMultiSurface
3324{
3325 protected:
3326 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3327 friend class OGRPolyhedralSurface;
3328 friend class OGRTriangulatedSurface;
3329
3330 private:
3332 OGRErr _addGeometryWithExpectedSubGeometryType(
3333 const OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3334 OGRErr _addGeometryDirectlyWithExpectedSubGeometryType(
3335 OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3337
3338 public:
3340 OGRMultiPolygon() = default;
3341
3345
3346 OGRMultiPolygon &operator=(const OGRMultiPolygon &other);
3349
3352
3357 {
3358 return reinterpret_cast<ChildType **>(papoGeoms);
3359 }
3360
3363 {
3364 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3365 }
3366
3370 const ChildType *const *begin() const
3371 {
3372 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3373 }
3374
3376 const ChildType *const *end() const
3377 {
3378 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3379 nGeomCount);
3380 }
3381
3382 // IGeometryCollection
3388
3390 const OGRPolygon *getGeometryRef(int i) const
3391 {
3393 }
3394
3395 // Non-standard (OGRGeometry).
3396 virtual const char *getGeometryName() const override;
3397 virtual OGRwkbGeometryType getGeometryType() const override;
3398 virtual OGRMultiPolygon *clone() const override;
3399
3400#ifndef DOXYGEN_XML
3402#endif
3403
3404 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3405 size_t &nBytesConsumedOut) override;
3406
3411 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3412 OGRErr *err = nullptr) const override;
3413
3414 // Non standard
3415 virtual OGRBoolean
3416 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3417
3420 {
3421 return this;
3422 }
3423
3426 {
3427 return this;
3428 }
3429
3430 virtual void accept(IOGRGeometryVisitor *visitor) override
3431 {
3432 visitor->visit(this);
3433 }
3434
3435 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3436 {
3437 visitor->visit(this);
3438 }
3439
3440 static OGRMultiSurface *CastToMultiSurface(OGRMultiPolygon *poMP);
3441
3442 OGR_ALLOW_CAST_TO_THIS(MultiPolygon)
3443 OGR_ALLOW_UPCAST_TO(MultiSurface)
3444};
3445
3447
3448inline const OGRMultiPolygon::ChildType *const *
3449begin(const OGRMultiPolygon *poGeom)
3450{
3451 return poGeom->begin();
3452}
3453
3455inline const OGRMultiPolygon::ChildType *const *
3456end(const OGRMultiPolygon *poGeom)
3457{
3458 return poGeom->end();
3459}
3460
3463{
3464 return poGeom->begin();
3465}
3466
3469{
3470 return poGeom->end();
3471}
3472
3474
3475/************************************************************************/
3476/* OGRPolyhedralSurface */
3477/************************************************************************/
3478
3485class CPL_DLL OGRPolyhedralSurface : public OGRSurface
3486{
3487 protected:
3489 friend class OGRTriangulatedSurface;
3490 OGRMultiPolygon oMP{};
3491 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
3492 virtual OGRSurfaceCasterToCurvePolygon
3493 GetCasterToCurvePolygon() const override;
3494 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
3495 virtual const char *getSubGeometryName() const;
3496 virtual OGRwkbGeometryType getSubGeometryType() const;
3497 std::string exportToWktInternal(const OGRWktOptions &opts,
3498 OGRErr *err) const;
3499
3500 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3501 GetCasterToMultiPolygon() const;
3502 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3504
3505 public:
3508
3512
3513 OGRPolyhedralSurface &operator=(const OGRPolyhedralSurface &other);
3516
3519
3524 {
3525 return oMP.begin();
3526 }
3527
3530 {
3531 return oMP.end();
3532 }
3533
3537 const ChildType *const *begin() const
3538 {
3539 return oMP.begin();
3540 }
3541
3543 const ChildType *const *end() const
3544 {
3545 return oMP.end();
3546 }
3547
3548 // IWks Interface.
3549 virtual size_t WkbSize() const override;
3550 virtual const char *getGeometryName() const override;
3551 virtual OGRwkbGeometryType getGeometryType() const override;
3552 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3553 size_t &nBytesConsumedOut) override;
3554 OGRErr exportToWkb(unsigned char *,
3555 const OGRwkbExportOptions * = nullptr) const override;
3556
3557#ifndef DOXYGEN_XML
3559#endif
3560
3561 OGRErr importFromWkt(const char **) override;
3562
3563#ifndef DOXYGEN_XML
3565#endif
3566
3571 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3572 OGRErr *err = nullptr) const override;
3573
3574 // IGeometry methods.
3575 virtual int getDimension() const override;
3576
3577 virtual void empty() override;
3578
3579 virtual OGRPolyhedralSurface *clone() const override;
3580 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
3581 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3582
3583 virtual void flattenTo2D() override;
3584 virtual OGRErr transform(OGRCoordinateTransformation *) override;
3585 virtual OGRBoolean Equals(const OGRGeometry *) const override;
3586 virtual double get_Area() const override;
3587 virtual double get_GeodesicArea(
3588 const OGRSpatialReference *poSRSOverride = nullptr) const override;
3589 virtual double get_Length() const override;
3590 virtual double get_GeodesicLength(
3591 const OGRSpatialReference *poSRSOverride = nullptr) const override;
3592
3593 virtual OGRErr PointOnSurface(OGRPoint *) const override;
3594
3595 static OGRMultiPolygon *CastToMultiPolygon(OGRPolyhedralSurface *poPS);
3596 virtual OGRBoolean
3597 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3598 virtual OGRErr addGeometry(const OGRGeometry *);
3599 OGRErr addGeometryDirectly(OGRGeometry *poNewGeom);
3600 OGRErr addGeometry(std::unique_ptr<OGRGeometry> poNewGeom);
3601
3602 int getNumGeometries() const;
3603 OGRPolygon *getGeometryRef(int i);
3604 const OGRPolygon *getGeometryRef(int i) const;
3605
3606 virtual OGRBoolean IsEmpty() const override;
3607 virtual bool setCoordinateDimension(int nDimension) override;
3608 virtual bool set3D(OGRBoolean bIs3D) override;
3609 virtual bool setMeasured(OGRBoolean bIsMeasured) override;
3610 virtual void swapXY() override;
3611 OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3612
3613 bool hasEmptyParts() const override;
3614 void removeEmptyParts() override;
3615
3616 virtual void accept(IOGRGeometryVisitor *visitor) override
3617 {
3618 visitor->visit(this);
3619 }
3620
3621 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3622 {
3623 visitor->visit(this);
3624 }
3625
3626 virtual void
3627 assignSpatialReference(const OGRSpatialReference *poSR) override;
3628
3629 OGR_ALLOW_CAST_TO_THIS(PolyhedralSurface)
3630 OGR_ALLOW_UPCAST_TO(Surface)
3631};
3632
3634
3635inline const OGRPolyhedralSurface::ChildType *const *
3636begin(const OGRPolyhedralSurface *poGeom)
3637{
3638 return poGeom->begin();
3639}
3640
3642inline const OGRPolyhedralSurface::ChildType *const *
3643end(const OGRPolyhedralSurface *poGeom)
3644{
3645 return poGeom->end();
3646}
3647
3650{
3651 return poGeom->begin();
3652}
3653
3656{
3657 return poGeom->end();
3658}
3659
3661
3662/************************************************************************/
3663/* OGRTriangulatedSurface */
3664/************************************************************************/
3665
3673{
3674 protected:
3676 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3677 virtual const char *getSubGeometryName() const override;
3678 virtual OGRwkbGeometryType getSubGeometryType() const override;
3679
3680 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3681 GetCasterToMultiPolygon() const override;
3682 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3684
3685 public:
3688
3692
3693 OGRTriangulatedSurface &operator=(const OGRTriangulatedSurface &other);
3696
3699
3704 {
3705 return reinterpret_cast<ChildType **>(oMP.begin());
3706 }
3707
3710 {
3711 return reinterpret_cast<ChildType **>(oMP.end());
3712 }
3713
3717 const ChildType *const *begin() const
3718 {
3719 return reinterpret_cast<const ChildType *const *>(oMP.begin());
3720 }
3721
3723 const ChildType *const *end() const
3724 {
3725 return reinterpret_cast<const ChildType *const *>(oMP.end());
3726 }
3727
3728 virtual const char *getGeometryName() const override;
3729 virtual OGRwkbGeometryType getGeometryType() const override;
3730 virtual OGRTriangulatedSurface *clone() const override;
3731
3737
3739 const OGRTriangle *getGeometryRef(int i) const
3740 {
3742 }
3743
3744 // IWks Interface.
3745 virtual OGRErr addGeometry(const OGRGeometry *) override;
3746
3747#ifndef DOXYGEN_XML
3749#endif
3750
3753 {
3754 return this;
3755 }
3756
3759 {
3760 return this;
3761 }
3762
3763 virtual void accept(IOGRGeometryVisitor *visitor) override
3764 {
3765 visitor->visit(this);
3766 }
3767
3768 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3769 {
3770 visitor->visit(this);
3771 }
3772
3773 static OGRPolyhedralSurface *
3774 CastToPolyhedralSurface(OGRTriangulatedSurface *poTS);
3775
3776 OGR_ALLOW_CAST_TO_THIS(TriangulatedSurface)
3777 OGR_ALLOW_UPCAST_TO(PolyhedralSurface)
3778};
3779
3781
3782inline const OGRTriangulatedSurface::ChildType *const *
3783begin(const OGRTriangulatedSurface *poGeom)
3784{
3785 return poGeom->begin();
3786}
3787
3789inline const OGRTriangulatedSurface::ChildType *const *
3790end(const OGRTriangulatedSurface *poGeom)
3791{
3792 return poGeom->end();
3793}
3794
3797{
3798 return poGeom->begin();
3799}
3800
3803{
3804 return poGeom->end();
3805}
3806
3808
3809/************************************************************************/
3810/* OGRMultiPoint */
3811/************************************************************************/
3812
3818{
3819 private:
3820 OGRErr importFromWkt_Bracketed(const char **, int bHasM, int bHasZ);
3821
3822 protected:
3823 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3824
3825 public:
3827 OGRMultiPoint() = default;
3828
3831 OGRMultiPoint(OGRMultiPoint &&other) = default;
3832
3833 OGRMultiPoint &operator=(const OGRMultiPoint &other);
3836
3839
3844 {
3845 return reinterpret_cast<ChildType **>(papoGeoms);
3846 }
3847
3850 {
3851 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3852 }
3853
3857 const ChildType *const *begin() const
3858 {
3859 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3860 }
3861
3863 const ChildType *const *end() const
3864 {
3865 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3866 nGeomCount);
3867 }
3868
3869 // IGeometryCollection
3875
3877 const OGRPoint *getGeometryRef(int i) const
3878 {
3880 }
3881
3882 // Non-standard (OGRGeometry).
3883 virtual const char *getGeometryName() const override;
3884 virtual OGRwkbGeometryType getGeometryType() const override;
3885 virtual OGRMultiPoint *clone() const override;
3886
3887#ifndef DOXYGEN_XML
3889#endif
3890
3891 OGRErr importFromWkt(const char **) override;
3892
3893#ifndef DOXYGEN_XML
3895#endif
3896
3901 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3902 OGRErr *err = nullptr) const override;
3903
3904 // IGeometry methods.
3905 virtual int getDimension() const override;
3906
3909 {
3910 return this;
3911 }
3912
3915 {
3916 return this;
3917 }
3918
3919 virtual void accept(IOGRGeometryVisitor *visitor) override
3920 {
3921 visitor->visit(this);
3922 }
3923
3924 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3925 {
3926 visitor->visit(this);
3927 }
3928
3929 // Non-standard.
3930 virtual OGRBoolean
3931 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3932
3933 OGR_ALLOW_CAST_TO_THIS(MultiPoint)
3934 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3935 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3936 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3937 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3938 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3939};
3940
3942
3943inline const OGRMultiPoint::ChildType *const *begin(const OGRMultiPoint *poGeom)
3944{
3945 return poGeom->begin();
3946}
3947
3949inline const OGRMultiPoint::ChildType *const *end(const OGRMultiPoint *poGeom)
3950{
3951 return poGeom->end();
3952}
3953
3956{
3957 return poGeom->begin();
3958}
3959
3962{
3963 return poGeom->end();
3964}
3965
3967
3968/************************************************************************/
3969/* OGRMultiCurve */
3970/************************************************************************/
3971
3979{
3980 protected:
3982 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
3983 OGRCurve *poCurve);
3985 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3986
3987 public:
3989 OGRMultiCurve() = default;
3990
3993 OGRMultiCurve(OGRMultiCurve &&other) = default;
3994
3995 OGRMultiCurve &operator=(const OGRMultiCurve &other);
3998
4001
4006 {
4007 return reinterpret_cast<ChildType **>(papoGeoms);
4008 }
4009
4012 {
4013 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
4014 }
4015
4019 const ChildType *const *begin() const
4020 {
4021 return reinterpret_cast<const ChildType *const *>(papoGeoms);
4022 }
4023
4025 const ChildType *const *end() const
4026 {
4027 return reinterpret_cast<const ChildType *const *>(papoGeoms +
4028 nGeomCount);
4029 }
4030
4031 // IGeometryCollection
4037
4039 const OGRCurve *getGeometryRef(int i) const
4040 {
4042 }
4043
4044 // Non standard (OGRGeometry).
4045 virtual const char *getGeometryName() const override;
4046 virtual OGRwkbGeometryType getGeometryType() const override;
4047 virtual OGRMultiCurve *clone() const override;
4048
4049#ifndef DOXYGEN_XML
4051#endif
4052
4053 OGRErr importFromWkt(const char **) override;
4054
4055#ifndef DOXYGEN_XML
4057#endif
4058
4063 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
4064 OGRErr *err = nullptr) const override;
4065
4066 // IGeometry methods.
4067 virtual int getDimension() const override;
4068
4069 // Non-standard.
4070 virtual OGRBoolean
4071 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
4072
4075 {
4076 return this;
4077 }
4078
4081 {
4082 return this;
4083 }
4084
4085 virtual void accept(IOGRGeometryVisitor *visitor) override
4086 {
4087 visitor->visit(this);
4088 }
4089
4090 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
4091 {
4092 visitor->visit(this);
4093 }
4094
4095 static OGRMultiLineString *CastToMultiLineString(OGRMultiCurve *poMC);
4096
4097 OGR_ALLOW_CAST_TO_THIS(MultiCurve)
4098 OGR_ALLOW_UPCAST_TO(GeometryCollection)
4099 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
4100 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
4101 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
4102};
4103
4105
4106inline const OGRMultiCurve::ChildType *const *begin(const OGRMultiCurve *poGeom)
4107{
4108 return poGeom->begin();
4109}
4110
4112inline const OGRMultiCurve::ChildType *const *end(const OGRMultiCurve *poGeom)
4113{
4114 return poGeom->end();
4115}
4116
4119{
4120 return poGeom->begin();
4121}
4122
4125{
4126 return poGeom->end();
4127}
4128
4130
4131/************************************************************************/
4132/* OGRMultiLineString */
4133/************************************************************************/
4134
4139class CPL_DLL OGRMultiLineString : public OGRMultiCurve
4140{
4141 protected:
4142 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
4143
4144 public:
4147
4151
4152 OGRMultiLineString &operator=(const OGRMultiLineString &other);
4155
4158
4163 {
4164 return reinterpret_cast<ChildType **>(papoGeoms);
4165 }
4166
4169 {
4170 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
4171 }
4172
4176 const ChildType *const *begin() const
4177 {
4178 return reinterpret_cast<const ChildType *const *>(papoGeoms);
4179 }
4180
4182 const ChildType *const *end() const
4183 {
4184 return reinterpret_cast<const ChildType *const *>(papoGeoms +
4185 nGeomCount);
4186 }
4187
4188 // IGeometryCollection
4194
4196 const OGRLineString *getGeometryRef(int i) const
4197 {
4199 }
4200
4201 // Non standard (OGRGeometry).
4202 virtual const char *getGeometryName() const override;
4203 virtual OGRwkbGeometryType getGeometryType() const override;
4204 virtual OGRMultiLineString *clone() const override;
4205
4206#ifndef DOXYGEN_XML
4208#endif
4209
4210 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
4211 size_t &nBytesConsumedOut) override;
4212
4217 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
4218 OGRErr *err = nullptr) const override;
4219
4220 // Non standard
4221 virtual OGRBoolean
4222 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
4223
4226 {
4227 return this;
4228 }
4229
4232 {
4233 return this;
4234 }
4235
4236 virtual void accept(IOGRGeometryVisitor *visitor) override
4237 {
4238 visitor->visit(this);
4239 }
4240
4241 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
4242 {
4243 visitor->visit(this);
4244 }
4245
4246 static OGRMultiCurve *CastToMultiCurve(OGRMultiLineString *poMLS);
4247
4248 OGR_ALLOW_CAST_TO_THIS(MultiLineString)
4249 OGR_ALLOW_UPCAST_TO(MultiCurve)
4250 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
4251 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
4252 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
4253};
4254
4256
4257inline const OGRMultiLineString::ChildType *const *
4258begin(const OGRMultiLineString *poGeom)
4259{
4260 return poGeom->begin();
4261}
4262
4264inline const OGRMultiLineString::ChildType *const *
4265end(const OGRMultiLineString *poGeom)
4266{
4267 return poGeom->end();
4268}
4269
4272{
4273 return poGeom->begin();
4274}
4275
4278{
4279 return poGeom->end();
4280}
4281
4283
4284/************************************************************************/
4285/* OGRGeometryFactory */
4286/************************************************************************/
4287
4293{
4294 static OGRErr createFromFgfInternal(const unsigned char *pabyData,
4295 OGRSpatialReference *poSR,
4296 OGRGeometry **ppoReturn, int nBytes,
4297 int *pnBytesConsumed, int nRecLevel);
4298
4299 public:
4300 static OGRErr createFromWkb(const void *, const OGRSpatialReference *,
4301 OGRGeometry **,
4302 size_t = static_cast<size_t>(-1),
4304 static OGRErr createFromWkb(const void *pabyData,
4305 const OGRSpatialReference *, OGRGeometry **,
4306 size_t nSize, OGRwkbVariant eVariant,
4307 size_t &nBytesConsumedOut);
4308 static OGRErr createFromWkt(const char *, const OGRSpatialReference *,
4309 OGRGeometry **);
4310 static OGRErr createFromWkt(const char **, const OGRSpatialReference *,
4311 OGRGeometry **);
4312 static std::pair<std::unique_ptr<OGRGeometry>, OGRErr>
4313 createFromWkt(const char *, const OGRSpatialReference * = nullptr);
4314
4318 static OGRErr createFromWkt(char **ppszInput,
4319 const OGRSpatialReference *poSRS,
4320 OGRGeometry **ppoGeom)
4321 CPL_WARN_DEPRECATED("Use createFromWkt(const char**, ...) instead")
4322 {
4323 return createFromWkt(const_cast<const char **>(ppszInput), poSRS,
4324 ppoGeom);
4325 }
4326
4327 static OGRErr createFromFgf(const void *, OGRSpatialReference *,
4328 OGRGeometry **, int = -1, int * = nullptr);
4329 static OGRGeometry *createFromGML(const char *);
4330 static OGRGeometry *createFromGEOS(GEOSContextHandle_t hGEOSCtxt, GEOSGeom);
4331 static OGRGeometry *createFromGeoJson(const char *, int = -1);
4332 static OGRGeometry *createFromGeoJson(const CPLJSONObject &oJSONObject);
4333
4334 static void destroyGeometry(OGRGeometry *);
4335 static OGRGeometry *createGeometry(OGRwkbGeometryType);
4336
4337 static OGRGeometry *forceToPolygon(OGRGeometry *);
4338 static OGRGeometry *forceToLineString(OGRGeometry *,
4339 bool bOnlyInOrder = true);
4340 static OGRGeometry *forceToMultiPolygon(OGRGeometry *);
4341 static OGRGeometry *forceToMultiPoint(OGRGeometry *);
4342 static OGRGeometry *forceToMultiLineString(OGRGeometry *);
4343
4344 static OGRGeometry *forceTo(OGRGeometry *poGeom,
4345 OGRwkbGeometryType eTargetType,
4346 const char *const *papszOptions = nullptr);
4347
4348 static OGRGeometry *removeLowerDimensionSubGeoms(const OGRGeometry *poGeom);
4349
4350 static OGRGeometry *organizePolygons(OGRGeometry **papoPolygons,
4351 int nPolygonCount,
4352 int *pbResultValidGeometry,
4353 const char **papszOptions = nullptr);
4354 static bool haveGEOS();
4355
4358 {
4359 friend class OGRGeometryFactory;
4360 struct Private;
4361 std::unique_ptr<Private> d;
4362
4363 public:
4366 };
4367
4369 static bool isTransformWithOptionsRegularTransform(
4370 const OGRSpatialReference *poSourceCRS,
4371 const OGRSpatialReference *poTargetCRS, CSLConstList papszOptions);
4373
4374 static OGRGeometry *transformWithOptions(
4375 const OGRGeometry *poSrcGeom, OGRCoordinateTransformation *poCT,
4376 char **papszOptions,
4378
4379 static double GetDefaultArcStepSize();
4380
4381 static OGRGeometry *
4382 approximateArcAngles(double dfX, double dfY, double dfZ,
4383 double dfPrimaryRadius, double dfSecondaryAxis,
4384 double dfRotation, double dfStartAngle,
4385 double dfEndAngle, double dfMaxAngleStepSizeDegrees,
4386 const bool bUseMaxGap = false);
4387
4388 static int GetCurveParameters(double x0, double y0, double x1, double y1,
4389 double x2, double y2, double &R, double &cx,
4390 double &cy, double &alpha0, double &alpha1,
4391 double &alpha2);
4392 static OGRLineString *
4393 curveToLineString(double x0, double y0, double z0, double x1, double y1,
4394 double z1, double x2, double y2, double z2, int bHasZ,
4395 double dfMaxAngleStepSizeDegrees,
4396 const char *const *papszOptions = nullptr);
4397 static OGRCurve *
4398 curveFromLineString(const OGRLineString *poLS,
4399 const char *const *papszOptions = nullptr);
4400};
4401
4402OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType(const char *pszGeomType);
4403const char CPL_DLL *OGRToOGCGeomType(OGRwkbGeometryType eGeomType,
4404 bool bCamelCase = false,
4405 bool bAddZM = false,
4406 bool bSpaceBeforeZM = false);
4407
4409typedef struct _OGRPreparedGeometry OGRPreparedGeometry;
4410
4411struct CPL_DLL OGRPreparedGeometryUniquePtrDeleter
4412{
4413 void operator()(OGRPreparedGeometry *) const;
4414};
4415
4417
4421typedef std::unique_ptr<OGRPreparedGeometry,
4422 OGRPreparedGeometryUniquePtrDeleter>
4424
4425#endif /* ndef OGR_GEOMETRY_H_INCLUDED */
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition cpl_json.h:41
OGRGeometry visitor interface.
Definition ogr_geometry.h:225
virtual void visit(const OGRCurvePolygon *)=0
Visit OGRCurvePolygon.
virtual void visit(const OGRPolyhedralSurface *)=0
Visit OGRPolyhedralSurface.
virtual void visit(const OGRCompoundCurve *)=0
Visit OGRCompoundCurve.
virtual void visit(const OGRMultiLineString *)=0
Visit OGRMultiLineString.
virtual void visit(const OGRTriangulatedSurface *)=0
Visit OGRTriangulatedSurface.
virtual void visit(const OGRPolygon *)=0
Visit OGRPolygon.
virtual void visit(const OGRMultiPolygon *)=0
Visit OGRMultiPolygon.
virtual void visit(const OGRTriangle *)=0
Visit OGRTriangle.
virtual void visit(const OGRLineString *)=0
Visit OGRLineString.
virtual void visit(const OGRMultiPoint *)=0
Visit OGRMultiPoint.
virtual void visit(const OGRMultiCurve *)=0
Visit OGRMultiCurve.
virtual void visit(const OGRGeometryCollection *)=0
Visit OGRGeometryCollection.
virtual void visit(const OGRPoint *)=0
Visit OGRPoint.
virtual ~IOGRConstGeometryVisitor()=default
Destructor/.
virtual void visit(const OGRMultiSurface *)=0
Visit OGRMultiSurface.
virtual void visit(const OGRLinearRing *)=0
Visit OGRLinearRing.
virtual void visit(const OGRCircularString *)=0
Visit OGRCircularString.
OGRGeometry visitor interface.
Definition ogr_geometry.h:149
virtual void visit(OGRMultiSurface *)=0
Visit OGRMultiSurface.
virtual void visit(OGRLinearRing *)=0
Visit OGRLinearRing.
virtual void visit(OGRTriangle *)=0
Visit OGRTriangle.
virtual void visit(OGRCircularString *)=0
Visit OGRCircularString.
virtual void visit(OGRPolygon *)=0
Visit OGRPolygon.
virtual void visit(OGRLineString *)=0
Visit OGRLineString.
virtual void visit(OGRCompoundCurve *)=0
Visit OGRCompoundCurve.
virtual void visit(OGRTriangulatedSurface *)=0
Visit OGRTriangulatedSurface.
virtual void visit(OGRPoint *)=0
Visit OGRPoint.
virtual void visit(OGRCurvePolygon *)=0
Visit OGRCurvePolygon.
virtual void visit(OGRGeometryCollection *)=0
Visit OGRGeometryCollection.
virtual void visit(OGRPolyhedralSurface *)=0
Visit OGRPolyhedralSurface.
virtual void visit(OGRMultiPolygon *)=0
Visit OGRMultiPolygon.
virtual ~IOGRGeometryVisitor()=default
Destructor/.
virtual void visit(OGRMultiLineString *)=0
Visit OGRMultiLineString.
virtual void visit(OGRMultiPoint *)=0
Visit OGRMultiPoint.
virtual void visit(OGRMultiCurve *)=0
Visit OGRMultiCurve.
Concrete representation of a circular string, that is to say a curve made of one or several arc circl...
Definition ogr_geometry.h:1966
OGRCircularString()=default
Create an empty circular string.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2056
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2051
OGRCircularString(const OGRCircularString &other)
Copy constructor.
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2045
OGRCircularString & operator=(OGRCircularString &&other)=default
Move assignment operator.
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2061
OGRCircularString(OGRCircularString &&other)=default
Move constructor.
Utility class to store a collection of curves.
Definition ogr_geometry.h:2202
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2368
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:2267
OGRCompoundCurve()=default
Create an empty compound curve.
const ChildType *const * begin() const
Return begin of curve iterator.
Definition ogr_geometry.h:2261
OGRCompoundCurve(const OGRCompoundCurve &other)
Copy constructor.
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:2242
OGRCompoundCurve(OGRCompoundCurve &&other)=default
Move constructor.
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:2253
OGRCompoundCurve & operator=(OGRCompoundCurve &&other)=default
Move assignment operator.
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:2247
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2363
Interface for transforming between coordinate systems.
Definition ogr_spatialref.h:772
Concrete class representing curve polygons.
Definition ogr_geometry.h:2472
OGRCurvePolygon()=default
Create an empty curve polygon.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2630
OGRCurvePolygon & operator=(OGRCurvePolygon &&other)=default
Move assignment operator.
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:2515
OGRCurvePolygon(OGRCurvePolygon &&)=default
Move constructor.
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:2540
const ChildType *const * begin() const
Return begin of curve iterator.
Definition ogr_geometry.h:2534
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:2520
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:2526
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2635
OGRCurvePolygon(const OGRCurvePolygon &)
Copy constructor.
Abstract curve base class for OGRLineString, OGRCircularString and OGRCompoundCurve.
Definition ogr_geometry.h:1321
virtual OGRLineString * CurveToLine(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const =0
Return a linestring from a curve geometry.
virtual double get_Length() const =0
Returns the length of the curve.
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:1415
virtual void StartPoint(OGRPoint *) const =0
Return the curve start point.
virtual void EndPoint(OGRPoint *) const =0
Return the curve end point.
virtual int getNumPoints() const =0
Return the number of points of a curve geometry.
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:1364
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:1407
virtual void Value(double, OGRPoint *) const =0
Fetch point at given distance along curve.
virtual OGRPointIterator * getPointIterator() const =0
Returns a point iterator over the curve.
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...
virtual double get_AreaOfCurveSegments() const =0
Get the area of the purely curve portions of a (closed) curve.
virtual double get_Area() const =0
Get the area of the (closed) curve.
virtual void reversePoints()=0
Reverse point order.
virtual OGRCurve * clone() const override=0
Make a copy of this object.
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...
OGRGeometry visitor default implementation.
Definition ogr_geometry.h:272
void visit(const OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:276
OGRGeometry visitor default implementation.
Definition ogr_geometry.h:196
void visit(OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:200
Simple container for a bounding region in 3D.
Definition ogr_core.h:199
Simple container for a bounding region (rectangle)
Definition ogr_core.h:44
A collection of 1 or more geometry objects.
Definition ogr_geometry.h:2959
ChildType ** end()
Return end of sub-geometry iterator.
Definition ogr_geometry.h:3003
OGRGeometryCollection()=default
Create an empty geometry collection.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3103
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3108
const ChildType *const * begin() const
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:3011
const ChildType *const * end() const
Return end of sub-geometry iterator.
Definition ogr_geometry.h:3017
ChildType ** begin()
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:2997
OGRGeometry * getGeometryRef(int)
Fetch geometry from container.
Definition ogrgeometrycollection.cpp:303
OGRGeometry ChildType
Type of child elements.
Definition ogr_geometry.h:2992
Opaque class used as argument to transformWithOptions()
Definition ogr_geometry.h:4358
Create geometry objects from well known text/binary.
Definition ogr_geometry.h:4293
static OGRErr createFromWkt(char **ppszInput, const OGRSpatialReference *poSRS, OGRGeometry **ppoGeom)
Deprecated.
Definition ogr_geometry.h:4318
Abstract base class for all geometry classes.
Definition ogr_geometry.h:360
const OGRSurface * toSurface() const
Down-cast to OGRSurface*.
Definition ogr_geometry.h:803
const OGRCurvePolygon * toCurvePolygon() const
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:861
const OGRMultiCurve * toMultiCurve() const
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:961
const OGRPolyhedralSurface * toPolyhedralSurface() const
Down-cast to OGRPolyhedralSurface*.
Definition ogr_geometry.h:1001
const OGRMultiPoint * toMultiPoint() const
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:901
virtual void empty()=0
Clear geometry information.
const OGRMultiPolygon * toMultiPolygon() const
Down-cast to OGRMultiPolygon*.
Definition ogr_geometry.h:941
virtual OGRBoolean Equals(const OGRGeometry *) const =0
Returns TRUE if two geometries are equivalent.
OGRPolyhedralSurface * toPolyhedralSurface()
Down-cast to OGRPolyhedralSurface*.
Definition ogr_geometry.h:991
const OGRMultiSurface * toMultiSurface() const
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:981
OGRPoint * toPoint()
Down-cast to OGRPoint*.
Definition ogr_geometry.h:656
bool operator!=(const OGRGeometry &other) const
Returns if two geometries are different.
Definition ogr_geometry.h:422
OGRTriangle * toTriangle()
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:832
OGRLineString * toLineString()
Down-cast to OGRLineString*.
Definition ogr_geometry.h:715
const OGRLinearRing * toLinearRing() const
Down-cast to OGRLinearRing*.
Definition ogr_geometry.h:743
const OGRPoint * toPoint() const
Down-cast to OGRPoint*.
Definition ogr_geometry.h:665
OGRMultiLineString * toMultiLineString()
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:911
OGRMultiSurface * toMultiSurface()
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:971
static OGRGeometry * FromHandle(OGRGeometryH hGeom)
Convert a OGRGeometryH to a OGRGeometry*.
Definition ogr_geometry.h:647
virtual OGRwkbGeometryType getGeometryType() const =0
Fetch geometry type.
virtual void accept(IOGRConstGeometryVisitor *visitor) const =0
Accept a visitor.
const OGRGeometryCollection * toGeometryCollection() const
Down-cast to OGRGeometryCollection*.
Definition ogr_geometry.h:881
const OGRMultiLineString * toMultiLineString() const
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:921
const OGRCircularString * toCircularString() const
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:763
OGRPolygon * toPolygon()
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:813
bool operator==(const OGRGeometry &other) const
Returns if two geometries are equal.
Definition ogr_geometry.h:416
OGRLinearRing * toLinearRing()
Down-cast to OGRLinearRing*.
Definition ogr_geometry.h:734
OGRBoolean IsMeasured() const
Definition ogr_geometry.h:444
virtual void accept(IOGRGeometryVisitor *visitor)=0
Accept a visitor.
OGRMultiCurve * toMultiCurve()
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:951
const OGRCompoundCurve * toCompoundCurve() const
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:783
virtual OGRErr transform(OGRCoordinateTransformation *poCT)=0
Apply arbitrary coordinate transformation to geometry.
virtual void flattenTo2D()=0
Convert geometry to strictly 2D.
virtual int getDimension() const =0
Get the dimension of this object.
OGRGeometryCollection * toGeometryCollection()
Down-cast to OGRGeometryCollection*.
Definition ogr_geometry.h:871
virtual const char * getGeometryName() const =0
Fetch WKT name for geometry type.
OGRMultiPolygon * toMultiPolygon()
Down-cast to OGRMultiPolygon*.
Definition ogr_geometry.h:931
const OGRPolygon * toPolygon() const
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:823
OGRCompoundCurve * toCompoundCurve()
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:773
OGRErr importFromWkt(char **ppszInput)
Deprecated.
Definition ogr_geometry.h:471
virtual OGRBoolean IsEmpty() const =0
Returns TRUE (non-zero) if the object has no points.
const OGRLineString * toLineString() const
Down-cast to OGRLineString*.
Definition ogr_geometry.h:725
OGRErr exportToWkt(char **ppszDstText, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known text format.
Definition ogrgeometry.cpp:1983
OGRCircularString * toCircularString()
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:753
const OGRCurve * toCurve() const
Down-cast to OGRCurve*.
Definition ogr_geometry.h:685
OGRCurvePolygon * toCurvePolygon()
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:851
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:705
static OGRGeometryH ToHandle(OGRGeometry *poGeom)
Convert a OGRGeometry* to a OGRGeometryH.
Definition ogr_geometry.h:639
OGRBoolean Is3D() const
Definition ogr_geometry.h:438
OGRMultiPoint * toMultiPoint()
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:891
const OGRTriangulatedSurface * toTriangulatedSurface() const
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:1019
const OGRTriangle * toTriangle() const
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:841
virtual OGRErr importFromWkt(const char **ppszInput)=0
Assign geometry from well known text data.
virtual OGRGeometry * clone() const =0
Make a copy of this object.
OGRSurface * toSurface()
Down-cast to OGRSurface*.
Definition ogr_geometry.h:793
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:695
OGRTriangulatedSurface * toTriangulatedSurface()
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:1010
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const =0
Export a WKT geometry.
OGRCurve * toCurve()
Down-cast to OGRCurve*.
Definition ogr_geometry.h:675
Definition ogr_geometry.h:1471
Concrete representation of a multi-vertex line.
Definition ogr_geometry.h:1770
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...
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:1814
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1830
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1825
OGRLineString(const OGRLineString &other)
Copy constructor.
OGRLineString(OGRLineString &&other)
Move constructor.
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...
virtual int isClockwise() const override
Returns TRUE if the ring has clockwise winding (or less than 2 points)
virtual double get_Area() const override
Get the area of the (closed) curve.
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1820
OGRLineString()=default
Create an empty line string.
Concrete representation of a closed ring.
Definition ogr_geometry.h:1864
OGRLinearRing()=default
Constructor.
OGRLinearRing & operator=(OGRLinearRing &&other)=default
Move assignment operator.
const OGRLineString * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1930
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1940
OGRLinearRing(const OGRLinearRing &other)
Copy constructor.
OGRLinearRing(OGRLinearRing &&other)=default
Move constructor.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1935
A collection of OGRCurve.
Definition ogr_geometry.h:3979
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:4019
OGRMultiCurve()=default
Create an empty multi curve collection.
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:4025
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:4090
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:4011
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:4080
OGRMultiCurve & operator=(OGRMultiCurve &&other)=default
Move assignment operator.
const OGRCurve * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:4039
OGRCurve * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:4033
OGRMultiCurve(const OGRMultiCurve &other)
Copy constructor.
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:4000
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:4005
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:4074
OGRMultiCurve(OGRMultiCurve &&other)=default
Move constructor.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:4085
A collection of OGRLineString.
Definition ogr_geometry.h:4140
OGRLineString ChildType
Type of child elements.
Definition ogr_geometry.h:4157
OGRLineString * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:4190
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:4225
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:4168
OGRMultiLineString()=default
Create an empty multi line string collection.
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:4182
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:4241
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:4176
OGRMultiLineString(OGRMultiLineString &&other)=default
Move constructor.
const OGRLineString * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:4196
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:4236
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:4162
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:4231
OGRMultiLineString & operator=(OGRMultiLineString &&other)=default
Move assignment operator.
OGRMultiLineString(const OGRMultiLineString &other)
Copy constructor.
A collection of OGRPoint.
Definition ogr_geometry.h:3818
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3908
OGRMultiPoint & operator=(OGRMultiPoint &&other)=default
Move assignment operator.
OGRMultiPoint()=default
Create an empty multi point collection.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3919
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3863
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3843
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3924
OGRMultiPoint(const OGRMultiPoint &other)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3857
OGRMultiPoint(OGRMultiPoint &&other)=default
Move constructor.
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3914
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:3838
const OGRPoint * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3877
OGRPoint * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3871
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3849
A collection of non-overlapping OGRPolygon.
Definition ogr_geometry.h:3324
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:3351
OGRMultiPolygon(const OGRMultiPolygon &other)
Copy constructor.
OGRMultiPolygon & operator=(OGRMultiPolygon &&other)=default
Move assignment operator.
OGRPolygon * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3384
OGRMultiPolygon()=default
Create an empty multi polygon collection.
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3435
const OGRPolygon * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3390
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3376
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3362
OGRMultiPolygon(OGRMultiPolygon &&other)=default
Move constructor.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3430
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3356
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3419
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3370
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3425
A collection of non-overlapping OGRSurface.
Definition ogr_geometry.h:3162
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3267
const OGRSurface * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3246
OGRMultiSurface & operator=(OGRMultiSurface &&other)=default
Move assignment operator.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3184
OGRSurface ChildType
Type of child elements.
Definition ogr_geometry.h:3179
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3262
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3198
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3204
OGRMultiSurface(const OGRMultiSurface &other)
Copy constructor.
OGRMultiSurface()=default
Create an empty multi surface collection.
OGRMultiSurface(OGRMultiSurface &&other)=default
Move constructor.
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3190
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3272
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3256
OGRSurface * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3240
Interface for a point iterator.
Definition ogr_geometry.h:1303
virtual OGRBoolean getNextPoint(OGRPoint *p)=0
Returns the next point followed by the iterator.
Point class.
Definition ogr_geometry.h:1137
double getM() const
Return m.
Definition ogr_geometry.h:1213
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1274
void setX(double xIn)
Set x.
Definition ogr_geometry.h:1224
OGRPoint(const OGRPoint &other)
Copy constructor.
OGRPoint & operator=(OGRPoint &&other)=default
Move assignment operator.
void setZ(double zIn)
Set z.
Definition ogr_geometry.h:1248
void setM(double mIn)
Set m.
Definition ogr_geometry.h:1257
double getX() const
Return x.
Definition ogr_geometry.h:1195
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1279
void setY(double yIn)
Set y.
Definition ogr_geometry.h:1236
virtual OGRBoolean IsEmpty() const override
Returns TRUE (non-zero) if the object has no points.
Definition ogr_geometry.h:1188
double getZ() const
Return z.
Definition ogr_geometry.h:1207
double getY() const
Return y.
Definition ogr_geometry.h:1201
OGRPoint(OGRPoint &&other)=default
Move constructor.
Concrete class representing polygons.
Definition ogr_geometry.h:2692
OGRPolygon & operator=(OGRPolygon &&other)=default
Move assignment operator.
OGRLinearRing ChildType
Type of child elements.
Definition ogr_geometry.h:2732
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2737
OGRPolygon(OGRPolygon &&other)=default
Move constructor.
const OGRCurvePolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2820
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2743
OGRPolygon(const OGRPolygon &other)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2751
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2830
OGRPolygon()=default
Create an empty polygon.
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2757
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2825
OGRCurvePolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2814
PolyhedralSurface class.
Definition ogr_geometry.h:3486
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3529
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3543
OGRPolyhedralSurface(const OGRPolyhedralSurface &other)
Copy constructor.
OGRPolygon * getGeometryRef(int i)
Fetch geometry from container.
Definition ogrpolyhedralsurface.cpp:862
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3537
OGRPolyhedralSurface(OGRPolyhedralSurface &&other)=default
Move constructor.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3523
OGRPolyhedralSurface()=default
Create an empty PolyhedralSurface.
virtual OGRErr addGeometry(const OGRGeometry *)
Add a new geometry to a collection.
Definition ogrpolyhedralsurface.cpp:744
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3616
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:3518
OGRPolyhedralSurface & operator=(OGRPolyhedralSurface &&other)=default
Move assignment operator.
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3621
Simple container for a position.
Definition ogr_geometry.h:89
OGRRawPoint(double xIn, double yIn)
Constructor.
Definition ogr_geometry.h:97
double x
x
Definition ogr_geometry.h:102
double y
y
Definition ogr_geometry.h:104
OGRRawPoint()
Constructor.
Definition ogr_geometry.h:92
Abstract curve base class for OGRLineString and OGRCircularString.
Definition ogr_geometry.h:1515
double getY(int i) const
Get Y at vertex.
Definition ogr_geometry.h:1670
double getX(int i) const
Get X at vertex.
Definition ogr_geometry.h:1665
OGRSimpleCurve()=default
Constructor.
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:1592
virtual OGRSimpleCurve * clone() const override=0
Make a copy of this object.
virtual int getNumPoints() const override
Fetch vertex count.
Definition ogr_geometry.h:1658
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
Abstract base class for 2 dimensional objects like polygons or curve polygons.
Definition ogr_geometry.h:2421
virtual double get_Area() const =0
Get the area of the surface object.
virtual double get_Length() const =0
Get the length of the surface.
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...
virtual OGRSurface * clone() const override=0
Make a copy of this object.
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...
virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
This method relates to the SFCOM ISurface::get_PointOnSurface() method.
Definition ogr_geometry.h:2436
Triangle class.
Definition ogr_geometry.h:2879
OGRTriangle()=default
Constructor.
const OGRPolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2924
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2929
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2934
OGRTriangle(OGRTriangle &&other)=default
Move constructor.
OGRPolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2918
OGRTriangle & operator=(OGRTriangle &&other)=default
Move assignment operator.
OGRTriangle(const OGRTriangle &other)
Copy constructor.
TriangulatedSurface class.
Definition ogr_geometry.h:3673
const OGRTriangle * getGeometryRef(int i) const
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:3739
OGRTriangle * getGeometryRef(int i)
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:3733
OGRTriangulatedSurface(OGRTriangulatedSurface &&other)=default
Move constructor.
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3723
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3717
OGRPolyhedralSurface * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3752
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3763
const OGRPolyhedralSurface * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3758
OGRTriangulatedSurface & operator=(OGRTriangulatedSurface &&other)=default
Move assignment operator.
OGRTriangle ChildType
Type of child elements.
Definition ogr_geometry.h:3698
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3768
OGRTriangulatedSurface()=default
Constructor.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3703
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3709
Various convenience functions for CPL.
Interface for read and write JSON documents.
#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:962
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1111
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition cpl_port.h:896
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175
Forward definitions of GDAL/OGR/OSR C handle types.
void * OGRGeometryH
Opaque type for a geometry.
Definition gdal_fwd.h:93
Core portability services for cross-platform OGR code.
int OGRBoolean
Type for a OGR boolean.
Definition ogr_core.h:387
OGRwkbByteOrder
Enumeration to describe byte order.
Definition ogr_core.h:615
@ wkbNDR
LSB/Intel/Vax: Least Significant Byte First
Definition ogr_core.h:617
OGRwkbVariant
Output variants of WKB we support.
Definition ogr_core.h:544
@ wkbVariantOldOgc
Old-style 99-402 extended dimension (Z) WKB types.
Definition ogr_core.h:545
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:406
int OGRErr
Type for a OGR error.
Definition ogr_core.h:370
Geometry coordinate precision class.
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:2626
OGRWktFormat
WKT Output formatting options.
Definition ogr_geometry.h:38
@ Default
Format as F when abs(value) < 1, otherwise as G.
@ F
F-type formatting.
@ G
G-type formatting.
std::unique_ptr< OGRPreparedGeometry, OGRPreparedGeometryUniquePtrDeleter > OGRPreparedGeometryUniquePtr
Unique pointer type for OGRPreparedGeometry.
Definition ogr_geometry.h:4423
struct GEOSContextHandle_HS * GEOSContextHandle_t
GEOS context handle type.
Definition ogr_geometry.h:110
OGRwkbGeometryType OGRFromOGCGeomType(const char *pszGeomType)
Map OGC geometry format type to corresponding OGR constants.
Definition ogrgeometry.cpp:2547
std::unique_ptr< OGRGeometry, OGRGeometryUniquePtrDeleter > OGRGeometryUniquePtr
Unique pointer type for OGRGeometry.
Definition ogr_geometry.h:1037
struct GEOSGeom_t * GEOSGeom
GEOS geometry type.
Definition ogr_geometry.h:108
void sfcgal_geometry_t
SFCGAL geometry type.
Definition ogr_geometry.h:112
Coordinate systems services.
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition ogrsf_frmts.h:467
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition ogrsf_frmts.h:475
Geometry coordinate precision for a binary representation.
Definition ogr_geometry.h:306
Geometry coordinate precision.
Definition ogr_geomcoordinateprecision.h:40
Options for formatting WKT output.
Definition ogr_geometry.h:46
int mPrecision
Precision of output for M coordinates. Interpretation depends on format.
Definition ogr_geometry.h:55
int zPrecision
Precision of output for Z coordinates. Interpretation depends on format.
Definition ogr_geometry.h:53
OGRWktOptions()
Constructor.
Definition ogr_geometry.h:62
OGRWktOptions(const OGRWktOptions &)=default
Copy constructor.
int xyPrecision
Precision of output for X,Y coordinates. Interpretation depends on format.
Definition ogr_geometry.h:51
bool round
Whether GDAL-special rounding should be applied.
Definition ogr_geometry.h:57
OGRWktOptions(int xyPrecisionIn, bool roundIn)
Constructor.
Definition ogr_geometry.h:69
WKB export options.
Definition ogr_geometry.h:329