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
45class 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
148{
149 public:
152
154 virtual void visit(OGRPoint *) = 0;
156 virtual void visit(OGRLineString *) = 0;
158 virtual void visit(OGRLinearRing *) = 0;
160 virtual void visit(OGRPolygon *) = 0;
162 virtual void visit(OGRMultiPoint *) = 0;
164 virtual void visit(OGRMultiLineString *) = 0;
166 virtual void visit(OGRMultiPolygon *) = 0;
168 virtual void visit(OGRGeometryCollection *) = 0;
170 virtual void visit(OGRCircularString *) = 0;
172 virtual void visit(OGRCompoundCurve *) = 0;
174 virtual void visit(OGRCurvePolygon *) = 0;
176 virtual void visit(OGRMultiCurve *) = 0;
178 virtual void visit(OGRMultiSurface *) = 0;
180 virtual void visit(OGRTriangle *) = 0;
182 virtual void visit(OGRPolyhedralSurface *) = 0;
184 virtual void visit(OGRTriangulatedSurface *) = 0;
185};
186
194{
195 void _visit(OGRSimpleCurve *poGeom);
196
197 public:
198 void visit(OGRPoint *) override
199 {
200 }
201
202 void visit(OGRLineString *) override;
203 void visit(OGRLinearRing *) override;
204 void visit(OGRPolygon *) override;
205 void visit(OGRMultiPoint *) override;
206 void visit(OGRMultiLineString *) override;
207 void visit(OGRMultiPolygon *) override;
208 void visit(OGRGeometryCollection *) override;
209 void visit(OGRCircularString *) override;
210 void visit(OGRCompoundCurve *) override;
211 void visit(OGRCurvePolygon *) override;
212 void visit(OGRMultiCurve *) override;
213 void visit(OGRMultiSurface *) override;
214 void visit(OGRTriangle *) override;
215 void visit(OGRPolyhedralSurface *) override;
216 void visit(OGRTriangulatedSurface *) override;
217};
218
222{
223 public:
226
228 virtual void visit(const OGRPoint *) = 0;
230 virtual void visit(const OGRLineString *) = 0;
232 virtual void visit(const OGRLinearRing *) = 0;
234 virtual void visit(const OGRPolygon *) = 0;
236 virtual void visit(const OGRMultiPoint *) = 0;
238 virtual void visit(const OGRMultiLineString *) = 0;
240 virtual void visit(const OGRMultiPolygon *) = 0;
242 virtual void visit(const OGRGeometryCollection *) = 0;
244 virtual void visit(const OGRCircularString *) = 0;
246 virtual void visit(const OGRCompoundCurve *) = 0;
248 virtual void visit(const OGRCurvePolygon *) = 0;
250 virtual void visit(const OGRMultiCurve *) = 0;
252 virtual void visit(const OGRMultiSurface *) = 0;
254 virtual void visit(const OGRTriangle *) = 0;
256 virtual void visit(const OGRPolyhedralSurface *) = 0;
258 virtual void visit(const OGRTriangulatedSurface *) = 0;
259};
260
268{
269 void _visit(const OGRSimpleCurve *poGeom);
270
271 public:
272 void visit(const OGRPoint *) override
273 {
274 }
275
276 void visit(const OGRLineString *) override;
277 void visit(const OGRLinearRing *) override;
278 void visit(const OGRPolygon *) override;
279 void visit(const OGRMultiPoint *) override;
280 void visit(const OGRMultiLineString *) override;
281 void visit(const OGRMultiPolygon *) override;
282 void visit(const OGRGeometryCollection *) override;
283 void visit(const OGRCircularString *) override;
284 void visit(const OGRCompoundCurve *) override;
285 void visit(const OGRCurvePolygon *) override;
286 void visit(const OGRMultiCurve *) override;
287 void visit(const OGRMultiSurface *) override;
288 void visit(const OGRTriangle *) override;
289 void visit(const OGRPolyhedralSurface *) override;
290 void visit(const OGRTriangulatedSurface *) override;
291};
292
293/************************************************************************/
294/* OGRGeomCoordinateBinaryPrecision */
295/************************************************************************/
296
302{
303 public:
304 int nXYBitPrecision =
305 INT_MIN;
307 int nZBitPrecision =
308 INT_MIN;
310 int nMBitPrecision =
311 INT_MIN;
314 void SetFrom(const OGRGeomCoordinatePrecision &);
315};
316
317/************************************************************************/
318/* OGRwkbExportOptions */
319/************************************************************************/
320
331
332/************************************************************************/
333/* OGRGeometry */
334/************************************************************************/
335
356class CPL_DLL OGRGeometry
357{
358 private:
359 const OGRSpatialReference *poSRS = nullptr; // may be NULL
360
361 protected:
363 friend class OGRCurveCollection;
364
365 unsigned int flags = 0;
366
367 OGRErr importPreambleFromWkt(const char **ppszInput, int *pbHasZ,
368 int *pbHasM, bool *pbIsEmpty);
369 OGRErr importCurveCollectionFromWkt(
370 const char **ppszInput, int bAllowEmptyComponent, int bAllowLineString,
371 int bAllowCurve, int bAllowCompoundCurve,
372 OGRErr (*pfnAddCurveDirectly)(OGRGeometry *poSelf, OGRCurve *poCurve));
373 OGRErr importPreambleFromWkb(const unsigned char *pabyData, size_t nSize,
374 OGRwkbByteOrder &eByteOrder,
375 OGRwkbVariant eWkbVariant);
376 OGRErr importPreambleOfCollectionFromWkb(const unsigned char *pabyData,
377 size_t &nSize, size_t &nDataOffset,
378 OGRwkbByteOrder &eByteOrder,
379 size_t nMinSubGeomSize,
380 int &nGeomCount,
381 OGRwkbVariant eWkbVariant);
382 OGRErr PointOnSurfaceInternal(OGRPoint *poPoint) const;
383 OGRBoolean IsSFCGALCompatible() const;
384
385 void HomogenizeDimensionalityWith(OGRGeometry *poOtherGeom);
386 std::string wktTypeString(OGRwkbVariant variant) const;
387
389
390 public:
391 /************************************************************************/
392 /* Bit flags for OGRGeometry */
393 /* The OGR_G_NOT_EMPTY_POINT is used *only* for points. */
394 /* Do not use these outside of the core. */
395 /* Use Is3D, IsMeasured, set3D, and setMeasured instead */
396 /************************************************************************/
397
399 static const unsigned int OGR_G_NOT_EMPTY_POINT = 0x1;
400 static const unsigned int OGR_G_3D = 0x2;
401 static const unsigned int OGR_G_MEASURED = 0x4;
403
404 OGRGeometry();
405 OGRGeometry(const OGRGeometry &other);
406 OGRGeometry(OGRGeometry &&other);
407 virtual ~OGRGeometry();
408
409 OGRGeometry &operator=(const OGRGeometry &other);
410 OGRGeometry &operator=(OGRGeometry &&other);
411
413 bool operator==(const OGRGeometry &other) const
414 {
415 return CPL_TO_BOOL(Equals(&other));
416 }
417
419 bool operator!=(const OGRGeometry &other) const
420 {
421 return !CPL_TO_BOOL(Equals(&other));
422 }
423
424 // Standard IGeometry.
425 virtual int getDimension() const = 0;
426 virtual int getCoordinateDimension() const;
427 int CoordinateDimension() const;
428 virtual OGRBoolean IsEmpty() const = 0;
429 virtual OGRBoolean IsValid(std::string *posReason = nullptr) const;
430 virtual OGRGeometry *MakeValid(CSLConstList papszOptions = nullptr) const;
431 virtual OGRGeometry *Normalize() const;
432 virtual OGRBoolean IsSimple() const;
433
436 {
437 return (flags & OGR_G_3D) != 0;
438 }
439
442 {
443 return (flags & OGR_G_MEASURED) != 0;
444 }
445
446 virtual OGRBoolean IsRing() const;
447 virtual void empty() = 0;
449 virtual void getEnvelope(OGREnvelope *psEnvelope) const = 0;
450 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const = 0;
451
452 // IWks Interface.
453 virtual size_t WkbSize() const = 0;
454 OGRErr importFromWkb(const GByte *, size_t = static_cast<size_t>(-1),
456 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
457 size_t &nBytesConsumedOut) = 0;
458 OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
460 virtual OGRErr exportToWkb(unsigned char *,
461 const OGRwkbExportOptions * = nullptr) const = 0;
462 virtual OGRErr importFromWkt(const char **ppszInput) = 0;
463
464#ifndef DOXYGEN_XML
468 OGRErr importFromWkt(char **ppszInput)
470 CPL_WARN_DEPRECATED("Use importFromWkt(const char**) instead")
472 {
473 return importFromWkt(const_cast<const char **>(ppszInput));
474 }
475#endif
476
477 OGRErr exportToWkt(char **ppszDstText,
479
484 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
485 OGRErr *err = nullptr) const = 0;
486
487 // Non-standard.
489 OGRwkbGeometryType getIsoGeometryType() const;
490 virtual const char *getGeometryName() const = 0;
491 void dumpReadable(FILE *, const char * = nullptr,
492 CSLConstList papszOptions = nullptr) const;
493 std::string dumpReadable(const char * = nullptr,
494 CSLConstList papszOptions = nullptr) const;
495 virtual void flattenTo2D() = 0;
496 virtual char *exportToGML(const char *const *papszOptions = nullptr) const;
497 virtual char *exportToKML() const;
498 virtual char *exportToJson(CSLConstList papszOptions = nullptr) const;
499
501 virtual void accept(IOGRGeometryVisitor *visitor) = 0;
502
504 virtual void accept(IOGRConstGeometryVisitor *visitor) const = 0;
505
506 static GEOSContextHandle_t createGEOSContext();
507 static void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt);
509 exportToGEOS(GEOSContextHandle_t hGEOSCtxt, bool bRemoveEmptyParts = false,
510 bool bAddPointsIfNeeded = false) const CPL_WARN_UNUSED_RESULT;
511 virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
512 virtual OGRGeometry *getCurveGeometry(
513 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
514 virtual OGRGeometry *getLinearGeometry(
515 double dfMaxAngleStepSizeDegrees = 0,
516 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
517
518 void roundCoordinates(const OGRGeomCoordinatePrecision &sPrecision);
519 void
520 roundCoordinatesIEEE754(const OGRGeomCoordinateBinaryPrecision &options);
521
522 // SFCGAL interfacing methods.
524 static sfcgal_geometry_t *OGRexportToSFCGAL(const OGRGeometry *poGeom);
525 static OGRGeometry *SFCGALexportToOGR(const sfcgal_geometry_t *_geometry);
527 virtual void closeRings();
528
529 virtual bool setCoordinateDimension(int nDimension);
530 virtual bool set3D(OGRBoolean bIs3D);
531 virtual bool setMeasured(OGRBoolean bIsMeasured);
532
533 virtual void assignSpatialReference(const OGRSpatialReference *poSR);
534
535 const OGRSpatialReference *getSpatialReference(void) const
536 {
537 return poSRS;
538 }
539
541 OGRErr transformTo(const OGRSpatialReference *poSR);
542
543 virtual bool segmentize(double dfMaxLength);
544
545 // ISpatialRelation
546 virtual OGRBoolean Intersects(const OGRGeometry *) const;
547 virtual OGRBoolean Equals(const OGRGeometry *) const = 0;
548 OGRBoolean Disjoint(const OGRGeometry *) const;
549 OGRBoolean Touches(const OGRGeometry *) const;
550 OGRBoolean Crosses(const OGRGeometry *) const;
551 virtual OGRBoolean Within(const OGRGeometry *) const;
552 virtual OGRBoolean Contains(const OGRGeometry *) const;
553 OGRBoolean Overlaps(const OGRGeometry *) const;
554
555 OGRGeometry *Boundary() const CPL_WARN_UNUSED_RESULT;
556
557 double Distance(const OGRGeometry *) const;
558
559 OGRGeometry *ConvexHull() const CPL_WARN_UNUSED_RESULT;
560
561 OGRGeometry *ConcaveHull(double dfRatio,
562 bool bAllowHoles) const CPL_WARN_UNUSED_RESULT;
563
565 ConcaveHullOfPolygons(double dfLengthRatio, bool bIsTight,
566 bool bAllowHoles) const CPL_WARN_UNUSED_RESULT;
567
568 OGRGeometry *Buffer(double dfDist,
569 int nQuadSegs = 30) const CPL_WARN_UNUSED_RESULT;
570
572 BufferEx(double dfDist,
573 CSLConstList papszOptions) const CPL_WARN_UNUSED_RESULT;
574
575 OGRGeometry *Intersection(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
576
577 OGRGeometry *Union(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
578
579 OGRGeometry *UnionCascaded() const CPL_WARN_UNUSED_RESULT;
580
581 OGRGeometry *UnaryUnion() const CPL_WARN_UNUSED_RESULT;
582
583 OGRGeometry *Difference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
584
586 SymDifference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
587
588 OGRErr Centroid(OGRPoint *poPoint) const;
589
590 OGRGeometry *Simplify(double dTolerance) const CPL_WARN_UNUSED_RESULT;
591
593 SimplifyPreserveTopology(double dTolerance) const CPL_WARN_UNUSED_RESULT;
594
596 DelaunayTriangulation(double dfTolerance,
597 int bOnlyEdges) const CPL_WARN_UNUSED_RESULT;
598
600 ConstrainedDelaunayTriangulation() const CPL_WARN_UNUSED_RESULT;
601
602 OGRGeometry *Polygonize() const CPL_WARN_UNUSED_RESULT;
603
604 OGRGeometry *BuildArea() const CPL_WARN_UNUSED_RESULT;
605
606 double Distance3D(const OGRGeometry *poOtherGeom) const;
607
608 OGRGeometry *SetPrecision(double dfGridSize, int nFlags) const;
609
610 virtual bool hasEmptyParts() const;
611 virtual void removeEmptyParts();
612
614 // backward compatibility to non-standard method names.
615 OGRBoolean Intersect(OGRGeometry *) const
616 CPL_WARN_DEPRECATED("Non standard method. "
617 "Use Intersects() instead");
618 OGRBoolean Equal(OGRGeometry *) const
619 CPL_WARN_DEPRECATED("Non standard method. "
620 "Use Equals() instead");
621 OGRGeometry *SymmetricDifference(const OGRGeometry *) const
622 CPL_WARN_DEPRECATED("Non standard method. "
623 "Use SymDifference() instead");
624 OGRGeometry *getBoundary() const
625 CPL_WARN_DEPRECATED("Non standard method. "
626 "Use Boundary() instead");
628
630 // Special HACK for DB2 7.2 support
631 static int bGenerate_DB2_V72_BYTE_ORDER;
633
634 virtual void swapXY();
635
636 bool IsRectangle() const;
637
639 static OGRGeometry *CastToIdentity(OGRGeometry *poGeom)
640 {
641 return poGeom;
642 }
643
644 static OGRGeometry *CastToError(OGRGeometry *poGeom);
645
647
650 static inline OGRGeometryH ToHandle(OGRGeometry *poGeom)
651 {
652 return reinterpret_cast<OGRGeometryH>(poGeom);
653 }
654
657 static inline OGRGeometry *FromHandle(OGRGeometryH hGeom)
658 {
659 return reinterpret_cast<OGRGeometry *>(hGeom);
660 }
661
666 {
667 return cpl::down_cast<OGRPoint *>(this);
668 }
669
673 inline const OGRPoint *toPoint() const
674 {
675 return cpl::down_cast<const OGRPoint *>(this);
676 }
677
683 {
684 return cpl::down_cast<OGRCurve *>(this);
685 }
686
691 inline const OGRCurve *toCurve() const
692 {
693 return cpl::down_cast<const OGRCurve *>(this);
694 }
695
701 {
702 return cpl::down_cast<OGRSimpleCurve *>(this);
703 }
704
709 inline const OGRSimpleCurve *toSimpleCurve() const
710 {
711 return cpl::down_cast<const OGRSimpleCurve *>(this);
712 }
713
719 {
720 return cpl::down_cast<OGRLineString *>(this);
721 }
722
727 inline const OGRLineString *toLineString() const
728 {
729 return cpl::down_cast<const OGRLineString *>(this);
730 }
731
736 {
737 return cpl::down_cast<OGRLinearRing *>(this);
738 }
739
743 inline const OGRLinearRing *toLinearRing() const
744 {
745 return cpl::down_cast<const OGRLinearRing *>(this);
746 }
747
753 {
754 return cpl::down_cast<OGRCircularString *>(this);
755 }
756
762 {
763 return cpl::down_cast<const OGRCircularString *>(this);
764 }
765
771 {
772 return cpl::down_cast<OGRCompoundCurve *>(this);
773 }
774
779 inline const OGRCompoundCurve *toCompoundCurve() const
780 {
781 return cpl::down_cast<const OGRCompoundCurve *>(this);
782 }
783
789 {
790 return cpl::down_cast<OGRSurface *>(this);
791 }
792
797 inline const OGRSurface *toSurface() const
798 {
799 return cpl::down_cast<const OGRSurface *>(this);
800 }
801
807 {
808 return cpl::down_cast<OGRPolygon *>(this);
809 }
810
815 inline const OGRPolygon *toPolygon() const
816 {
817 return cpl::down_cast<const OGRPolygon *>(this);
818 }
819
824 {
825 return cpl::down_cast<OGRTriangle *>(this);
826 }
827
831 inline const OGRTriangle *toTriangle() const
832 {
833 return cpl::down_cast<const OGRTriangle *>(this);
834 }
835
841 {
842 return cpl::down_cast<OGRCurvePolygon *>(this);
843 }
844
849 inline const OGRCurvePolygon *toCurvePolygon() const
850 {
851 return cpl::down_cast<const OGRCurvePolygon *>(this);
852 }
853
859 {
860 return cpl::down_cast<OGRGeometryCollection *>(this);
861 }
862
868 {
869 return cpl::down_cast<const OGRGeometryCollection *>(this);
870 }
871
877 {
878 return cpl::down_cast<OGRMultiPoint *>(this);
879 }
880
885 inline const OGRMultiPoint *toMultiPoint() const
886 {
887 return cpl::down_cast<const OGRMultiPoint *>(this);
888 }
889
895 {
896 return cpl::down_cast<OGRMultiLineString *>(this);
897 }
898
904 {
905 return cpl::down_cast<const OGRMultiLineString *>(this);
906 }
907
913 {
914 return cpl::down_cast<OGRMultiPolygon *>(this);
915 }
916
921 inline const OGRMultiPolygon *toMultiPolygon() const
922 {
923 return cpl::down_cast<const OGRMultiPolygon *>(this);
924 }
925
931 {
932 return cpl::down_cast<OGRMultiCurve *>(this);
933 }
934
939 inline const OGRMultiCurve *toMultiCurve() const
940 {
941 return cpl::down_cast<const OGRMultiCurve *>(this);
942 }
943
949 {
950 return cpl::down_cast<OGRMultiSurface *>(this);
951 }
952
957 inline const OGRMultiSurface *toMultiSurface() const
958 {
959 return cpl::down_cast<const OGRMultiSurface *>(this);
960 }
961
967 {
968 return cpl::down_cast<OGRPolyhedralSurface *>(this);
969 }
970
976 {
977 return cpl::down_cast<const OGRPolyhedralSurface *>(this);
978 }
979
984 {
985 return cpl::down_cast<OGRTriangulatedSurface *>(this);
986 }
987
992 {
993 return cpl::down_cast<const OGRTriangulatedSurface *>(this);
994 }
995};
996
998struct CPL_DLL OGRGeometryUniquePtrDeleter
999{
1000 void operator()(OGRGeometry *) const;
1001};
1002
1004
1007typedef std::unique_ptr<OGRGeometry, OGRGeometryUniquePtrDeleter>
1009
1011#define OGR_FORBID_DOWNCAST_TO(name) \
1012 inline OGR##name *to##name() = delete; \
1013 inline const OGR##name *to##name() const = delete;
1014
1015#define OGR_FORBID_DOWNCAST_TO_POINT OGR_FORBID_DOWNCAST_TO(Point)
1016#define OGR_FORBID_DOWNCAST_TO_CURVE OGR_FORBID_DOWNCAST_TO(Curve)
1017#define OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE OGR_FORBID_DOWNCAST_TO(SimpleCurve)
1018#define OGR_FORBID_DOWNCAST_TO_LINESTRING OGR_FORBID_DOWNCAST_TO(LineString)
1019#define OGR_FORBID_DOWNCAST_TO_LINEARRING OGR_FORBID_DOWNCAST_TO(LinearRing)
1020#define OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1021 OGR_FORBID_DOWNCAST_TO(CircularString)
1022#define OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE \
1023 OGR_FORBID_DOWNCAST_TO(CompoundCurve)
1024#define OGR_FORBID_DOWNCAST_TO_SURFACE OGR_FORBID_DOWNCAST_TO(Surface)
1025#define OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON OGR_FORBID_DOWNCAST_TO(CurvePolygon)
1026#define OGR_FORBID_DOWNCAST_TO_POLYGON OGR_FORBID_DOWNCAST_TO(Polygon)
1027#define OGR_FORBID_DOWNCAST_TO_TRIANGLE OGR_FORBID_DOWNCAST_TO(Triangle)
1028#define OGR_FORBID_DOWNCAST_TO_MULTIPOINT OGR_FORBID_DOWNCAST_TO(MultiPoint)
1029#define OGR_FORBID_DOWNCAST_TO_MULTICURVE OGR_FORBID_DOWNCAST_TO(MultiCurve)
1030#define OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1031 OGR_FORBID_DOWNCAST_TO(MultiLineString)
1032#define OGR_FORBID_DOWNCAST_TO_MULTISURFACE OGR_FORBID_DOWNCAST_TO(MultiSurface)
1033#define OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON OGR_FORBID_DOWNCAST_TO(MultiPolygon)
1034#define OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1035 OGR_FORBID_DOWNCAST_TO(GeometryCollection)
1036#define OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1037 OGR_FORBID_DOWNCAST_TO(PolyhedralSurface)
1038#define OGR_FORBID_DOWNCAST_TO_TIN OGR_FORBID_DOWNCAST_TO(TriangulatedSurface)
1039
1040#define OGR_ALLOW_UPCAST_TO(name) \
1041 inline OGR##name *to##name() \
1042 { \
1043 return this; \
1044 } \
1045 inline const OGR##name *to##name() const \
1046 { \
1047 return this; \
1048 }
1049
1050#ifndef SUPPRESS_OGR_ALLOW_CAST_TO_THIS_WARNING
1051#define CAST_TO_THIS_WARNING CPL_WARN_DEPRECATED("Casting to this is useless")
1052#else
1053#define CAST_TO_THIS_WARNING
1054#endif
1055
1056#define OGR_ALLOW_CAST_TO_THIS(name) \
1057 inline OGR##name *to##name() CAST_TO_THIS_WARNING \
1058 { \
1059 return this; \
1060 } \
1061 inline const OGR##name *to##name() const CAST_TO_THIS_WARNING \
1062 { \
1063 return this; \
1064 }
1065
1066#define OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1067 OGR_FORBID_DOWNCAST_TO_CURVE \
1068 OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE \
1069 OGR_FORBID_DOWNCAST_TO_LINESTRING \
1070 OGR_FORBID_DOWNCAST_TO_LINEARRING \
1071 OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1072 OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE
1073
1074#define OGR_FORBID_DOWNCAST_TO_ALL_SURFACES \
1075 OGR_FORBID_DOWNCAST_TO_SURFACE \
1076 OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON \
1077 OGR_FORBID_DOWNCAST_TO_POLYGON \
1078 OGR_FORBID_DOWNCAST_TO_TRIANGLE \
1079 OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1080 OGR_FORBID_DOWNCAST_TO_TIN
1081
1082#define OGR_FORBID_DOWNCAST_TO_ALL_SINGLES \
1083 OGR_FORBID_DOWNCAST_TO_POINT \
1084 OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1085 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1086
1087#define OGR_FORBID_DOWNCAST_TO_ALL_MULTI \
1088 OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1089 OGR_FORBID_DOWNCAST_TO_MULTIPOINT \
1090 OGR_FORBID_DOWNCAST_TO_MULTICURVE \
1091 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1092 OGR_FORBID_DOWNCAST_TO_MULTISURFACE \
1093 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
1094
1096
1097/************************************************************************/
1098/* OGRPoint */
1099/************************************************************************/
1100
1107class CPL_DLL OGRPoint : public OGRGeometry
1108{
1109 double x;
1110 double y;
1111 double z;
1112 double m;
1113
1114 public:
1115 OGRPoint();
1116 OGRPoint(double x, double y);
1117 OGRPoint(double x, double y, double z);
1118 OGRPoint(double x, double y, double z, double m);
1119 OGRPoint(const OGRPoint &other);
1121 OGRPoint(OGRPoint &&other) = default;
1122 static OGRPoint *createXYM(double x, double y, double m);
1123
1124 OGRPoint &operator=(const OGRPoint &other);
1126 OGRPoint &operator=(OGRPoint &&other) = default;
1127
1128 // IWks Interface
1129 size_t WkbSize() const override;
1130 OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1131 size_t &nBytesConsumedOut) override;
1132 OGRErr exportToWkb(unsigned char *,
1133 const OGRwkbExportOptions * = nullptr) const override;
1134
1135#ifndef DOXYGEN_XML
1137#endif
1138
1139 OGRErr importFromWkt(const char **) override;
1140
1141#ifndef DOXYGEN_XML
1143#endif
1144
1149 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1150 OGRErr *err = nullptr) const override;
1151
1152 // IGeometry
1153 int getDimension() const override;
1154 OGRPoint *clone() const override;
1155 void empty() override;
1156 void getEnvelope(OGREnvelope *psEnvelope) const override;
1157 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1158
1159 OGRBoolean IsEmpty() const override
1160 {
1161 return !(flags & OGR_G_NOT_EMPTY_POINT);
1162 }
1163
1164 // IPoint
1166 double getX() const
1167 {
1168 return x;
1169 }
1170
1172 double getY() const
1173 {
1174 return y;
1175 }
1176
1178 double getZ() const
1179 {
1180 return z;
1181 }
1182
1184 double getM() const
1185 {
1186 return m;
1187 }
1188
1189 // Non standard
1190 bool setCoordinateDimension(int nDimension) override;
1191
1195 void setX(double xIn)
1196 {
1197 x = xIn;
1198 if (std::isnan(x) || std::isnan(y))
1199 flags &= ~OGR_G_NOT_EMPTY_POINT;
1200 else
1201 flags |= OGR_G_NOT_EMPTY_POINT;
1202 }
1203
1207 void setY(double yIn)
1208 {
1209 y = yIn;
1210 if (std::isnan(x) || std::isnan(y))
1211 flags &= ~OGR_G_NOT_EMPTY_POINT;
1212 else
1213 flags |= OGR_G_NOT_EMPTY_POINT;
1214 }
1215
1219 void setZ(double zIn)
1220 {
1221 z = zIn;
1222 flags |= OGR_G_3D;
1223 }
1224
1228 void setM(double mIn)
1229 {
1230 m = mIn;
1231 flags |= OGR_G_MEASURED;
1232 }
1233
1234 // ISpatialRelation
1235 OGRBoolean Equals(const OGRGeometry *) const override;
1236 OGRBoolean Intersects(const OGRGeometry *) const override;
1237 OGRBoolean Within(const OGRGeometry *) const override;
1238
1239 // Non standard from OGRGeometry
1240 const char *getGeometryName() const override;
1241 OGRwkbGeometryType getGeometryType() const override;
1242 OGRErr transform(OGRCoordinateTransformation *poCT) override;
1243 void flattenTo2D() override;
1244
1245 void accept(IOGRGeometryVisitor *visitor) override
1246 {
1247 visitor->visit(this);
1248 }
1249
1250 void accept(IOGRConstGeometryVisitor *visitor) const override
1251 {
1252 visitor->visit(this);
1253 }
1254
1255 void swapXY() override;
1256
1257 OGR_ALLOW_CAST_TO_THIS(Point)
1258 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
1259 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1260 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1261};
1262
1263/************************************************************************/
1264/* OGRPointIterator */
1265/************************************************************************/
1266
1272class CPL_DLL OGRPointIterator
1273{
1274 public:
1275 virtual ~OGRPointIterator();
1277
1278 static void destroy(OGRPointIterator *);
1279};
1280
1281/************************************************************************/
1282/* OGRCurve */
1283/************************************************************************/
1284
1290class CPL_DLL OGRCurve : public OGRGeometry
1291{
1292 protected:
1294 OGRCurve() = default;
1295 OGRCurve(const OGRCurve &other) = default;
1296 OGRCurve(OGRCurve &&other) = default;
1297
1298 virtual OGRCurveCasterToLineString GetCasterToLineString() const = 0;
1299 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const = 0;
1300
1301 friend class OGRCurvePolygon;
1302 friend class OGRCompoundCurve;
1304 virtual int ContainsPoint(const OGRPoint *p) const;
1305 virtual int IntersectsPoint(const OGRPoint *p) const;
1306 virtual double get_AreaOfCurveSegments() const = 0;
1307
1308 private:
1309 class CPL_DLL ConstIterator
1310 {
1311 struct Private;
1312 std::unique_ptr<Private> m_poPrivate;
1313
1314 public:
1315 ConstIterator(const OGRCurve *poSelf, bool bStart);
1316 ConstIterator(ConstIterator &&oOther) noexcept;
1317 ConstIterator &operator=(ConstIterator &&oOther);
1318 ~ConstIterator();
1319 const OGRPoint &operator*() const;
1320 ConstIterator &operator++();
1321 bool operator!=(const ConstIterator &it) const;
1322 };
1323
1324 friend inline ConstIterator begin(const OGRCurve *);
1325 friend inline ConstIterator end(const OGRCurve *);
1326
1327 public:
1329 OGRCurve &operator=(const OGRCurve &other);
1330 OGRCurve &operator=(OGRCurve &&other) = default;
1332
1335
1343 ConstIterator begin() const;
1345 ConstIterator end() const;
1346
1347 // IGeometry
1348 OGRCurve *clone() const override = 0;
1349
1350 // ICurve methods
1351 virtual double get_Length() const = 0;
1352 virtual void StartPoint(OGRPoint *) const = 0;
1353 virtual void EndPoint(OGRPoint *) const = 0;
1354 virtual int get_IsClosed() const;
1355 virtual void Value(double, OGRPoint *) const = 0;
1356 virtual OGRLineString *
1357 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1358 const char *const *papszOptions = nullptr) const = 0;
1359 int getDimension() const override;
1360
1361 // non standard
1362 virtual int getNumPoints() const = 0;
1364 virtual OGRBoolean IsConvex() const;
1365 virtual double get_Area() const = 0;
1366 virtual double get_GeodesicArea(
1367 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
1368 virtual double get_GeodesicLength(
1369 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
1370 virtual int isClockwise() const;
1371 virtual void reversePoints() = 0;
1372
1377 {
1378 return cpl::down_cast<OGRSimpleCurve *>(this);
1379 }
1380
1384 inline const OGRSimpleCurve *toSimpleCurve() const
1385 {
1386 return cpl::down_cast<const OGRSimpleCurve *>(this);
1387 }
1388
1389 static OGRCompoundCurve *CastToCompoundCurve(OGRCurve *puCurve);
1390 static OGRLineString *CastToLineString(OGRCurve *poCurve);
1391 static OGRLinearRing *CastToLinearRing(OGRCurve *poCurve);
1392
1393 OGR_FORBID_DOWNCAST_TO_POINT
1394 OGR_ALLOW_CAST_TO_THIS(Curve)
1395 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1396 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1397};
1398
1400
1401inline OGRCurve::ConstIterator begin(const OGRCurve *poCurve)
1402{
1403 return poCurve->begin();
1404}
1405
1407inline OGRCurve::ConstIterator end(const OGRCurve *poCurve)
1408{
1409 return poCurve->end();
1410}
1411
1413
1414/************************************************************************/
1415/* OGRIteratedPoint */
1416/************************************************************************/
1417
1439class CPL_DLL OGRIteratedPoint : public OGRPoint
1440{
1441 private:
1442 friend class OGRSimpleCurve;
1443
1444 OGRSimpleCurve *m_poCurve = nullptr;
1445 int m_nPos = 0;
1446
1447 OGRIteratedPoint() = default;
1448
1450
1451 public:
1455 void setX(double xIn);
1459 void setY(double yIn);
1463 void setZ(double zIn);
1467 void setM(double mIn);
1468
1471};
1472
1473/************************************************************************/
1474/* OGRSimpleCurve */
1475/************************************************************************/
1476
1485class CPL_DLL OGRSimpleCurve : public OGRCurve
1486{
1487 protected:
1489 friend class OGRGeometry;
1490
1491 int nPointCount = 0;
1492 int m_nPointCapacity = 0;
1493 OGRRawPoint *paoPoints = nullptr;
1494 double *padfZ = nullptr;
1495 double *padfM = nullptr;
1496
1497 bool Make3D();
1498 void Make2D();
1499 void RemoveM();
1500 bool AddM();
1501
1502 OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ, int bHasM,
1503 OGRRawPoint *&paoPointsIn, int &nMaxPoints,
1504 double *&padfZIn);
1506
1507 virtual double get_LinearArea() const;
1508
1510 OGRSimpleCurve() = default;
1511
1512 OGRSimpleCurve(const OGRSimpleCurve &other);
1513
1515
1516 private:
1517 class CPL_DLL Iterator
1518 {
1519 struct Private;
1520 std::unique_ptr<Private> m_poPrivate;
1521 void update();
1522
1523 public:
1524 Iterator(OGRSimpleCurve *poSelf, int nPos);
1525 Iterator(Iterator &&oOther) noexcept; // declared but not defined.
1526 // Needed for gcc 5.4 at least
1527 ~Iterator();
1528 OGRIteratedPoint &operator*();
1529 Iterator &operator++();
1530 bool operator!=(const Iterator &it) const;
1531 };
1532
1533 friend inline Iterator begin(OGRSimpleCurve *);
1534 friend inline Iterator end(OGRSimpleCurve *);
1535
1536 class CPL_DLL ConstIterator
1537 {
1538 struct Private;
1539 std::unique_ptr<Private> m_poPrivate;
1540
1541 public:
1542 ConstIterator(const OGRSimpleCurve *poSelf, int nPos);
1543 ConstIterator(
1544 ConstIterator &&oOther) noexcept; // declared but not defined.
1545 // Needed for gcc 5.4 at least
1546 ~ConstIterator();
1547 const OGRPoint &operator*() const;
1548 ConstIterator &operator++();
1549 bool operator!=(const ConstIterator &it) const;
1550 };
1551
1552 friend inline ConstIterator begin(const OGRSimpleCurve *);
1553 friend inline ConstIterator end(const OGRSimpleCurve *);
1554
1555 public:
1556 ~OGRSimpleCurve() override;
1557
1558 OGRSimpleCurve &operator=(const OGRSimpleCurve &other);
1559
1560 OGRSimpleCurve &operator=(OGRSimpleCurve &&other);
1561
1564
1572 Iterator begin();
1574 Iterator end();
1582 ConstIterator begin() const;
1584 ConstIterator end() const;
1585
1586 // IWks Interface.
1587 size_t WkbSize() const override;
1588 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1589 size_t &nBytesConsumedOut) override;
1590 virtual OGRErr
1591 exportToWkb(unsigned char *,
1592 const OGRwkbExportOptions * = nullptr) const override;
1593
1594#ifndef DOXYGEN_XML
1596#endif
1597
1598 OGRErr importFromWkt(const char **) override;
1599
1600#ifndef DOXYGEN_XML
1602#endif
1603
1608 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1609 OGRErr *err = nullptr) const override;
1610
1611 // IGeometry interface.
1612 void empty() override;
1613 void getEnvelope(OGREnvelope *psEnvelope) const override;
1614 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1615 OGRBoolean IsEmpty() const override;
1616 OGRSimpleCurve *clone() const override = 0;
1617
1618 // ICurve methods.
1619 double get_Length() const override;
1620 void StartPoint(OGRPoint *) const override;
1621 void EndPoint(OGRPoint *) const override;
1622 void Value(double, OGRPoint *) const override;
1623 virtual double Project(const OGRPoint *) const;
1624 virtual OGRLineString *getSubLine(double, double, int) const;
1625
1626 // ILineString methods.
1627 int getNumPoints() const override
1628 {
1629 return nPointCount;
1630 }
1631
1632 void getPoint(int, OGRPoint *) const;
1633
1634 double getX(int i) const
1635 {
1636 return paoPoints[i].x;
1637 }
1638
1639 double getY(int i) const
1640 {
1641 return paoPoints[i].y;
1642 }
1643
1644 double getZ(int i) const;
1645 double getM(int i) const;
1646
1647 // ISpatialRelation
1648 OGRBoolean Equals(const OGRGeometry *) const override;
1649
1650 // non standard.
1651 bool setCoordinateDimension(int nDimension) override;
1652 bool set3D(OGRBoolean bIs3D) override;
1653 bool setMeasured(OGRBoolean bIsMeasured) override;
1654 bool setNumPoints(int nNewPointCount, int bZeroizeNewContent = TRUE);
1655 bool setPoint(int, OGRPoint *);
1656 bool setPoint(int, double, double);
1657 bool setZ(int, double);
1658 bool setM(int, double);
1659 bool setPoint(int, double, double, double);
1660 bool setPointM(int, double, double, double);
1661 bool setPoint(int, double, double, double, double);
1662 bool setPoints(int, const OGRRawPoint *, const double * = nullptr);
1663 bool setPointsM(int, const OGRRawPoint *, const double *);
1664 bool setPoints(int, const OGRRawPoint *, const double *, const double *);
1665 bool setPoints(int, const double *padfX, const double *padfY,
1666 const double *padfZIn = nullptr);
1667 bool setPointsM(int, const double *padfX, const double *padfY,
1668 const double *padfMIn = nullptr);
1669 bool setPoints(int, const double *padfX, const double *padfY,
1670 const double *padfZIn, const double *padfMIn);
1671 bool addPoint(const OGRPoint *);
1672 bool addPoint(double, double);
1673 bool addPoint(double, double, double);
1674 bool addPointM(double, double, double);
1675 bool addPoint(double, double, double, double);
1676
1677 bool removePoint(int);
1678
1679 void getPoints(OGRRawPoint *, double * = nullptr) const;
1680 void getPoints(void *pabyX, int nXStride, void *pabyY, int nYStride,
1681 void *pabyZ = nullptr, int nZStride = 0,
1682 void *pabyM = nullptr, int nMStride = 0) const;
1683
1684 void addSubLineString(const OGRLineString *, int nStartVertex = 0,
1685 int nEndVertex = -1);
1686 void reversePoints() override;
1687 OGRPointIterator *getPointIterator() const override;
1688
1689 // non-standard from OGRGeometry
1690 OGRErr transform(OGRCoordinateTransformation *poCT) override;
1691 void flattenTo2D() override;
1692 bool segmentize(double dfMaxLength) override;
1693
1694 void swapXY() override;
1695
1696 OGR_ALLOW_UPCAST_TO(Curve)
1697 OGR_ALLOW_CAST_TO_THIS(SimpleCurve)
1698};
1699
1701
1702inline OGRSimpleCurve::Iterator begin(OGRSimpleCurve *poCurve)
1703{
1704 return poCurve->begin();
1705}
1706
1708inline OGRSimpleCurve::Iterator end(OGRSimpleCurve *poCurve)
1709{
1710 return poCurve->end();
1711}
1712
1714inline OGRSimpleCurve::ConstIterator begin(const OGRSimpleCurve *poCurve)
1715{
1716 return poCurve->begin();
1717}
1718
1720inline OGRSimpleCurve::ConstIterator end(const OGRSimpleCurve *poCurve)
1721{
1722 return poCurve->end();
1723}
1724
1726
1727/************************************************************************/
1728/* OGRLineString */
1729/************************************************************************/
1730
1738class CPL_DLL OGRLineString : public OGRSimpleCurve
1739{
1740 // cppcheck-suppress unusedPrivateFunction
1741 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
1742
1743 protected:
1745 static OGRLineString *TransferMembersAndDestroy(OGRLineString *poSrc,
1746 OGRLineString *poDst);
1747
1748 OGRCurveCasterToLineString GetCasterToLineString() const override;
1749 OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1750
1751 double get_AreaOfCurveSegments() const override;
1753
1754 static OGRLinearRing *CastToLinearRing(OGRLineString *poLS);
1755
1756 public:
1758 OGRLineString() = default;
1761
1762 OGRLineString &operator=(const OGRLineString &other);
1763 OGRLineString &operator=(OGRLineString &&other);
1764
1765 OGRLineString *clone() const override;
1766 virtual OGRLineString *
1767 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1768 const char *const *papszOptions = nullptr) const override;
1769 virtual OGRGeometry *
1770 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
1771 double get_Area() const override;
1772 virtual double get_GeodesicArea(
1773 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1774 virtual double get_GeodesicLength(
1775 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1776
1777 // Non-standard from OGRGeometry.
1778 OGRwkbGeometryType getGeometryType() const override;
1779 const char *getGeometryName() const override;
1780 int isClockwise() const override;
1781
1784 {
1785 return this;
1786 }
1787
1789 inline const OGRSimpleCurve *toUpperClass() const
1790 {
1791 return this;
1792 }
1793
1794 void accept(IOGRGeometryVisitor *visitor) override
1795 {
1796 visitor->visit(this);
1797 }
1798
1799 void accept(IOGRConstGeometryVisitor *visitor) const override
1800 {
1801 visitor->visit(this);
1802 }
1803
1804 OGR_ALLOW_UPCAST_TO(SimpleCurve)
1805 OGR_ALLOW_CAST_TO_THIS(LineString)
1806};
1807
1808/************************************************************************/
1809/* OGRLinearRing */
1810/************************************************************************/
1811
1832class CPL_DLL OGRLinearRing : public OGRLineString
1833{
1834 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
1835
1836 // IWks Interface - Note this isn't really a first class object
1837 // for the purposes of WKB form. These methods always fail since this
1838 // object can't be serialized on its own.
1839 size_t WkbSize() const override;
1840 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1841 size_t &nBytesConsumedOut) override;
1842 OGRErr exportToWkb(unsigned char *,
1843 const OGRwkbExportOptions * = nullptr) const override;
1844
1845 protected:
1847 friend class OGRPolygon;
1848 friend class OGRTriangle;
1849
1850 // These are not IWks compatible ... just a convenience for OGRPolygon.
1851 virtual size_t _WkbSize(int _flags) const;
1852 virtual OGRErr _importFromWkb(OGRwkbByteOrder, int _flags,
1853 const unsigned char *, size_t,
1854 size_t &nBytesConsumedOut);
1855 virtual OGRErr _exportToWkb(int _flags, unsigned char *,
1856 const OGRwkbExportOptions *) const;
1857
1858 OGRCurveCasterToLineString GetCasterToLineString() const override;
1859 OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1861
1862 static OGRLineString *CastToLineString(OGRLinearRing *poLR);
1863
1864 public:
1866 OGRLinearRing() = default;
1869 OGRLinearRing(OGRLinearRing &&other) = default;
1870 explicit OGRLinearRing(const OGRLinearRing *);
1871
1872 OGRLinearRing &operator=(const OGRLinearRing &other);
1875
1876 // Non standard.
1877 const char *getGeometryName() const override;
1878 OGRLinearRing *clone() const override;
1879
1881 void reverseWindingOrder()
1882 CPL_WARN_DEPRECATED("Use reversePoints() instead");
1884
1885 void closeRings() override;
1886 OGRBoolean isPointInRing(const OGRPoint *pt,
1887 int bTestEnvelope = TRUE) const;
1888 OGRBoolean isPointOnRingBoundary(const OGRPoint *pt,
1889 int bTestEnvelope = TRUE) const;
1890 OGRErr transform(OGRCoordinateTransformation *poCT) override;
1891
1893 inline OGRLineString *toUpperClass()
1894 {
1895 return this;
1896 }
1897
1899 inline const OGRLineString *toUpperClass() const
1900 {
1901 return this;
1902 }
1903
1904 void accept(IOGRGeometryVisitor *visitor) override
1905 {
1906 visitor->visit(this);
1907 }
1908
1909 void accept(IOGRConstGeometryVisitor *visitor) const override
1910 {
1911 visitor->visit(this);
1912 }
1913
1914 OGR_ALLOW_UPCAST_TO(LineString)
1915 OGR_ALLOW_CAST_TO_THIS(LinearRing)
1916};
1917
1918/************************************************************************/
1919/* OGRCircularString */
1920/************************************************************************/
1921
1933class CPL_DLL OGRCircularString : public OGRSimpleCurve
1934{
1935 private:
1936 void ExtendEnvelopeWithCircular(OGREnvelope *psEnvelope) const;
1937 OGRBoolean IsValidFast(std::string *posReason = nullptr) const;
1938 int IsFullCircle(double &cx, double &cy, double &square_R) const;
1939
1940 protected:
1942 OGRCurveCasterToLineString GetCasterToLineString() const override;
1943 OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1944 int IntersectsPoint(const OGRPoint *p) const override;
1945 int ContainsPoint(const OGRPoint *p) const override;
1946 double get_AreaOfCurveSegments() const override;
1948
1949 public:
1952
1956
1957 OGRCircularString &operator=(const OGRCircularString &other);
1960
1961 // IWks Interface.
1962 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1963 size_t &nBytesConsumedOut) override;
1964 OGRErr exportToWkb(unsigned char *,
1965 const OGRwkbExportOptions * = nullptr) const override;
1966
1967#ifndef DOXYGEN_XML
1969#endif
1970
1971 OGRErr importFromWkt(const char **) override;
1972
1973#ifndef DOXYGEN_XML
1975#endif
1976
1981 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1982 OGRErr *err = nullptr) const override;
1983
1984 // IGeometry interface.
1985 OGRBoolean IsValid(std::string *posReason = nullptr) const override;
1986 void getEnvelope(OGREnvelope *psEnvelope) const override;
1987 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1988 OGRCircularString *clone() const override;
1989
1990 // ICurve methods.
1991 double get_Length() const override;
1992 virtual OGRLineString *
1993 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1994 const char *const *papszOptions = nullptr) const override;
1995 void Value(double, OGRPoint *) const override;
1996 double get_Area() const override;
1997 virtual double get_GeodesicArea(
1998 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1999 virtual double get_GeodesicLength(
2000 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2001
2002 // Non-standard from OGRGeometry.
2003 OGRwkbGeometryType getGeometryType() const override;
2004 const char *getGeometryName() const override;
2005 bool segmentize(double dfMaxLength) override;
2006 virtual OGRBoolean
2007 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2008 virtual OGRGeometry *
2009 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2010 const char *const *papszOptions = nullptr) const override;
2011
2014 {
2015 return this;
2016 }
2017
2019 inline const OGRSimpleCurve *toUpperClass() const
2020 {
2021 return this;
2022 }
2023
2024 void accept(IOGRGeometryVisitor *visitor) override
2025 {
2026 visitor->visit(this);
2027 }
2028
2029 void accept(IOGRConstGeometryVisitor *visitor) const override
2030 {
2031 visitor->visit(this);
2032 }
2033
2034 OGR_ALLOW_UPCAST_TO(SimpleCurve)
2035 OGR_ALLOW_CAST_TO_THIS(CircularString)
2036};
2037
2038/************************************************************************/
2039/* OGRCurveCollection */
2040/************************************************************************/
2041
2052class CPL_DLL OGRCurveCollection
2053{
2054 protected:
2055 friend class OGRCompoundCurve;
2056 friend class OGRCurvePolygon;
2057 friend class OGRPolygon;
2058 friend class OGRTriangle;
2059
2060 int nCurveCount = 0;
2061 OGRCurve **papoCurves = nullptr;
2062
2063 public:
2064 OGRCurveCollection() = default;
2065 OGRCurveCollection(const OGRCurveCollection &other);
2066 OGRCurveCollection(OGRCurveCollection &&other);
2067 ~OGRCurveCollection();
2068
2069 OGRCurveCollection &operator=(const OGRCurveCollection &other);
2070 OGRCurveCollection &operator=(OGRCurveCollection &&other);
2071
2073 typedef OGRCurve ChildType;
2074
2077 OGRCurve **begin()
2078 {
2079 return papoCurves;
2080 }
2081
2083 OGRCurve **end()
2084 {
2085 return papoCurves + nCurveCount;
2086 }
2087
2090 const OGRCurve *const *begin() const
2091 {
2092 return papoCurves;
2093 }
2094
2096 const OGRCurve *const *end() const
2097 {
2098 return papoCurves + nCurveCount;
2099 }
2100
2101 void empty(OGRGeometry *poGeom);
2102 OGRBoolean IsEmpty() const;
2103 void getEnvelope(OGREnvelope *psEnvelope) const;
2104 void getEnvelope(OGREnvelope3D *psEnvelope) const;
2105
2106 OGRErr addCurveDirectly(OGRGeometry *poGeom, OGRCurve *poCurve,
2107 int bNeedRealloc);
2108 size_t WkbSize() const;
2109 OGRErr importPreambleFromWkb(OGRGeometry *poGeom,
2110 const unsigned char *pabyData, size_t &nSize,
2111 size_t &nDataOffset,
2112 OGRwkbByteOrder &eByteOrder,
2113 size_t nMinSubGeomSize,
2114 OGRwkbVariant eWkbVariant);
2115 OGRErr
2116 importBodyFromWkb(OGRGeometry *poGeom, const unsigned char *pabyData,
2117 size_t nSize, bool bAcceptCompoundCurve,
2118 OGRErr (*pfnAddCurveDirectlyFromWkb)(OGRGeometry *poGeom,
2119 OGRCurve *poCurve),
2120 OGRwkbVariant eWkbVariant, size_t &nBytesConsumedOut);
2121 std::string exportToWkt(const OGRGeometry *geom, const OGRWktOptions &opts,
2122 OGRErr *err) const;
2123 OGRErr exportToWkb(const OGRGeometry *poGeom, unsigned char *,
2124 const OGRwkbExportOptions * = nullptr) const;
2125 OGRBoolean Equals(const OGRCurveCollection *poOCC) const;
2126 bool setCoordinateDimension(OGRGeometry *poGeom, int nNewDimension);
2127 bool set3D(OGRGeometry *poGeom, OGRBoolean bIs3D);
2128 bool setMeasured(OGRGeometry *poGeom, OGRBoolean bIsMeasured);
2129 void assignSpatialReference(OGRGeometry *poGeom,
2130 const OGRSpatialReference *poSR);
2131 int getNumCurves() const;
2132 OGRCurve *getCurve(int);
2133 const OGRCurve *getCurve(int) const;
2134 OGRCurve *stealCurve(int);
2135
2136 OGRErr removeCurve(int iIndex, bool bDelete = true);
2137
2138 bool hasEmptyParts() const;
2139 void removeEmptyParts();
2140
2141 void reversePoints();
2142
2143 OGRErr transform(OGRGeometry *poGeom, OGRCoordinateTransformation *poCT);
2144 void flattenTo2D(OGRGeometry *poGeom);
2145 bool segmentize(double dfMaxLength);
2146 void swapXY();
2147 OGRBoolean hasCurveGeometry(int bLookForNonLinear) const;
2148};
2149
2151
2152/************************************************************************/
2153/* OGRCompoundCurve */
2154/************************************************************************/
2155
2165class CPL_DLL OGRCompoundCurve : public OGRCurve
2166{
2167 private:
2168 OGRCurveCollection oCC{};
2169
2170 OGRErr addCurveDirectlyInternal(OGRCurve *poCurve, double dfToleranceEps,
2171 int bNeedRealloc);
2172 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2173 OGRCurve *poCurve);
2174 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2175 OGRCurve *poCurve);
2176 OGRLineString *CurveToLineInternal(double dfMaxAngleStepSizeDegrees,
2177 const char *const *papszOptions,
2178 int bIsLinearRing) const;
2179 // cppcheck-suppress unusedPrivateFunction
2180 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
2181 // cppcheck-suppress unusedPrivateFunction
2182 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
2183
2184 protected:
2186 static OGRLineString *CastToLineString(OGRCompoundCurve *poCC);
2187 static OGRLinearRing *CastToLinearRing(OGRCompoundCurve *poCC);
2188
2189 OGRCurveCasterToLineString GetCasterToLineString() const override;
2190 OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
2192
2193 public:
2195 OGRCompoundCurve() = default;
2196
2200
2201 OGRCompoundCurve &operator=(const OGRCompoundCurve &other);
2204
2207
2211 {
2212 return oCC.begin();
2213 }
2214
2217 {
2218 return oCC.end();
2219 }
2220
2223 const ChildType *const *begin() const
2224 {
2225 return oCC.begin();
2226 }
2227
2229 const ChildType *const *end() const
2230 {
2231 return oCC.end();
2232 }
2233
2234 // IWks Interface
2235 size_t WkbSize() const override;
2236 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2237 size_t &nBytesConsumedOut) override;
2238 OGRErr exportToWkb(unsigned char *,
2239 const OGRwkbExportOptions * = nullptr) const override;
2240
2241#ifndef DOXYGEN_XML
2243#endif
2244
2245 OGRErr importFromWkt(const char **) override;
2246
2247#ifndef DOXYGEN_XML
2249#endif
2250
2255 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2256 OGRErr *err = nullptr) const override;
2257
2258 // IGeometry interface.
2259 OGRCompoundCurve *clone() const override;
2260 void empty() override;
2261 void getEnvelope(OGREnvelope *psEnvelope) const override;
2262 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2263 OGRBoolean IsEmpty() const override;
2264
2265 // ICurve methods.
2266 double get_Length() const override;
2267 void StartPoint(OGRPoint *) const override;
2268 void EndPoint(OGRPoint *) const override;
2269 void Value(double, OGRPoint *) const override;
2270 virtual OGRLineString *
2271 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
2272 const char *const *papszOptions = nullptr) const override;
2273
2274 int getNumPoints() const override;
2275 double get_AreaOfCurveSegments() const override;
2276 double get_Area() const override;
2277 virtual double get_GeodesicArea(
2278 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2279 virtual double get_GeodesicLength(
2280 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2281
2282 // ISpatialRelation.
2283 OGRBoolean Equals(const OGRGeometry *) const override;
2284
2285 // ICompoundCurve method.
2286 int getNumCurves() const;
2287 OGRCurve *getCurve(int);
2288 const OGRCurve *getCurve(int) const;
2289
2290 // Non-standard.
2291 bool setCoordinateDimension(int nDimension) override;
2292 bool set3D(OGRBoolean bIs3D) override;
2293 bool setMeasured(OGRBoolean bIsMeasured) override;
2294
2295 virtual void
2296 assignSpatialReference(const OGRSpatialReference *poSR) override;
2297
2301 static constexpr double DEFAULT_TOLERANCE_EPSILON = 1e-14;
2302
2303 OGRErr addCurve(const OGRCurve *,
2304 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2305 OGRErr addCurveDirectly(OGRCurve *,
2306 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2307 OGRErr addCurve(std::unique_ptr<OGRCurve>,
2308 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2309 OGRCurve *stealCurve(int);
2310 OGRPointIterator *getPointIterator() const override;
2311 void reversePoints() override;
2312
2313 // Non-standard from OGRGeometry.
2314 OGRwkbGeometryType getGeometryType() const override;
2315 const char *getGeometryName() const override;
2316 OGRErr transform(OGRCoordinateTransformation *poCT) override;
2317 void flattenTo2D() override;
2318 bool segmentize(double dfMaxLength) override;
2319 virtual OGRBoolean
2320 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2321 virtual OGRGeometry *
2322 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2323 const char *const *papszOptions = nullptr) const override;
2324
2325 void accept(IOGRGeometryVisitor *visitor) override
2326 {
2327 visitor->visit(this);
2328 }
2329
2330 void accept(IOGRConstGeometryVisitor *visitor) const override
2331 {
2332 visitor->visit(this);
2333 }
2334
2335 void swapXY() override;
2336
2337 bool hasEmptyParts() const override;
2338 void removeEmptyParts() override;
2339
2340 OGR_ALLOW_UPCAST_TO(Curve)
2341 OGR_ALLOW_CAST_TO_THIS(CompoundCurve)
2342};
2343
2345
2346inline const OGRCompoundCurve::ChildType *const *
2347begin(const OGRCompoundCurve *poCurve)
2348{
2349 return poCurve->begin();
2350}
2351
2353inline const OGRCompoundCurve::ChildType *const *
2354end(const OGRCompoundCurve *poCurve)
2355{
2356 return poCurve->end();
2357}
2358
2361{
2362 return poCurve->begin();
2363}
2364
2367{
2368 return poCurve->end();
2369}
2370
2372
2373/************************************************************************/
2374/* OGRSurface */
2375/************************************************************************/
2376
2382class CPL_DLL OGRSurface : public OGRGeometry
2383{
2384 protected:
2386 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const = 0;
2387 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const = 0;
2389
2390 public:
2391 virtual double get_Area() const = 0;
2392 virtual double get_GeodesicArea(
2393 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
2394 virtual double get_Length() const = 0;
2395 virtual double get_GeodesicLength(
2396 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
2397
2398 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const;
2399
2400 OGRSurface *clone() const override = 0;
2401
2403 static OGRPolygon *CastToPolygon(OGRSurface *poSurface);
2404 static OGRCurvePolygon *CastToCurvePolygon(OGRSurface *poSurface);
2406
2407 OGR_FORBID_DOWNCAST_TO_POINT
2408 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
2409 OGR_ALLOW_CAST_TO_THIS(Surface)
2410 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
2411};
2412
2413/************************************************************************/
2414/* OGRCurvePolygon */
2415/************************************************************************/
2416
2429class CPL_DLL OGRCurvePolygon : public OGRSurface
2430{
2431 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2432
2433 private:
2434 OGRBoolean IntersectsPoint(const OGRPoint *p) const;
2435 OGRBoolean ContainsPoint(const OGRPoint *p) const;
2436
2437 virtual bool isRingCorrectType(const OGRCurve *poRing) const;
2438
2439 virtual bool checkRing(const OGRCurve *poNewRing) const;
2440 OGRErr addRingDirectlyInternal(OGRCurve *poCurve, int bNeedRealloc);
2441 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2442 OGRCurve *poCurve);
2443 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2444 OGRCurve *poCurve);
2445
2446 protected:
2448 friend class OGRPolygon;
2449 friend class OGRTriangle;
2450 OGRCurveCollection oCC{};
2451
2452 OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2453 virtual OGRSurfaceCasterToCurvePolygon
2454 GetCasterToCurvePolygon() const override;
2455
2457
2458 static OGRPolygon *CastToPolygon(OGRCurvePolygon *poCP);
2459
2460 public:
2462 OGRCurvePolygon() = default;
2463
2467
2468 OGRCurvePolygon &operator=(const OGRCurvePolygon &other);
2471
2474
2478 {
2479 return oCC.begin();
2480 }
2481
2484 {
2485 return oCC.end();
2486 }
2487
2490 const ChildType *const *begin() const
2491 {
2492 return oCC.begin();
2493 }
2494
2496 const ChildType *const *end() const
2497 {
2498 return oCC.end();
2499 }
2500
2501 // Non standard (OGRGeometry).
2502 const char *getGeometryName() const override;
2503 OGRwkbGeometryType getGeometryType() const override;
2504 OGRCurvePolygon *clone() const override;
2505 void empty() override;
2506 OGRErr transform(OGRCoordinateTransformation *poCT) override;
2507 void flattenTo2D() override;
2508 OGRBoolean IsEmpty() const override;
2509 bool segmentize(double dfMaxLength) override;
2510 virtual OGRBoolean
2511 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2512 virtual OGRGeometry *
2513 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2514 const char *const *papszOptions = nullptr) const override;
2515 virtual double get_GeodesicArea(
2516 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2517 virtual double get_GeodesicLength(
2518 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2519
2520 // ISurface Interface
2521 double get_Area() const override;
2522
2523 double get_Length() const override;
2524
2525 // IWks Interface
2526 size_t WkbSize() const override;
2527 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2528 size_t &nBytesConsumedOut) override;
2529 OGRErr exportToWkb(unsigned char *,
2530 const OGRwkbExportOptions * = nullptr) const override;
2531
2532#ifndef DOXYGEN_XML
2534#endif
2535
2536 OGRErr importFromWkt(const char **) override;
2537
2538#ifndef DOXYGEN_XML
2540#endif
2541
2546 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2547 OGRErr *err = nullptr) const override;
2548
2549 // IGeometry
2550 int getDimension() const override;
2551 void getEnvelope(OGREnvelope *psEnvelope) const override;
2552 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2553
2554 // ICurvePolygon
2555 virtual OGRPolygon *
2556 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2557 const char *const *papszOptions = nullptr) const;
2558
2559 // ISpatialRelation
2560 OGRBoolean Equals(const OGRGeometry *) const override;
2561 OGRBoolean Intersects(const OGRGeometry *) const override;
2562 OGRBoolean Contains(const OGRGeometry *) const override;
2563
2564 // Non standard
2565 bool setCoordinateDimension(int nDimension) override;
2566 bool set3D(OGRBoolean bIs3D) override;
2567 bool setMeasured(OGRBoolean bIsMeasured) override;
2568
2569 virtual void
2570 assignSpatialReference(const OGRSpatialReference *poSR) override;
2571
2572 virtual OGRErr addRing(const OGRCurve *);
2573 virtual OGRErr addRingDirectly(OGRCurve *);
2574 OGRErr addRing(std::unique_ptr<OGRCurve>);
2575
2576 OGRCurve *getExteriorRingCurve();
2577 const OGRCurve *getExteriorRingCurve() const;
2578 int getNumInteriorRings() const;
2579 OGRCurve *getInteriorRingCurve(int);
2580 const OGRCurve *getInteriorRingCurve(int) const;
2581
2582 OGRCurve *stealExteriorRingCurve();
2583
2584 OGRErr removeRing(int iIndex, bool bDelete = true);
2585
2586 void accept(IOGRGeometryVisitor *visitor) override
2587 {
2588 visitor->visit(this);
2589 }
2590
2591 void accept(IOGRConstGeometryVisitor *visitor) const override
2592 {
2593 visitor->visit(this);
2594 }
2595
2596 void swapXY() override;
2597
2598 bool hasEmptyParts() const override;
2599 void removeEmptyParts() override;
2600
2601 OGR_ALLOW_UPCAST_TO(Surface)
2602 OGR_ALLOW_CAST_TO_THIS(CurvePolygon)
2603};
2604
2606
2607inline const OGRCurvePolygon::ChildType *const *
2608begin(const OGRCurvePolygon *poGeom)
2609{
2610 return poGeom->begin();
2611}
2612
2614inline const OGRCurvePolygon::ChildType *const *
2615end(const OGRCurvePolygon *poGeom)
2616{
2617 return poGeom->end();
2618}
2619
2622{
2623 return poGeom->begin();
2624}
2625
2628{
2629 return poGeom->end();
2630}
2631
2633
2634/************************************************************************/
2635/* OGRPolygon */
2636/************************************************************************/
2637
2647class CPL_DLL OGRPolygon : public OGRCurvePolygon
2648{
2649 static OGRCurvePolygon *CasterToCurvePolygon(OGRSurface *poSurface);
2650
2651 protected:
2653 friend class OGRMultiSurface;
2654 friend class OGRPolyhedralSurface;
2655 friend class OGRTriangulatedSurface;
2656
2657 bool isRingCorrectType(const OGRCurve *poRing) const override;
2658
2659 bool checkRing(const OGRCurve *poNewRing) const override;
2660 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2661 int bHasM, OGRRawPoint *&paoPoints,
2662 int &nMaxPoints, double *&padfZ);
2663
2664 static OGRCurvePolygon *CastToCurvePolygon(OGRPolygon *poPoly);
2665
2666 OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2667 virtual OGRSurfaceCasterToCurvePolygon
2668 GetCasterToCurvePolygon() const override;
2670
2671 public:
2673 OGRPolygon() = default;
2674
2675 OGRPolygon(double x1, double y1, double x2, double y2);
2676
2677 explicit OGRPolygon(const OGREnvelope &envelope);
2678
2679 OGRPolygon(const OGRPolygon &other);
2681 OGRPolygon(OGRPolygon &&other) = default;
2682
2683 OGRPolygon &operator=(const OGRPolygon &other);
2685 OGRPolygon &operator=(OGRPolygon &&other) = default;
2686
2689
2693 {
2694 return reinterpret_cast<ChildType **>(oCC.begin());
2695 }
2696
2699 {
2700 return reinterpret_cast<ChildType **>(oCC.end());
2701 }
2702
2705 const ChildType *const *begin() const
2706 {
2707 return reinterpret_cast<const ChildType *const *>(oCC.begin());
2708 }
2709
2711 const ChildType *const *end() const
2712 {
2713 return reinterpret_cast<const ChildType *const *>(oCC.end());
2714 }
2715
2716 // Non-standard (OGRGeometry).
2717 const char *getGeometryName() const override;
2718 OGRwkbGeometryType getGeometryType() const override;
2719 OGRPolygon *clone() const override;
2720 virtual OGRBoolean
2721 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2722 virtual OGRGeometry *
2723 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2724 virtual OGRGeometry *
2725 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2726 const char *const *papszOptions = nullptr) const override;
2727
2728 // IWks Interface.
2729 size_t WkbSize() const override;
2730 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2731 size_t &nBytesConsumedOut) override;
2732 OGRErr exportToWkb(unsigned char *,
2733 const OGRwkbExportOptions * = nullptr) const override;
2734
2735#ifndef DOXYGEN_XML
2737#endif
2738
2739 OGRErr importFromWkt(const char **) override;
2740
2741#ifndef DOXYGEN_XML
2743#endif
2744
2749 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2750 OGRErr *err = nullptr) const override;
2751
2752 // ICurvePolygon.
2753 virtual OGRPolygon *
2754 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2755 const char *const *papszOptions = nullptr) const override;
2756
2757 OGRLinearRing *getExteriorRing();
2758 const OGRLinearRing *getExteriorRing() const;
2759 virtual OGRLinearRing *getInteriorRing(int);
2760 virtual const OGRLinearRing *getInteriorRing(int) const;
2761
2762 OGRLinearRing *stealExteriorRing();
2763 virtual OGRLinearRing *stealInteriorRing(int);
2764
2765 OGRBoolean IsPointOnSurface(const OGRPoint *) const;
2766
2769 {
2770 return this;
2771 }
2772
2774 inline const OGRCurvePolygon *toUpperClass() const
2775 {
2776 return this;
2777 }
2778
2779 void accept(IOGRGeometryVisitor *visitor) override
2780 {
2781 visitor->visit(this);
2782 }
2783
2784 void accept(IOGRConstGeometryVisitor *visitor) const override
2785 {
2786 visitor->visit(this);
2787 }
2788
2789 void closeRings() override;
2790
2791 OGR_ALLOW_UPCAST_TO(CurvePolygon)
2792 OGR_ALLOW_CAST_TO_THIS(Polygon)
2793};
2794
2796
2797inline const OGRPolygon::ChildType *const *begin(const OGRPolygon *poGeom)
2798{
2799 return poGeom->begin();
2800}
2801
2803inline const OGRPolygon::ChildType *const *end(const OGRPolygon *poGeom)
2804{
2805 return poGeom->end();
2806}
2807
2809inline OGRPolygon::ChildType **begin(OGRPolygon *poGeom)
2810{
2811 return poGeom->begin();
2812}
2813
2815inline OGRPolygon::ChildType **end(OGRPolygon *poGeom)
2816{
2817 return poGeom->end();
2818}
2819
2821
2822/************************************************************************/
2823/* OGRTriangle */
2824/************************************************************************/
2825
2831class CPL_DLL OGRTriangle : public OGRPolygon
2832{
2833 private:
2834 // cppcheck-suppress unusedPrivateFunction
2835 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2836 bool quickValidityCheck() const;
2837
2838 protected:
2840 OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2841 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2842 int bHasM, OGRRawPoint *&paoPoints,
2843 int &nMaxPoints,
2844 double *&padfZ) override;
2846
2847 public:
2849 OGRTriangle() = default;
2850 OGRTriangle(const OGRPoint &p, const OGRPoint &q, const OGRPoint &r);
2853 OGRTriangle(OGRTriangle &&other) = default;
2854 OGRTriangle(const OGRPolygon &other, OGRErr &eErr);
2855 OGRTriangle &operator=(const OGRTriangle &other);
2857 OGRTriangle &operator=(OGRTriangle &&other) = default;
2858
2859 const char *getGeometryName() const override;
2860 OGRwkbGeometryType getGeometryType() const override;
2861 OGRTriangle *clone() const override;
2862
2863 // IWks Interface.
2864 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2865 size_t &nBytesConsumedOut) override;
2866
2867 // New methods rewritten from OGRPolygon/OGRCurvePolygon/OGRGeometry.
2868 OGRErr addRingDirectly(OGRCurve *poNewRing) override;
2869
2872 {
2873 return this;
2874 }
2875
2877 inline const OGRPolygon *toUpperClass() const
2878 {
2879 return this;
2880 }
2881
2882 void accept(IOGRGeometryVisitor *visitor) override
2883 {
2884 visitor->visit(this);
2885 }
2886
2887 void accept(IOGRConstGeometryVisitor *visitor) const override
2888 {
2889 visitor->visit(this);
2890 }
2891
2893 static OGRGeometry *CastToPolygon(OGRGeometry *poGeom);
2895
2896 OGR_ALLOW_UPCAST_TO(Polygon)
2897 OGR_ALLOW_CAST_TO_THIS(Triangle)
2898};
2899
2900/************************************************************************/
2901/* OGRGeometryCollection */
2902/************************************************************************/
2903
2912{
2913 OGRErr importFromWktInternal(const char **ppszInput, int nRecLevel);
2914
2915 protected:
2917 int nGeomCount = 0;
2918 OGRGeometry **papoGeoms = nullptr;
2919
2920 std::string
2921 exportToWktInternal(const OGRWktOptions &opts, OGRErr *err,
2922 const std::string &exclude = std::string()) const;
2923 static OGRGeometryCollection *
2924 TransferMembersAndDestroy(OGRGeometryCollection *poSrc,
2925 OGRGeometryCollection *poDst);
2926
2927 OGRErr importFromWkbInternal(const unsigned char *pabyData, size_t nSize,
2928 int nRecLevel, OGRwkbVariant,
2929 size_t &nBytesConsumedOut);
2931 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
2932
2933 public:
2936
2939 ~OGRGeometryCollection() override;
2940
2941 OGRGeometryCollection &operator=(const OGRGeometryCollection &other);
2942 OGRGeometryCollection &operator=(OGRGeometryCollection &&other);
2943
2946
2950 {
2951 return papoGeoms;
2952 }
2953
2956 {
2957 return papoGeoms + nGeomCount;
2958 }
2959
2962 const ChildType *const *begin() const
2963 {
2964 return papoGeoms;
2965 }
2966
2968 const ChildType *const *end() const
2969 {
2970 return papoGeoms + nGeomCount;
2971 }
2972
2973 // Non standard (OGRGeometry).
2974 const char *getGeometryName() const override;
2975 OGRwkbGeometryType getGeometryType() const override;
2976 OGRGeometryCollection *clone() const override;
2977 void empty() override;
2978 OGRErr transform(OGRCoordinateTransformation *poCT) override;
2979 void flattenTo2D() override;
2980 OGRBoolean IsEmpty() const override;
2981 bool segmentize(double dfMaxLength) override;
2982 virtual OGRBoolean
2983 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2984 virtual OGRGeometry *
2985 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2986 virtual OGRGeometry *
2987 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2988 const char *const *papszOptions = nullptr) const override;
2989 virtual double
2990 get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const;
2991 virtual double get_GeodesicLength(
2992 const OGRSpatialReference *poSRSOverride = nullptr) const;
2993
2994 // IWks Interface
2995 size_t WkbSize() const override;
2996 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2997 size_t &nBytesConsumedOut) override;
2998 OGRErr exportToWkb(unsigned char *,
2999 const OGRwkbExportOptions * = nullptr) const override;
3000
3001#ifndef DOXYGEN_XML
3003#endif
3004
3005 OGRErr importFromWkt(const char **) override;
3006
3007#ifndef DOXYGEN_XML
3009#endif
3010
3015 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3016 OGRErr *err = nullptr) const override;
3017
3018 virtual double get_Length() const;
3019 virtual double get_Area() const;
3020
3021 // IGeometry methods
3022 int getDimension() const override;
3023 void getEnvelope(OGREnvelope *psEnvelope) const override;
3024 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3025
3026 // IGeometryCollection
3027 int getNumGeometries() const;
3028 OGRGeometry *getGeometryRef(int);
3029 const OGRGeometry *getGeometryRef(int) const;
3030
3031 // ISpatialRelation
3032 OGRBoolean Equals(const OGRGeometry *) const override;
3033
3034 // Non standard
3035 bool setCoordinateDimension(int nDimension) override;
3036 bool set3D(OGRBoolean bIs3D) override;
3037 bool setMeasured(OGRBoolean bIsMeasured) override;
3038 virtual OGRErr addGeometry(const OGRGeometry *);
3039 virtual OGRErr addGeometryDirectly(OGRGeometry *);
3040 OGRErr addGeometry(std::unique_ptr<OGRGeometry> geom);
3041 OGRErr addGeometryComponents(std::unique_ptr<OGRGeometryCollection> geom);
3042 virtual OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3043 std::unique_ptr<OGRGeometry> stealGeometry(int iIndex);
3044
3045 bool hasEmptyParts() const override;
3046 void removeEmptyParts() override;
3047
3048 virtual void
3049 assignSpatialReference(const OGRSpatialReference *poSR) override;
3050
3051 void closeRings() override;
3052
3053 void swapXY() override;
3054
3055 void accept(IOGRGeometryVisitor *visitor) override
3056 {
3057 visitor->visit(this);
3058 }
3059
3060 void accept(IOGRConstGeometryVisitor *visitor) const override
3061 {
3062 visitor->visit(this);
3063 }
3064
3065 static OGRGeometryCollection *
3066 CastToGeometryCollection(OGRGeometryCollection *poSrc);
3067
3068 OGR_FORBID_DOWNCAST_TO_POINT
3069 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
3070 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
3071 OGR_ALLOW_CAST_TO_THIS(GeometryCollection)
3072};
3073
3075
3076inline const OGRGeometryCollection::ChildType *const *
3077begin(const OGRGeometryCollection *poGeom)
3078{
3079 return poGeom->begin();
3080}
3081
3083inline const OGRGeometryCollection::ChildType *const *
3084end(const OGRGeometryCollection *poGeom)
3085{
3086 return poGeom->end();
3087}
3088
3091{
3092 return poGeom->begin();
3093}
3094
3097{
3098 return poGeom->end();
3099}
3100
3102
3103/************************************************************************/
3104/* OGRMultiSurface */
3105/************************************************************************/
3106
3113{
3114 protected:
3115 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3116
3117 public:
3119 OGRMultiSurface() = default;
3120
3124
3125 OGRMultiSurface &operator=(const OGRMultiSurface &other);
3128
3131
3135 {
3136 return reinterpret_cast<ChildType **>(papoGeoms);
3137 }
3138
3141 {
3142 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3143 }
3144
3147 const ChildType *const *begin() const
3148 {
3149 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3150 }
3151
3153 const ChildType *const *end() const
3154 {
3155 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3156 nGeomCount);
3157 }
3158
3159 // Non standard (OGRGeometry).
3160 const char *getGeometryName() const override;
3161 OGRwkbGeometryType getGeometryType() const override;
3162 OGRMultiSurface *clone() const override;
3163
3164#ifndef DOXYGEN_XML
3166#endif
3167
3168 OGRErr importFromWkt(const char **) override;
3169
3170#ifndef DOXYGEN_XML
3172#endif
3173
3178 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3179 OGRErr *err = nullptr) const override;
3180
3181 // IMultiSurface methods
3182 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const;
3183
3184 // IGeometry methods
3185 int getDimension() const override;
3186
3187 // IGeometryCollection
3193
3195 const OGRSurface *getGeometryRef(int i) const
3196 {
3198 }
3199
3200 // Non standard
3201 virtual OGRBoolean
3202 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3203
3206 {
3207 return this;
3208 }
3209
3212 {
3213 return this;
3214 }
3215
3216 void accept(IOGRGeometryVisitor *visitor) override
3217 {
3218 visitor->visit(this);
3219 }
3220
3221 void accept(IOGRConstGeometryVisitor *visitor) const override
3222 {
3223 visitor->visit(this);
3224 }
3225
3226 static OGRMultiPolygon *CastToMultiPolygon(OGRMultiSurface *poMS);
3227
3228 OGR_ALLOW_CAST_TO_THIS(MultiSurface)
3229 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3230 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3231 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3232 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3233};
3234
3236
3237inline const OGRMultiSurface::ChildType *const *
3238begin(const OGRMultiSurface *poGeom)
3239{
3240 return poGeom->begin();
3241}
3242
3244inline const OGRMultiSurface::ChildType *const *
3245end(const OGRMultiSurface *poGeom)
3246{
3247 return poGeom->end();
3248}
3249
3252{
3253 return poGeom->begin();
3254}
3255
3258{
3259 return poGeom->end();
3260}
3261
3263
3264/************************************************************************/
3265/* OGRMultiPolygon */
3266/************************************************************************/
3267
3272class CPL_DLL OGRMultiPolygon : public OGRMultiSurface
3273{
3274 protected:
3275 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3276 friend class OGRPolyhedralSurface;
3277 friend class OGRTriangulatedSurface;
3278
3279 private:
3281 OGRErr _addGeometryWithExpectedSubGeometryType(
3282 const OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3283 OGRErr _addGeometryDirectlyWithExpectedSubGeometryType(
3284 OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3286
3287 public:
3289 OGRMultiPolygon() = default;
3290
3294
3295 OGRMultiPolygon &operator=(const OGRMultiPolygon &other);
3298
3301
3305 {
3306 return reinterpret_cast<ChildType **>(papoGeoms);
3307 }
3308
3311 {
3312 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3313 }
3314
3317 const ChildType *const *begin() const
3318 {
3319 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3320 }
3321
3323 const ChildType *const *end() const
3324 {
3325 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3326 nGeomCount);
3327 }
3328
3329 // IGeometryCollection
3335
3337 const OGRPolygon *getGeometryRef(int i) const
3338 {
3340 }
3341
3342 // Non-standard (OGRGeometry).
3343 const char *getGeometryName() const override;
3344 OGRwkbGeometryType getGeometryType() const override;
3345 OGRMultiPolygon *clone() const override;
3346
3347#ifndef DOXYGEN_XML
3349#endif
3350
3351 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3352 size_t &nBytesConsumedOut) override;
3353
3358 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3359 OGRErr *err = nullptr) const override;
3360
3361 // Non standard
3362 virtual OGRBoolean
3363 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3364
3367 {
3368 return this;
3369 }
3370
3373 {
3374 return this;
3375 }
3376
3377 void accept(IOGRGeometryVisitor *visitor) override
3378 {
3379 visitor->visit(this);
3380 }
3381
3382 void accept(IOGRConstGeometryVisitor *visitor) const override
3383 {
3384 visitor->visit(this);
3385 }
3386
3387 static OGRMultiSurface *CastToMultiSurface(OGRMultiPolygon *poMP);
3388
3389 OGR_ALLOW_CAST_TO_THIS(MultiPolygon)
3390 OGR_ALLOW_UPCAST_TO(MultiSurface)
3391};
3392
3394
3395inline const OGRMultiPolygon::ChildType *const *
3396begin(const OGRMultiPolygon *poGeom)
3397{
3398 return poGeom->begin();
3399}
3400
3402inline const OGRMultiPolygon::ChildType *const *
3403end(const OGRMultiPolygon *poGeom)
3404{
3405 return poGeom->end();
3406}
3407
3410{
3411 return poGeom->begin();
3412}
3413
3416{
3417 return poGeom->end();
3418}
3419
3421
3422/************************************************************************/
3423/* OGRPolyhedralSurface */
3424/************************************************************************/
3425
3431class CPL_DLL OGRPolyhedralSurface : public OGRSurface
3432{
3433 protected:
3435 friend class OGRTriangulatedSurface;
3436 OGRMultiPolygon oMP{};
3437 OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
3438 virtual OGRSurfaceCasterToCurvePolygon
3439 GetCasterToCurvePolygon() const override;
3440 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
3441 virtual const char *getSubGeometryName() const;
3442 virtual OGRwkbGeometryType getSubGeometryType() const;
3443 std::string exportToWktInternal(const OGRWktOptions &opts,
3444 OGRErr *err) const;
3445
3446 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3447 GetCasterToMultiPolygon() const;
3448 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3450
3451 public:
3454
3458
3459 OGRPolyhedralSurface &operator=(const OGRPolyhedralSurface &other);
3462
3465
3469 {
3470 return oMP.begin();
3471 }
3472
3475 {
3476 return oMP.end();
3477 }
3478
3481 const ChildType *const *begin() const
3482 {
3483 return oMP.begin();
3484 }
3485
3487 const ChildType *const *end() const
3488 {
3489 return oMP.end();
3490 }
3491
3492 // IWks Interface.
3493 size_t WkbSize() const override;
3494 const char *getGeometryName() const override;
3495 OGRwkbGeometryType getGeometryType() const override;
3496 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3497 size_t &nBytesConsumedOut) override;
3498 OGRErr exportToWkb(unsigned char *,
3499 const OGRwkbExportOptions * = nullptr) const override;
3500
3501#ifndef DOXYGEN_XML
3503#endif
3504
3505 OGRErr importFromWkt(const char **) override;
3506
3507#ifndef DOXYGEN_XML
3509#endif
3510
3515 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3516 OGRErr *err = nullptr) const override;
3517
3518 // IGeometry methods.
3519 int getDimension() const override;
3520
3521 void empty() override;
3522
3523 OGRPolyhedralSurface *clone() const override;
3524 void getEnvelope(OGREnvelope *psEnvelope) const override;
3525 void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3526
3527 void flattenTo2D() override;
3528 OGRErr transform(OGRCoordinateTransformation *) override;
3529 OGRBoolean Equals(const OGRGeometry *) const override;
3530 double get_Area() const override;
3531 virtual double get_GeodesicArea(
3532 const OGRSpatialReference *poSRSOverride = nullptr) const override;
3533 double get_Length() const override;
3534 virtual double get_GeodesicLength(
3535 const OGRSpatialReference *poSRSOverride = nullptr) const override;
3536
3537 OGRErr PointOnSurface(OGRPoint *) const override;
3538
3539 static OGRMultiPolygon *CastToMultiPolygon(OGRPolyhedralSurface *poPS);
3540 virtual OGRBoolean
3541 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3542 virtual OGRErr addGeometry(const OGRGeometry *);
3543 OGRErr addGeometryDirectly(OGRGeometry *poNewGeom);
3544 OGRErr addGeometry(std::unique_ptr<OGRGeometry> poNewGeom);
3545
3546 int getNumGeometries() const;
3547 OGRPolygon *getGeometryRef(int i);
3548 const OGRPolygon *getGeometryRef(int i) const;
3549
3550 OGRBoolean IsEmpty() const override;
3551 bool setCoordinateDimension(int nDimension) override;
3552 bool set3D(OGRBoolean bIs3D) override;
3553 bool setMeasured(OGRBoolean bIsMeasured) override;
3554 void swapXY() override;
3555 OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3556
3557 bool hasEmptyParts() const override;
3558 void removeEmptyParts() override;
3559
3560 void accept(IOGRGeometryVisitor *visitor) override
3561 {
3562 visitor->visit(this);
3563 }
3564
3565 void accept(IOGRConstGeometryVisitor *visitor) const override
3566 {
3567 visitor->visit(this);
3568 }
3569
3570 virtual void
3571 assignSpatialReference(const OGRSpatialReference *poSR) override;
3572
3573 OGR_ALLOW_CAST_TO_THIS(PolyhedralSurface)
3574 OGR_ALLOW_UPCAST_TO(Surface)
3575};
3576
3578
3579inline const OGRPolyhedralSurface::ChildType *const *
3580begin(const OGRPolyhedralSurface *poGeom)
3581{
3582 return poGeom->begin();
3583}
3584
3586inline const OGRPolyhedralSurface::ChildType *const *
3587end(const OGRPolyhedralSurface *poGeom)
3588{
3589 return poGeom->end();
3590}
3591
3594{
3595 return poGeom->begin();
3596}
3597
3600{
3601 return poGeom->end();
3602}
3603
3605
3606/************************************************************************/
3607/* OGRTriangulatedSurface */
3608/************************************************************************/
3609
3616{
3617 protected:
3619 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3620 const char *getSubGeometryName() const override;
3621 OGRwkbGeometryType getSubGeometryType() const override;
3622
3623 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3624 GetCasterToMultiPolygon() const override;
3625 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3627
3628 public:
3631
3635
3636 OGRTriangulatedSurface &operator=(const OGRTriangulatedSurface &other);
3639
3642
3646 {
3647 return reinterpret_cast<ChildType **>(oMP.begin());
3648 }
3649
3652 {
3653 return reinterpret_cast<ChildType **>(oMP.end());
3654 }
3655
3658 const ChildType *const *begin() const
3659 {
3660 return reinterpret_cast<const ChildType *const *>(oMP.begin());
3661 }
3662
3664 const ChildType *const *end() const
3665 {
3666 return reinterpret_cast<const ChildType *const *>(oMP.end());
3667 }
3668
3669 const char *getGeometryName() const override;
3670 OGRwkbGeometryType getGeometryType() const override;
3671 OGRTriangulatedSurface *clone() const override;
3672
3678
3680 const OGRTriangle *getGeometryRef(int i) const
3681 {
3683 }
3684
3685 // IWks Interface.
3686 OGRErr addGeometry(const OGRGeometry *) override;
3687
3688#ifndef DOXYGEN_XML
3690#endif
3691
3694 {
3695 return this;
3696 }
3697
3700 {
3701 return this;
3702 }
3703
3704 void accept(IOGRGeometryVisitor *visitor) override
3705 {
3706 visitor->visit(this);
3707 }
3708
3709 void accept(IOGRConstGeometryVisitor *visitor) const override
3710 {
3711 visitor->visit(this);
3712 }
3713
3714 static OGRPolyhedralSurface *
3715 CastToPolyhedralSurface(OGRTriangulatedSurface *poTS);
3716
3717 OGR_ALLOW_CAST_TO_THIS(TriangulatedSurface)
3718 OGR_ALLOW_UPCAST_TO(PolyhedralSurface)
3719};
3720
3722
3723inline const OGRTriangulatedSurface::ChildType *const *
3724begin(const OGRTriangulatedSurface *poGeom)
3725{
3726 return poGeom->begin();
3727}
3728
3730inline const OGRTriangulatedSurface::ChildType *const *
3731end(const OGRTriangulatedSurface *poGeom)
3732{
3733 return poGeom->end();
3734}
3735
3738{
3739 return poGeom->begin();
3740}
3741
3744{
3745 return poGeom->end();
3746}
3747
3749
3750/************************************************************************/
3751/* OGRMultiPoint */
3752/************************************************************************/
3753
3759{
3760 private:
3761 OGRErr importFromWkt_Bracketed(const char **, int bHasM, int bHasZ);
3762
3763 protected:
3764 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3765
3766 public:
3768 OGRMultiPoint() = default;
3769
3772 OGRMultiPoint(OGRMultiPoint &&other) = default;
3773
3774 OGRMultiPoint &operator=(const OGRMultiPoint &other);
3777
3780
3784 {
3785 return reinterpret_cast<ChildType **>(papoGeoms);
3786 }
3787
3790 {
3791 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3792 }
3793
3796 const ChildType *const *begin() const
3797 {
3798 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3799 }
3800
3802 const ChildType *const *end() const
3803 {
3804 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3805 nGeomCount);
3806 }
3807
3808 // IGeometryCollection
3814
3816 const OGRPoint *getGeometryRef(int i) const
3817 {
3819 }
3820
3821 // Non-standard (OGRGeometry).
3822 const char *getGeometryName() const override;
3823 OGRwkbGeometryType getGeometryType() const override;
3824 OGRMultiPoint *clone() const override;
3825
3826#ifndef DOXYGEN_XML
3828#endif
3829
3830 OGRErr importFromWkt(const char **) override;
3831
3832#ifndef DOXYGEN_XML
3834#endif
3835
3840 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3841 OGRErr *err = nullptr) const override;
3842
3843 // IGeometry methods.
3844 int getDimension() const override;
3845
3848 {
3849 return this;
3850 }
3851
3854 {
3855 return this;
3856 }
3857
3858 void accept(IOGRGeometryVisitor *visitor) override
3859 {
3860 visitor->visit(this);
3861 }
3862
3863 void accept(IOGRConstGeometryVisitor *visitor) const override
3864 {
3865 visitor->visit(this);
3866 }
3867
3868 // Non-standard.
3869 virtual OGRBoolean
3870 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3871
3872 OGR_ALLOW_CAST_TO_THIS(MultiPoint)
3873 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3874 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3875 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3876 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3877 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3878};
3879
3881
3882inline const OGRMultiPoint::ChildType *const *begin(const OGRMultiPoint *poGeom)
3883{
3884 return poGeom->begin();
3885}
3886
3888inline const OGRMultiPoint::ChildType *const *end(const OGRMultiPoint *poGeom)
3889{
3890 return poGeom->end();
3891}
3892
3895{
3896 return poGeom->begin();
3897}
3898
3901{
3902 return poGeom->end();
3903}
3904
3906
3907/************************************************************************/
3908/* OGRMultiCurve */
3909/************************************************************************/
3910
3917{
3918 protected:
3920 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
3921 OGRCurve *poCurve);
3923 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3924
3925 public:
3927 OGRMultiCurve() = default;
3928
3931 OGRMultiCurve(OGRMultiCurve &&other) = default;
3932
3933 OGRMultiCurve &operator=(const OGRMultiCurve &other);
3936
3939
3943 {
3944 return reinterpret_cast<ChildType **>(papoGeoms);
3945 }
3946
3949 {
3950 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3951 }
3952
3955 const ChildType *const *begin() const
3956 {
3957 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3958 }
3959
3961 const ChildType *const *end() const
3962 {
3963 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3964 nGeomCount);
3965 }
3966
3967 // IGeometryCollection
3973
3975 const OGRCurve *getGeometryRef(int i) const
3976 {
3978 }
3979
3980 // Non standard (OGRGeometry).
3981 const char *getGeometryName() const override;
3982 OGRwkbGeometryType getGeometryType() const override;
3983 OGRMultiCurve *clone() const override;
3984
3985#ifndef DOXYGEN_XML
3987#endif
3988
3989 OGRErr importFromWkt(const char **) override;
3990
3991#ifndef DOXYGEN_XML
3993#endif
3994
3999 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
4000 OGRErr *err = nullptr) const override;
4001
4002 // IGeometry methods.
4003 int getDimension() const override;
4004
4005 // Non-standard.
4006 virtual OGRBoolean
4007 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
4008
4011 {
4012 return this;
4013 }
4014
4017 {
4018 return this;
4019 }
4020
4021 void accept(IOGRGeometryVisitor *visitor) override
4022 {
4023 visitor->visit(this);
4024 }
4025
4026 void accept(IOGRConstGeometryVisitor *visitor) const override
4027 {
4028 visitor->visit(this);
4029 }
4030
4031 static OGRMultiLineString *CastToMultiLineString(OGRMultiCurve *poMC);
4032
4033 OGR_ALLOW_CAST_TO_THIS(MultiCurve)
4034 OGR_ALLOW_UPCAST_TO(GeometryCollection)
4035 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
4036 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
4037 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
4038};
4039
4041
4042inline const OGRMultiCurve::ChildType *const *begin(const OGRMultiCurve *poGeom)
4043{
4044 return poGeom->begin();
4045}
4046
4048inline const OGRMultiCurve::ChildType *const *end(const OGRMultiCurve *poGeom)
4049{
4050 return poGeom->end();
4051}
4052
4055{
4056 return poGeom->begin();
4057}
4058
4061{
4062 return poGeom->end();
4063}
4064
4066
4067/************************************************************************/
4068/* OGRMultiLineString */
4069/************************************************************************/
4070
4075class CPL_DLL OGRMultiLineString : public OGRMultiCurve
4076{
4077 protected:
4078 OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
4079
4080 public:
4083
4087
4088 OGRMultiLineString &operator=(const OGRMultiLineString &other);
4091
4094
4098 {
4099 return reinterpret_cast<ChildType **>(papoGeoms);
4100 }
4101
4104 {
4105 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
4106 }
4107
4110 const ChildType *const *begin() const
4111 {
4112 return reinterpret_cast<const ChildType *const *>(papoGeoms);
4113 }
4114
4116 const ChildType *const *end() const
4117 {
4118 return reinterpret_cast<const ChildType *const *>(papoGeoms +
4119 nGeomCount);
4120 }
4121
4122 // IGeometryCollection
4128
4130 const OGRLineString *getGeometryRef(int i) const
4131 {
4133 }
4134
4135 // Non standard (OGRGeometry).
4136 const char *getGeometryName() const override;
4137 OGRwkbGeometryType getGeometryType() const override;
4138 OGRMultiLineString *clone() const override;
4139
4140#ifndef DOXYGEN_XML
4142#endif
4143
4144 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
4145 size_t &nBytesConsumedOut) override;
4146
4151 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
4152 OGRErr *err = nullptr) const override;
4153
4154 // Non standard
4155 virtual OGRBoolean
4156 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
4157
4160 {
4161 return this;
4162 }
4163
4166 {
4167 return this;
4168 }
4169
4170 void accept(IOGRGeometryVisitor *visitor) override
4171 {
4172 visitor->visit(this);
4173 }
4174
4175 void accept(IOGRConstGeometryVisitor *visitor) const override
4176 {
4177 visitor->visit(this);
4178 }
4179
4180 static OGRMultiCurve *CastToMultiCurve(OGRMultiLineString *poMLS);
4181
4182 OGR_ALLOW_CAST_TO_THIS(MultiLineString)
4183 OGR_ALLOW_UPCAST_TO(MultiCurve)
4184 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
4185 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
4186 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
4187};
4188
4190
4191inline const OGRMultiLineString::ChildType *const *
4192begin(const OGRMultiLineString *poGeom)
4193{
4194 return poGeom->begin();
4195}
4196
4198inline const OGRMultiLineString::ChildType *const *
4199end(const OGRMultiLineString *poGeom)
4200{
4201 return poGeom->end();
4202}
4203
4206{
4207 return poGeom->begin();
4208}
4209
4212{
4213 return poGeom->end();
4214}
4215
4217
4218/************************************************************************/
4219/* OGRGeometryFactory */
4220/************************************************************************/
4221
4227{
4228 static OGRErr createFromFgfInternal(const unsigned char *pabyData,
4229 OGRSpatialReference *poSR,
4230 OGRGeometry **ppoReturn, int nBytes,
4231 int *pnBytesConsumed, int nRecLevel);
4232
4233 public:
4234 static OGRErr createFromWkb(const void *, const OGRSpatialReference *,
4235 OGRGeometry **,
4236 size_t = static_cast<size_t>(-1),
4238 static OGRErr createFromWkb(const void *pabyData,
4239 const OGRSpatialReference *, OGRGeometry **,
4240 size_t nSize, OGRwkbVariant eVariant,
4241 size_t &nBytesConsumedOut);
4242 static OGRErr createFromWkt(const char *, const OGRSpatialReference *,
4243 OGRGeometry **);
4244 static OGRErr createFromWkt(const char **, const OGRSpatialReference *,
4245 OGRGeometry **);
4246 static std::pair<std::unique_ptr<OGRGeometry>, OGRErr>
4247 createFromWkt(const char *, const OGRSpatialReference * = nullptr);
4248
4252 static OGRErr createFromWkt(char **ppszInput,
4253 const OGRSpatialReference *poSRS,
4254 OGRGeometry **ppoGeom)
4255 CPL_WARN_DEPRECATED("Use createFromWkt(const char**, ...) instead")
4256 {
4257 return createFromWkt(const_cast<const char **>(ppszInput), poSRS,
4258 ppoGeom);
4259 }
4260
4261 static OGRErr createFromFgf(const void *, OGRSpatialReference *,
4262 OGRGeometry **, int = -1, int * = nullptr);
4263 static OGRGeometry *createFromGML(const char *);
4264 static OGRGeometry *createFromGEOS(GEOSContextHandle_t hGEOSCtxt, GEOSGeom);
4265 static OGRGeometry *createFromGeoJson(const char *, int = -1);
4266 static OGRGeometry *createFromGeoJson(const CPLJSONObject &oJSONObject);
4267
4268 static void destroyGeometry(OGRGeometry *);
4269 static OGRGeometry *createGeometry(OGRwkbGeometryType);
4270
4271 static OGRGeometry *forceToPolygon(OGRGeometry *);
4272 static OGRGeometry *forceToLineString(OGRGeometry *,
4273 bool bOnlyInOrder = true);
4274 static OGRGeometry *forceToMultiPolygon(OGRGeometry *);
4275 static OGRGeometry *forceToMultiPoint(OGRGeometry *);
4276 static OGRGeometry *forceToMultiLineString(OGRGeometry *);
4277
4278 static OGRGeometry *forceTo(OGRGeometry *poGeom,
4279 OGRwkbGeometryType eTargetType,
4280 const char *const *papszOptions = nullptr)
4281#ifndef DOXYGEN_SKIP
4282 CPL_WARN_DEPRECATED("Use variant that accepts and returns a "
4283 "std::unique_ptr<OGRGeometry")
4284#endif
4285 ;
4286
4287 static std::unique_ptr<OGRGeometry>
4288 forceTo(std::unique_ptr<OGRGeometry> poGeom, OGRwkbGeometryType eTargetType,
4289 const char *const *papszOptions = nullptr);
4290
4291 static std::unique_ptr<OGRGeometry>
4292 makeCompatibleWith(std::unique_ptr<OGRGeometry>,
4293 OGRwkbGeometryType eTargetType);
4294
4295 static OGRGeometry *removeLowerDimensionSubGeoms(const OGRGeometry *poGeom);
4296
4297 static std::unique_ptr<OGRGeometry>
4298 organizePolygons(std::vector<std::unique_ptr<OGRGeometry>> &apoPolygons,
4299 bool *pbResultValidGeometry = nullptr,
4300 CSLConstList papszOptions = nullptr);
4301
4302 static OGRGeometry *organizePolygons(OGRGeometry **papoPolygons,
4303 int nPolygonCount,
4304 int *pbResultValidGeometry,
4305 CSLConstList papszOptions = nullptr)
4306#ifndef DOXYGEN_SKIP
4307 CPL_WARN_DEPRECATED("Use variant that accepts a "
4308 "std::vector<std::unique_ptr<OGRGeometry>>&")
4309#endif
4310 ;
4311
4312 static bool haveGEOS();
4313
4316 {
4317 friend class OGRGeometryFactory;
4318 struct Private;
4319 std::unique_ptr<Private> d;
4320
4321 public:
4324 };
4325
4327 static bool isTransformWithOptionsRegularTransform(
4328 const OGRSpatialReference *poSourceCRS,
4329 const OGRSpatialReference *poTargetCRS, CSLConstList papszOptions);
4331
4332 static OGRGeometry *transformWithOptions(
4333 const OGRGeometry *poSrcGeom, OGRCoordinateTransformation *poCT,
4334 CSLConstList papszOptions,
4336
4337 static double GetDefaultArcStepSize();
4338
4339 static OGRGeometry *
4340 approximateArcAngles(double dfX, double dfY, double dfZ,
4341 double dfPrimaryRadius, double dfSecondaryAxis,
4342 double dfRotation, double dfStartAngle,
4343 double dfEndAngle, double dfMaxAngleStepSizeDegrees,
4344 const bool bUseMaxGap = false);
4345
4346 static int GetCurveParameters(double x0, double y0, double x1, double y1,
4347 double x2, double y2, double &R, double &cx,
4348 double &cy, double &alpha0, double &alpha1,
4349 double &alpha2);
4350 static OGRLineString *
4351 curveToLineString(double x0, double y0, double z0, double x1, double y1,
4352 double z1, double x2, double y2, double z2, int bHasZ,
4353 double dfMaxAngleStepSizeDegrees,
4354 const char *const *papszOptions = nullptr);
4355 static OGRCurve *
4356 curveFromLineString(const OGRLineString *poLS,
4357 const char *const *papszOptions = nullptr);
4358};
4359
4360OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType(const char *pszGeomType);
4361const char CPL_DLL *OGRToOGCGeomType(OGRwkbGeometryType eGeomType,
4362 bool bCamelCase = false,
4363 bool bAddZM = false,
4364 bool bSpaceBeforeZM = false);
4365
4367typedef struct _OGRPreparedGeometry OGRPreparedGeometry;
4368
4369struct CPL_DLL OGRPreparedGeometryUniquePtrDeleter
4370{
4371 void operator()(OGRPreparedGeometry *) const;
4372};
4373
4375
4378typedef std::unique_ptr<OGRPreparedGeometry,
4379 OGRPreparedGeometryUniquePtrDeleter>
4381
4382#endif /* ndef OGR_GEOMETRY_H_INCLUDED */
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition cpl_json.h:60
OGRGeometry visitor interface.
Definition ogr_geometry.h:222
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 ~IOGRConstGeometryVisitor()
Destructor/.
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 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:148
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()
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:1934
OGRCircularString()=default
Create an empty circular string.
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2029
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2019
OGRCircularString(const OGRCircularString &other)
Copy constructor.
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2013
OGRCircularString & operator=(OGRCircularString &&other)=default
Move assignment operator.
OGRCircularString(OGRCircularString &&other)=default
Move constructor.
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2024
Utility class to store a collection of curves.
Definition ogr_geometry.h:2166
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:2229
OGRCompoundCurve()=default
Create an empty compound curve.
const ChildType *const * begin() const
Return begin of curve iterator.
Definition ogr_geometry.h:2223
OGRCompoundCurve(const OGRCompoundCurve &other)
Copy constructor.
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:2206
OGRCompoundCurve(OGRCompoundCurve &&other)=default
Move constructor.
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:2216
OGRCompoundCurve & operator=(OGRCompoundCurve &&other)=default
Move assignment operator.
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:2210
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2330
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2325
Interface for transforming between coordinate systems.
Definition ogr_spatialref.h:867
Concrete class representing curve polygons.
Definition ogr_geometry.h:2430
OGRCurvePolygon()=default
Create an empty curve polygon.
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2586
OGRCurvePolygon & operator=(OGRCurvePolygon &&other)=default
Move assignment operator.
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:2473
OGRCurvePolygon(OGRCurvePolygon &&)=default
Move constructor.
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:2496
const ChildType *const * begin() const
Return begin of curve iterator.
Definition ogr_geometry.h:2490
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:2477
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:2483
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2591
OGRCurvePolygon(const OGRCurvePolygon &)
Copy constructor.
Abstract curve base class for OGRLineString, OGRCircularString and OGRCompoundCurve.
Definition ogr_geometry.h:1291
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.
OGRCurve * clone() const override=0
Make a copy of this object.
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:1384
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:1334
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:1376
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 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:268
void visit(const OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:272
OGRGeometry visitor default implementation.
Definition ogr_geometry.h:194
void visit(OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:198
Simple container for a bounding region in 3D.
Definition ogr_core.h:217
Simple container for a bounding region (rectangle)
Definition ogr_core.h:44
Geometry coordinate precision for a binary representation.
Definition ogr_geometry.h:302
A collection of 1 or more geometry objects.
Definition ogr_geometry.h:2912
ChildType ** end()
Return end of sub-geometry iterator.
Definition ogr_geometry.h:2955
OGRGeometryCollection()=default
Create an empty geometry collection.
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3055
const ChildType *const * begin() const
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:2962
const ChildType *const * end() const
Return end of sub-geometry iterator.
Definition ogr_geometry.h:2968
ChildType ** begin()
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:2949
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3060
OGRGeometry * getGeometryRef(int)
Fetch geometry from container.
Definition ogrgeometrycollection.cpp:293
OGRGeometry ChildType
Type of child elements.
Definition ogr_geometry.h:2945
Opaque class used as argument to transformWithOptions()
Definition ogr_geometry.h:4316
Create geometry objects from well known text/binary.
Definition ogr_geometry.h:4227
static OGRErr createFromWkt(char **ppszInput, const OGRSpatialReference *poSRS, OGRGeometry **ppoGeom)
Deprecated.
Definition ogr_geometry.h:4252
Abstract base class for all geometry classes.
Definition ogr_geometry.h:357
const OGRSurface * toSurface() const
Down-cast to OGRSurface*.
Definition ogr_geometry.h:797
const OGRCurvePolygon * toCurvePolygon() const
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:849
const OGRMultiCurve * toMultiCurve() const
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:939
const OGRPolyhedralSurface * toPolyhedralSurface() const
Down-cast to OGRPolyhedralSurface*.
Definition ogr_geometry.h:975
const OGRMultiPoint * toMultiPoint() const
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:885
virtual void empty()=0
Clear geometry information.
const OGRMultiPolygon * toMultiPolygon() const
Down-cast to OGRMultiPolygon*.
Definition ogr_geometry.h:921
virtual OGRBoolean Equals(const OGRGeometry *) const =0
Returns TRUE if two geometries are equivalent.
OGRPolyhedralSurface * toPolyhedralSurface()
Down-cast to OGRPolyhedralSurface*.
Definition ogr_geometry.h:966
const OGRMultiSurface * toMultiSurface() const
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:957
OGRPoint * toPoint()
Down-cast to OGRPoint*.
Definition ogr_geometry.h:665
bool operator!=(const OGRGeometry &other) const
Returns if two geometries are different.
Definition ogr_geometry.h:419
OGRTriangle * toTriangle()
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:823
OGRLineString * toLineString()
Down-cast to OGRLineString*.
Definition ogr_geometry.h:718
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:673
OGRMultiLineString * toMultiLineString()
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:894
OGRMultiSurface * toMultiSurface()
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:948
static OGRGeometry * FromHandle(OGRGeometryH hGeom)
Convert a OGRGeometryH to a OGRGeometry*.
Definition ogr_geometry.h:657
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:867
const OGRMultiLineString * toMultiLineString() const
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:903
const OGRCircularString * toCircularString() const
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:761
OGRPolygon * toPolygon()
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:806
bool operator==(const OGRGeometry &other) const
Returns if two geometries are equal.
Definition ogr_geometry.h:413
OGRLinearRing * toLinearRing()
Down-cast to OGRLinearRing*.
Definition ogr_geometry.h:735
OGRBoolean IsMeasured() const
Definition ogr_geometry.h:441
virtual void accept(IOGRGeometryVisitor *visitor)=0
Accept a visitor.
OGRMultiCurve * toMultiCurve()
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:930
const OGRCompoundCurve * toCompoundCurve() const
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:779
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:858
virtual const char * getGeometryName() const =0
Fetch WKT name for geometry type.
OGRMultiPolygon * toMultiPolygon()
Down-cast to OGRMultiPolygon*.
Definition ogr_geometry.h:912
const OGRPolygon * toPolygon() const
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:815
OGRCompoundCurve * toCompoundCurve()
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:770
OGRErr importFromWkt(char **ppszInput)
Deprecated.
Definition ogr_geometry.h:468
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:727
OGRErr exportToWkt(char **ppszDstText, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known text format.
Definition ogrgeometry.cpp:1968
OGRCircularString * toCircularString()
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:752
const OGRCurve * toCurve() const
Down-cast to OGRCurve*.
Definition ogr_geometry.h:691
OGRCurvePolygon * toCurvePolygon()
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:840
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:709
static OGRGeometryH ToHandle(OGRGeometry *poGeom)
Convert a OGRGeometry* to a OGRGeometryH.
Definition ogr_geometry.h:650
OGRBoolean Is3D() const
Definition ogr_geometry.h:435
OGRMultiPoint * toMultiPoint()
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:876
const OGRTriangulatedSurface * toTriangulatedSurface() const
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:991
const OGRTriangle * toTriangle() const
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:831
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:788
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:700
OGRTriangulatedSurface * toTriangulatedSurface()
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:983
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:682
Definition ogr_geometry.h:1440
~OGRIteratedPoint() override
Destructor.
Concrete representation of a multi-vertex line.
Definition ogr_geometry.h:1739
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:1783
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1799
OGRLineString(const OGRLineString &other)
Copy constructor.
double get_Area() const override
Get the area of the (closed) curve.
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...
int isClockwise() const override
Returns TRUE if the ring has clockwise winding (or less than 2 points)
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1794
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1789
OGRLineString()=default
Create an empty line string.
Concrete representation of a closed ring.
Definition ogr_geometry.h:1833
OGRLinearRing()=default
Constructor.
OGRLinearRing & operator=(OGRLinearRing &&other)=default
Move assignment operator.
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1909
const OGRLineString * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1899
OGRLinearRing(const OGRLinearRing &other)
Copy constructor.
OGRLinearRing(OGRLinearRing &&other)=default
Move constructor.
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1904
A collection of OGRCurve.
Definition ogr_geometry.h:3917
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3955
OGRMultiCurve()=default
Create an empty multi curve collection.
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3961
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3948
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:4026
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:4016
OGRMultiCurve & operator=(OGRMultiCurve &&other)=default
Move assignment operator.
const OGRCurve * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3975
OGRCurve * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3969
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:4021
OGRMultiCurve(const OGRMultiCurve &other)
Copy constructor.
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:3938
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3942
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:4010
OGRMultiCurve(OGRMultiCurve &&other)=default
Move constructor.
A collection of OGRLineString.
Definition ogr_geometry.h:4076
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:4175
OGRLineString ChildType
Type of child elements.
Definition ogr_geometry.h:4093
OGRLineString * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:4124
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:4159
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:4103
OGRMultiLineString()=default
Create an empty multi line string collection.
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:4116
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:4110
OGRMultiLineString(OGRMultiLineString &&other)=default
Move constructor.
const OGRLineString * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:4130
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:4097
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:4165
OGRMultiLineString & operator=(OGRMultiLineString &&other)=default
Move assignment operator.
OGRMultiLineString(const OGRMultiLineString &other)
Copy constructor.
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:4170
A collection of OGRPoint.
Definition ogr_geometry.h:3759
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3847
OGRMultiPoint & operator=(OGRMultiPoint &&other)=default
Move assignment operator.
OGRMultiPoint()=default
Create an empty multi point collection.
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3802
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3783
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3863
OGRMultiPoint(const OGRMultiPoint &other)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3796
OGRMultiPoint(OGRMultiPoint &&other)=default
Move constructor.
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3853
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:3779
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3858
const OGRPoint * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3816
OGRPoint * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3810
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3789
A collection of non-overlapping OGRPolygon.
Definition ogr_geometry.h:3273
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3377
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:3300
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:3331
OGRMultiPolygon()=default
Create an empty multi polygon collection.
const OGRPolygon * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3337
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3323
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3310
OGRMultiPolygon(OGRMultiPolygon &&other)=default
Move constructor.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3304
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3366
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3317
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3382
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3372
A collection of non-overlapping OGRSurface.
Definition ogr_geometry.h:3113
const OGRSurface * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3195
OGRMultiSurface & operator=(OGRMultiSurface &&other)=default
Move assignment operator.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3134
OGRSurface ChildType
Type of child elements.
Definition ogr_geometry.h:3130
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3211
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3147
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3153
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3221
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:3140
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3216
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3205
OGRSurface * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3189
Interface for a point iterator.
Definition ogr_geometry.h:1273
virtual OGRBoolean getNextPoint(OGRPoint *p)=0
Returns the next point followed by the iterator.
Point class.
Definition ogr_geometry.h:1108
double getM() const
Return m.
Definition ogr_geometry.h:1184
void setX(double xIn)
Set x.
Definition ogr_geometry.h:1195
OGRPoint(const OGRPoint &other)
Copy constructor.
OGRPoint & operator=(OGRPoint &&other)=default
Move assignment operator.
void setZ(double zIn)
Set z.
Definition ogr_geometry.h:1219
void setM(double mIn)
Set m.
Definition ogr_geometry.h:1228
double getX() const
Return x.
Definition ogr_geometry.h:1166
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1245
OGRBoolean IsEmpty() const override
Returns TRUE (non-zero) if the object has no points.
Definition ogr_geometry.h:1159
void setY(double yIn)
Set y.
Definition ogr_geometry.h:1207
double getZ() const
Return z.
Definition ogr_geometry.h:1178
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1250
double getY() const
Return y.
Definition ogr_geometry.h:1172
OGRPoint(OGRPoint &&other)=default
Move constructor.
Concrete class representing polygons.
Definition ogr_geometry.h:2648
OGRPolygon & operator=(OGRPolygon &&other)=default
Move assignment operator.
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2784
OGRLinearRing ChildType
Type of child elements.
Definition ogr_geometry.h:2688
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2692
OGRPolygon(OGRPolygon &&other)=default
Move constructor.
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2779
const OGRCurvePolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2774
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2698
OGRPolygon(const OGRPolygon &other)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2705
OGRPolygon()=default
Create an empty polygon.
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2711
OGRCurvePolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2768
PolyhedralSurface class.
Definition ogr_geometry.h:3432
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3474
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3487
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:3481
OGRPolyhedralSurface(OGRPolyhedralSurface &&other)=default
Move constructor.
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3560
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3468
OGRPolyhedralSurface()=default
Create an empty PolyhedralSurface.
virtual OGRErr addGeometry(const OGRGeometry *)
Add a new geometry to a collection.
Definition ogrpolyhedralsurface.cpp:744
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3565
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:3464
OGRPolyhedralSurface & operator=(OGRPolyhedralSurface &&other)=default
Move assignment operator.
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:1486
double getY(int i) const
Get Y at vertex.
Definition ogr_geometry.h:1639
double getX(int i) const
Get X at vertex.
Definition ogr_geometry.h:1634
OGRSimpleCurve()=default
Constructor.
OGRSimpleCurve * clone() const override=0
Make a copy of this object.
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:1563
int getNumPoints() const override
Fetch vertex count.
Definition ogr_geometry.h:1627
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:2383
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 double get_GeodesicLength(const OGRSpatialReference *poSRSOverride=nullptr) const =0
Get the length of the surface, where curve edges are geodesic lines on the underlying ellipsoid of th...
OGRSurface * clone() const override=0
Make a copy of this object.
Triangle class.
Definition ogr_geometry.h:2832
OGRTriangle()=default
Constructor.
const OGRPolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2877
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2887
OGRTriangle(OGRTriangle &&other)=default
Move constructor.
OGRPolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2871
OGRTriangle & operator=(OGRTriangle &&other)=default
Move assignment operator.
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2882
OGRTriangle(const OGRTriangle &other)
Copy constructor.
TriangulatedSurface class.
Definition ogr_geometry.h:3616
const OGRTriangle * getGeometryRef(int i) const
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:3680
OGRTriangle * getGeometryRef(int i)
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:3674
OGRTriangulatedSurface(OGRTriangulatedSurface &&other)=default
Move constructor.
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3664
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3658
OGRPolyhedralSurface * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3693
const OGRPolyhedralSurface * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3699
void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3709
OGRTriangulatedSurface & operator=(OGRTriangulatedSurface &&other)=default
Move assignment operator.
OGRTriangle ChildType
Type of child elements.
Definition ogr_geometry.h:3641
OGRTriangulatedSurface()=default
Constructor.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3645
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3651
void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3704
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
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:1101
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1252
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition cpl_port.h:1035
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:165
Forward definitions of GDAL/OGR/OSR C handle types.
void * OGRGeometryH
Opaque type for a geometry.
Definition gdal_fwd.h:96
Core portability services for cross-platform OGR code.
int OGRBoolean
Type for a OGR boolean.
Definition ogr_core.h:404
OGRwkbByteOrder
Enumeration to describe byte order.
Definition ogr_core.h:625
@ wkbNDR
LSB/Intel/Vax: Least Significant Byte First
Definition ogr_core.h:627
OGRwkbVariant
Output variants of WKB we support.
Definition ogr_core.h:558
@ wkbVariantOldOgc
Old-style 99-402 extended dimension (Z) WKB types.
Definition ogr_core.h:559
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:423
int OGRErr
Type for a OGR error.
Definition ogr_core.h:388
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:2725
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:4380
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:2646
std::unique_ptr< OGRGeometry, OGRGeometryUniquePtrDeleter > OGRGeometryUniquePtr
Unique pointer type for OGRGeometry.
Definition ogr_geometry.h:1008
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:478
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition ogrsf_frmts.h:486
Geometry coordinate precision.
Definition ogr_geomcoordinateprecision.h:40
WKB export options.
Definition ogr_geometry.h:326