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 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included
21 * in all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 * DEALINGS IN THE SOFTWARE.
30 ****************************************************************************/
31
32#ifndef OGR_GEOMETRY_H_INCLUDED
33#define OGR_GEOMETRY_H_INCLUDED
34
35#include "cpl_conv.h"
36#include "cpl_json.h"
37#include "ogr_core.h"
38#include "ogr_spatialref.h"
39
40#include <cmath>
41#include <memory>
42
50#ifndef DEFINEH_OGRGeometryH
51#define DEFINEH_OGRGeometryH
52#ifdef DEBUG
53typedef struct OGRGeometryHS *OGRGeometryH;
54#else
55typedef void *OGRGeometryH;
56#endif
57#endif /* DEFINEH_OGRGeometryH */
61enum class OGRWktFormat
62{
63 F,
64 G,
65 Default
66};
67
69struct CPL_DLL OGRWktOptions
70{
71 public:
77 bool round;
80
83 : variant(wkbVariantOldOgc), precision(15), round(true),
84 format(OGRWktFormat::Default)
85 {
86 static int defPrecision = getDefaultPrecision();
87 static bool defRound = getDefaultRound();
88
89 precision = defPrecision;
90 round = defRound;
91 }
92
94 OGRWktOptions(const OGRWktOptions &) = default;
95
96 private:
97 static int getDefaultPrecision();
98 static bool getDefaultRound();
99};
100
105{
106 public:
108 OGRRawPoint() : x(0.0), y(0.0)
109 {
110 }
111
113 OGRRawPoint(double xIn, double yIn) : x(xIn), y(yIn)
114 {
115 }
116
118 double x;
120 double y;
121};
122
124typedef struct GEOSGeom_t *GEOSGeom;
126typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
128typedef void sfcgal_geometry_t;
129
130class OGRPoint;
131class OGRCurve;
132class OGRCompoundCurve;
133class OGRSimpleCurve;
134class OGRLinearRing;
135class OGRLineString;
137class OGRSurface;
138class OGRCurvePolygon;
139class OGRPolygon;
140class OGRMultiPoint;
141class OGRMultiSurface;
142class OGRMultiPolygon;
143class OGRMultiCurve;
146class OGRTriangle;
149
151typedef OGRLineString *(*OGRCurveCasterToLineString)(OGRCurve *);
152typedef OGRLinearRing *(*OGRCurveCasterToLinearRing)(OGRCurve *);
153
154typedef OGRPolygon *(*OGRSurfaceCasterToPolygon)(OGRSurface *);
155typedef OGRCurvePolygon *(*OGRSurfaceCasterToCurvePolygon)(OGRSurface *);
156typedef OGRMultiPolygon *(*OGRPolyhedralSurfaceCastToMultiPolygon)(
159
164{
165 public:
167 virtual ~IOGRGeometryVisitor() = default;
168
170 virtual void visit(OGRPoint *) = 0;
172 virtual void visit(OGRLineString *) = 0;
174 virtual void visit(OGRLinearRing *) = 0;
176 virtual void visit(OGRPolygon *) = 0;
178 virtual void visit(OGRMultiPoint *) = 0;
180 virtual void visit(OGRMultiLineString *) = 0;
182 virtual void visit(OGRMultiPolygon *) = 0;
184 virtual void visit(OGRGeometryCollection *) = 0;
186 virtual void visit(OGRCircularString *) = 0;
188 virtual void visit(OGRCompoundCurve *) = 0;
190 virtual void visit(OGRCurvePolygon *) = 0;
192 virtual void visit(OGRMultiCurve *) = 0;
194 virtual void visit(OGRMultiSurface *) = 0;
196 virtual void visit(OGRTriangle *) = 0;
198 virtual void visit(OGRPolyhedralSurface *) = 0;
200 virtual void visit(OGRTriangulatedSurface *) = 0;
201};
202
211{
212 void _visit(OGRSimpleCurve *poGeom);
213
214 public:
215 void visit(OGRPoint *) override
216 {
217 }
218 void visit(OGRLineString *) override;
219 void visit(OGRLinearRing *) override;
220 void visit(OGRPolygon *) override;
221 void visit(OGRMultiPoint *) override;
222 void visit(OGRMultiLineString *) override;
223 void visit(OGRMultiPolygon *) override;
224 void visit(OGRGeometryCollection *) override;
225 void visit(OGRCircularString *) override;
226 void visit(OGRCompoundCurve *) override;
227 void visit(OGRCurvePolygon *) override;
228 void visit(OGRMultiCurve *) override;
229 void visit(OGRMultiSurface *) override;
230 void visit(OGRTriangle *) override;
231 void visit(OGRPolyhedralSurface *) override;
232 void visit(OGRTriangulatedSurface *) override;
233};
234
239{
240 public:
242 virtual ~IOGRConstGeometryVisitor() = default;
243
245 virtual void visit(const OGRPoint *) = 0;
247 virtual void visit(const OGRLineString *) = 0;
249 virtual void visit(const OGRLinearRing *) = 0;
251 virtual void visit(const OGRPolygon *) = 0;
253 virtual void visit(const OGRMultiPoint *) = 0;
255 virtual void visit(const OGRMultiLineString *) = 0;
257 virtual void visit(const OGRMultiPolygon *) = 0;
259 virtual void visit(const OGRGeometryCollection *) = 0;
261 virtual void visit(const OGRCircularString *) = 0;
263 virtual void visit(const OGRCompoundCurve *) = 0;
265 virtual void visit(const OGRCurvePolygon *) = 0;
267 virtual void visit(const OGRMultiCurve *) = 0;
269 virtual void visit(const OGRMultiSurface *) = 0;
271 virtual void visit(const OGRTriangle *) = 0;
273 virtual void visit(const OGRPolyhedralSurface *) = 0;
275 virtual void visit(const OGRTriangulatedSurface *) = 0;
276};
277
286{
287 void _visit(const OGRSimpleCurve *poGeom);
288
289 public:
290 void visit(const OGRPoint *) override
291 {
292 }
293 void visit(const OGRLineString *) override;
294 void visit(const OGRLinearRing *) override;
295 void visit(const OGRPolygon *) override;
296 void visit(const OGRMultiPoint *) override;
297 void visit(const OGRMultiLineString *) override;
298 void visit(const OGRMultiPolygon *) override;
299 void visit(const OGRGeometryCollection *) override;
300 void visit(const OGRCircularString *) override;
301 void visit(const OGRCompoundCurve *) override;
302 void visit(const OGRCurvePolygon *) override;
303 void visit(const OGRMultiCurve *) override;
304 void visit(const OGRMultiSurface *) override;
305 void visit(const OGRTriangle *) override;
306 void visit(const OGRPolyhedralSurface *) override;
307 void visit(const OGRTriangulatedSurface *) override;
308};
309
310/************************************************************************/
311/* OGRGeometry */
312/************************************************************************/
313
334class CPL_DLL OGRGeometry
335{
336 private:
337 OGRSpatialReference *poSRS = nullptr; // may be NULL
338
339 protected:
341 friend class OGRCurveCollection;
342
343 unsigned int flags = 0;
344
345 OGRErr importPreambleFromWkt(const char **ppszInput, int *pbHasZ,
346 int *pbHasM, bool *pbIsEmpty);
347 OGRErr importCurveCollectionFromWkt(
348 const char **ppszInput, int bAllowEmptyComponent, int bAllowLineString,
349 int bAllowCurve, int bAllowCompoundCurve,
350 OGRErr (*pfnAddCurveDirectly)(OGRGeometry *poSelf, OGRCurve *poCurve));
351 OGRErr importPreambleFromWkb(const unsigned char *pabyData, size_t nSize,
352 OGRwkbByteOrder &eByteOrder,
353 OGRwkbVariant eWkbVariant);
354 OGRErr importPreambleOfCollectionFromWkb(const unsigned char *pabyData,
355 size_t &nSize, size_t &nDataOffset,
356 OGRwkbByteOrder &eByteOrder,
357 size_t nMinSubGeomSize,
358 int &nGeomCount,
359 OGRwkbVariant eWkbVariant);
360 OGRErr PointOnSurfaceInternal(OGRPoint *poPoint) const;
361 OGRBoolean IsSFCGALCompatible() const;
362
363 void HomogenizeDimensionalityWith(OGRGeometry *poOtherGeom);
364 std::string wktTypeString(OGRwkbVariant variant) const;
365
367
368 public:
369 /************************************************************************/
370 /* Bit flags for OGRGeometry */
371 /* The OGR_G_NOT_EMPTY_POINT is used *only* for points. */
372 /* Do not use these outside of the core. */
373 /* Use Is3D, IsMeasured, set3D, and setMeasured instead */
374 /************************************************************************/
375
377 static const unsigned int OGR_G_NOT_EMPTY_POINT = 0x1;
378 static const unsigned int OGR_G_3D = 0x2;
379 static const unsigned int OGR_G_MEASURED = 0x4;
381
382 OGRGeometry();
383 OGRGeometry(const OGRGeometry &other);
384 virtual ~OGRGeometry();
385
386 OGRGeometry &operator=(const OGRGeometry &other);
387
389 bool operator==(const OGRGeometry &other) const
390 {
391 return CPL_TO_BOOL(Equals(&other));
392 }
393
395 bool operator!=(const OGRGeometry &other) const
396 {
397 return !CPL_TO_BOOL(Equals(&other));
398 }
399
400 // Standard IGeometry.
401 virtual int getDimension() const = 0;
402 virtual int getCoordinateDimension() const;
403 int CoordinateDimension() const;
404 virtual OGRBoolean IsEmpty() const = 0;
405 virtual OGRBoolean IsValid() const;
406 virtual OGRGeometry *MakeValid(CSLConstList papszOptions = nullptr) const;
407 virtual OGRGeometry *Normalize() const;
408 virtual OGRBoolean IsSimple() const;
411 {
412 return (flags & OGR_G_3D) != 0;
413 }
416 {
417 return (flags & OGR_G_MEASURED) != 0;
418 }
419 virtual OGRBoolean IsRing() const;
420 virtual void empty() = 0;
422 virtual void getEnvelope(OGREnvelope *psEnvelope) const = 0;
423 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const = 0;
424
425 // IWks Interface.
426 virtual size_t WkbSize() const = 0;
427 OGRErr importFromWkb(const GByte *, size_t = static_cast<size_t>(-1),
429 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
430 size_t &nBytesConsumedOut) = 0;
431 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
432 OGRwkbVariant = wkbVariantOldOgc) const = 0;
433 virtual OGRErr importFromWkt(const char **ppszInput) = 0;
434
435#ifndef DOXYGEN_XML
439 OGRErr importFromWkt(char **ppszInput)
441 CPL_WARN_DEPRECATED("Use importFromWkt(const char**) instead")
443 {
444 return importFromWkt(const_cast<const char **>(ppszInput));
445 }
446#endif
447
448 OGRErr exportToWkt(char **ppszDstText,
450
455 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
456 OGRErr *err = nullptr) const = 0;
457
458 // Non-standard.
460 OGRwkbGeometryType getIsoGeometryType() const;
461 virtual const char *getGeometryName() const = 0;
462 virtual void dumpReadable(FILE *, const char * = nullptr,
463 char **papszOptions = nullptr) const;
464 virtual void flattenTo2D() = 0;
465 virtual char *exportToGML(const char *const *papszOptions = nullptr) const;
466 virtual char *exportToKML() const;
467 virtual char *exportToJson() const;
468
470 virtual void accept(IOGRGeometryVisitor *visitor) = 0;
471
473 virtual void accept(IOGRConstGeometryVisitor *visitor) const = 0;
474
475 static GEOSContextHandle_t createGEOSContext();
476 static void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt);
477 virtual GEOSGeom
478 exportToGEOS(GEOSContextHandle_t hGEOSCtxt) const CPL_WARN_UNUSED_RESULT;
479 virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
480 virtual OGRGeometry *getCurveGeometry(
481 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
482 virtual OGRGeometry *getLinearGeometry(
483 double dfMaxAngleStepSizeDegrees = 0,
484 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
485
486 // SFCGAL interfacing methods.
488 static sfcgal_geometry_t *OGRexportToSFCGAL(const OGRGeometry *poGeom);
489 static OGRGeometry *SFCGALexportToOGR(const sfcgal_geometry_t *_geometry);
491 virtual void closeRings();
492
493 virtual void setCoordinateDimension(int nDimension);
494 virtual void set3D(OGRBoolean bIs3D);
495 virtual void setMeasured(OGRBoolean bIsMeasured);
496
497 virtual void assignSpatialReference(OGRSpatialReference *poSR);
498 OGRSpatialReference *getSpatialReference(void) const
499 {
500 return poSRS;
501 }
502
504 OGRErr transformTo(OGRSpatialReference *poSR);
505
506 virtual void segmentize(double dfMaxLength);
507
508 // ISpatialRelation
509 virtual OGRBoolean Intersects(const OGRGeometry *) const;
510 virtual OGRBoolean Equals(const OGRGeometry *) const = 0;
511 virtual OGRBoolean Disjoint(const OGRGeometry *) const;
512 virtual OGRBoolean Touches(const OGRGeometry *) const;
513 virtual OGRBoolean Crosses(const OGRGeometry *) const;
514 virtual OGRBoolean Within(const OGRGeometry *) const;
515 virtual OGRBoolean Contains(const OGRGeometry *) const;
516 virtual OGRBoolean Overlaps(const OGRGeometry *) const;
517 // virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
518 // virtual OGRGeometry *LocateAlong( double mValue ) const;
519 // virtual OGRGeometry *LocateBetween( double mStart, double mEnd )
520 // const;
521
522 virtual OGRGeometry *Boundary() const CPL_WARN_UNUSED_RESULT;
523 virtual double Distance(const OGRGeometry *) const;
524 virtual OGRGeometry *ConvexHull() const CPL_WARN_UNUSED_RESULT;
525 virtual OGRGeometry *
526 ConcaveHull(double dfRatio, bool bAllowHoles) const CPL_WARN_UNUSED_RESULT;
527 virtual OGRGeometry *
528 Buffer(double dfDist, int nQuadSegs = 30) const CPL_WARN_UNUSED_RESULT;
529 virtual OGRGeometry *
530 Intersection(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
531 virtual OGRGeometry *
532 Union(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
533 virtual OGRGeometry *UnionCascaded() const CPL_WARN_UNUSED_RESULT;
534 virtual OGRGeometry *
535 Difference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
536 virtual OGRGeometry *
537 SymDifference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
538 virtual OGRErr Centroid(OGRPoint *poPoint) const;
539 virtual OGRGeometry *
540 Simplify(double dTolerance) const CPL_WARN_UNUSED_RESULT;
542 SimplifyPreserveTopology(double dTolerance) const CPL_WARN_UNUSED_RESULT;
543 virtual OGRGeometry *
544 DelaunayTriangulation(double dfTolerance,
545 int bOnlyEdges) const CPL_WARN_UNUSED_RESULT;
546
547 virtual OGRGeometry *Polygonize() const CPL_WARN_UNUSED_RESULT;
548
549 virtual double Distance3D(const OGRGeometry *poOtherGeom) const;
550
552 // backward compatibility to non-standard method names.
553 OGRBoolean Intersect(OGRGeometry *) const
554 CPL_WARN_DEPRECATED("Non standard method. "
555 "Use Intersects() instead");
556 OGRBoolean Equal(OGRGeometry *) const
557 CPL_WARN_DEPRECATED("Non standard method. "
558 "Use Equals() instead");
559 OGRGeometry *SymmetricDifference(const OGRGeometry *) const
560 CPL_WARN_DEPRECATED("Non standard method. "
561 "Use SymDifference() instead");
562 OGRGeometry *getBoundary() const
563 CPL_WARN_DEPRECATED("Non standard method. "
564 "Use Boundary() instead");
566
568 // Special HACK for DB2 7.2 support
569 static int bGenerate_DB2_V72_BYTE_ORDER;
571
572 virtual void swapXY();
574 static OGRGeometry *CastToIdentity(OGRGeometry *poGeom)
575 {
576 return poGeom;
577 }
578 static OGRGeometry *CastToError(OGRGeometry *poGeom);
580
584 static inline OGRGeometryH ToHandle(OGRGeometry *poGeom)
585 {
586 return reinterpret_cast<OGRGeometryH>(poGeom);
587 }
588
592 static inline OGRGeometry *FromHandle(OGRGeometryH hGeom)
593 {
594 return reinterpret_cast<OGRGeometry *>(hGeom);
595 }
596
602 {
603 return cpl::down_cast<OGRPoint *>(this);
604 }
605
610 inline const OGRPoint *toPoint() const
611 {
612 return cpl::down_cast<const OGRPoint *>(this);
613 }
614
621 {
622 return cpl::down_cast<OGRCurve *>(this);
623 }
624
630 inline const OGRCurve *toCurve() const
631 {
632 return cpl::down_cast<const OGRCurve *>(this);
633 }
634
641 {
642 return cpl::down_cast<OGRSimpleCurve *>(this);
643 }
644
650 inline const OGRSimpleCurve *toSimpleCurve() const
651 {
652 return cpl::down_cast<const OGRSimpleCurve *>(this);
653 }
654
661 {
662 return cpl::down_cast<OGRLineString *>(this);
663 }
664
670 inline const OGRLineString *toLineString() const
671 {
672 return cpl::down_cast<const OGRLineString *>(this);
673 }
674
680 {
681 return cpl::down_cast<OGRLinearRing *>(this);
682 }
683
688 inline const OGRLinearRing *toLinearRing() const
689 {
690 return cpl::down_cast<const OGRLinearRing *>(this);
691 }
692
699 {
700 return cpl::down_cast<OGRCircularString *>(this);
701 }
702
709 {
710 return cpl::down_cast<const OGRCircularString *>(this);
711 }
712
719 {
720 return cpl::down_cast<OGRCompoundCurve *>(this);
721 }
722
728 inline const OGRCompoundCurve *toCompoundCurve() const
729 {
730 return cpl::down_cast<const OGRCompoundCurve *>(this);
731 }
732
739 {
740 return cpl::down_cast<OGRSurface *>(this);
741 }
742
748 inline const OGRSurface *toSurface() const
749 {
750 return cpl::down_cast<const OGRSurface *>(this);
751 }
752
759 {
760 return cpl::down_cast<OGRPolygon *>(this);
761 }
762
768 inline const OGRPolygon *toPolygon() const
769 {
770 return cpl::down_cast<const OGRPolygon *>(this);
771 }
772
778 {
779 return cpl::down_cast<OGRTriangle *>(this);
780 }
781
786 inline const OGRTriangle *toTriangle() const
787 {
788 return cpl::down_cast<const OGRTriangle *>(this);
789 }
790
797 {
798 return cpl::down_cast<OGRCurvePolygon *>(this);
799 }
800
806 inline const OGRCurvePolygon *toCurvePolygon() const
807 {
808 return cpl::down_cast<const OGRCurvePolygon *>(this);
809 }
810
817 {
818 return cpl::down_cast<OGRGeometryCollection *>(this);
819 }
820
827 {
828 return cpl::down_cast<const OGRGeometryCollection *>(this);
829 }
830
837 {
838 return cpl::down_cast<OGRMultiPoint *>(this);
839 }
840
846 inline const OGRMultiPoint *toMultiPoint() const
847 {
848 return cpl::down_cast<const OGRMultiPoint *>(this);
849 }
850
857 {
858 return cpl::down_cast<OGRMultiLineString *>(this);
859 }
860
867 {
868 return cpl::down_cast<const OGRMultiLineString *>(this);
869 }
870
877 {
878 return cpl::down_cast<OGRMultiPolygon *>(this);
879 }
880
886 inline const OGRMultiPolygon *toMultiPolygon() const
887 {
888 return cpl::down_cast<const OGRMultiPolygon *>(this);
889 }
890
897 {
898 return cpl::down_cast<OGRMultiCurve *>(this);
899 }
900
906 inline const OGRMultiCurve *toMultiCurve() const
907 {
908 return cpl::down_cast<const OGRMultiCurve *>(this);
909 }
910
917 {
918 return cpl::down_cast<OGRMultiSurface *>(this);
919 }
920
926 inline const OGRMultiSurface *toMultiSurface() const
927 {
928 return cpl::down_cast<const OGRMultiSurface *>(this);
929 }
930
937 {
938 return cpl::down_cast<OGRPolyhedralSurface *>(this);
939 }
940
947 {
948 return cpl::down_cast<const OGRPolyhedralSurface *>(this);
949 }
950
956 {
957 return cpl::down_cast<OGRTriangulatedSurface *>(this);
958 }
959
965 {
966 return cpl::down_cast<const OGRTriangulatedSurface *>(this);
967 }
968};
969
971struct CPL_DLL OGRGeometryUniquePtrDeleter
972{
973 void operator()(OGRGeometry *) const;
974};
976
980typedef std::unique_ptr<OGRGeometry, OGRGeometryUniquePtrDeleter>
982
984#define OGR_FORBID_DOWNCAST_TO(name) \
985 inline OGR##name *to##name() = delete; \
986 inline const OGR##name *to##name() const = delete;
987
988#define OGR_FORBID_DOWNCAST_TO_POINT OGR_FORBID_DOWNCAST_TO(Point)
989#define OGR_FORBID_DOWNCAST_TO_CURVE OGR_FORBID_DOWNCAST_TO(Curve)
990#define OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE OGR_FORBID_DOWNCAST_TO(SimpleCurve)
991#define OGR_FORBID_DOWNCAST_TO_LINESTRING OGR_FORBID_DOWNCAST_TO(LineString)
992#define OGR_FORBID_DOWNCAST_TO_LINEARRING OGR_FORBID_DOWNCAST_TO(LinearRing)
993#define OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
994 OGR_FORBID_DOWNCAST_TO(CircularString)
995#define OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE \
996 OGR_FORBID_DOWNCAST_TO(CompoundCurve)
997#define OGR_FORBID_DOWNCAST_TO_SURFACE OGR_FORBID_DOWNCAST_TO(Surface)
998#define OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON OGR_FORBID_DOWNCAST_TO(CurvePolygon)
999#define OGR_FORBID_DOWNCAST_TO_POLYGON OGR_FORBID_DOWNCAST_TO(Polygon)
1000#define OGR_FORBID_DOWNCAST_TO_TRIANGLE OGR_FORBID_DOWNCAST_TO(Triangle)
1001#define OGR_FORBID_DOWNCAST_TO_MULTIPOINT OGR_FORBID_DOWNCAST_TO(MultiPoint)
1002#define OGR_FORBID_DOWNCAST_TO_MULTICURVE OGR_FORBID_DOWNCAST_TO(MultiCurve)
1003#define OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1004 OGR_FORBID_DOWNCAST_TO(MultiLineString)
1005#define OGR_FORBID_DOWNCAST_TO_MULTISURFACE OGR_FORBID_DOWNCAST_TO(MultiSurface)
1006#define OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON OGR_FORBID_DOWNCAST_TO(MultiPolygon)
1007#define OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1008 OGR_FORBID_DOWNCAST_TO(GeometryCollection)
1009#define OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1010 OGR_FORBID_DOWNCAST_TO(PolyhedralSurface)
1011#define OGR_FORBID_DOWNCAST_TO_TIN OGR_FORBID_DOWNCAST_TO(TriangulatedSurface)
1012
1013#define OGR_ALLOW_UPCAST_TO(name) \
1014 inline OGR##name *to##name() \
1015 { \
1016 return this; \
1017 } \
1018 inline const OGR##name *to##name() const \
1019 { \
1020 return this; \
1021 }
1022
1023#ifndef SUPPRESS_OGR_ALLOW_CAST_TO_THIS_WARNING
1024#define CAST_TO_THIS_WARNING CPL_WARN_DEPRECATED("Casting to this is useless")
1025#else
1026#define CAST_TO_THIS_WARNING
1027#endif
1028
1029#define OGR_ALLOW_CAST_TO_THIS(name) \
1030 inline OGR##name *to##name() CAST_TO_THIS_WARNING \
1031 { \
1032 return this; \
1033 } \
1034 inline const OGR##name *to##name() const CAST_TO_THIS_WARNING \
1035 { \
1036 return this; \
1037 }
1038
1039#define OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1040 OGR_FORBID_DOWNCAST_TO_CURVE \
1041 OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE \
1042 OGR_FORBID_DOWNCAST_TO_LINESTRING \
1043 OGR_FORBID_DOWNCAST_TO_LINEARRING \
1044 OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1045 OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE
1046
1047#define OGR_FORBID_DOWNCAST_TO_ALL_SURFACES \
1048 OGR_FORBID_DOWNCAST_TO_SURFACE \
1049 OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON \
1050 OGR_FORBID_DOWNCAST_TO_POLYGON \
1051 OGR_FORBID_DOWNCAST_TO_TRIANGLE \
1052 OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1053 OGR_FORBID_DOWNCAST_TO_TIN
1054
1055#define OGR_FORBID_DOWNCAST_TO_ALL_SINGLES \
1056 OGR_FORBID_DOWNCAST_TO_POINT \
1057 OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1058 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1059
1060#define OGR_FORBID_DOWNCAST_TO_ALL_MULTI \
1061 OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1062 OGR_FORBID_DOWNCAST_TO_MULTIPOINT \
1063 OGR_FORBID_DOWNCAST_TO_MULTICURVE \
1064 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1065 OGR_FORBID_DOWNCAST_TO_MULTISURFACE \
1066 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
1067
1069
1070/************************************************************************/
1071/* OGRPoint */
1072/************************************************************************/
1073
1080class CPL_DLL OGRPoint : public OGRGeometry
1081{
1082 double x;
1083 double y;
1084 double z;
1085 double m;
1086
1087 public:
1088 OGRPoint();
1089 OGRPoint(double x, double y);
1090 OGRPoint(double x, double y, double z);
1091 OGRPoint(double x, double y, double z, double m);
1092 OGRPoint(const OGRPoint &other);
1093 static OGRPoint *createXYM(double x, double y, double m);
1094 ~OGRPoint() override;
1095
1096 OGRPoint &operator=(const OGRPoint &other);
1097
1098 // IWks Interface
1099 size_t WkbSize() const override;
1100 OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1101 size_t &nBytesConsumedOut) override;
1102 OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
1103 OGRwkbVariant = wkbVariantOldOgc) const override;
1104
1105#ifndef DOXYGEN_XML
1107#endif
1108
1109 OGRErr importFromWkt(const char **) override;
1110
1111#ifndef DOXYGEN_XML
1113#endif
1114
1119 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1120 OGRErr *err = nullptr) const override;
1121
1122 // IGeometry
1123 virtual int getDimension() const override;
1124 virtual OGRPoint *clone() const override;
1125 virtual void empty() override;
1126 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1127 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1128 virtual OGRBoolean IsEmpty() const override
1129 {
1130 return !(flags & OGR_G_NOT_EMPTY_POINT);
1131 }
1132
1133 // IPoint
1135 double getX() const
1136 {
1137 return x;
1138 }
1140 double getY() const
1141 {
1142 return y;
1143 }
1145 double getZ() const
1146 {
1147 return z;
1148 }
1150 double getM() const
1151 {
1152 return m;
1153 }
1154
1155 // Non standard
1156 virtual void setCoordinateDimension(int nDimension) override;
1160 void setX(double xIn)
1161 {
1162 x = xIn;
1163 if (std::isnan(x) || std::isnan(y))
1164 flags &= ~OGR_G_NOT_EMPTY_POINT;
1165 else
1166 flags |= OGR_G_NOT_EMPTY_POINT;
1167 }
1171 void setY(double yIn)
1172 {
1173 y = yIn;
1174 if (std::isnan(x) || std::isnan(y))
1175 flags &= ~OGR_G_NOT_EMPTY_POINT;
1176 else
1177 flags |= OGR_G_NOT_EMPTY_POINT;
1178 }
1182 void setZ(double zIn)
1183 {
1184 z = zIn;
1185 flags |= OGR_G_3D;
1186 }
1190 void setM(double mIn)
1191 {
1192 m = mIn;
1193 flags |= OGR_G_MEASURED;
1194 }
1195
1196 // ISpatialRelation
1197 virtual OGRBoolean Equals(const OGRGeometry *) const override;
1198 virtual OGRBoolean Intersects(const OGRGeometry *) const override;
1199 virtual OGRBoolean Within(const OGRGeometry *) const override;
1200
1201 // Non standard from OGRGeometry
1202 virtual const char *getGeometryName() const override;
1203 virtual OGRwkbGeometryType getGeometryType() const override;
1204 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1205 virtual void flattenTo2D() override;
1206 virtual void accept(IOGRGeometryVisitor *visitor) override
1207 {
1208 visitor->visit(this);
1209 }
1210 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1211 {
1212 visitor->visit(this);
1213 }
1214
1215 virtual void swapXY() override;
1216
1217 OGR_ALLOW_CAST_TO_THIS(Point)
1218 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
1219 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1220 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1221};
1222
1223/************************************************************************/
1224/* OGRPointIterator */
1225/************************************************************************/
1226
1233class CPL_DLL OGRPointIterator
1234{
1235 public:
1236 virtual ~OGRPointIterator();
1238
1239 static void destroy(OGRPointIterator *);
1240};
1241
1242/************************************************************************/
1243/* OGRCurve */
1244/************************************************************************/
1245
1251class CPL_DLL OGRCurve : public OGRGeometry
1252{
1253 protected:
1255 OGRCurve();
1256 OGRCurve(const OGRCurve &other);
1257
1258 virtual OGRCurveCasterToLineString GetCasterToLineString() const = 0;
1259 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const = 0;
1260
1261 friend class OGRCurvePolygon;
1262 friend class OGRCompoundCurve;
1264 virtual int ContainsPoint(const OGRPoint *p) const;
1265 virtual int IntersectsPoint(const OGRPoint *p) const;
1266 virtual double get_AreaOfCurveSegments() const = 0;
1267
1268 private:
1269 class CPL_DLL ConstIterator
1270 {
1271 struct Private;
1272 std::unique_ptr<Private> m_poPrivate;
1273
1274 public:
1275 ConstIterator(const OGRCurve *poSelf, bool bStart);
1276 ConstIterator(ConstIterator &&oOther) noexcept;
1277 ConstIterator &operator=(ConstIterator &&oOther);
1278 ~ConstIterator();
1279 const OGRPoint &operator*() const;
1280 ConstIterator &operator++();
1281 bool operator!=(const ConstIterator &it) const;
1282 };
1283
1284 friend inline ConstIterator begin(const OGRCurve *);
1285 friend inline ConstIterator end(const OGRCurve *);
1286
1287 public:
1288 ~OGRCurve() override;
1289
1291 OGRCurve &operator=(const OGRCurve &other);
1293
1296
1305 ConstIterator begin() const;
1307 ConstIterator end() const;
1308
1309 // IGeometry
1310 virtual OGRCurve *clone() const override = 0;
1311
1312 // ICurve methods
1313 virtual double get_Length() const = 0;
1314 virtual void StartPoint(OGRPoint *) const = 0;
1315 virtual void EndPoint(OGRPoint *) const = 0;
1316 virtual int get_IsClosed() const;
1317 virtual void Value(double, OGRPoint *) const = 0;
1318 virtual OGRLineString *
1319 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1320 const char *const *papszOptions = nullptr) const = 0;
1321 virtual int getDimension() const override;
1322
1323 // non standard
1324 virtual int getNumPoints() const = 0;
1326 virtual OGRBoolean IsConvex() const;
1327 virtual double get_Area() const = 0;
1328 virtual int isClockwise() const;
1329
1334 {
1335 return cpl::down_cast<OGRSimpleCurve *>(this);
1336 }
1337
1341 inline const OGRSimpleCurve *toSimpleCurve() const
1342 {
1343 return cpl::down_cast<const OGRSimpleCurve *>(this);
1344 }
1345
1346 static OGRCompoundCurve *CastToCompoundCurve(OGRCurve *puCurve);
1347 static OGRLineString *CastToLineString(OGRCurve *poCurve);
1348 static OGRLinearRing *CastToLinearRing(OGRCurve *poCurve);
1349
1350 OGR_FORBID_DOWNCAST_TO_POINT
1351 OGR_ALLOW_CAST_TO_THIS(Curve)
1352 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1353 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1354};
1355
1357
1358inline OGRCurve::ConstIterator begin(const OGRCurve *poCurve)
1359{
1360 return poCurve->begin();
1361}
1363inline OGRCurve::ConstIterator end(const OGRCurve *poCurve)
1364{
1365 return poCurve->end();
1366}
1368
1369/************************************************************************/
1370/* OGRIteratedPoint */
1371/************************************************************************/
1372
1394class CPL_DLL OGRIteratedPoint : public OGRPoint
1395{
1396 private:
1397 friend class OGRSimpleCurve;
1398
1399 OGRSimpleCurve *m_poCurve = nullptr;
1400 int m_nPos = 0;
1401
1402 OGRIteratedPoint() = default;
1403
1405
1406 public:
1410 void setX(double xIn);
1414 void setY(double yIn);
1418 void setZ(double zIn);
1422 void setM(double mIn);
1423};
1424
1425/************************************************************************/
1426/* OGRSimpleCurve */
1427/************************************************************************/
1428
1438class CPL_DLL OGRSimpleCurve : public OGRCurve
1439{
1440 protected:
1442 friend class OGRGeometry;
1443
1444 int nPointCount;
1445 OGRRawPoint *paoPoints;
1446 double *padfZ;
1447 double *padfM;
1448
1449 void Make3D();
1450 void Make2D();
1451 void RemoveM();
1452 void AddM();
1453
1454 OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ, int bHasM,
1455 OGRRawPoint *&paoPointsIn, int &nMaxPoints,
1456 double *&padfZIn);
1458
1459 virtual double get_LinearArea() const;
1460
1462 OGRSimpleCurve(const OGRSimpleCurve &other);
1463
1464 private:
1465 class CPL_DLL Iterator
1466 {
1467 struct Private;
1468 std::unique_ptr<Private> m_poPrivate;
1469 void update();
1470
1471 public:
1472 Iterator(OGRSimpleCurve *poSelf, int nPos);
1473 Iterator(Iterator &&oOther) noexcept; // declared but not defined.
1474 // Needed for gcc 5.4 at least
1475 ~Iterator();
1476 OGRIteratedPoint &operator*();
1477 Iterator &operator++();
1478 bool operator!=(const Iterator &it) const;
1479 };
1480
1481 friend inline Iterator begin(OGRSimpleCurve *);
1482 friend inline Iterator end(OGRSimpleCurve *);
1483
1484 class CPL_DLL ConstIterator
1485 {
1486 struct Private;
1487 std::unique_ptr<Private> m_poPrivate;
1488
1489 public:
1490 ConstIterator(const OGRSimpleCurve *poSelf, int nPos);
1491 ConstIterator(
1492 ConstIterator &&oOther) noexcept; // declared but not defined.
1493 // Needed for gcc 5.4 at least
1494 ~ConstIterator();
1495 const OGRPoint &operator*() const;
1496 ConstIterator &operator++();
1497 bool operator!=(const ConstIterator &it) const;
1498 };
1499
1500 friend inline ConstIterator begin(const OGRSimpleCurve *);
1501 friend inline ConstIterator end(const OGRSimpleCurve *);
1502
1503 public:
1504 ~OGRSimpleCurve() override;
1505
1506 OGRSimpleCurve &operator=(const OGRSimpleCurve &other);
1507
1510
1519 Iterator begin();
1521 Iterator end();
1530 ConstIterator begin() const;
1532 ConstIterator end() const;
1533
1534 // IWks Interface.
1535 virtual size_t WkbSize() const override;
1536 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1537 size_t &nBytesConsumedOut) override;
1538 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
1539 OGRwkbVariant = wkbVariantOldOgc) const override;
1540
1541#ifndef DOXYGEN_XML
1543#endif
1544
1545 OGRErr importFromWkt(const char **) override;
1546
1547#ifndef DOXYGEN_XML
1549#endif
1550
1555 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1556 OGRErr *err = nullptr) const override;
1557
1558 // IGeometry interface.
1559 virtual void empty() override;
1560 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1561 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1562 virtual OGRBoolean IsEmpty() const override;
1563 virtual OGRSimpleCurve *clone() const override = 0;
1564
1565 // ICurve methods.
1566 virtual double get_Length() const override;
1567 virtual void StartPoint(OGRPoint *) const override;
1568 virtual void EndPoint(OGRPoint *) const override;
1569 virtual void Value(double, OGRPoint *) const override;
1570 virtual double Project(const OGRPoint *) const;
1571 virtual OGRLineString *getSubLine(double, double, int) const;
1572
1573 // ILineString methods.
1574 virtual int getNumPoints() const override
1575 {
1576 return nPointCount;
1577 }
1578 void getPoint(int, OGRPoint *) const;
1579 double getX(int i) const
1580 {
1581 return paoPoints[i].x;
1582 }
1583 double getY(int i) const
1584 {
1585 return paoPoints[i].y;
1586 }
1587 double getZ(int i) const;
1588 double getM(int i) const;
1589
1590 // ISpatialRelation
1591 virtual OGRBoolean Equals(const OGRGeometry *) const override;
1592
1593 // non standard.
1594 virtual void setCoordinateDimension(int nDimension) override;
1595 virtual void set3D(OGRBoolean bIs3D) override;
1596 virtual void setMeasured(OGRBoolean bIsMeasured) override;
1597 void setNumPoints(int nNewPointCount, int bZeroizeNewContent = TRUE);
1598 void setPoint(int, OGRPoint *);
1599 void setPoint(int, double, double);
1600 void setZ(int, double);
1601 void setM(int, double);
1602 void setPoint(int, double, double, double);
1603 void setPointM(int, double, double, double);
1604 void setPoint(int, double, double, double, double);
1605 void setPoints(int, const OGRRawPoint *, const double * = nullptr);
1606 void setPointsM(int, const OGRRawPoint *, const double *);
1607 void setPoints(int, const OGRRawPoint *, const double *, const double *);
1608 void setPoints(int, const double *padfX, const double *padfY,
1609 const double *padfZIn = nullptr);
1610 void setPointsM(int, const double *padfX, const double *padfY,
1611 const double *padfMIn = nullptr);
1612 void setPoints(int, const double *padfX, const double *padfY,
1613 const double *padfZIn, const double *padfMIn);
1614 void addPoint(const OGRPoint *);
1615 void addPoint(double, double);
1616 void addPoint(double, double, double);
1617 void addPointM(double, double, double);
1618 void addPoint(double, double, double, double);
1619
1620 bool removePoint(int);
1621
1622 void getPoints(OGRRawPoint *, double * = nullptr) const;
1623 void getPoints(void *pabyX, int nXStride, void *pabyY, int nYStride,
1624 void *pabyZ = nullptr, int nZStride = 0,
1625 void *pabyM = nullptr, int nMStride = 0) const;
1626
1627 void addSubLineString(const OGRLineString *, int nStartVertex = 0,
1628 int nEndVertex = -1);
1629 void reversePoints(void);
1630 virtual OGRPointIterator *getPointIterator() const override;
1631
1632 // non-standard from OGRGeometry
1633 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1634 virtual void flattenTo2D() override;
1635 virtual void segmentize(double dfMaxLength) override;
1636
1637 virtual void swapXY() override;
1638
1639 OGR_ALLOW_UPCAST_TO(Curve)
1640 OGR_ALLOW_CAST_TO_THIS(SimpleCurve)
1641};
1642
1644
1645inline OGRSimpleCurve::Iterator begin(OGRSimpleCurve *poCurve)
1646{
1647 return poCurve->begin();
1648}
1650inline OGRSimpleCurve::Iterator end(OGRSimpleCurve *poCurve)
1651{
1652 return poCurve->end();
1653}
1654
1656inline OGRSimpleCurve::ConstIterator begin(const OGRSimpleCurve *poCurve)
1657{
1658 return poCurve->begin();
1659}
1661inline OGRSimpleCurve::ConstIterator end(const OGRSimpleCurve *poCurve)
1662{
1663 return poCurve->end();
1664}
1666
1667/************************************************************************/
1668/* OGRLineString */
1669/************************************************************************/
1670
1678class CPL_DLL OGRLineString : public OGRSimpleCurve
1679{
1680 // cppcheck-suppress unusedPrivateFunction
1681 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
1682
1683 protected:
1685 static OGRLineString *TransferMembersAndDestroy(OGRLineString *poSrc,
1686 OGRLineString *poDst);
1687
1688 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1689 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1690
1691 virtual double get_AreaOfCurveSegments() const override;
1693
1694 static OGRLinearRing *CastToLinearRing(OGRLineString *poLS);
1695
1696 public:
1699 ~OGRLineString() override;
1700
1701 OGRLineString &operator=(const OGRLineString &other);
1702
1703 virtual OGRLineString *clone() const override;
1704 virtual OGRLineString *
1705 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1706 const char *const *papszOptions = nullptr) const override;
1707 virtual OGRGeometry *
1708 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
1709 virtual double get_Area() const override;
1710
1711 // Non-standard from OGRGeometry.
1712 virtual OGRwkbGeometryType getGeometryType() const override;
1713 virtual const char *getGeometryName() const override;
1714 virtual int isClockwise() const override;
1715
1718 {
1719 return this;
1720 }
1722 inline const OGRSimpleCurve *toUpperClass() const
1723 {
1724 return this;
1725 }
1726
1727 virtual void accept(IOGRGeometryVisitor *visitor) override
1728 {
1729 visitor->visit(this);
1730 }
1731 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1732 {
1733 visitor->visit(this);
1734 }
1735
1736 OGR_ALLOW_UPCAST_TO(SimpleCurve)
1737 OGR_ALLOW_CAST_TO_THIS(LineString)
1738};
1739
1740/************************************************************************/
1741/* OGRLinearRing */
1742/************************************************************************/
1743
1764class CPL_DLL OGRLinearRing : public OGRLineString
1765{
1766 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
1767
1768 // IWks Interface - Note this isn't really a first class object
1769 // for the purposes of WKB form. These methods always fail since this
1770 // object can't be serialized on its own.
1771 virtual size_t WkbSize() const override;
1772 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1773 size_t &nBytesConsumedOut) override;
1774 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
1775 OGRwkbVariant = wkbVariantOldOgc) const override;
1776
1777 protected:
1779 friend class OGRPolygon;
1780 friend class OGRTriangle;
1781
1782 // These are not IWks compatible ... just a convenience for OGRPolygon.
1783 virtual size_t _WkbSize(int _flags) const;
1784 virtual OGRErr _importFromWkb(OGRwkbByteOrder, int _flags,
1785 const unsigned char *, size_t,
1786 size_t &nBytesConsumedOut);
1787 virtual OGRErr _exportToWkb(OGRwkbByteOrder, int _flags,
1788 unsigned char *) const;
1789
1790 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1791 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1793
1794 static OGRLineString *CastToLineString(OGRLinearRing *poLR);
1795
1796 public:
1799 explicit OGRLinearRing(OGRLinearRing *);
1800 ~OGRLinearRing() override;
1801
1802 OGRLinearRing &operator=(const OGRLinearRing &other);
1803
1804 // Non standard.
1805 virtual const char *getGeometryName() const override;
1806 virtual OGRLinearRing *clone() const override;
1807 virtual void reverseWindingOrder();
1808 virtual void closeRings() override;
1809 OGRBoolean isPointInRing(const OGRPoint *pt,
1810 int bTestEnvelope = TRUE) const;
1811 OGRBoolean isPointOnRingBoundary(const OGRPoint *pt,
1812 int bTestEnvelope = TRUE) const;
1813 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1814
1817 {
1818 return this;
1819 }
1821 inline const OGRLineString *toUpperClass() const
1822 {
1823 return this;
1824 }
1825
1826 virtual void accept(IOGRGeometryVisitor *visitor) override
1827 {
1828 visitor->visit(this);
1829 }
1830 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1831 {
1832 visitor->visit(this);
1833 }
1834
1835 OGR_ALLOW_UPCAST_TO(LineString)
1836 OGR_ALLOW_CAST_TO_THIS(LinearRing)
1837};
1838
1839/************************************************************************/
1840/* OGRCircularString */
1841/************************************************************************/
1842
1855class CPL_DLL OGRCircularString : public OGRSimpleCurve
1856{
1857 private:
1858 void ExtendEnvelopeWithCircular(OGREnvelope *psEnvelope) const;
1859 OGRBoolean IsValidFast() const;
1860 int IsFullCircle(double &cx, double &cy, double &square_R) const;
1861
1862 protected:
1864 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1865 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1866 virtual int IntersectsPoint(const OGRPoint *p) const override;
1867 virtual int ContainsPoint(const OGRPoint *p) const override;
1868 virtual double get_AreaOfCurveSegments() const override;
1870
1871 public:
1874 ~OGRCircularString() override;
1875
1876 OGRCircularString &operator=(const OGRCircularString &other);
1877
1878 // IWks Interface.
1879 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1880 size_t &nBytesConsumedOut) override;
1881 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
1882 OGRwkbVariant = wkbVariantOldOgc) const override;
1883
1884#ifndef DOXYGEN_XML
1886#endif
1887
1888 OGRErr importFromWkt(const char **) override;
1889
1890#ifndef DOXYGEN_XML
1892#endif
1893
1898 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1899 OGRErr *err = nullptr) const override;
1900
1901 // IGeometry interface.
1902 virtual OGRBoolean IsValid() const override;
1903 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1904 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1905 virtual OGRCircularString *clone() const override;
1906
1907 // ICurve methods.
1908 virtual double get_Length() const override;
1909 virtual OGRLineString *
1910 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1911 const char *const *papszOptions = nullptr) const override;
1912 virtual void Value(double, OGRPoint *) const override;
1913 virtual double get_Area() const override;
1914
1915 // Non-standard from OGRGeometry.
1916 virtual OGRwkbGeometryType getGeometryType() const override;
1917 virtual const char *getGeometryName() const override;
1918 virtual void segmentize(double dfMaxLength) override;
1919 virtual OGRBoolean
1920 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
1921 virtual OGRGeometry *
1922 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
1923 const char *const *papszOptions = nullptr) const override;
1924
1927 {
1928 return this;
1929 }
1931 inline const OGRSimpleCurve *toUpperClass() const
1932 {
1933 return this;
1934 }
1935
1936 virtual void accept(IOGRGeometryVisitor *visitor) override
1937 {
1938 visitor->visit(this);
1939 }
1940 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1941 {
1942 visitor->visit(this);
1943 }
1944
1945 OGR_ALLOW_UPCAST_TO(SimpleCurve)
1946 OGR_ALLOW_CAST_TO_THIS(CircularString)
1947};
1948
1949/************************************************************************/
1950/* OGRCurveCollection */
1951/************************************************************************/
1952
1964class CPL_DLL OGRCurveCollection
1965{
1966 protected:
1967 friend class OGRCompoundCurve;
1968 friend class OGRCurvePolygon;
1969 friend class OGRPolygon;
1970 friend class OGRTriangle;
1971
1972 int nCurveCount = 0;
1973 OGRCurve **papoCurves = nullptr;
1974
1975 public:
1976 OGRCurveCollection();
1977 OGRCurveCollection(const OGRCurveCollection &other);
1978 ~OGRCurveCollection();
1979
1980 OGRCurveCollection &operator=(const OGRCurveCollection &other);
1981
1983 typedef OGRCurve ChildType;
1984
1988 OGRCurve **begin()
1989 {
1990 return papoCurves;
1991 }
1993 OGRCurve **end()
1994 {
1995 return papoCurves + nCurveCount;
1996 }
2000 const OGRCurve *const *begin() const
2001 {
2002 return papoCurves;
2003 }
2005 const OGRCurve *const *end() const
2006 {
2007 return papoCurves + nCurveCount;
2008 }
2009
2010 void empty(OGRGeometry *poGeom);
2011 OGRBoolean IsEmpty() const;
2012 void getEnvelope(OGREnvelope *psEnvelope) const;
2013 void getEnvelope(OGREnvelope3D *psEnvelope) const;
2014
2015 OGRErr addCurveDirectly(OGRGeometry *poGeom, OGRCurve *poCurve,
2016 int bNeedRealloc);
2017 size_t WkbSize() const;
2018 OGRErr importPreambleFromWkb(OGRGeometry *poGeom,
2019 const unsigned char *pabyData, size_t &nSize,
2020 size_t &nDataOffset,
2021 OGRwkbByteOrder &eByteOrder,
2022 size_t nMinSubGeomSize,
2023 OGRwkbVariant eWkbVariant);
2024 OGRErr
2025 importBodyFromWkb(OGRGeometry *poGeom, const unsigned char *pabyData,
2026 size_t nSize, bool bAcceptCompoundCurve,
2027 OGRErr (*pfnAddCurveDirectlyFromWkb)(OGRGeometry *poGeom,
2028 OGRCurve *poCurve),
2029 OGRwkbVariant eWkbVariant, size_t &nBytesConsumedOut);
2030 std::string exportToWkt(const OGRGeometry *geom, const OGRWktOptions &opts,
2031 OGRErr *err) const;
2032 OGRErr exportToWkb(const OGRGeometry *poGeom, OGRwkbByteOrder,
2033 unsigned char *, OGRwkbVariant eWkbVariant) const;
2034 OGRBoolean Equals(const OGRCurveCollection *poOCC) const;
2035 void setCoordinateDimension(OGRGeometry *poGeom, int nNewDimension);
2036 void set3D(OGRGeometry *poGeom, OGRBoolean bIs3D);
2037 void setMeasured(OGRGeometry *poGeom, OGRBoolean bIsMeasured);
2038 void assignSpatialReference(OGRGeometry *poGeom, OGRSpatialReference *poSR);
2039 int getNumCurves() const;
2040 OGRCurve *getCurve(int);
2041 const OGRCurve *getCurve(int) const;
2042 OGRCurve *stealCurve(int);
2043
2044 OGRErr removeCurve(int iIndex, bool bDelete = true);
2045
2046 OGRErr transform(OGRGeometry *poGeom, OGRCoordinateTransformation *poCT);
2047 void flattenTo2D(OGRGeometry *poGeom);
2048 void segmentize(double dfMaxLength);
2049 void swapXY();
2050 OGRBoolean hasCurveGeometry(int bLookForNonLinear) const;
2051};
2053
2054/************************************************************************/
2055/* OGRCompoundCurve */
2056/************************************************************************/
2057
2068class CPL_DLL OGRCompoundCurve : public OGRCurve
2069{
2070 private:
2071 OGRCurveCollection oCC{};
2072
2073 OGRErr addCurveDirectlyInternal(OGRCurve *poCurve, double dfToleranceEps,
2074 int bNeedRealloc);
2075 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2076 OGRCurve *poCurve);
2077 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2078 OGRCurve *poCurve);
2079 OGRLineString *CurveToLineInternal(double dfMaxAngleStepSizeDegrees,
2080 const char *const *papszOptions,
2081 int bIsLinearRing) const;
2082 // cppcheck-suppress unusedPrivateFunction
2083 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
2084 // cppcheck-suppress unusedPrivateFunction
2085 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
2086
2087 protected:
2089 static OGRLineString *CastToLineString(OGRCompoundCurve *poCC);
2090 static OGRLinearRing *CastToLinearRing(OGRCompoundCurve *poCC);
2091
2092 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
2093 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
2095
2096 public:
2099 ~OGRCompoundCurve() override;
2100
2101 OGRCompoundCurve &operator=(const OGRCompoundCurve &other);
2102
2105
2110 {
2111 return oCC.begin();
2112 }
2115 {
2116 return oCC.end();
2117 }
2121 const ChildType *const *begin() const
2122 {
2123 return oCC.begin();
2124 }
2126 const ChildType *const *end() const
2127 {
2128 return oCC.end();
2129 }
2130
2131 // IWks Interface
2132 virtual size_t WkbSize() const override;
2133 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2134 size_t &nBytesConsumedOut) override;
2135 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
2136 OGRwkbVariant = wkbVariantOldOgc) const override;
2137
2138#ifndef DOXYGEN_XML
2140#endif
2141
2142 OGRErr importFromWkt(const char **) override;
2143
2144#ifndef DOXYGEN_XML
2146#endif
2147
2152 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2153 OGRErr *err = nullptr) const override;
2154
2155 // IGeometry interface.
2156 virtual OGRCompoundCurve *clone() const override;
2157 virtual void empty() override;
2158 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2159 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2160 virtual OGRBoolean IsEmpty() const override;
2161
2162 // ICurve methods.
2163 virtual double get_Length() const override;
2164 virtual void StartPoint(OGRPoint *) const override;
2165 virtual void EndPoint(OGRPoint *) const override;
2166 virtual void Value(double, OGRPoint *) const override;
2167 virtual OGRLineString *
2168 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
2169 const char *const *papszOptions = nullptr) const override;
2170
2171 virtual int getNumPoints() const override;
2172 virtual double get_AreaOfCurveSegments() const override;
2173 virtual double get_Area() const override;
2174
2175 // ISpatialRelation.
2176 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2177
2178 // ICompoundCurve method.
2179 int getNumCurves() const;
2180 OGRCurve *getCurve(int);
2181 const OGRCurve *getCurve(int) const;
2182
2183 // Non-standard.
2184 virtual void setCoordinateDimension(int nDimension) override;
2185 virtual void set3D(OGRBoolean bIs3D) override;
2186 virtual void setMeasured(OGRBoolean bIsMeasured) override;
2187
2188 virtual void assignSpatialReference(OGRSpatialReference *poSR) override;
2189
2190 OGRErr addCurve(const OGRCurve *, double dfToleranceEps = 1e-14);
2191 OGRErr addCurveDirectly(OGRCurve *, double dfToleranceEps = 1e-14);
2192 OGRCurve *stealCurve(int);
2193 virtual OGRPointIterator *getPointIterator() const override;
2194
2195 // Non-standard from OGRGeometry.
2196 virtual OGRwkbGeometryType getGeometryType() const override;
2197 virtual const char *getGeometryName() const override;
2198 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2199 virtual void flattenTo2D() override;
2200 virtual void segmentize(double dfMaxLength) override;
2201 virtual OGRBoolean
2202 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2203 virtual OGRGeometry *
2204 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2205 const char *const *papszOptions = nullptr) const override;
2206 virtual void accept(IOGRGeometryVisitor *visitor) override
2207 {
2208 visitor->visit(this);
2209 }
2210 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2211 {
2212 visitor->visit(this);
2213 }
2214
2215 virtual void swapXY() override;
2216
2217 OGR_ALLOW_UPCAST_TO(Curve)
2218 OGR_ALLOW_CAST_TO_THIS(CompoundCurve)
2219};
2220
2222
2223inline const OGRCompoundCurve::ChildType *const *
2224begin(const OGRCompoundCurve *poCurve)
2225{
2226 return poCurve->begin();
2227}
2229inline const OGRCompoundCurve::ChildType *const *
2230end(const OGRCompoundCurve *poCurve)
2231{
2232 return poCurve->end();
2233}
2234
2237{
2238 return poCurve->begin();
2239}
2242{
2243 return poCurve->end();
2244}
2246
2247/************************************************************************/
2248/* OGRSurface */
2249/************************************************************************/
2250
2256class CPL_DLL OGRSurface : public OGRGeometry
2257{
2258 protected:
2260 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const = 0;
2261 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const = 0;
2263
2264 public:
2265 virtual double get_Area() const = 0;
2266 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
2267 {
2268 return PointOnSurfaceInternal(poPoint);
2269 }
2270 virtual OGRSurface *clone() const override = 0;
2271
2273 static OGRPolygon *CastToPolygon(OGRSurface *poSurface);
2274 static OGRCurvePolygon *CastToCurvePolygon(OGRSurface *poSurface);
2276
2277 OGR_FORBID_DOWNCAST_TO_POINT
2278 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
2279 OGR_ALLOW_CAST_TO_THIS(Surface)
2280 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
2281};
2282
2283/************************************************************************/
2284/* OGRCurvePolygon */
2285/************************************************************************/
2286
2300class CPL_DLL OGRCurvePolygon : public OGRSurface
2301{
2302 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2303
2304 private:
2305 OGRBoolean IntersectsPoint(const OGRPoint *p) const;
2306 OGRBoolean ContainsPoint(const OGRPoint *p) const;
2307 virtual int checkRing(OGRCurve *poNewRing) const;
2308 OGRErr addRingDirectlyInternal(OGRCurve *poCurve, int bNeedRealloc);
2309 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2310 OGRCurve *poCurve);
2311 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2312 OGRCurve *poCurve);
2313
2314 protected:
2316 friend class OGRPolygon;
2317 friend class OGRTriangle;
2318 OGRCurveCollection oCC{};
2319
2320 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2321 virtual OGRSurfaceCasterToCurvePolygon
2322 GetCasterToCurvePolygon() const override;
2323
2325
2326 static OGRPolygon *CastToPolygon(OGRCurvePolygon *poCP);
2327
2328 public:
2331 ~OGRCurvePolygon() override;
2332
2333 OGRCurvePolygon &operator=(const OGRCurvePolygon &other);
2334
2337
2342 {
2343 return oCC.begin();
2344 }
2347 {
2348 return oCC.end();
2349 }
2353 const ChildType *const *begin() const
2354 {
2355 return oCC.begin();
2356 }
2358 const ChildType *const *end() const
2359 {
2360 return oCC.end();
2361 }
2362
2363 // Non standard (OGRGeometry).
2364 virtual const char *getGeometryName() const override;
2365 virtual OGRwkbGeometryType getGeometryType() const override;
2366 virtual OGRCurvePolygon *clone() const override;
2367 virtual void empty() override;
2368 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2369 virtual void flattenTo2D() override;
2370 virtual OGRBoolean IsEmpty() const override;
2371 virtual void segmentize(double dfMaxLength) override;
2372 virtual OGRBoolean
2373 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2374 virtual OGRGeometry *
2375 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2376 const char *const *papszOptions = nullptr) const override;
2377
2378 // ISurface Interface
2379 virtual double get_Area() const override;
2380
2381 // IWks Interface
2382 virtual size_t WkbSize() const override;
2383 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2384 size_t &nBytesConsumedOut) override;
2385 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
2386 OGRwkbVariant = wkbVariantOldOgc) const override;
2387
2388#ifndef DOXYGEN_XML
2390#endif
2391
2392 OGRErr importFromWkt(const char **) override;
2393
2394#ifndef DOXYGEN_XML
2396#endif
2397
2402 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2403 OGRErr *err = nullptr) const override;
2404
2405 // IGeometry
2406 virtual int getDimension() const override;
2407 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2408 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2409
2410 // ICurvePolygon
2411 virtual OGRPolygon *
2412 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2413 const char *const *papszOptions = nullptr) const;
2414
2415 // ISpatialRelation
2416 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2417 virtual OGRBoolean Intersects(const OGRGeometry *) const override;
2418 virtual OGRBoolean Contains(const OGRGeometry *) const override;
2419
2420 // Non standard
2421 virtual void setCoordinateDimension(int nDimension) override;
2422 virtual void set3D(OGRBoolean bIs3D) override;
2423 virtual void setMeasured(OGRBoolean bIsMeasured) override;
2424
2425 virtual void assignSpatialReference(OGRSpatialReference *poSR) override;
2426
2427 virtual OGRErr addRing(OGRCurve *);
2428 virtual OGRErr addRingDirectly(OGRCurve *);
2429
2430 OGRCurve *getExteriorRingCurve();
2431 const OGRCurve *getExteriorRingCurve() const;
2432 int getNumInteriorRings() const;
2433 OGRCurve *getInteriorRingCurve(int);
2434 const OGRCurve *getInteriorRingCurve(int) const;
2435
2436 OGRCurve *stealExteriorRingCurve();
2437
2438 OGRErr removeRing(int iIndex, bool bDelete = true);
2439 virtual void accept(IOGRGeometryVisitor *visitor) override
2440 {
2441 visitor->visit(this);
2442 }
2443 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2444 {
2445 visitor->visit(this);
2446 }
2447
2448 virtual void swapXY() override;
2449
2450 OGR_ALLOW_UPCAST_TO(Surface)
2451 OGR_ALLOW_CAST_TO_THIS(CurvePolygon)
2452};
2453
2455
2456inline const OGRCurvePolygon::ChildType *const *
2457begin(const OGRCurvePolygon *poGeom)
2458{
2459 return poGeom->begin();
2460}
2462inline const OGRCurvePolygon::ChildType *const *
2463end(const OGRCurvePolygon *poGeom)
2464{
2465 return poGeom->end();
2466}
2467
2470{
2471 return poGeom->begin();
2472}
2475{
2476 return poGeom->end();
2477}
2479
2480/************************************************************************/
2481/* OGRPolygon */
2482/************************************************************************/
2483
2493class CPL_DLL OGRPolygon : public OGRCurvePolygon
2494{
2495 static OGRCurvePolygon *CasterToCurvePolygon(OGRSurface *poSurface);
2496
2497 protected:
2499 friend class OGRMultiSurface;
2500 friend class OGRPolyhedralSurface;
2501 friend class OGRTriangulatedSurface;
2502
2503 virtual int checkRing(OGRCurve *poNewRing) const override;
2504 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2505 int bHasM, OGRRawPoint *&paoPoints,
2506 int &nMaxPoints, double *&padfZ);
2507
2508 static OGRCurvePolygon *CastToCurvePolygon(OGRPolygon *poPoly);
2509
2510 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2511 virtual OGRSurfaceCasterToCurvePolygon
2512 GetCasterToCurvePolygon() const override;
2514
2515 public:
2517 OGRPolygon(const OGRPolygon &other);
2518 ~OGRPolygon() override;
2519
2520 OGRPolygon &operator=(const OGRPolygon &other);
2521
2524
2529 {
2530 return reinterpret_cast<ChildType **>(oCC.begin());
2531 }
2534 {
2535 return reinterpret_cast<ChildType **>(oCC.end());
2536 }
2540 const ChildType *const *begin() const
2541 {
2542 return reinterpret_cast<const ChildType *const *>(oCC.begin());
2543 }
2545 const ChildType *const *end() const
2546 {
2547 return reinterpret_cast<const ChildType *const *>(oCC.end());
2548 }
2549
2550 // Non-standard (OGRGeometry).
2551 virtual const char *getGeometryName() const override;
2552 virtual OGRwkbGeometryType getGeometryType() const override;
2553 virtual OGRPolygon *clone() const override;
2554 virtual OGRBoolean
2555 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2556 virtual OGRGeometry *
2557 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2558 virtual OGRGeometry *
2559 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2560 const char *const *papszOptions = nullptr) const override;
2561
2562 // IWks Interface.
2563 virtual size_t WkbSize() const override;
2564 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2565 size_t &nBytesConsumedOut) override;
2566 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
2567 OGRwkbVariant = wkbVariantOldOgc) const override;
2568
2569#ifndef DOXYGEN_XML
2571#endif
2572
2573 OGRErr importFromWkt(const char **) override;
2574
2575#ifndef DOXYGEN_XML
2577#endif
2578
2583 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2584 OGRErr *err = nullptr) const override;
2585
2586 // ICurvePolygon.
2587 virtual OGRPolygon *
2588 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2589 const char *const *papszOptions = nullptr) const override;
2590
2591 OGRLinearRing *getExteriorRing();
2592 const OGRLinearRing *getExteriorRing() const;
2593 virtual OGRLinearRing *getInteriorRing(int);
2594 virtual const OGRLinearRing *getInteriorRing(int) const;
2595
2596 OGRLinearRing *stealExteriorRing();
2597 virtual OGRLinearRing *stealInteriorRing(int);
2598
2599 OGRBoolean IsPointOnSurface(const OGRPoint *) const;
2600
2603 {
2604 return this;
2605 }
2607 inline const OGRCurvePolygon *toUpperClass() const
2608 {
2609 return this;
2610 }
2611
2612 virtual void accept(IOGRGeometryVisitor *visitor) override
2613 {
2614 visitor->visit(this);
2615 }
2616 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2617 {
2618 visitor->visit(this);
2619 }
2620
2621 virtual void closeRings() override;
2622
2623 OGR_ALLOW_UPCAST_TO(CurvePolygon)
2624 OGR_ALLOW_CAST_TO_THIS(Polygon)
2625};
2626
2628
2629inline const OGRPolygon::ChildType *const *begin(const OGRPolygon *poGeom)
2630{
2631 return poGeom->begin();
2632}
2634inline const OGRPolygon::ChildType *const *end(const OGRPolygon *poGeom)
2635{
2636 return poGeom->end();
2637}
2638
2640inline OGRPolygon::ChildType **begin(OGRPolygon *poGeom)
2641{
2642 return poGeom->begin();
2643}
2645inline OGRPolygon::ChildType **end(OGRPolygon *poGeom)
2646{
2647 return poGeom->end();
2648}
2650
2651/************************************************************************/
2652/* OGRTriangle */
2653/************************************************************************/
2654
2661class CPL_DLL OGRTriangle : public OGRPolygon
2662{
2663 private:
2664 // cppcheck-suppress unusedPrivateFunction
2665 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2666 bool quickValidityCheck() const;
2667
2668 protected:
2670 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2671 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2672 int bHasM, OGRRawPoint *&paoPoints,
2673 int &nMaxPoints,
2674 double *&padfZ) override;
2676
2677 public:
2679 OGRTriangle(const OGRPoint &p, const OGRPoint &q, const OGRPoint &r);
2681 OGRTriangle(const OGRPolygon &other, OGRErr &eErr);
2682 OGRTriangle &operator=(const OGRTriangle &other);
2683 ~OGRTriangle() override;
2684 virtual const char *getGeometryName() const override;
2685 virtual OGRwkbGeometryType getGeometryType() const override;
2686 virtual OGRTriangle *clone() const override;
2687
2688 // IWks Interface.
2689 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2690 size_t &nBytesConsumedOut) override;
2691
2692 // New methods rewritten from OGRPolygon/OGRCurvePolygon/OGRGeometry.
2693 virtual OGRErr addRingDirectly(OGRCurve *poNewRing) override;
2694
2697 {
2698 return this;
2699 }
2701 inline const OGRPolygon *toUpperClass() const
2702 {
2703 return this;
2704 }
2705
2706 virtual void accept(IOGRGeometryVisitor *visitor) override
2707 {
2708 visitor->visit(this);
2709 }
2710 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2711 {
2712 visitor->visit(this);
2713 }
2714
2716 static OGRGeometry *CastToPolygon(OGRGeometry *poGeom);
2718
2719 OGR_ALLOW_UPCAST_TO(Polygon)
2720 OGR_ALLOW_CAST_TO_THIS(Triangle)
2721};
2722
2723/************************************************************************/
2724/* OGRGeometryCollection */
2725/************************************************************************/
2726
2735{
2736 OGRErr importFromWkbInternal(const unsigned char *pabyData, size_t nSize,
2737 int nRecLevel, OGRwkbVariant,
2738 size_t &nBytesConsumedOut);
2739 OGRErr importFromWktInternal(const char **ppszInput, int nRecLevel);
2740
2741 protected:
2743 int nGeomCount = 0;
2744 OGRGeometry **papoGeoms = nullptr;
2745
2746 std::string
2747 exportToWktInternal(const OGRWktOptions &opts, OGRErr *err,
2748 const std::string &exclude = std::string()) const;
2749 static OGRGeometryCollection *
2750 TransferMembersAndDestroy(OGRGeometryCollection *poSrc,
2751 OGRGeometryCollection *poDst);
2753 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
2754
2755 public:
2758 ~OGRGeometryCollection() override;
2759
2760 OGRGeometryCollection &operator=(const OGRGeometryCollection &other);
2761
2764
2769 {
2770 return papoGeoms;
2771 }
2774 {
2775 return papoGeoms + nGeomCount;
2776 }
2780 const ChildType *const *begin() const
2781 {
2782 return papoGeoms;
2783 }
2785 const ChildType *const *end() const
2786 {
2787 return papoGeoms + nGeomCount;
2788 }
2789
2790 // Non standard (OGRGeometry).
2791 virtual const char *getGeometryName() const override;
2792 virtual OGRwkbGeometryType getGeometryType() const override;
2793 virtual OGRGeometryCollection *clone() const override;
2794 virtual void empty() override;
2795 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2796 virtual void flattenTo2D() override;
2797 virtual OGRBoolean IsEmpty() const override;
2798 virtual void segmentize(double dfMaxLength) override;
2799 virtual OGRBoolean
2800 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2801 virtual OGRGeometry *
2802 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2803 virtual OGRGeometry *
2804 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2805 const char *const *papszOptions = nullptr) const override;
2806
2807 // IWks Interface
2808 virtual size_t WkbSize() const override;
2809 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2810 size_t &nBytesConsumedOut) override;
2811 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
2812 OGRwkbVariant = wkbVariantOldOgc) const override;
2813
2814#ifndef DOXYGEN_XML
2816#endif
2817
2818 OGRErr importFromWkt(const char **) override;
2819
2820#ifndef DOXYGEN_XML
2822#endif
2823
2828 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2829 OGRErr *err = nullptr) const override;
2830
2831 virtual double get_Length() const;
2832 virtual double get_Area() const;
2833
2834 // IGeometry methods
2835 virtual int getDimension() const override;
2836 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2837 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2838
2839 // IGeometryCollection
2840 int getNumGeometries() const;
2841 OGRGeometry *getGeometryRef(int);
2842 const OGRGeometry *getGeometryRef(int) const;
2843
2844 // ISpatialRelation
2845 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2846
2847 // Non standard
2848 virtual void setCoordinateDimension(int nDimension) override;
2849 virtual void set3D(OGRBoolean bIs3D) override;
2850 virtual void setMeasured(OGRBoolean bIsMeasured) override;
2851 virtual OGRErr addGeometry(const OGRGeometry *);
2852 virtual OGRErr addGeometryDirectly(OGRGeometry *);
2853 virtual OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
2854
2855 virtual void assignSpatialReference(OGRSpatialReference *poSR) override;
2856
2857 void closeRings() override;
2858
2859 virtual void swapXY() override;
2860
2861 virtual void accept(IOGRGeometryVisitor *visitor) override
2862 {
2863 visitor->visit(this);
2864 }
2865 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2866 {
2867 visitor->visit(this);
2868 }
2869
2870 static OGRGeometryCollection *
2871 CastToGeometryCollection(OGRGeometryCollection *poSrc);
2872
2873 OGR_FORBID_DOWNCAST_TO_POINT
2874 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
2875 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
2876 OGR_ALLOW_CAST_TO_THIS(GeometryCollection)
2877};
2878
2880
2881inline const OGRGeometryCollection::ChildType *const *
2882begin(const OGRGeometryCollection *poGeom)
2883{
2884 return poGeom->begin();
2885}
2887inline const OGRGeometryCollection::ChildType *const *
2888end(const OGRGeometryCollection *poGeom)
2889{
2890 return poGeom->end();
2891}
2892
2895{
2896 return poGeom->begin();
2897}
2900{
2901 return poGeom->end();
2902}
2904
2905/************************************************************************/
2906/* OGRMultiSurface */
2907/************************************************************************/
2908
2916{
2917 protected:
2918 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
2919
2920 public:
2923 ~OGRMultiSurface() override;
2924
2925 OGRMultiSurface &operator=(const OGRMultiSurface &other);
2926
2929
2934 {
2935 return reinterpret_cast<ChildType **>(papoGeoms);
2936 }
2939 {
2940 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
2941 }
2945 const ChildType *const *begin() const
2946 {
2947 return reinterpret_cast<const ChildType *const *>(papoGeoms);
2948 }
2950 const ChildType *const *end() const
2951 {
2952 return reinterpret_cast<const ChildType *const *>(papoGeoms +
2953 nGeomCount);
2954 }
2955
2956 // Non standard (OGRGeometry).
2957 virtual const char *getGeometryName() const override;
2958 virtual OGRwkbGeometryType getGeometryType() const override;
2959 virtual OGRMultiSurface *clone() const override;
2960
2961#ifndef DOXYGEN_XML
2963#endif
2964
2965 OGRErr importFromWkt(const char **) override;
2966
2967#ifndef DOXYGEN_XML
2969#endif
2970
2975 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2976 OGRErr *err = nullptr) const override;
2977
2978 // IMultiSurface methods
2979 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const;
2980
2981 // IGeometry methods
2982 virtual int getDimension() const override;
2983
2984 // IGeometryCollection
2991 const OGRSurface *getGeometryRef(int i) const
2992 {
2994 }
2995
2996 // Non standard
2997 virtual OGRBoolean
2998 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2999
3002 {
3003 return this;
3004 }
3007 {
3008 return this;
3009 }
3010
3011 virtual void accept(IOGRGeometryVisitor *visitor) override
3012 {
3013 visitor->visit(this);
3014 }
3015 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3016 {
3017 visitor->visit(this);
3018 }
3019
3020 static OGRMultiPolygon *CastToMultiPolygon(OGRMultiSurface *poMS);
3021
3022 OGR_ALLOW_CAST_TO_THIS(MultiSurface)
3023 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3024 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3025 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3026 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3027};
3028
3030
3031inline const OGRMultiSurface::ChildType *const *
3032begin(const OGRMultiSurface *poGeom)
3033{
3034 return poGeom->begin();
3035}
3037inline const OGRMultiSurface::ChildType *const *
3038end(const OGRMultiSurface *poGeom)
3039{
3040 return poGeom->end();
3041}
3042
3045{
3046 return poGeom->begin();
3047}
3050{
3051 return poGeom->end();
3052}
3054
3055/************************************************************************/
3056/* OGRMultiPolygon */
3057/************************************************************************/
3058
3063class CPL_DLL OGRMultiPolygon : public OGRMultiSurface
3064{
3065 protected:
3066 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3067 friend class OGRPolyhedralSurface;
3068 friend class OGRTriangulatedSurface;
3069
3070 private:
3072 OGRErr _addGeometryWithExpectedSubGeometryType(
3073 const OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3074 OGRErr _addGeometryDirectlyWithExpectedSubGeometryType(
3075 OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3077
3078 public:
3081 ~OGRMultiPolygon() override;
3082
3083 OGRMultiPolygon &operator=(const OGRMultiPolygon &other);
3084
3087
3092 {
3093 return reinterpret_cast<ChildType **>(papoGeoms);
3094 }
3097 {
3098 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3099 }
3103 const ChildType *const *begin() const
3104 {
3105 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3106 }
3108 const ChildType *const *end() const
3109 {
3110 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3111 nGeomCount);
3112 }
3113
3114 // IGeometryCollection
3121 const OGRPolygon *getGeometryRef(int i) const
3122 {
3124 }
3125
3126 // Non-standard (OGRGeometry).
3127 virtual const char *getGeometryName() const override;
3128 virtual OGRwkbGeometryType getGeometryType() const override;
3129 virtual OGRMultiPolygon *clone() const override;
3130
3131#ifndef DOXYGEN_XML
3133#endif
3134
3139 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3140 OGRErr *err = nullptr) const override;
3141
3142 // Non standard
3143 virtual OGRBoolean
3144 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3145
3148 {
3149 return this;
3150 }
3153 {
3154 return this;
3155 }
3156
3157 virtual void accept(IOGRGeometryVisitor *visitor) override
3158 {
3159 visitor->visit(this);
3160 }
3161 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3162 {
3163 visitor->visit(this);
3164 }
3165
3166 static OGRMultiSurface *CastToMultiSurface(OGRMultiPolygon *poMP);
3167
3168 OGR_ALLOW_CAST_TO_THIS(MultiPolygon)
3169 OGR_ALLOW_UPCAST_TO(MultiSurface)
3170};
3171
3173
3174inline const OGRMultiPolygon::ChildType *const *
3175begin(const OGRMultiPolygon *poGeom)
3176{
3177 return poGeom->begin();
3178}
3180inline const OGRMultiPolygon::ChildType *const *
3181end(const OGRMultiPolygon *poGeom)
3182{
3183 return poGeom->end();
3184}
3185
3188{
3189 return poGeom->begin();
3190}
3193{
3194 return poGeom->end();
3195}
3197
3198/************************************************************************/
3199/* OGRPolyhedralSurface */
3200/************************************************************************/
3201
3208class CPL_DLL OGRPolyhedralSurface : public OGRSurface
3209{
3210 protected:
3212 friend class OGRTriangulatedSurface;
3213 OGRMultiPolygon oMP{};
3214 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
3215 virtual OGRSurfaceCasterToCurvePolygon
3216 GetCasterToCurvePolygon() const override;
3217 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
3218 virtual const char *getSubGeometryName() const;
3219 virtual OGRwkbGeometryType getSubGeometryType() const;
3220 std::string exportToWktInternal(const OGRWktOptions &opts,
3221 OGRErr *err) const;
3222
3223 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3224 GetCasterToMultiPolygon() const;
3225 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3227
3228 public:
3232 OGRPolyhedralSurface &operator=(const OGRPolyhedralSurface &other);
3233
3236
3241 {
3242 return oMP.begin();
3243 }
3246 {
3247 return oMP.end();
3248 }
3252 const ChildType *const *begin() const
3253 {
3254 return oMP.begin();
3255 }
3257 const ChildType *const *end() const
3258 {
3259 return oMP.end();
3260 }
3261
3262 // IWks Interface.
3263 virtual size_t WkbSize() const override;
3264 virtual const char *getGeometryName() const override;
3265 virtual OGRwkbGeometryType getGeometryType() const override;
3266 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3267 size_t &nBytesConsumedOut) override;
3268 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
3269 OGRwkbVariant = wkbVariantOldOgc) const override;
3270
3271#ifndef DOXYGEN_XML
3273#endif
3274
3275 OGRErr importFromWkt(const char **) override;
3276
3277#ifndef DOXYGEN_XML
3279#endif
3280
3285 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3286 OGRErr *err = nullptr) const override;
3287
3288 // IGeometry methods.
3289 virtual int getDimension() const override;
3290
3291 virtual void empty() override;
3292
3293 virtual OGRPolyhedralSurface *clone() const override;
3294 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
3295 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3296
3297 virtual void flattenTo2D() override;
3298 virtual OGRErr transform(OGRCoordinateTransformation *) override;
3299 virtual OGRBoolean Equals(const OGRGeometry *) const override;
3300 virtual double get_Area() const override;
3301 virtual OGRErr PointOnSurface(OGRPoint *) const override;
3302
3303 static OGRMultiPolygon *CastToMultiPolygon(OGRPolyhedralSurface *poPS);
3304 virtual OGRBoolean
3305 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3306 virtual OGRErr addGeometry(const OGRGeometry *);
3307 OGRErr addGeometryDirectly(OGRGeometry *poNewGeom);
3308 int getNumGeometries() const;
3309 OGRPolygon *getGeometryRef(int i);
3310 const OGRPolygon *getGeometryRef(int i) const;
3311
3312 virtual OGRBoolean IsEmpty() const override;
3313 virtual void setCoordinateDimension(int nDimension) override;
3314 virtual void set3D(OGRBoolean bIs3D) override;
3315 virtual void setMeasured(OGRBoolean bIsMeasured) override;
3316 virtual void swapXY() override;
3317 OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3318
3319 virtual void accept(IOGRGeometryVisitor *visitor) override
3320 {
3321 visitor->visit(this);
3322 }
3323 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3324 {
3325 visitor->visit(this);
3326 }
3327
3328 virtual void assignSpatialReference(OGRSpatialReference *poSR) override;
3329
3330 OGR_ALLOW_CAST_TO_THIS(PolyhedralSurface)
3331 OGR_ALLOW_UPCAST_TO(Surface)
3332};
3333
3335
3336inline const OGRPolyhedralSurface::ChildType *const *
3337begin(const OGRPolyhedralSurface *poGeom)
3338{
3339 return poGeom->begin();
3340}
3342inline const OGRPolyhedralSurface::ChildType *const *
3343end(const OGRPolyhedralSurface *poGeom)
3344{
3345 return poGeom->end();
3346}
3347
3350{
3351 return poGeom->begin();
3352}
3355{
3356 return poGeom->end();
3357}
3359
3360/************************************************************************/
3361/* OGRTriangulatedSurface */
3362/************************************************************************/
3363
3371{
3372 protected:
3374 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3375 virtual const char *getSubGeometryName() const override;
3376 virtual OGRwkbGeometryType getSubGeometryType() const override;
3377
3378 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3379 GetCasterToMultiPolygon() const override;
3380 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3382
3383 public:
3387
3390
3395 {
3396 return reinterpret_cast<ChildType **>(oMP.begin());
3397 }
3400 {
3401 return reinterpret_cast<ChildType **>(oMP.end());
3402 }
3406 const ChildType *const *begin() const
3407 {
3408 return reinterpret_cast<const ChildType *const *>(oMP.begin());
3409 }
3411 const ChildType *const *end() const
3412 {
3413 return reinterpret_cast<const ChildType *const *>(oMP.end());
3414 }
3415
3416 OGRTriangulatedSurface &operator=(const OGRTriangulatedSurface &other);
3417 virtual const char *getGeometryName() const override;
3418 virtual OGRwkbGeometryType getGeometryType() const override;
3419 virtual OGRTriangulatedSurface *clone() const override;
3420
3427 const OGRTriangle *getGeometryRef(int i) const
3428 {
3430 }
3431
3432 // IWks Interface.
3433 virtual OGRErr addGeometry(const OGRGeometry *) override;
3434
3437 {
3438 return this;
3439 }
3442 {
3443 return this;
3444 }
3445
3446 virtual void accept(IOGRGeometryVisitor *visitor) override
3447 {
3448 visitor->visit(this);
3449 }
3450 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3451 {
3452 visitor->visit(this);
3453 }
3454
3455 static OGRPolyhedralSurface *
3456 CastToPolyhedralSurface(OGRTriangulatedSurface *poTS);
3457
3458 OGR_ALLOW_CAST_TO_THIS(TriangulatedSurface)
3459 OGR_ALLOW_UPCAST_TO(PolyhedralSurface)
3460};
3461
3463
3464inline const OGRTriangulatedSurface::ChildType *const *
3465begin(const OGRTriangulatedSurface *poGeom)
3466{
3467 return poGeom->begin();
3468}
3470inline const OGRTriangulatedSurface::ChildType *const *
3471end(const OGRTriangulatedSurface *poGeom)
3472{
3473 return poGeom->end();
3474}
3475
3478{
3479 return poGeom->begin();
3480}
3483{
3484 return poGeom->end();
3485}
3487
3488/************************************************************************/
3489/* OGRMultiPoint */
3490/************************************************************************/
3491
3497{
3498 private:
3499 OGRErr importFromWkt_Bracketed(const char **, int bHasM, int bHasZ);
3500
3501 protected:
3502 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3503
3504 public:
3507 ~OGRMultiPoint() override;
3508
3509 OGRMultiPoint &operator=(const OGRMultiPoint &other);
3510
3513
3518 {
3519 return reinterpret_cast<ChildType **>(papoGeoms);
3520 }
3523 {
3524 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3525 }
3529 const ChildType *const *begin() const
3530 {
3531 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3532 }
3534 const ChildType *const *end() const
3535 {
3536 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3537 nGeomCount);
3538 }
3539
3540 // IGeometryCollection
3547 const OGRPoint *getGeometryRef(int i) const
3548 {
3550 }
3551
3552 // Non-standard (OGRGeometry).
3553 virtual const char *getGeometryName() const override;
3554 virtual OGRwkbGeometryType getGeometryType() const override;
3555 virtual OGRMultiPoint *clone() const override;
3556
3557#ifndef DOXYGEN_XML
3559#endif
3560
3561 OGRErr importFromWkt(const char **) override;
3562
3563#ifndef DOXYGEN_XML
3565#endif
3566
3571 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3572 OGRErr *err = nullptr) const override;
3573
3574 // IGeometry methods.
3575 virtual int getDimension() const override;
3576
3579 {
3580 return this;
3581 }
3584 {
3585 return this;
3586 }
3587
3588 virtual void accept(IOGRGeometryVisitor *visitor) override
3589 {
3590 visitor->visit(this);
3591 }
3592 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3593 {
3594 visitor->visit(this);
3595 }
3596
3597 // Non-standard.
3598 virtual OGRBoolean
3599 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3600
3601 OGR_ALLOW_CAST_TO_THIS(MultiPoint)
3602 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3603 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3604 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3605 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3606 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3607};
3608
3610
3611inline const OGRMultiPoint::ChildType *const *begin(const OGRMultiPoint *poGeom)
3612{
3613 return poGeom->begin();
3614}
3616inline const OGRMultiPoint::ChildType *const *end(const OGRMultiPoint *poGeom)
3617{
3618 return poGeom->end();
3619}
3620
3623{
3624 return poGeom->begin();
3625}
3628{
3629 return poGeom->end();
3630}
3632
3633/************************************************************************/
3634/* OGRMultiCurve */
3635/************************************************************************/
3636
3644{
3645 protected:
3647 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
3648 OGRCurve *poCurve);
3650 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3651
3652 public:
3655 ~OGRMultiCurve() override;
3656
3657 OGRMultiCurve &operator=(const OGRMultiCurve &other);
3658
3661
3666 {
3667 return reinterpret_cast<ChildType **>(papoGeoms);
3668 }
3671 {
3672 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3673 }
3677 const ChildType *const *begin() const
3678 {
3679 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3680 }
3682 const ChildType *const *end() const
3683 {
3684 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3685 nGeomCount);
3686 }
3687
3688 // IGeometryCollection
3695 const OGRCurve *getGeometryRef(int i) const
3696 {
3698 }
3699
3700 // Non standard (OGRGeometry).
3701 virtual const char *getGeometryName() const override;
3702 virtual OGRwkbGeometryType getGeometryType() const override;
3703 virtual OGRMultiCurve *clone() const override;
3704
3705#ifndef DOXYGEN_XML
3707#endif
3708
3709 OGRErr importFromWkt(const char **) override;
3710
3711#ifndef DOXYGEN_XML
3713#endif
3714
3719 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3720 OGRErr *err = nullptr) const override;
3721
3722 // IGeometry methods.
3723 virtual int getDimension() const override;
3724
3725 // Non-standard.
3726 virtual OGRBoolean
3727 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3728
3731 {
3732 return this;
3733 }
3736 {
3737 return this;
3738 }
3739
3740 virtual void accept(IOGRGeometryVisitor *visitor) override
3741 {
3742 visitor->visit(this);
3743 }
3744 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3745 {
3746 visitor->visit(this);
3747 }
3748
3749 static OGRMultiLineString *CastToMultiLineString(OGRMultiCurve *poMC);
3750
3751 OGR_ALLOW_CAST_TO_THIS(MultiCurve)
3752 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3753 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3754 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3755 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3756};
3757
3759
3760inline const OGRMultiCurve::ChildType *const *begin(const OGRMultiCurve *poGeom)
3761{
3762 return poGeom->begin();
3763}
3765inline const OGRMultiCurve::ChildType *const *end(const OGRMultiCurve *poGeom)
3766{
3767 return poGeom->end();
3768}
3769
3772{
3773 return poGeom->begin();
3774}
3777{
3778 return poGeom->end();
3779}
3781
3782/************************************************************************/
3783/* OGRMultiLineString */
3784/************************************************************************/
3785
3790class CPL_DLL OGRMultiLineString : public OGRMultiCurve
3791{
3792 protected:
3793 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3794
3795 public:
3798 ~OGRMultiLineString() override;
3799
3800 OGRMultiLineString &operator=(const OGRMultiLineString &other);
3801
3804
3809 {
3810 return reinterpret_cast<ChildType **>(papoGeoms);
3811 }
3814 {
3815 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3816 }
3820 const ChildType *const *begin() const
3821 {
3822 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3823 }
3825 const ChildType *const *end() const
3826 {
3827 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3828 nGeomCount);
3829 }
3830
3831 // IGeometryCollection
3838 const OGRLineString *getGeometryRef(int i) const
3839 {
3841 }
3842
3843 // Non standard (OGRGeometry).
3844 virtual const char *getGeometryName() const override;
3845 virtual OGRwkbGeometryType getGeometryType() const override;
3846 virtual OGRMultiLineString *clone() const override;
3847
3848#ifndef DOXYGEN_XML
3850#endif
3851
3856 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3857 OGRErr *err = nullptr) const override;
3858
3859 // Non standard
3860 virtual OGRBoolean
3861 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3862
3865 {
3866 return this;
3867 }
3870 {
3871 return this;
3872 }
3873
3874 virtual void accept(IOGRGeometryVisitor *visitor) override
3875 {
3876 visitor->visit(this);
3877 }
3878 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3879 {
3880 visitor->visit(this);
3881 }
3882
3883 static OGRMultiCurve *CastToMultiCurve(OGRMultiLineString *poMLS);
3884
3885 OGR_ALLOW_CAST_TO_THIS(MultiLineString)
3886 OGR_ALLOW_UPCAST_TO(MultiCurve)
3887 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3888 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3889 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3890};
3891
3893
3894inline const OGRMultiLineString::ChildType *const *
3895begin(const OGRMultiLineString *poGeom)
3896{
3897 return poGeom->begin();
3898}
3900inline const OGRMultiLineString::ChildType *const *
3901end(const OGRMultiLineString *poGeom)
3902{
3903 return poGeom->end();
3904}
3905
3908{
3909 return poGeom->begin();
3910}
3913{
3914 return poGeom->end();
3915}
3917
3918/************************************************************************/
3919/* OGRGeometryFactory */
3920/************************************************************************/
3921
3927{
3928 static OGRErr createFromFgfInternal(const unsigned char *pabyData,
3929 OGRSpatialReference *poSR,
3930 OGRGeometry **ppoReturn, int nBytes,
3931 int *pnBytesConsumed, int nRecLevel);
3932
3933 public:
3934 static OGRErr createFromWkb(const void *, OGRSpatialReference *,
3935 OGRGeometry **,
3936 size_t = static_cast<size_t>(-1),
3938 static OGRErr createFromWkb(const void *pabyData, OGRSpatialReference *,
3939 OGRGeometry **, size_t nSize,
3940 OGRwkbVariant eVariant,
3941 size_t &nBytesConsumedOut);
3942 static OGRErr createFromWkt(const char *, OGRSpatialReference *,
3943 OGRGeometry **);
3944 static OGRErr createFromWkt(const char **, OGRSpatialReference *,
3945 OGRGeometry **);
3949 static OGRErr createFromWkt(char **ppszInput, OGRSpatialReference *poSRS,
3950 OGRGeometry **ppoGeom)
3951 CPL_WARN_DEPRECATED("Use createFromWkt(const char**, ...) instead")
3952 {
3953 return createFromWkt(const_cast<const char **>(ppszInput), poSRS,
3954 ppoGeom);
3955 }
3956
3957 static OGRErr createFromFgf(const void *, OGRSpatialReference *,
3958 OGRGeometry **, int = -1, int * = nullptr);
3959 static OGRGeometry *createFromGML(const char *);
3960 static OGRGeometry *createFromGEOS(GEOSContextHandle_t hGEOSCtxt, GEOSGeom);
3961 static OGRGeometry *createFromGeoJson(const char *, int = -1);
3962 static OGRGeometry *createFromGeoJson(const CPLJSONObject &oJSONObject);
3963
3964 static void destroyGeometry(OGRGeometry *);
3965 static OGRGeometry *createGeometry(OGRwkbGeometryType);
3966
3967 static OGRGeometry *forceToPolygon(OGRGeometry *);
3968 static OGRGeometry *forceToLineString(OGRGeometry *,
3969 bool bOnlyInOrder = true);
3970 static OGRGeometry *forceToMultiPolygon(OGRGeometry *);
3971 static OGRGeometry *forceToMultiPoint(OGRGeometry *);
3972 static OGRGeometry *forceToMultiLineString(OGRGeometry *);
3973
3974 static OGRGeometry *forceTo(OGRGeometry *poGeom,
3975 OGRwkbGeometryType eTargetType,
3976 const char *const *papszOptions = nullptr);
3977
3978 static OGRGeometry *removeLowerDimensionSubGeoms(const OGRGeometry *poGeom);
3979
3980 static OGRGeometry *organizePolygons(OGRGeometry **papoPolygons,
3981 int nPolygonCount,
3982 int *pbResultValidGeometry,
3983 const char **papszOptions = nullptr);
3984 static bool haveGEOS();
3985
3988 {
3989 friend class OGRGeometryFactory;
3990 struct Private;
3991 std::unique_ptr<Private> d;
3992
3993 public:
3996 };
3997
3998 static OGRGeometry *transformWithOptions(
3999 const OGRGeometry *poSrcGeom, OGRCoordinateTransformation *poCT,
4000 char **papszOptions,
4002
4003 static OGRGeometry *
4004 approximateArcAngles(double dfX, double dfY, double dfZ,
4005 double dfPrimaryRadius, double dfSecondaryAxis,
4006 double dfRotation, double dfStartAngle,
4007 double dfEndAngle, double dfMaxAngleStepSizeDegrees,
4008 const bool bUseMaxGap = false);
4009
4010 static int GetCurveParameters(double x0, double y0, double x1, double y1,
4011 double x2, double y2, double &R, double &cx,
4012 double &cy, double &alpha0, double &alpha1,
4013 double &alpha2);
4014 static OGRLineString *
4015 curveToLineString(double x0, double y0, double z0, double x1, double y1,
4016 double z1, double x2, double y2, double z2, int bHasZ,
4017 double dfMaxAngleStepSizeDegrees,
4018 const char *const *papszOptions = nullptr);
4019 static OGRCurve *
4020 curveFromLineString(const OGRLineString *poLS,
4021 const char *const *papszOptions = nullptr);
4022};
4023
4024OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType(const char *pszGeomType);
4025const char CPL_DLL *OGRToOGCGeomType(OGRwkbGeometryType eGeomType);
4026
4028typedef struct _OGRPreparedGeometry OGRPreparedGeometry;
4029
4030struct CPL_DLL OGRPreparedGeometryUniquePtrDeleter
4031{
4032 void operator()(OGRPreparedGeometry *) const;
4033};
4035
4039typedef std::unique_ptr<OGRPreparedGeometry,
4040 OGRPreparedGeometryUniquePtrDeleter>
4042
4043#endif /* ndef OGR_GEOMETRY_H_INCLUDED */
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition cpl_json.h:54
OGRGeometry visitor interface.
Definition ogr_geometry.h:239
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:164
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:1856
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1936
OGRCircularString()
Create an empty circular string.
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1931
OGRCircularString(const OGRCircularString &other)
Copy constructor.
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:1926
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1940
Utility class to store a collection of curves.
Definition ogr_geometry.h:2069
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2210
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:2126
const ChildType *const * begin() const
Return begin of curve iterator.
Definition ogr_geometry.h:2121
OGRCompoundCurve(const OGRCompoundCurve &other)
Copy constructor.
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:2104
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:2114
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:2109
OGRCompoundCurve()
Create an empty compound curve.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2206
Interface for transforming between coordinate systems.
Definition ogr_spatialref.h:750
Concrete class representing curve polygons.
Definition ogr_geometry.h:2301
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2439
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:2336
OGRCurvePolygon()
Create an empty curve polygon.
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:2358
const ChildType *const * begin() const
Return begin of curve iterator.
Definition ogr_geometry.h:2353
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:2341
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:2346
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2443
OGRCurvePolygon(const OGRCurvePolygon &)
Copy constructor.
Abstract curve base class for OGRLineString, OGRCircularString and OGRCompoundCurve.
Definition ogr_geometry.h:1252
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:1341
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:1295
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:1333
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_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 OGRCurve * clone() const override=0
Make a copy of this object.
OGRGeometry visitor default implementation.
Definition ogr_geometry.h:286
void visit(const OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:290
OGRGeometry visitor default implementation.
Definition ogr_geometry.h:211
void visit(OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:215
Simple container for a bounding region in 3D.
Definition ogr_core.h:213
Simple container for a bounding region (rectangle)
Definition ogr_core.h:58
A collection of 1 or more geometry objects.
Definition ogr_geometry.h:2735
ChildType ** end()
Return end of sub-geometry iterator.
Definition ogr_geometry.h:2773
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2861
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2865
const ChildType *const * begin() const
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:2780
const ChildType *const * end() const
Return end of sub-geometry iterator.
Definition ogr_geometry.h:2785
ChildType ** begin()
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:2768
OGRGeometry * getGeometryRef(int)
Fetch geometry from container.
Definition ogrgeometrycollection.cpp:259
OGRGeometryCollection()
Create an empty geometry collection.
OGRGeometry ChildType
Type of child elements.
Definition ogr_geometry.h:2763
Opaque class used as argument to transformWithOptions()
Definition ogr_geometry.h:3988
Create geometry objects from well known text/binary.
Definition ogr_geometry.h:3927
static OGRErr createFromWkt(char **ppszInput, OGRSpatialReference *poSRS, OGRGeometry **ppoGeom)
Deprecated.
Definition ogr_geometry.h:3949
Abstract base class for all geometry classes.
Definition ogr_geometry.h:335
const OGRSurface * toSurface() const
Down-cast to OGRSurface*.
Definition ogr_geometry.h:748
const OGRCurvePolygon * toCurvePolygon() const
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:806
const OGRMultiCurve * toMultiCurve() const
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:906
const OGRPolyhedralSurface * toPolyhedralSurface() const
Down-cast to OGRPolyhedralSurface*.
Definition ogr_geometry.h:946
const OGRMultiPoint * toMultiPoint() const
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:846
virtual void empty()=0
Clear geometry information.
const OGRMultiPolygon * toMultiPolygon() const
Down-cast to OGRMultiPolygon*.
Definition ogr_geometry.h:886
virtual OGRBoolean Equals(const OGRGeometry *) const =0
Returns TRUE if two geometries are equivalent.
OGRPolyhedralSurface * toPolyhedralSurface()
Down-cast to OGRPolyhedralSurface*.
Definition ogr_geometry.h:936
const OGRMultiSurface * toMultiSurface() const
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:926
OGRPoint * toPoint()
Down-cast to OGRPoint*.
Definition ogr_geometry.h:601
bool operator!=(const OGRGeometry &other) const
Returns if two geometries are different.
Definition ogr_geometry.h:395
OGRTriangle * toTriangle()
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:777
OGRLineString * toLineString()
Down-cast to OGRLineString*.
Definition ogr_geometry.h:660
const OGRLinearRing * toLinearRing() const
Down-cast to OGRLinearRing*.
Definition ogr_geometry.h:688
const OGRPoint * toPoint() const
Down-cast to OGRPoint*.
Definition ogr_geometry.h:610
OGRMultiLineString * toMultiLineString()
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:856
OGRMultiSurface * toMultiSurface()
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:916
static OGRGeometry * FromHandle(OGRGeometryH hGeom)
Convert a OGRGeometryH to a OGRGeometry*.
Definition ogr_geometry.h:592
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:826
const OGRMultiLineString * toMultiLineString() const
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:866
const OGRCircularString * toCircularString() const
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:708
OGRPolygon * toPolygon()
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:758
bool operator==(const OGRGeometry &other) const
Returns if two geometries are equal.
Definition ogr_geometry.h:389
OGRLinearRing * toLinearRing()
Down-cast to OGRLinearRing*.
Definition ogr_geometry.h:679
OGRBoolean IsMeasured() const
Definition ogr_geometry.h:415
virtual void accept(IOGRGeometryVisitor *visitor)=0
Accept a visitor.
OGRMultiCurve * toMultiCurve()
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:896
const OGRCompoundCurve * toCompoundCurve() const
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:728
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:816
virtual const char * getGeometryName() const =0
Fetch WKT name for geometry type.
OGRMultiPolygon * toMultiPolygon()
Down-cast to OGRMultiPolygon*.
Definition ogr_geometry.h:876
const OGRPolygon * toPolygon() const
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:768
OGRCompoundCurve * toCompoundCurve()
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:718
OGRErr importFromWkt(char **ppszInput)
Deprecated.
Definition ogr_geometry.h:439
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:670
OGRErr exportToWkt(char **ppszDstText, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known text format.
Definition ogrgeometry.cpp:1816
OGRCircularString * toCircularString()
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:698
const OGRCurve * toCurve() const
Down-cast to OGRCurve*.
Definition ogr_geometry.h:630
OGRCurvePolygon * toCurvePolygon()
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:796
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:650
static OGRGeometryH ToHandle(OGRGeometry *poGeom)
Convert a OGRGeometry* to a OGRGeometryH.
Definition ogr_geometry.h:584
OGRBoolean Is3D() const
Definition ogr_geometry.h:410
OGRMultiPoint * toMultiPoint()
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:836
const OGRTriangulatedSurface * toTriangulatedSurface() const
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:964
const OGRTriangle * toTriangle() const
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:786
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:738
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:640
OGRTriangulatedSurface * toTriangulatedSurface()
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:955
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:620
Definition ogr_geometry.h:1395
Concrete representation of a multi-vertex line.
Definition ogr_geometry.h:1679
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:1717
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1731
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1727
OGRLineString(const OGRLineString &other)
Copy constructor.
virtual int isClockwise() const override
Returns TRUE if the ring has clockwise winding (or less than 2 points)
OGRLineString()
Create an empty line string.
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:1722
Concrete representation of a closed ring.
Definition ogr_geometry.h:1765
OGRLineString * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:1816
const OGRLineString * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1821
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1830
OGRLinearRing(const OGRLinearRing &other)
Copy constructor.
OGRLinearRing()
Constructor.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1826
A collection of OGRCurve.
Definition ogr_geometry.h:3644
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3677
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3682
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3744
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3670
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3735
const OGRCurve * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3695
OGRCurve * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3690
OGRMultiCurve()
Create an empty multi curve collection.
OGRMultiCurve(const OGRMultiCurve &other)
Copy constructor.
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:3660
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3665
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3730
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3740
A collection of OGRLineString.
Definition ogr_geometry.h:3791
OGRLineString ChildType
Type of child elements.
Definition ogr_geometry.h:3803
OGRLineString * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3833
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3864
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3813
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3825
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3878
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3820
OGRMultiLineString()
Create an empty multi line string collection.
const OGRLineString * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3838
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3874
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3808
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3869
OGRMultiLineString(const OGRMultiLineString &other)
Copy constructor.
A collection of OGRPoint.
Definition ogr_geometry.h:3497
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3578
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3588
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3534
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3517
OGRMultiPoint()
Create an empty multi point collection.
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3592
OGRMultiPoint(const OGRMultiPoint &other)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3529
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3583
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:3512
const OGRPoint * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3547
OGRPoint * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3542
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3522
A collection of non-overlapping OGRPolygon.
Definition ogr_geometry.h:3064
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:3086
OGRMultiPolygon(const OGRMultiPolygon &other)
Copy constructor.
OGRPolygon * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3116
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3161
const OGRPolygon * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3121
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3108
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3096
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3157
OGRMultiPolygon()
Create an empty multi polygon collection.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3091
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3147
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3103
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3152
A collection of non-overlapping OGRSurface.
Definition ogr_geometry.h:2916
OGRMultiSurface()
Create an empty multi surface collection.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3011
const OGRSurface * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:2991
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2933
OGRSurface ChildType
Type of child elements.
Definition ogr_geometry.h:2928
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3006
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2945
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2950
OGRMultiSurface(const OGRMultiSurface &other)
Copy constructor.
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2938
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3015
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3001
OGRSurface * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:2986
Interface for a point iterator.
Definition ogr_geometry.h:1234
virtual OGRBoolean getNextPoint(OGRPoint *p)=0
Returns the next point followed by the iterator.
Point class.
Definition ogr_geometry.h:1081
double getM() const
Return m.
Definition ogr_geometry.h:1150
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1206
void setX(double xIn)
Set x.
Definition ogr_geometry.h:1160
OGRPoint(const OGRPoint &other)
Copy constructor.
void setZ(double zIn)
Set z.
Definition ogr_geometry.h:1182
void setM(double mIn)
Set m.
Definition ogr_geometry.h:1190
double getX() const
Return x.
Definition ogr_geometry.h:1135
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1210
void setY(double yIn)
Set y.
Definition ogr_geometry.h:1171
virtual OGRBoolean IsEmpty() const override
Returns TRUE (non-zero) if the object has no points.
Definition ogr_geometry.h:1128
double getZ() const
Return z.
Definition ogr_geometry.h:1145
double getY() const
Return y.
Definition ogr_geometry.h:1140
Concrete class representing polygons.
Definition ogr_geometry.h:2494
OGRLinearRing ChildType
Type of child elements.
Definition ogr_geometry.h:2523
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2528
const OGRCurvePolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2607
OGRPolygon()
Create an empty polygon.
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2533
OGRPolygon(const OGRPolygon &other)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2540
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2616
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2545
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2612
OGRCurvePolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2602
PolyhedralSurface class.
Definition ogr_geometry.h:3209
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3245
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3257
OGRPolygon * getGeometryRef(int i)
Fetch geometry from container.
Definition ogrpolyhedralsurface.cpp:816
OGRPolyhedralSurface(const OGRPolyhedralSurface &poGeom)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3252
~OGRPolyhedralSurface() override
Destructor.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3240
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3319
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:3235
OGRPolyhedralSurface()
Create an empty PolyhedralSurface.
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3323
Simple container for a position.
Definition ogr_geometry.h:105
OGRRawPoint(double xIn, double yIn)
Constructor.
Definition ogr_geometry.h:113
double x
x
Definition ogr_geometry.h:118
double y
y
Definition ogr_geometry.h:120
OGRRawPoint()
Constructor.
Definition ogr_geometry.h:108
Abstract curve base class for OGRLineString and OGRCircularString.
Definition ogr_geometry.h:1439
double getY(int i) const
Get Y at vertex.
Definition ogr_geometry.h:1583
double getX(int i) const
Get X at vertex.
Definition ogr_geometry.h:1579
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:1509
virtual OGRSimpleCurve * clone() const override=0
Make a copy of this object.
virtual int getNumPoints() const override
Fetch vertex count.
Definition ogr_geometry.h:1574
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:167
Abstract base class for 2 dimensional objects like polygons or curve polygons.
Definition ogr_geometry.h:2257
virtual double get_Area() const =0
Get the area of the surface object.
virtual OGRSurface * clone() const override=0
Make a copy of this object.
virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
This method relates to the SFCOM ISurface::get_PointOnSurface() method.
Definition ogr_geometry.h:2266
Triangle class.
Definition ogr_geometry.h:2662
const OGRPolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2701
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2706
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2710
OGRTriangle()
Constructor.
~OGRTriangle() override
Destructor.
OGRPolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2696
OGRTriangle(const OGRTriangle &other)
Copy constructor.
TriangulatedSurface class.
Definition ogr_geometry.h:3371
const OGRTriangle * getGeometryRef(int i) const
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:3427
~OGRTriangulatedSurface()
Destructor.
OGRTriangle * getGeometryRef(int i)
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:3422
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3411
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3406
OGRPolyhedralSurface * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3436
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3446
const OGRPolyhedralSurface * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3441
OGRTriangle ChildType
Type of child elements.
Definition ogr_geometry.h:3389
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3450
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3394
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3399
OGRTriangulatedSurface()
Constructor.
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:1049
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1190
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition cpl_port.h:983
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:205
void * OGRGeometryH
Opaque type for a geometry.
Definition ogr_api.h:66
Core portability services for cross-platform OGR code.
int OGRBoolean
Type for a OGR boolean.
Definition ogr_core.h:395
OGRwkbByteOrder
Enumeration to describe byte order.
Definition ogr_core.h:611
OGRwkbVariant
Output variants of WKB we support.
Definition ogr_core.h:541
@ wkbVariantOldOgc
Old-style 99-402 extended dimension (Z) WKB types.
Definition ogr_core.h:542
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:407
int OGRErr
Type for a OGR error.
Definition ogr_core.h:378
OGRWktFormat
WKT Output formatting options.
Definition ogr_geometry.h:62
@ 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:4041
struct GEOSContextHandle_HS * GEOSContextHandle_t
GEOS context handle type.
Definition ogr_geometry.h:126
OGRwkbGeometryType OGRFromOGCGeomType(const char *pszGeomType)
Map OGCgeometry format type to corresponding OGR constants.
Definition ogrgeometry.cpp:2379
const char * OGRToOGCGeomType(OGRwkbGeometryType eGeomType)
Map OGR geometry format constants to corresponding OGC geometry type.
Definition ogrgeometry.cpp:2452
std::unique_ptr< OGRGeometry, OGRGeometryUniquePtrDeleter > OGRGeometryUniquePtr
Unique pointer type for OGRGeometry.
Definition ogr_geometry.h:981
struct GEOSGeom_t * GEOSGeom
GEOS geometry type.
Definition ogr_geometry.h:124
void sfcgal_geometry_t
SFCGAL geometry type.
Definition ogr_geometry.h:128
Coordinate systems services.
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition ogrsf_frmts.h:345
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition ogrsf_frmts.h:353
Options for formatting WKT output.
Definition ogr_geometry.h:70
OGRwkbVariant variant
Type of WKT output to produce.
Definition ogr_geometry.h:73
OGRWktOptions()
Constructor.
Definition ogr_geometry.h:82
OGRWktOptions(const OGRWktOptions &)=default
Copy constructor.
bool round
Whether GDAL-special rounding should be applied.
Definition ogr_geometry.h:77
int precision
Precision of output. Interpretation depends on format.
Definition ogr_geometry.h:75
OGRWktFormat format
Formatting type.
Definition ogr_geometry.h:79