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