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
53 typedef struct OGRGeometryHS *OGRGeometryH;
54 #else
55 typedef void *OGRGeometryH;
56 #endif
57 #endif /* DEFINEH_OGRGeometryH */
58
60 enum class OGRWktFormat
62 {
63 F,
64 G,
65 Default
66 };
67
69 struct CPL_DLL OGRWktOptions
70 {
71 public:
73 OGRwkbVariant variant;
75 int precision;
77 bool round;
79 OGRWktFormat format;
80
82 OGRWktOptions()
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
104 class OGRRawPoint
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
124 typedef struct GEOSGeom_t *GEOSGeom;
126 typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
128 typedef void sfcgal_geometry_t;
129
130 class OGRPoint;
131 class OGRCurve;
132 class OGRCompoundCurve;
133 class OGRSimpleCurve;
134 class OGRLinearRing;
135 class OGRLineString;
136 class OGRCircularString;
137 class OGRSurface;
138 class OGRCurvePolygon;
139 class OGRPolygon;
140 class OGRMultiPoint;
141 class OGRMultiSurface;
142 class OGRMultiPolygon;
143 class OGRMultiCurve;
144 class OGRMultiLineString;
145 class OGRGeometryCollection;
146 class OGRTriangle;
147 class OGRPolyhedralSurface;
148 class OGRTriangulatedSurface;
149
151 typedef OGRLineString *(*OGRCurveCasterToLineString)(OGRCurve *);
152 typedef OGRLinearRing *(*OGRCurveCasterToLinearRing)(OGRCurve *);
153
154 typedef OGRPolygon *(*OGRSurfaceCasterToPolygon)(OGRSurface *);
155 typedef OGRCurvePolygon *(*OGRSurfaceCasterToCurvePolygon)(OGRSurface *);
156 typedef OGRMultiPolygon *(*OGRPolyhedralSurfaceCastToMultiPolygon)(
157 OGRPolyhedralSurface *);
159
163 class CPL_DLL IOGRGeometryVisitor
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
210 class CPL_DLL OGRDefaultGeometryVisitor : public IOGRGeometryVisitor
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
238 class CPL_DLL IOGRConstGeometryVisitor
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
285 class CPL_DLL OGRDefaultConstGeometryVisitor : public IOGRConstGeometryVisitor
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
334 class CPL_DLL OGRGeometry
335 {
336 private:
337 const 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;
410 OGRBoolean Is3D() const
411 {
412 return (flags & OGR_G_3D) != 0;
413 }
415 OGRBoolean IsMeasured() const
416 {
417 return (flags & OGR_G_MEASURED) != 0;
418 }
419 virtual OGRBoolean IsRing() const;
420 virtual void empty() = 0;
421 virtual OGRGeometry *clone() const CPL_WARN_UNUSED_RESULT = 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),
428 OGRwkbVariant = wkbVariantOldOgc);
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
436
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,
449 OGRwkbVariant = wkbVariantOldOgc) const;
450
455 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
456 OGRErr *err = nullptr) const = 0;
457
458 // Non-standard.
459 virtual OGRwkbGeometryType getGeometryType() const = 0;
460 OGRwkbGeometryType getIsoGeometryType() const;
461 virtual const char *getGeometryName() const = 0;
462 void dumpReadable(FILE *, const char * = nullptr,
463 CSLConstList papszOptions = nullptr) const;
464 std::string dumpReadable(const char * = nullptr,
465 CSLConstList papszOptions = nullptr) const;
466 virtual void flattenTo2D() = 0;
467 virtual char *exportToGML(const char *const *papszOptions = nullptr) const;
468 virtual char *exportToKML() const;
469 virtual char *exportToJson() const;
470
472 virtual void accept(IOGRGeometryVisitor *visitor) = 0;
473
475 virtual void accept(IOGRConstGeometryVisitor *visitor) const = 0;
476
477 static GEOSContextHandle_t createGEOSContext();
478 static void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt);
479 virtual GEOSGeom
480 exportToGEOS(GEOSContextHandle_t hGEOSCtxt) const CPL_WARN_UNUSED_RESULT;
481 virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
482 virtual OGRGeometry *getCurveGeometry(
483 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
484 virtual OGRGeometry *getLinearGeometry(
485 double dfMaxAngleStepSizeDegrees = 0,
486 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
487
488 // SFCGAL interfacing methods.
490 static sfcgal_geometry_t *OGRexportToSFCGAL(const OGRGeometry *poGeom);
491 static OGRGeometry *SFCGALexportToOGR(const sfcgal_geometry_t *_geometry);
493 virtual void closeRings();
494
495 virtual void setCoordinateDimension(int nDimension);
496 virtual void set3D(OGRBoolean bIs3D);
497 virtual void setMeasured(OGRBoolean bIsMeasured);
498
499 virtual void assignSpatialReference(const OGRSpatialReference *poSR);
500 const OGRSpatialReference *getSpatialReference(void) const
501 {
502 return poSRS;
503 }
504
505 virtual OGRErr transform(OGRCoordinateTransformation *poCT) = 0;
506 OGRErr transformTo(const OGRSpatialReference *poSR);
507
508 virtual void segmentize(double dfMaxLength);
509
510 // ISpatialRelation
511 virtual OGRBoolean Intersects(const OGRGeometry *) const;
512 virtual OGRBoolean Equals(const OGRGeometry *) const = 0;
513 virtual OGRBoolean Disjoint(const OGRGeometry *) const;
514 virtual OGRBoolean Touches(const OGRGeometry *) const;
515 virtual OGRBoolean Crosses(const OGRGeometry *) const;
516 virtual OGRBoolean Within(const OGRGeometry *) const;
517 virtual OGRBoolean Contains(const OGRGeometry *) const;
518 virtual OGRBoolean Overlaps(const OGRGeometry *) const;
519 // virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
520 // virtual OGRGeometry *LocateAlong( double mValue ) const;
521 // virtual OGRGeometry *LocateBetween( double mStart, double mEnd )
522 // const;
523
524 virtual OGRGeometry *Boundary() const CPL_WARN_UNUSED_RESULT;
525 virtual double Distance(const OGRGeometry *) const;
526 virtual OGRGeometry *ConvexHull() const CPL_WARN_UNUSED_RESULT;
527 virtual OGRGeometry *
528 ConcaveHull(double dfRatio, bool bAllowHoles) const CPL_WARN_UNUSED_RESULT;
529 virtual OGRGeometry *
530 Buffer(double dfDist, int nQuadSegs = 30) const CPL_WARN_UNUSED_RESULT;
531 virtual OGRGeometry *
532 Intersection(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
533 virtual OGRGeometry *
534 Union(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
535 virtual OGRGeometry *UnionCascaded() const CPL_WARN_UNUSED_RESULT;
536 OGRGeometry *UnaryUnion() const CPL_WARN_UNUSED_RESULT;
537 virtual OGRGeometry *
538 Difference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
539 virtual OGRGeometry *
540 SymDifference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
541 virtual OGRErr Centroid(OGRPoint *poPoint) const;
542 virtual OGRGeometry *
543 Simplify(double dTolerance) const CPL_WARN_UNUSED_RESULT;
544 OGRGeometry *
545 SimplifyPreserveTopology(double dTolerance) const CPL_WARN_UNUSED_RESULT;
546 virtual OGRGeometry *
547 DelaunayTriangulation(double dfTolerance,
548 int bOnlyEdges) const CPL_WARN_UNUSED_RESULT;
549
550 virtual OGRGeometry *Polygonize() const CPL_WARN_UNUSED_RESULT;
551
552 virtual double Distance3D(const OGRGeometry *poOtherGeom) const;
553
555 // backward compatibility to non-standard method names.
556 OGRBoolean Intersect(OGRGeometry *) const
557 CPL_WARN_DEPRECATED("Non standard method. "
558 "Use Intersects() instead");
559 OGRBoolean Equal(OGRGeometry *) const
560 CPL_WARN_DEPRECATED("Non standard method. "
561 "Use Equals() instead");
562 OGRGeometry *SymmetricDifference(const OGRGeometry *) const
563 CPL_WARN_DEPRECATED("Non standard method. "
564 "Use SymDifference() instead");
565 OGRGeometry *getBoundary() const
566 CPL_WARN_DEPRECATED("Non standard method. "
567 "Use Boundary() instead");
569
571 // Special HACK for DB2 7.2 support
572 static int bGenerate_DB2_V72_BYTE_ORDER;
574
575 virtual void swapXY();
577 static OGRGeometry *CastToIdentity(OGRGeometry *poGeom)
578 {
579 return poGeom;
580 }
581 static OGRGeometry *CastToError(OGRGeometry *poGeom);
583
587 static inline OGRGeometryH ToHandle(OGRGeometry *poGeom)
588 {
589 return reinterpret_cast<OGRGeometryH>(poGeom);
590 }
591
595 static inline OGRGeometry *FromHandle(OGRGeometryH hGeom)
596 {
597 return reinterpret_cast<OGRGeometry *>(hGeom);
598 }
599
604 inline OGRPoint *toPoint()
605 {
606 return cpl::down_cast<OGRPoint *>(this);
607 }
608
613 inline const OGRPoint *toPoint() const
614 {
615 return cpl::down_cast<const OGRPoint *>(this);
616 }
617
623 inline OGRCurve *toCurve()
624 {
625 return cpl::down_cast<OGRCurve *>(this);
626 }
627
633 inline const OGRCurve *toCurve() const
634 {
635 return cpl::down_cast<const OGRCurve *>(this);
636 }
637
643 inline OGRSimpleCurve *toSimpleCurve()
644 {
645 return cpl::down_cast<OGRSimpleCurve *>(this);
646 }
647
653 inline const OGRSimpleCurve *toSimpleCurve() const
654 {
655 return cpl::down_cast<const OGRSimpleCurve *>(this);
656 }
657
663 inline OGRLineString *toLineString()
664 {
665 return cpl::down_cast<OGRLineString *>(this);
666 }
667
673 inline const OGRLineString *toLineString() const
674 {
675 return cpl::down_cast<const OGRLineString *>(this);
676 }
677
682 inline OGRLinearRing *toLinearRing()
683 {
684 return cpl::down_cast<OGRLinearRing *>(this);
685 }
686
691 inline const OGRLinearRing *toLinearRing() const
692 {
693 return cpl::down_cast<const OGRLinearRing *>(this);
694 }
695
701 inline OGRCircularString *toCircularString()
702 {
703 return cpl::down_cast<OGRCircularString *>(this);
704 }
705
711 inline const OGRCircularString *toCircularString() const
712 {
713 return cpl::down_cast<const OGRCircularString *>(this);
714 }
715
721 inline OGRCompoundCurve *toCompoundCurve()
722 {
723 return cpl::down_cast<OGRCompoundCurve *>(this);
724 }
725
731 inline const OGRCompoundCurve *toCompoundCurve() const
732 {
733 return cpl::down_cast<const OGRCompoundCurve *>(this);
734 }
735
741 inline OGRSurface *toSurface()
742 {
743 return cpl::down_cast<OGRSurface *>(this);
744 }
745
751 inline const OGRSurface *toSurface() const
752 {
753 return cpl::down_cast<const OGRSurface *>(this);
754 }
755
761 inline OGRPolygon *toPolygon()
762 {
763 return cpl::down_cast<OGRPolygon *>(this);
764 }
765
771 inline const OGRPolygon *toPolygon() const
772 {
773 return cpl::down_cast<const OGRPolygon *>(this);
774 }
775
780 inline OGRTriangle *toTriangle()
781 {
782 return cpl::down_cast<OGRTriangle *>(this);
783 }
784
789 inline const OGRTriangle *toTriangle() const
790 {
791 return cpl::down_cast<const OGRTriangle *>(this);
792 }
793
799 inline OGRCurvePolygon *toCurvePolygon()
800 {
801 return cpl::down_cast<OGRCurvePolygon *>(this);
802 }
803
809 inline const OGRCurvePolygon *toCurvePolygon() const
810 {
811 return cpl::down_cast<const OGRCurvePolygon *>(this);
812 }
813
819 inline OGRGeometryCollection *toGeometryCollection()
820 {
821 return cpl::down_cast<OGRGeometryCollection *>(this);
822 }
823
829 inline const OGRGeometryCollection *toGeometryCollection() const
830 {
831 return cpl::down_cast<const OGRGeometryCollection *>(this);
832 }
833
839 inline OGRMultiPoint *toMultiPoint()
840 {
841 return cpl::down_cast<OGRMultiPoint *>(this);
842 }
843
849 inline const OGRMultiPoint *toMultiPoint() const
850 {
851 return cpl::down_cast<const OGRMultiPoint *>(this);
852 }
853
859 inline OGRMultiLineString *toMultiLineString()
860 {
861 return cpl::down_cast<OGRMultiLineString *>(this);
862 }
863
869 inline const OGRMultiLineString *toMultiLineString() const
870 {
871 return cpl::down_cast<const OGRMultiLineString *>(this);
872 }
873
879 inline OGRMultiPolygon *toMultiPolygon()
880 {
881 return cpl::down_cast<OGRMultiPolygon *>(this);
882 }
883
889 inline const OGRMultiPolygon *toMultiPolygon() const
890 {
891 return cpl::down_cast<const OGRMultiPolygon *>(this);
892 }
893
899 inline OGRMultiCurve *toMultiCurve()
900 {
901 return cpl::down_cast<OGRMultiCurve *>(this);
902 }
903
909 inline const OGRMultiCurve *toMultiCurve() const
910 {
911 return cpl::down_cast<const OGRMultiCurve *>(this);
912 }
913
919 inline OGRMultiSurface *toMultiSurface()
920 {
921 return cpl::down_cast<OGRMultiSurface *>(this);
922 }
923
929 inline const OGRMultiSurface *toMultiSurface() const
930 {
931 return cpl::down_cast<const OGRMultiSurface *>(this);
932 }
933
939 inline OGRPolyhedralSurface *toPolyhedralSurface()
940 {
941 return cpl::down_cast<OGRPolyhedralSurface *>(this);
942 }
943
949 inline const OGRPolyhedralSurface *toPolyhedralSurface() const
950 {
951 return cpl::down_cast<const OGRPolyhedralSurface *>(this);
952 }
953
958 inline OGRTriangulatedSurface *toTriangulatedSurface()
959 {
960 return cpl::down_cast<OGRTriangulatedSurface *>(this);
961 }
962
967 inline const OGRTriangulatedSurface *toTriangulatedSurface() const
968 {
969 return cpl::down_cast<const OGRTriangulatedSurface *>(this);
970 }
971 };
972
974 struct CPL_DLL OGRGeometryUniquePtrDeleter
975 {
976 void operator()(OGRGeometry *) const;
977 };
979
983 typedef std::unique_ptr<OGRGeometry, OGRGeometryUniquePtrDeleter>
984 OGRGeometryUniquePtr;
985
987 #define OGR_FORBID_DOWNCAST_TO(name) \
988 inline OGR##name *to##name() = delete; \
989 inline const OGR##name *to##name() const = delete;
990
991 #define OGR_FORBID_DOWNCAST_TO_POINT OGR_FORBID_DOWNCAST_TO(Point)
992 #define OGR_FORBID_DOWNCAST_TO_CURVE OGR_FORBID_DOWNCAST_TO(Curve)
993 #define OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE OGR_FORBID_DOWNCAST_TO(SimpleCurve)
994 #define OGR_FORBID_DOWNCAST_TO_LINESTRING OGR_FORBID_DOWNCAST_TO(LineString)
995 #define OGR_FORBID_DOWNCAST_TO_LINEARRING OGR_FORBID_DOWNCAST_TO(LinearRing)
996 #define OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
997 OGR_FORBID_DOWNCAST_TO(CircularString)
998 #define OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE \
999 OGR_FORBID_DOWNCAST_TO(CompoundCurve)
1000 #define OGR_FORBID_DOWNCAST_TO_SURFACE OGR_FORBID_DOWNCAST_TO(Surface)
1001 #define OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON OGR_FORBID_DOWNCAST_TO(CurvePolygon)
1002 #define OGR_FORBID_DOWNCAST_TO_POLYGON OGR_FORBID_DOWNCAST_TO(Polygon)
1003 #define OGR_FORBID_DOWNCAST_TO_TRIANGLE OGR_FORBID_DOWNCAST_TO(Triangle)
1004 #define OGR_FORBID_DOWNCAST_TO_MULTIPOINT OGR_FORBID_DOWNCAST_TO(MultiPoint)
1005 #define OGR_FORBID_DOWNCAST_TO_MULTICURVE OGR_FORBID_DOWNCAST_TO(MultiCurve)
1006 #define OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1007 OGR_FORBID_DOWNCAST_TO(MultiLineString)
1008 #define OGR_FORBID_DOWNCAST_TO_MULTISURFACE OGR_FORBID_DOWNCAST_TO(MultiSurface)
1009 #define OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON OGR_FORBID_DOWNCAST_TO(MultiPolygon)
1010 #define OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1011 OGR_FORBID_DOWNCAST_TO(GeometryCollection)
1012 #define OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1013 OGR_FORBID_DOWNCAST_TO(PolyhedralSurface)
1014 #define OGR_FORBID_DOWNCAST_TO_TIN OGR_FORBID_DOWNCAST_TO(TriangulatedSurface)
1015
1016 #define OGR_ALLOW_UPCAST_TO(name) \
1017 inline OGR##name *to##name() \
1018 { \
1019 return this; \
1020 } \
1021 inline const OGR##name *to##name() const \
1022 { \
1023 return this; \
1024 }
1025
1026 #ifndef SUPPRESS_OGR_ALLOW_CAST_TO_THIS_WARNING
1027 #define CAST_TO_THIS_WARNING CPL_WARN_DEPRECATED("Casting to this is useless")
1028 #else
1029 #define CAST_TO_THIS_WARNING
1030 #endif
1031
1032 #define OGR_ALLOW_CAST_TO_THIS(name) \
1033 inline OGR##name *to##name() CAST_TO_THIS_WARNING \
1034 { \
1035 return this; \
1036 } \
1037 inline const OGR##name *to##name() const CAST_TO_THIS_WARNING \
1038 { \
1039 return this; \
1040 }
1041
1042 #define OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1043 OGR_FORBID_DOWNCAST_TO_CURVE \
1044 OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE \
1045 OGR_FORBID_DOWNCAST_TO_LINESTRING \
1046 OGR_FORBID_DOWNCAST_TO_LINEARRING \
1047 OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1048 OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE
1049
1050 #define OGR_FORBID_DOWNCAST_TO_ALL_SURFACES \
1051 OGR_FORBID_DOWNCAST_TO_SURFACE \
1052 OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON \
1053 OGR_FORBID_DOWNCAST_TO_POLYGON \
1054 OGR_FORBID_DOWNCAST_TO_TRIANGLE \
1055 OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1056 OGR_FORBID_DOWNCAST_TO_TIN
1057
1058 #define OGR_FORBID_DOWNCAST_TO_ALL_SINGLES \
1059 OGR_FORBID_DOWNCAST_TO_POINT \
1060 OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1061 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1062
1063 #define OGR_FORBID_DOWNCAST_TO_ALL_MULTI \
1064 OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1065 OGR_FORBID_DOWNCAST_TO_MULTIPOINT \
1066 OGR_FORBID_DOWNCAST_TO_MULTICURVE \
1067 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1068 OGR_FORBID_DOWNCAST_TO_MULTISURFACE \
1069 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
1070
1072
1073 /************************************************************************/
1074 /* OGRPoint */
1075 /************************************************************************/
1076
1083 class CPL_DLL OGRPoint : public OGRGeometry
1084 {
1085 double x;
1086 double y;
1087 double z;
1088 double m;
1089
1090 public:
1091 OGRPoint();
1092 OGRPoint(double x, double y);
1093 OGRPoint(double x, double y, double z);
1094 OGRPoint(double x, double y, double z, double m);
1095 OGRPoint(const OGRPoint &other);
1096 static OGRPoint *createXYM(double x, double y, double m);
1097 ~OGRPoint() override;
1098
1099 OGRPoint &operator=(const OGRPoint &other);
1100
1101 // IWks Interface
1102 size_t WkbSize() const override;
1103 OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1104 size_t &nBytesConsumedOut) override;
1105 OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
1106 OGRwkbVariant = wkbVariantOldOgc) const override;
1107
1108 #ifndef DOXYGEN_XML
1109 using OGRGeometry::importFromWkt;
1110 #endif
1111
1112 OGRErr importFromWkt(const char **) override;
1113
1114 #ifndef DOXYGEN_XML
1115 using OGRGeometry::exportToWkt;
1116 #endif
1117
1122 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1123 OGRErr *err = nullptr) const override;
1124
1125 // IGeometry
1126 virtual int getDimension() const override;
1127 virtual OGRPoint *clone() const override;
1128 virtual void empty() override;
1129 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1130 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1131 virtual OGRBoolean IsEmpty() const override
1132 {
1133 return !(flags & OGR_G_NOT_EMPTY_POINT);
1134 }
1135
1136 // IPoint
1138 double getX() const
1139 {
1140 return x;
1141 }
1143 double getY() const
1144 {
1145 return y;
1146 }
1148 double getZ() const
1149 {
1150 return z;
1151 }
1153 double getM() const
1154 {
1155 return m;
1156 }
1157
1158 // Non standard
1159 virtual void setCoordinateDimension(int nDimension) override;
1163 void setX(double xIn)
1164 {
1165 x = xIn;
1166 if (std::isnan(x) || std::isnan(y))
1167 flags &= ~OGR_G_NOT_EMPTY_POINT;
1168 else
1169 flags |= OGR_G_NOT_EMPTY_POINT;
1170 }
1174 void setY(double yIn)
1175 {
1176 y = yIn;
1177 if (std::isnan(x) || std::isnan(y))
1178 flags &= ~OGR_G_NOT_EMPTY_POINT;
1179 else
1180 flags |= OGR_G_NOT_EMPTY_POINT;
1181 }
1185 void setZ(double zIn)
1186 {
1187 z = zIn;
1188 flags |= OGR_G_3D;
1189 }
1193 void setM(double mIn)
1194 {
1195 m = mIn;
1196 flags |= OGR_G_MEASURED;
1197 }
1198
1199 // ISpatialRelation
1200 virtual OGRBoolean Equals(const OGRGeometry *) const override;
1201 virtual OGRBoolean Intersects(const OGRGeometry *) const override;
1202 virtual OGRBoolean Within(const OGRGeometry *) const override;
1203
1204 // Non standard from OGRGeometry
1205 virtual const char *getGeometryName() const override;
1206 virtual OGRwkbGeometryType getGeometryType() const override;
1207 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1208 virtual void flattenTo2D() override;
1209 virtual void accept(IOGRGeometryVisitor *visitor) override
1210 {
1211 visitor->visit(this);
1212 }
1213 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1214 {
1215 visitor->visit(this);
1216 }
1217
1218 virtual void swapXY() override;
1219
1220 OGR_ALLOW_CAST_TO_THIS(Point)
1221 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
1222 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1223 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1224 };
1225
1226 /************************************************************************/
1227 /* OGRPointIterator */
1228 /************************************************************************/
1229
1236 class CPL_DLL OGRPointIterator
1237 {
1238 public:
1239 virtual ~OGRPointIterator();
1240 virtual OGRBoolean getNextPoint(OGRPoint *p) = 0;
1241
1242 static void destroy(OGRPointIterator *);
1243 };
1244
1245 /************************************************************************/
1246 /* OGRCurve */
1247 /************************************************************************/
1248
1254 class CPL_DLL OGRCurve : public OGRGeometry
1255 {
1256 protected:
1258 OGRCurve();
1259 OGRCurve(const OGRCurve &other);
1260
1261 virtual OGRCurveCasterToLineString GetCasterToLineString() const = 0;
1262 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const = 0;
1263
1264 friend class OGRCurvePolygon;
1265 friend class OGRCompoundCurve;
1267 virtual int ContainsPoint(const OGRPoint *p) const;
1268 virtual int IntersectsPoint(const OGRPoint *p) const;
1269 virtual double get_AreaOfCurveSegments() const = 0;
1270
1271 private:
1272 class CPL_DLL ConstIterator
1273 {
1274 struct Private;
1275 std::unique_ptr<Private> m_poPrivate;
1276
1277 public:
1278 ConstIterator(const OGRCurve *poSelf, bool bStart);
1279 ConstIterator(ConstIterator &&oOther) noexcept;
1280 ConstIterator &operator=(ConstIterator &&oOther);
1281 ~ConstIterator();
1282 const OGRPoint &operator*() const;
1283 ConstIterator &operator++();
1284 bool operator!=(const ConstIterator &it) const;
1285 };
1286
1287 friend inline ConstIterator begin(const OGRCurve *);
1288 friend inline ConstIterator end(const OGRCurve *);
1289
1290 public:
1291 ~OGRCurve() override;
1292
1294 OGRCurve &operator=(const OGRCurve &other);
1296
1298 typedef OGRPoint ChildType;
1299
1308 ConstIterator begin() const;
1310 ConstIterator end() const;
1311
1312 // IGeometry
1313 virtual OGRCurve *clone() const override = 0;
1314
1315 // ICurve methods
1316 virtual double get_Length() const = 0;
1317 virtual void StartPoint(OGRPoint *) const = 0;
1318 virtual void EndPoint(OGRPoint *) const = 0;
1319 virtual int get_IsClosed() const;
1320 virtual void Value(double, OGRPoint *) const = 0;
1321 virtual OGRLineString *
1322 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1323 const char *const *papszOptions = nullptr) const = 0;
1324 virtual int getDimension() const override;
1325
1326 // non standard
1327 virtual int getNumPoints() const = 0;
1328 virtual OGRPointIterator *getPointIterator() const = 0;
1329 virtual OGRBoolean IsConvex() const;
1330 virtual double get_Area() const = 0;
1331 virtual int isClockwise() const;
1332
1336 inline OGRSimpleCurve *toSimpleCurve()
1337 {
1338 return cpl::down_cast<OGRSimpleCurve *>(this);
1339 }
1340
1344 inline const OGRSimpleCurve *toSimpleCurve() const
1345 {
1346 return cpl::down_cast<const OGRSimpleCurve *>(this);
1347 }
1348
1349 static OGRCompoundCurve *CastToCompoundCurve(OGRCurve *puCurve);
1350 static OGRLineString *CastToLineString(OGRCurve *poCurve);
1351 static OGRLinearRing *CastToLinearRing(OGRCurve *poCurve);
1352
1353 OGR_FORBID_DOWNCAST_TO_POINT
1354 OGR_ALLOW_CAST_TO_THIS(Curve)
1355 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1356 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1357 };
1358
1360
1361 inline OGRCurve::ConstIterator begin(const OGRCurve *poCurve)
1362 {
1363 return poCurve->begin();
1364 }
1366 inline OGRCurve::ConstIterator end(const OGRCurve *poCurve)
1367 {
1368 return poCurve->end();
1369 }
1371
1372 /************************************************************************/
1373 /* OGRIteratedPoint */
1374 /************************************************************************/
1375
1397 class CPL_DLL OGRIteratedPoint : public OGRPoint
1398 {
1399 private:
1400 friend class OGRSimpleCurve;
1401
1402 OGRSimpleCurve *m_poCurve = nullptr;
1403 int m_nPos = 0;
1404
1405 OGRIteratedPoint() = default;
1406
1407 CPL_DISALLOW_COPY_ASSIGN(OGRIteratedPoint)
1408
1409 public:
1413 void setX(double xIn);
1417 void setY(double yIn);
1421 void setZ(double zIn);
1425 void setM(double mIn);
1426 };
1427
1428 /************************************************************************/
1429 /* OGRSimpleCurve */
1430 /************************************************************************/
1431
1441 class CPL_DLL OGRSimpleCurve : public OGRCurve
1442 {
1443 protected:
1445 friend class OGRGeometry;
1446
1447 int nPointCount;
1448 int m_nPointCapacity = 0;
1449 OGRRawPoint *paoPoints;
1450 double *padfZ;
1451 double *padfM;
1452
1453 void Make3D();
1454 void Make2D();
1455 void RemoveM();
1456 void AddM();
1457
1458 OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ, int bHasM,
1459 OGRRawPoint *&paoPointsIn, int &nMaxPoints,
1460 double *&padfZIn);
1462
1463 virtual double get_LinearArea() const;
1464
1465 OGRSimpleCurve();
1466 OGRSimpleCurve(const OGRSimpleCurve &other);
1467
1468 private:
1469 class CPL_DLL Iterator
1470 {
1471 struct Private;
1472 std::unique_ptr<Private> m_poPrivate;
1473 void update();
1474
1475 public:
1476 Iterator(OGRSimpleCurve *poSelf, int nPos);
1477 Iterator(Iterator &&oOther) noexcept; // declared but not defined.
1478 // Needed for gcc 5.4 at least
1479 ~Iterator();
1480 OGRIteratedPoint &operator*();
1481 Iterator &operator++();
1482 bool operator!=(const Iterator &it) const;
1483 };
1484
1485 friend inline Iterator begin(OGRSimpleCurve *);
1486 friend inline Iterator end(OGRSimpleCurve *);
1487
1488 class CPL_DLL ConstIterator
1489 {
1490 struct Private;
1491 std::unique_ptr<Private> m_poPrivate;
1492
1493 public:
1494 ConstIterator(const OGRSimpleCurve *poSelf, int nPos);
1495 ConstIterator(
1496 ConstIterator &&oOther) noexcept; // declared but not defined.
1497 // Needed for gcc 5.4 at least
1498 ~ConstIterator();
1499 const OGRPoint &operator*() const;
1500 ConstIterator &operator++();
1501 bool operator!=(const ConstIterator &it) const;
1502 };
1503
1504 friend inline ConstIterator begin(const OGRSimpleCurve *);
1505 friend inline ConstIterator end(const OGRSimpleCurve *);
1506
1507 public:
1508 ~OGRSimpleCurve() override;
1509
1510 OGRSimpleCurve &operator=(const OGRSimpleCurve &other);
1511
1513 typedef OGRPoint ChildType;
1514
1523 Iterator begin();
1525 Iterator end();
1534 ConstIterator begin() const;
1536 ConstIterator end() const;
1537
1538 // IWks Interface.
1539 virtual size_t WkbSize() const override;
1540 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1541 size_t &nBytesConsumedOut) override;
1542 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
1543 OGRwkbVariant = wkbVariantOldOgc) const override;
1544
1545 #ifndef DOXYGEN_XML
1546 using OGRGeometry::importFromWkt;
1547 #endif
1548
1549 OGRErr importFromWkt(const char **) override;
1550
1551 #ifndef DOXYGEN_XML
1552 using OGRGeometry::exportToWkt;
1553 #endif
1554
1559 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1560 OGRErr *err = nullptr) const override;
1561
1562 // IGeometry interface.
1563 virtual void empty() override;
1564 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1565 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1566 virtual OGRBoolean IsEmpty() const override;
1567 virtual OGRSimpleCurve *clone() const override = 0;
1568
1569 // ICurve methods.
1570 virtual double get_Length() const override;
1571 virtual void StartPoint(OGRPoint *) const override;
1572 virtual void EndPoint(OGRPoint *) const override;
1573 virtual void Value(double, OGRPoint *) const override;
1574 virtual double Project(const OGRPoint *) const;
1575 virtual OGRLineString *getSubLine(double, double, int) const;
1576
1577 // ILineString methods.
1578 virtual int getNumPoints() const override
1579 {
1580 return nPointCount;
1581 }
1582 void getPoint(int, OGRPoint *) const;
1583 double getX(int i) const
1584 {
1585 return paoPoints[i].x;
1586 }
1587 double getY(int i) const
1588 {
1589 return paoPoints[i].y;
1590 }
1591 double getZ(int i) const;
1592 double getM(int i) const;
1593
1594 // ISpatialRelation
1595 virtual OGRBoolean Equals(const OGRGeometry *) const override;
1596
1597 // non standard.
1598 virtual void setCoordinateDimension(int nDimension) override;
1599 virtual void set3D(OGRBoolean bIs3D) override;
1600 virtual void setMeasured(OGRBoolean bIsMeasured) override;
1601 void setNumPoints(int nNewPointCount, int bZeroizeNewContent = TRUE);
1602 void setPoint(int, OGRPoint *);
1603 void setPoint(int, double, double);
1604 void setZ(int, double);
1605 void setM(int, double);
1606 void setPoint(int, double, double, double);
1607 void setPointM(int, double, double, double);
1608 void setPoint(int, double, double, double, double);
1609 void setPoints(int, const OGRRawPoint *, const double * = nullptr);
1610 void setPointsM(int, const OGRRawPoint *, const double *);
1611 void setPoints(int, const OGRRawPoint *, const double *, const double *);
1612 void setPoints(int, const double *padfX, const double *padfY,
1613 const double *padfZIn = nullptr);
1614 void setPointsM(int, const double *padfX, const double *padfY,
1615 const double *padfMIn = nullptr);
1616 void setPoints(int, const double *padfX, const double *padfY,
1617 const double *padfZIn, const double *padfMIn);
1618 void addPoint(const OGRPoint *);
1619 void addPoint(double, double);
1620 void addPoint(double, double, double);
1621 void addPointM(double, double, double);
1622 void addPoint(double, double, double, double);
1623
1624 bool removePoint(int);
1625
1626 void getPoints(OGRRawPoint *, double * = nullptr) const;
1627 void getPoints(void *pabyX, int nXStride, void *pabyY, int nYStride,
1628 void *pabyZ = nullptr, int nZStride = 0,
1629 void *pabyM = nullptr, int nMStride = 0) const;
1630
1631 void addSubLineString(const OGRLineString *, int nStartVertex = 0,
1632 int nEndVertex = -1);
1633 void reversePoints(void);
1634 virtual OGRPointIterator *getPointIterator() const override;
1635
1636 // non-standard from OGRGeometry
1637 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1638 virtual void flattenTo2D() override;
1639 virtual void segmentize(double dfMaxLength) override;
1640
1641 virtual void swapXY() override;
1642
1643 OGR_ALLOW_UPCAST_TO(Curve)
1644 OGR_ALLOW_CAST_TO_THIS(SimpleCurve)
1645 };
1646
1648
1649 inline OGRSimpleCurve::Iterator begin(OGRSimpleCurve *poCurve)
1650 {
1651 return poCurve->begin();
1652 }
1654 inline OGRSimpleCurve::Iterator end(OGRSimpleCurve *poCurve)
1655 {
1656 return poCurve->end();
1657 }
1658
1660 inline OGRSimpleCurve::ConstIterator begin(const OGRSimpleCurve *poCurve)
1661 {
1662 return poCurve->begin();
1663 }
1665 inline OGRSimpleCurve::ConstIterator end(const OGRSimpleCurve *poCurve)
1666 {
1667 return poCurve->end();
1668 }
1670
1671 /************************************************************************/
1672 /* OGRLineString */
1673 /************************************************************************/
1674
1682 class CPL_DLL OGRLineString : public OGRSimpleCurve
1683 {
1684 // cppcheck-suppress unusedPrivateFunction
1685 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
1686
1687 protected:
1689 static OGRLineString *TransferMembersAndDestroy(OGRLineString *poSrc,
1690 OGRLineString *poDst);
1691
1692 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1693 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1694
1695 virtual double get_AreaOfCurveSegments() const override;
1697
1698 static OGRLinearRing *CastToLinearRing(OGRLineString *poLS);
1699
1700 public:
1701 OGRLineString();
1702 OGRLineString(const OGRLineString &other);
1703 ~OGRLineString() override;
1704
1705 OGRLineString &operator=(const OGRLineString &other);
1706
1707 virtual OGRLineString *clone() const override;
1708 virtual OGRLineString *
1709 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1710 const char *const *papszOptions = nullptr) const override;
1711 virtual OGRGeometry *
1712 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
1713 virtual double get_Area() const override;
1714
1715 // Non-standard from OGRGeometry.
1716 virtual OGRwkbGeometryType getGeometryType() const override;
1717 virtual const char *getGeometryName() const override;
1718 virtual int isClockwise() const override;
1719
1721 inline OGRSimpleCurve *toUpperClass()
1722 {
1723 return this;
1724 }
1726 inline const OGRSimpleCurve *toUpperClass() const
1727 {
1728 return this;
1729 }
1730
1731 virtual void accept(IOGRGeometryVisitor *visitor) override
1732 {
1733 visitor->visit(this);
1734 }
1735 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1736 {
1737 visitor->visit(this);
1738 }
1739
1740 OGR_ALLOW_UPCAST_TO(SimpleCurve)
1741 OGR_ALLOW_CAST_TO_THIS(LineString)
1742 };
1743
1744 /************************************************************************/
1745 /* OGRLinearRing */
1746 /************************************************************************/
1747
1768 class CPL_DLL OGRLinearRing : public OGRLineString
1769 {
1770 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
1771
1772 // IWks Interface - Note this isn't really a first class object
1773 // for the purposes of WKB form. These methods always fail since this
1774 // object can't be serialized on its own.
1775 virtual size_t WkbSize() const override;
1776 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1777 size_t &nBytesConsumedOut) override;
1778 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
1779 OGRwkbVariant = wkbVariantOldOgc) const override;
1780
1781 protected:
1783 friend class OGRPolygon;
1784 friend class OGRTriangle;
1785
1786 // These are not IWks compatible ... just a convenience for OGRPolygon.
1787 virtual size_t _WkbSize(int _flags) const;
1788 virtual OGRErr _importFromWkb(OGRwkbByteOrder, int _flags,
1789 const unsigned char *, size_t,
1790 size_t &nBytesConsumedOut);
1791 virtual OGRErr _exportToWkb(OGRwkbByteOrder, int _flags,
1792 unsigned char *) const;
1793
1794 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1795 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1797
1798 static OGRLineString *CastToLineString(OGRLinearRing *poLR);
1799
1800 public:
1801 OGRLinearRing();
1802 OGRLinearRing(const OGRLinearRing &other);
1803 explicit OGRLinearRing(OGRLinearRing *);
1804 ~OGRLinearRing() override;
1805
1806 OGRLinearRing &operator=(const OGRLinearRing &other);
1807
1808 // Non standard.
1809 virtual const char *getGeometryName() const override;
1810 virtual OGRLinearRing *clone() const override;
1811 virtual void reverseWindingOrder();
1812 virtual void closeRings() override;
1813 OGRBoolean isPointInRing(const OGRPoint *pt,
1814 int bTestEnvelope = TRUE) const;
1815 OGRBoolean isPointOnRingBoundary(const OGRPoint *pt,
1816 int bTestEnvelope = TRUE) const;
1817 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1818
1820 inline OGRLineString *toUpperClass()
1821 {
1822 return this;
1823 }
1825 inline const OGRLineString *toUpperClass() const
1826 {
1827 return this;
1828 }
1829
1830 virtual void accept(IOGRGeometryVisitor *visitor) override
1831 {
1832 visitor->visit(this);
1833 }
1834 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1835 {
1836 visitor->visit(this);
1837 }
1838
1839 OGR_ALLOW_UPCAST_TO(LineString)
1840 OGR_ALLOW_CAST_TO_THIS(LinearRing)
1841 };
1842
1843 /************************************************************************/
1844 /* OGRCircularString */
1845 /************************************************************************/
1846
1859 class CPL_DLL OGRCircularString : public OGRSimpleCurve
1860 {
1861 private:
1862 void ExtendEnvelopeWithCircular(OGREnvelope *psEnvelope) const;
1863 OGRBoolean IsValidFast() const;
1864 int IsFullCircle(double &cx, double &cy, double &square_R) const;
1865
1866 protected:
1868 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1869 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1870 virtual int IntersectsPoint(const OGRPoint *p) const override;
1871 virtual int ContainsPoint(const OGRPoint *p) const override;
1872 virtual double get_AreaOfCurveSegments() const override;
1874
1875 public:
1876 OGRCircularString();
1877 OGRCircularString(const OGRCircularString &other);
1878 ~OGRCircularString() override;
1879
1880 OGRCircularString &operator=(const OGRCircularString &other);
1881
1882 // IWks Interface.
1883 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1884 size_t &nBytesConsumedOut) override;
1885 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
1886 OGRwkbVariant = wkbVariantOldOgc) const override;
1887
1888 #ifndef DOXYGEN_XML
1889 using OGRGeometry::importFromWkt;
1890 #endif
1891
1892 OGRErr importFromWkt(const char **) override;
1893
1894 #ifndef DOXYGEN_XML
1895 using OGRGeometry::exportToWkt;
1896 #endif
1897
1902 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1903 OGRErr *err = nullptr) const override;
1904
1905 // IGeometry interface.
1906 virtual OGRBoolean IsValid() const override;
1907 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1908 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1909 virtual OGRCircularString *clone() const override;
1910
1911 // ICurve methods.
1912 virtual double get_Length() const override;
1913 virtual OGRLineString *
1914 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1915 const char *const *papszOptions = nullptr) const override;
1916 virtual void Value(double, OGRPoint *) const override;
1917 virtual double get_Area() const override;
1918
1919 // Non-standard from OGRGeometry.
1920 virtual OGRwkbGeometryType getGeometryType() const override;
1921 virtual const char *getGeometryName() const override;
1922 virtual void segmentize(double dfMaxLength) override;
1923 virtual OGRBoolean
1924 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
1925 virtual OGRGeometry *
1926 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
1927 const char *const *papszOptions = nullptr) const override;
1928
1930 inline OGRSimpleCurve *toUpperClass()
1931 {
1932 return this;
1933 }
1935 inline const OGRSimpleCurve *toUpperClass() const
1936 {
1937 return this;
1938 }
1939
1940 virtual void accept(IOGRGeometryVisitor *visitor) override
1941 {
1942 visitor->visit(this);
1943 }
1944 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1945 {
1946 visitor->visit(this);
1947 }
1948
1949 OGR_ALLOW_UPCAST_TO(SimpleCurve)
1950 OGR_ALLOW_CAST_TO_THIS(CircularString)
1951 };
1952
1953 /************************************************************************/
1954 /* OGRCurveCollection */
1955 /************************************************************************/
1956
1967 class CPL_DLL OGRCurveCollection
1969 {
1970 protected:
1971 friend class OGRCompoundCurve;
1972 friend class OGRCurvePolygon;
1973 friend class OGRPolygon;
1974 friend class OGRTriangle;
1975
1976 int nCurveCount = 0;
1977 OGRCurve **papoCurves = nullptr;
1978
1979 public:
1980 OGRCurveCollection();
1981 OGRCurveCollection(const OGRCurveCollection &other);
1982 ~OGRCurveCollection();
1983
1984 OGRCurveCollection &operator=(const OGRCurveCollection &other);
1985
1987 typedef OGRCurve ChildType;
1988
1992 OGRCurve **begin()
1993 {
1994 return papoCurves;
1995 }
1997 OGRCurve **end()
1998 {
1999 return papoCurves + nCurveCount;
2000 }
2004 const OGRCurve *const *begin() const
2005 {
2006 return papoCurves;
2007 }
2009 const OGRCurve *const *end() const
2010 {
2011 return papoCurves + nCurveCount;
2012 }
2013
2014 void empty(OGRGeometry *poGeom);
2015 OGRBoolean IsEmpty() const;
2016 void getEnvelope(OGREnvelope *psEnvelope) const;
2017 void getEnvelope(OGREnvelope3D *psEnvelope) const;
2018
2019 OGRErr addCurveDirectly(OGRGeometry *poGeom, OGRCurve *poCurve,
2020 int bNeedRealloc);
2021 size_t WkbSize() const;
2022 OGRErr importPreambleFromWkb(OGRGeometry *poGeom,
2023 const unsigned char *pabyData, size_t &nSize,
2024 size_t &nDataOffset,
2025 OGRwkbByteOrder &eByteOrder,
2026 size_t nMinSubGeomSize,
2027 OGRwkbVariant eWkbVariant);
2028 OGRErr
2029 importBodyFromWkb(OGRGeometry *poGeom, const unsigned char *pabyData,
2030 size_t nSize, bool bAcceptCompoundCurve,
2031 OGRErr (*pfnAddCurveDirectlyFromWkb)(OGRGeometry *poGeom,
2032 OGRCurve *poCurve),
2033 OGRwkbVariant eWkbVariant, size_t &nBytesConsumedOut);
2034 std::string exportToWkt(const OGRGeometry *geom, const OGRWktOptions &opts,
2035 OGRErr *err) const;
2036 OGRErr exportToWkb(const OGRGeometry *poGeom, OGRwkbByteOrder,
2037 unsigned char *, OGRwkbVariant eWkbVariant) const;
2038 OGRBoolean Equals(const OGRCurveCollection *poOCC) const;
2039 void setCoordinateDimension(OGRGeometry *poGeom, int nNewDimension);
2040 void set3D(OGRGeometry *poGeom, OGRBoolean bIs3D);
2041 void setMeasured(OGRGeometry *poGeom, OGRBoolean bIsMeasured);
2042 void assignSpatialReference(OGRGeometry *poGeom,
2043 const OGRSpatialReference *poSR);
2044 int getNumCurves() const;
2045 OGRCurve *getCurve(int);
2046 const OGRCurve *getCurve(int) const;
2047 OGRCurve *stealCurve(int);
2048
2049 OGRErr removeCurve(int iIndex, bool bDelete = true);
2050
2051 OGRErr transform(OGRGeometry *poGeom, OGRCoordinateTransformation *poCT);
2052 void flattenTo2D(OGRGeometry *poGeom);
2053 void segmentize(double dfMaxLength);
2054 void swapXY();
2055 OGRBoolean hasCurveGeometry(int bLookForNonLinear) const;
2056 };
2058
2059 /************************************************************************/
2060 /* OGRCompoundCurve */
2061 /************************************************************************/
2062
2073 class CPL_DLL OGRCompoundCurve : public OGRCurve
2074 {
2075 private:
2076 OGRCurveCollection oCC{};
2077
2078 OGRErr addCurveDirectlyInternal(OGRCurve *poCurve, double dfToleranceEps,
2079 int bNeedRealloc);
2080 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2081 OGRCurve *poCurve);
2082 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2083 OGRCurve *poCurve);
2084 OGRLineString *CurveToLineInternal(double dfMaxAngleStepSizeDegrees,
2085 const char *const *papszOptions,
2086 int bIsLinearRing) const;
2087 // cppcheck-suppress unusedPrivateFunction
2088 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
2089 // cppcheck-suppress unusedPrivateFunction
2090 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
2091
2092 protected:
2094 static OGRLineString *CastToLineString(OGRCompoundCurve *poCC);
2095 static OGRLinearRing *CastToLinearRing(OGRCompoundCurve *poCC);
2096
2097 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
2098 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
2100
2101 public:
2102 OGRCompoundCurve();
2103 OGRCompoundCurve(const OGRCompoundCurve &other);
2104 ~OGRCompoundCurve() override;
2105
2106 OGRCompoundCurve &operator=(const OGRCompoundCurve &other);
2107
2109 typedef OGRCurve ChildType;
2110
2114 ChildType **begin()
2115 {
2116 return oCC.begin();
2117 }
2119 ChildType **end()
2120 {
2121 return oCC.end();
2122 }
2126 const ChildType *const *begin() const
2127 {
2128 return oCC.begin();
2129 }
2131 const ChildType *const *end() const
2132 {
2133 return oCC.end();
2134 }
2135
2136 // IWks Interface
2137 virtual size_t WkbSize() const override;
2138 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2139 size_t &nBytesConsumedOut) override;
2140 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
2141 OGRwkbVariant = wkbVariantOldOgc) const override;
2142
2143 #ifndef DOXYGEN_XML
2144 using OGRGeometry::importFromWkt;
2145 #endif
2146
2147 OGRErr importFromWkt(const char **) override;
2148
2149 #ifndef DOXYGEN_XML
2150 using OGRGeometry::exportToWkt;
2151 #endif
2152
2157 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2158 OGRErr *err = nullptr) const override;
2159
2160 // IGeometry interface.
2161 virtual OGRCompoundCurve *clone() const override;
2162 virtual void empty() override;
2163 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2164 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2165 virtual OGRBoolean IsEmpty() const override;
2166
2167 // ICurve methods.
2168 virtual double get_Length() const override;
2169 virtual void StartPoint(OGRPoint *) const override;
2170 virtual void EndPoint(OGRPoint *) const override;
2171 virtual void Value(double, OGRPoint *) const override;
2172 virtual OGRLineString *
2173 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
2174 const char *const *papszOptions = nullptr) const override;
2175
2176 virtual int getNumPoints() const override;
2177 virtual double get_AreaOfCurveSegments() const override;
2178 virtual double get_Area() const override;
2179
2180 // ISpatialRelation.
2181 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2182
2183 // ICompoundCurve method.
2184 int getNumCurves() const;
2185 OGRCurve *getCurve(int);
2186 const OGRCurve *getCurve(int) const;
2187
2188 // Non-standard.
2189 virtual void setCoordinateDimension(int nDimension) override;
2190 virtual void set3D(OGRBoolean bIs3D) override;
2191 virtual void setMeasured(OGRBoolean bIsMeasured) override;
2192
2193 virtual void
2194 assignSpatialReference(const OGRSpatialReference *poSR) override;
2195
2196 OGRErr addCurve(const OGRCurve *, double dfToleranceEps = 1e-14);
2197 OGRErr addCurveDirectly(OGRCurve *, double dfToleranceEps = 1e-14);
2198 OGRErr addCurve(std::unique_ptr<OGRCurve>, double dfToleranceEps = 1e-14);
2199 OGRCurve *stealCurve(int);
2200 virtual OGRPointIterator *getPointIterator() const override;
2201
2202 // Non-standard from OGRGeometry.
2203 virtual OGRwkbGeometryType getGeometryType() const override;
2204 virtual const char *getGeometryName() const override;
2205 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2206 virtual void flattenTo2D() override;
2207 virtual void segmentize(double dfMaxLength) override;
2208 virtual OGRBoolean
2209 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2210 virtual OGRGeometry *
2211 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2212 const char *const *papszOptions = nullptr) const override;
2213 virtual void accept(IOGRGeometryVisitor *visitor) override
2214 {
2215 visitor->visit(this);
2216 }
2217 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2218 {
2219 visitor->visit(this);
2220 }
2221
2222 virtual void swapXY() override;
2223
2224 OGR_ALLOW_UPCAST_TO(Curve)
2225 OGR_ALLOW_CAST_TO_THIS(CompoundCurve)
2226 };
2227
2229
2230 inline const OGRCompoundCurve::ChildType *const *
2231 begin(const OGRCompoundCurve *poCurve)
2232 {
2233 return poCurve->begin();
2234 }
2236 inline const OGRCompoundCurve::ChildType *const *
2237 end(const OGRCompoundCurve *poCurve)
2238 {
2239 return poCurve->end();
2240 }
2241
2243 inline OGRCompoundCurve::ChildType **begin(OGRCompoundCurve *poCurve)
2244 {
2245 return poCurve->begin();
2246 }
2248 inline OGRCompoundCurve::ChildType **end(OGRCompoundCurve *poCurve)
2249 {
2250 return poCurve->end();
2251 }
2253
2254 /************************************************************************/
2255 /* OGRSurface */
2256 /************************************************************************/
2257
2263 class CPL_DLL OGRSurface : public OGRGeometry
2264 {
2265 protected:
2267 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const = 0;
2268 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const = 0;
2270
2271 public:
2272 virtual double get_Area() const = 0;
2273 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
2274 {
2275 return PointOnSurfaceInternal(poPoint);
2276 }
2277 virtual OGRSurface *clone() const override = 0;
2278
2280 static OGRPolygon *CastToPolygon(OGRSurface *poSurface);
2281 static OGRCurvePolygon *CastToCurvePolygon(OGRSurface *poSurface);
2283
2284 OGR_FORBID_DOWNCAST_TO_POINT
2285 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
2286 OGR_ALLOW_CAST_TO_THIS(Surface)
2287 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
2288 };
2289
2290 /************************************************************************/
2291 /* OGRCurvePolygon */
2292 /************************************************************************/
2293
2307 class CPL_DLL OGRCurvePolygon : public OGRSurface
2308 {
2309 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2310
2311 private:
2312 OGRBoolean IntersectsPoint(const OGRPoint *p) const;
2313 OGRBoolean ContainsPoint(const OGRPoint *p) const;
2314 virtual int checkRing(OGRCurve *poNewRing) const;
2315 OGRErr addRingDirectlyInternal(OGRCurve *poCurve, int bNeedRealloc);
2316 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2317 OGRCurve *poCurve);
2318 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2319 OGRCurve *poCurve);
2320
2321 protected:
2323 friend class OGRPolygon;
2324 friend class OGRTriangle;
2325 OGRCurveCollection oCC{};
2326
2327 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2328 virtual OGRSurfaceCasterToCurvePolygon
2329 GetCasterToCurvePolygon() const override;
2330
2332
2333 static OGRPolygon *CastToPolygon(OGRCurvePolygon *poCP);
2334
2335 public:
2336 OGRCurvePolygon();
2337 OGRCurvePolygon(const OGRCurvePolygon &);
2338 ~OGRCurvePolygon() override;
2339
2340 OGRCurvePolygon &operator=(const OGRCurvePolygon &other);
2341
2343 typedef OGRCurve ChildType;
2344
2348 ChildType **begin()
2349 {
2350 return oCC.begin();
2351 }
2353 ChildType **end()
2354 {
2355 return oCC.end();
2356 }
2360 const ChildType *const *begin() const
2361 {
2362 return oCC.begin();
2363 }
2365 const ChildType *const *end() const
2366 {
2367 return oCC.end();
2368 }
2369
2370 // Non standard (OGRGeometry).
2371 virtual const char *getGeometryName() const override;
2372 virtual OGRwkbGeometryType getGeometryType() const override;
2373 virtual OGRCurvePolygon *clone() const override;
2374 virtual void empty() override;
2375 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2376 virtual void flattenTo2D() override;
2377 virtual OGRBoolean IsEmpty() const override;
2378 virtual void segmentize(double dfMaxLength) override;
2379 virtual OGRBoolean
2380 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2381 virtual OGRGeometry *
2382 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2383 const char *const *papszOptions = nullptr) const override;
2384
2385 // ISurface Interface
2386 virtual double get_Area() const override;
2387
2388 // IWks Interface
2389 virtual size_t WkbSize() const override;
2390 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2391 size_t &nBytesConsumedOut) override;
2392 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
2393 OGRwkbVariant = wkbVariantOldOgc) const override;
2394
2395 #ifndef DOXYGEN_XML
2396 using OGRGeometry::importFromWkt;
2397 #endif
2398
2399 OGRErr importFromWkt(const char **) override;
2400
2401 #ifndef DOXYGEN_XML
2402 using OGRGeometry::exportToWkt;
2403 #endif
2404
2409 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2410 OGRErr *err = nullptr) const override;
2411
2412 // IGeometry
2413 virtual int getDimension() const override;
2414 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2415 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2416
2417 // ICurvePolygon
2418 virtual OGRPolygon *
2419 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2420 const char *const *papszOptions = nullptr) const;
2421
2422 // ISpatialRelation
2423 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2424 virtual OGRBoolean Intersects(const OGRGeometry *) const override;
2425 virtual OGRBoolean Contains(const OGRGeometry *) const override;
2426
2427 // Non standard
2428 virtual void setCoordinateDimension(int nDimension) override;
2429 virtual void set3D(OGRBoolean bIs3D) override;
2430 virtual void setMeasured(OGRBoolean bIsMeasured) override;
2431
2432 virtual void
2433 assignSpatialReference(const OGRSpatialReference *poSR) override;
2434
2435 virtual OGRErr addRing(OGRCurve *);
2436 virtual OGRErr addRingDirectly(OGRCurve *);
2437 OGRErr addRing(std::unique_ptr<OGRCurve>);
2438
2439 OGRCurve *getExteriorRingCurve();
2440 const OGRCurve *getExteriorRingCurve() const;
2441 int getNumInteriorRings() const;
2442 OGRCurve *getInteriorRingCurve(int);
2443 const OGRCurve *getInteriorRingCurve(int) const;
2444
2445 OGRCurve *stealExteriorRingCurve();
2446
2447 OGRErr removeRing(int iIndex, bool bDelete = true);
2448 virtual void accept(IOGRGeometryVisitor *visitor) override
2449 {
2450 visitor->visit(this);
2451 }
2452 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2453 {
2454 visitor->visit(this);
2455 }
2456
2457 virtual void swapXY() override;
2458
2459 OGR_ALLOW_UPCAST_TO(Surface)
2460 OGR_ALLOW_CAST_TO_THIS(CurvePolygon)
2461 };
2462
2464
2465 inline const OGRCurvePolygon::ChildType *const *
2466 begin(const OGRCurvePolygon *poGeom)
2467 {
2468 return poGeom->begin();
2469 }
2471 inline const OGRCurvePolygon::ChildType *const *
2472 end(const OGRCurvePolygon *poGeom)
2473 {
2474 return poGeom->end();
2475 }
2476
2478 inline OGRCurvePolygon::ChildType **begin(OGRCurvePolygon *poGeom)
2479 {
2480 return poGeom->begin();
2481 }
2483 inline OGRCurvePolygon::ChildType **end(OGRCurvePolygon *poGeom)
2484 {
2485 return poGeom->end();
2486 }
2488
2489 /************************************************************************/
2490 /* OGRPolygon */
2491 /************************************************************************/
2492
2502 class CPL_DLL OGRPolygon : public OGRCurvePolygon
2503 {
2504 static OGRCurvePolygon *CasterToCurvePolygon(OGRSurface *poSurface);
2505
2506 protected:
2508 friend class OGRMultiSurface;
2509 friend class OGRPolyhedralSurface;
2510 friend class OGRTriangulatedSurface;
2511
2512 virtual int checkRing(OGRCurve *poNewRing) const override;
2513 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2514 int bHasM, OGRRawPoint *&paoPoints,
2515 int &nMaxPoints, double *&padfZ);
2516
2517 static OGRCurvePolygon *CastToCurvePolygon(OGRPolygon *poPoly);
2518
2519 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2520 virtual OGRSurfaceCasterToCurvePolygon
2521 GetCasterToCurvePolygon() const override;
2523
2524 public:
2525 OGRPolygon();
2526 OGRPolygon(const OGRPolygon &other);
2527 ~OGRPolygon() override;
2528
2529 OGRPolygon &operator=(const OGRPolygon &other);
2530
2532 typedef OGRLinearRing ChildType;
2533
2537 ChildType **begin()
2538 {
2539 return reinterpret_cast<ChildType **>(oCC.begin());
2540 }
2542 ChildType **end()
2543 {
2544 return reinterpret_cast<ChildType **>(oCC.end());
2545 }
2549 const ChildType *const *begin() const
2550 {
2551 return reinterpret_cast<const ChildType *const *>(oCC.begin());
2552 }
2554 const ChildType *const *end() const
2555 {
2556 return reinterpret_cast<const ChildType *const *>(oCC.end());
2557 }
2558
2559 // Non-standard (OGRGeometry).
2560 virtual const char *getGeometryName() const override;
2561 virtual OGRwkbGeometryType getGeometryType() const override;
2562 virtual OGRPolygon *clone() const override;
2563 virtual OGRBoolean
2564 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2565 virtual OGRGeometry *
2566 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2567 virtual OGRGeometry *
2568 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2569 const char *const *papszOptions = nullptr) const override;
2570
2571 // IWks Interface.
2572 virtual size_t WkbSize() const override;
2573 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2574 size_t &nBytesConsumedOut) override;
2575 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
2576 OGRwkbVariant = wkbVariantOldOgc) const override;
2577
2578 #ifndef DOXYGEN_XML
2579 using OGRGeometry::importFromWkt;
2580 #endif
2581
2582 OGRErr importFromWkt(const char **) override;
2583
2584 #ifndef DOXYGEN_XML
2585 using OGRGeometry::exportToWkt;
2586 #endif
2587
2592 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2593 OGRErr *err = nullptr) const override;
2594
2595 // ICurvePolygon.
2596 virtual OGRPolygon *
2597 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2598 const char *const *papszOptions = nullptr) const override;
2599
2600 OGRLinearRing *getExteriorRing();
2601 const OGRLinearRing *getExteriorRing() const;
2602 virtual OGRLinearRing *getInteriorRing(int);
2603 virtual const OGRLinearRing *getInteriorRing(int) const;
2604
2605 OGRLinearRing *stealExteriorRing();
2606 virtual OGRLinearRing *stealInteriorRing(int);
2607
2608 OGRBoolean IsPointOnSurface(const OGRPoint *) const;
2609
2611 inline OGRCurvePolygon *toUpperClass()
2612 {
2613 return this;
2614 }
2616 inline const OGRCurvePolygon *toUpperClass() const
2617 {
2618 return this;
2619 }
2620
2621 virtual void accept(IOGRGeometryVisitor *visitor) override
2622 {
2623 visitor->visit(this);
2624 }
2625 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2626 {
2627 visitor->visit(this);
2628 }
2629
2630 virtual void closeRings() override;
2631
2632 OGR_ALLOW_UPCAST_TO(CurvePolygon)
2633 OGR_ALLOW_CAST_TO_THIS(Polygon)
2634 };
2635
2637
2638 inline const OGRPolygon::ChildType *const *begin(const OGRPolygon *poGeom)
2639 {
2640 return poGeom->begin();
2641 }
2643 inline const OGRPolygon::ChildType *const *end(const OGRPolygon *poGeom)
2644 {
2645 return poGeom->end();
2646 }
2647
2649 inline OGRPolygon::ChildType **begin(OGRPolygon *poGeom)
2650 {
2651 return poGeom->begin();
2652 }
2654 inline OGRPolygon::ChildType **end(OGRPolygon *poGeom)
2655 {
2656 return poGeom->end();
2657 }
2659
2660 /************************************************************************/
2661 /* OGRTriangle */
2662 /************************************************************************/
2663
2670 class CPL_DLL OGRTriangle : public OGRPolygon
2671 {
2672 private:
2673 // cppcheck-suppress unusedPrivateFunction
2674 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2675 bool quickValidityCheck() const;
2676
2677 protected:
2679 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2680 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2681 int bHasM, OGRRawPoint *&paoPoints,
2682 int &nMaxPoints,
2683 double *&padfZ) override;
2685
2686 public:
2687 OGRTriangle();
2688 OGRTriangle(const OGRPoint &p, const OGRPoint &q, const OGRPoint &r);
2689 OGRTriangle(const OGRTriangle &other);
2690 OGRTriangle(const OGRPolygon &other, OGRErr &eErr);
2691 OGRTriangle &operator=(const OGRTriangle &other);
2692 ~OGRTriangle() override;
2693 virtual const char *getGeometryName() const override;
2694 virtual OGRwkbGeometryType getGeometryType() const override;
2695 virtual OGRTriangle *clone() const override;
2696
2697 // IWks Interface.
2698 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2699 size_t &nBytesConsumedOut) override;
2700
2701 // New methods rewritten from OGRPolygon/OGRCurvePolygon/OGRGeometry.
2702 virtual OGRErr addRingDirectly(OGRCurve *poNewRing) override;
2703
2705 inline OGRPolygon *toUpperClass()
2706 {
2707 return this;
2708 }
2710 inline const OGRPolygon *toUpperClass() const
2711 {
2712 return this;
2713 }
2714
2715 virtual void accept(IOGRGeometryVisitor *visitor) override
2716 {
2717 visitor->visit(this);
2718 }
2719 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2720 {
2721 visitor->visit(this);
2722 }
2723
2725 static OGRGeometry *CastToPolygon(OGRGeometry *poGeom);
2727
2728 OGR_ALLOW_UPCAST_TO(Polygon)
2729 OGR_ALLOW_CAST_TO_THIS(Triangle)
2730 };
2731
2732 /************************************************************************/
2733 /* OGRGeometryCollection */
2734 /************************************************************************/
2735
2743 class CPL_DLL OGRGeometryCollection : public OGRGeometry
2744 {
2745 OGRErr importFromWktInternal(const char **ppszInput, int nRecLevel);
2746
2747 protected:
2749 int nGeomCount = 0;
2750 OGRGeometry **papoGeoms = nullptr;
2751
2752 std::string
2753 exportToWktInternal(const OGRWktOptions &opts, OGRErr *err,
2754 const std::string &exclude = std::string()) const;
2755 static OGRGeometryCollection *
2756 TransferMembersAndDestroy(OGRGeometryCollection *poSrc,
2757 OGRGeometryCollection *poDst);
2758
2759 OGRErr importFromWkbInternal(const unsigned char *pabyData, size_t nSize,
2760 int nRecLevel, OGRwkbVariant,
2761 size_t &nBytesConsumedOut);
2763 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
2764
2765 public:
2766 OGRGeometryCollection();
2767 OGRGeometryCollection(const OGRGeometryCollection &other);
2768 ~OGRGeometryCollection() override;
2769
2770 OGRGeometryCollection &operator=(const OGRGeometryCollection &other);
2771
2773 typedef OGRGeometry ChildType;
2774
2778 ChildType **begin()
2779 {
2780 return papoGeoms;
2781 }
2783 ChildType **end()
2784 {
2785 return papoGeoms + nGeomCount;
2786 }
2790 const ChildType *const *begin() const
2791 {
2792 return papoGeoms;
2793 }
2795 const ChildType *const *end() const
2796 {
2797 return papoGeoms + nGeomCount;
2798 }
2799
2800 // Non standard (OGRGeometry).
2801 virtual const char *getGeometryName() const override;
2802 virtual OGRwkbGeometryType getGeometryType() const override;
2803 virtual OGRGeometryCollection *clone() const override;
2804 virtual void empty() override;
2805 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2806 virtual void flattenTo2D() override;
2807 virtual OGRBoolean IsEmpty() const override;
2808 virtual void segmentize(double dfMaxLength) override;
2809 virtual OGRBoolean
2810 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2811 virtual OGRGeometry *
2812 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2813 virtual OGRGeometry *
2814 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2815 const char *const *papszOptions = nullptr) const override;
2816
2817 // IWks Interface
2818 virtual size_t WkbSize() const override;
2819 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2820 size_t &nBytesConsumedOut) override;
2821 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
2822 OGRwkbVariant = wkbVariantOldOgc) const override;
2823
2824 #ifndef DOXYGEN_XML
2825 using OGRGeometry::importFromWkt;
2826 #endif
2827
2828 OGRErr importFromWkt(const char **) override;
2829
2830 #ifndef DOXYGEN_XML
2831 using OGRGeometry::exportToWkt;
2832 #endif
2833
2838 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2839 OGRErr *err = nullptr) const override;
2840
2841 virtual double get_Length() const;
2842 virtual double get_Area() const;
2843
2844 // IGeometry methods
2845 virtual int getDimension() const override;
2846 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2847 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2848
2849 // IGeometryCollection
2850 int getNumGeometries() const;
2851 OGRGeometry *getGeometryRef(int);
2852 const OGRGeometry *getGeometryRef(int) const;
2853
2854 // ISpatialRelation
2855 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2856
2857 // Non standard
2858 virtual void setCoordinateDimension(int nDimension) override;
2859 virtual void set3D(OGRBoolean bIs3D) override;
2860 virtual void setMeasured(OGRBoolean bIsMeasured) override;
2861 virtual OGRErr addGeometry(const OGRGeometry *);
2862 virtual OGRErr addGeometryDirectly(OGRGeometry *);
2863 OGRErr addGeometry(std::unique_ptr<OGRGeometry> geom);
2864 virtual OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
2865
2866 virtual void
2867 assignSpatialReference(const OGRSpatialReference *poSR) override;
2868
2869 void closeRings() override;
2870
2871 virtual void swapXY() override;
2872
2873 virtual void accept(IOGRGeometryVisitor *visitor) override
2874 {
2875 visitor->visit(this);
2876 }
2877 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2878 {
2879 visitor->visit(this);
2880 }
2881
2882 static OGRGeometryCollection *
2883 CastToGeometryCollection(OGRGeometryCollection *poSrc);
2884
2885 OGR_FORBID_DOWNCAST_TO_POINT
2886 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
2887 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
2888 OGR_ALLOW_CAST_TO_THIS(GeometryCollection)
2889 };
2890
2892
2893 inline const OGRGeometryCollection::ChildType *const *
2894 begin(const OGRGeometryCollection *poGeom)
2895 {
2896 return poGeom->begin();
2897 }
2899 inline const OGRGeometryCollection::ChildType *const *
2900 end(const OGRGeometryCollection *poGeom)
2901 {
2902 return poGeom->end();
2903 }
2904
2906 inline OGRGeometryCollection::ChildType **begin(OGRGeometryCollection *poGeom)
2907 {
2908 return poGeom->begin();
2909 }
2911 inline OGRGeometryCollection::ChildType **end(OGRGeometryCollection *poGeom)
2912 {
2913 return poGeom->end();
2914 }
2916
2917 /************************************************************************/
2918 /* OGRMultiSurface */
2919 /************************************************************************/
2920
2927 class CPL_DLL OGRMultiSurface : public OGRGeometryCollection
2928 {
2929 protected:
2930 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
2931
2932 public:
2933 OGRMultiSurface();
2934 OGRMultiSurface(const OGRMultiSurface &other);
2935 ~OGRMultiSurface() override;
2936
2937 OGRMultiSurface &operator=(const OGRMultiSurface &other);
2938
2940 typedef OGRSurface ChildType;
2941
2945 ChildType **begin()
2946 {
2947 return reinterpret_cast<ChildType **>(papoGeoms);
2948 }
2950 ChildType **end()
2951 {
2952 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
2953 }
2957 const ChildType *const *begin() const
2958 {
2959 return reinterpret_cast<const ChildType *const *>(papoGeoms);
2960 }
2962 const ChildType *const *end() const
2963 {
2964 return reinterpret_cast<const ChildType *const *>(papoGeoms +
2965 nGeomCount);
2966 }
2967
2968 // Non standard (OGRGeometry).
2969 virtual const char *getGeometryName() const override;
2970 virtual OGRwkbGeometryType getGeometryType() const override;
2971 virtual OGRMultiSurface *clone() const override;
2972
2973 #ifndef DOXYGEN_XML
2974 using OGRGeometry::importFromWkt;
2975 #endif
2976
2977 OGRErr importFromWkt(const char **) override;
2978
2979 #ifndef DOXYGEN_XML
2980 using OGRGeometry::exportToWkt;
2981 #endif
2982
2987 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2988 OGRErr *err = nullptr) const override;
2989
2990 // IMultiSurface methods
2991 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const;
2992
2993 // IGeometry methods
2994 virtual int getDimension() const override;
2995
2996 // IGeometryCollection
2998 OGRSurface *getGeometryRef(int i)
2999 {
3000 return OGRGeometryCollection::getGeometryRef(i)->toSurface();
3001 }
3003 const OGRSurface *getGeometryRef(int i) const
3004 {
3005 return OGRGeometryCollection::getGeometryRef(i)->toSurface();
3006 }
3007
3008 // Non standard
3009 virtual OGRBoolean
3010 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3011
3013 inline OGRGeometryCollection *toUpperClass()
3014 {
3015 return this;
3016 }
3018 inline const OGRGeometryCollection *toUpperClass() const
3019 {
3020 return this;
3021 }
3022
3023 virtual void accept(IOGRGeometryVisitor *visitor) override
3024 {
3025 visitor->visit(this);
3026 }
3027 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3028 {
3029 visitor->visit(this);
3030 }
3031
3032 static OGRMultiPolygon *CastToMultiPolygon(OGRMultiSurface *poMS);
3033
3034 OGR_ALLOW_CAST_TO_THIS(MultiSurface)
3035 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3036 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3037 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3038 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3039 };
3040
3042
3043 inline const OGRMultiSurface::ChildType *const *
3044 begin(const OGRMultiSurface *poGeom)
3045 {
3046 return poGeom->begin();
3047 }
3049 inline const OGRMultiSurface::ChildType *const *
3050 end(const OGRMultiSurface *poGeom)
3051 {
3052 return poGeom->end();
3053 }
3054
3056 inline OGRMultiSurface::ChildType **begin(OGRMultiSurface *poGeom)
3057 {
3058 return poGeom->begin();
3059 }
3061 inline OGRMultiSurface::ChildType **end(OGRMultiSurface *poGeom)
3062 {
3063 return poGeom->end();
3064 }
3066
3067 /************************************************************************/
3068 /* OGRMultiPolygon */
3069 /************************************************************************/
3070
3075 class CPL_DLL OGRMultiPolygon : public OGRMultiSurface
3076 {
3077 protected:
3078 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3079 friend class OGRPolyhedralSurface;
3080 friend class OGRTriangulatedSurface;
3081
3082 private:
3084 OGRErr _addGeometryWithExpectedSubGeometryType(
3085 const OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3086 OGRErr _addGeometryDirectlyWithExpectedSubGeometryType(
3087 OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3089
3090 public:
3091 OGRMultiPolygon();
3092 OGRMultiPolygon(const OGRMultiPolygon &other);
3093 ~OGRMultiPolygon() override;
3094
3095 OGRMultiPolygon &operator=(const OGRMultiPolygon &other);
3096
3098 typedef OGRPolygon ChildType;
3099
3103 ChildType **begin()
3104 {
3105 return reinterpret_cast<ChildType **>(papoGeoms);
3106 }
3108 ChildType **end()
3109 {
3110 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3111 }
3115 const ChildType *const *begin() const
3116 {
3117 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3118 }
3120 const ChildType *const *end() const
3121 {
3122 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3123 nGeomCount);
3124 }
3125
3126 // IGeometryCollection
3128 OGRPolygon *getGeometryRef(int i)
3129 {
3130 return OGRGeometryCollection::getGeometryRef(i)->toPolygon();
3131 }
3133 const OGRPolygon *getGeometryRef(int i) const
3134 {
3135 return OGRGeometryCollection::getGeometryRef(i)->toPolygon();
3136 }
3137
3138 // Non-standard (OGRGeometry).
3139 virtual const char *getGeometryName() const override;
3140 virtual OGRwkbGeometryType getGeometryType() const override;
3141 virtual OGRMultiPolygon *clone() const override;
3142
3143 #ifndef DOXYGEN_XML
3144 using OGRGeometry::exportToWkt;
3145 #endif
3146
3147 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3148 size_t &nBytesConsumedOut) override;
3149
3154 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3155 OGRErr *err = nullptr) const override;
3156
3157 // Non standard
3158 virtual OGRBoolean
3159 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3160
3162 inline OGRGeometryCollection *toUpperClass()
3163 {
3164 return this;
3165 }
3167 inline const OGRGeometryCollection *toUpperClass() const
3168 {
3169 return this;
3170 }
3171
3172 virtual void accept(IOGRGeometryVisitor *visitor) override
3173 {
3174 visitor->visit(this);
3175 }
3176 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3177 {
3178 visitor->visit(this);
3179 }
3180
3181 static OGRMultiSurface *CastToMultiSurface(OGRMultiPolygon *poMP);
3182
3183 OGR_ALLOW_CAST_TO_THIS(MultiPolygon)
3184 OGR_ALLOW_UPCAST_TO(MultiSurface)
3185 };
3186
3188
3189 inline const OGRMultiPolygon::ChildType *const *
3190 begin(const OGRMultiPolygon *poGeom)
3191 {
3192 return poGeom->begin();
3193 }
3195 inline const OGRMultiPolygon::ChildType *const *
3196 end(const OGRMultiPolygon *poGeom)
3197 {
3198 return poGeom->end();
3199 }
3200
3202 inline OGRMultiPolygon::ChildType **begin(OGRMultiPolygon *poGeom)
3203 {
3204 return poGeom->begin();
3205 }
3207 inline OGRMultiPolygon::ChildType **end(OGRMultiPolygon *poGeom)
3208 {
3209 return poGeom->end();
3210 }
3212
3213 /************************************************************************/
3214 /* OGRPolyhedralSurface */
3215 /************************************************************************/
3216
3223 class CPL_DLL OGRPolyhedralSurface : public OGRSurface
3224 {
3225 protected:
3227 friend class OGRTriangulatedSurface;
3228 OGRMultiPolygon oMP{};
3229 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
3230 virtual OGRSurfaceCasterToCurvePolygon
3231 GetCasterToCurvePolygon() const override;
3232 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
3233 virtual const char *getSubGeometryName() const;
3234 virtual OGRwkbGeometryType getSubGeometryType() const;
3235 std::string exportToWktInternal(const OGRWktOptions &opts,
3236 OGRErr *err) const;
3237
3238 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3239 GetCasterToMultiPolygon() const;
3240 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3242
3243 public:
3244 OGRPolyhedralSurface();
3245 OGRPolyhedralSurface(const OGRPolyhedralSurface &poGeom);
3246 ~OGRPolyhedralSurface() override;
3247 OGRPolyhedralSurface &operator=(const OGRPolyhedralSurface &other);
3248
3250 typedef OGRPolygon ChildType;
3251
3255 ChildType **begin()
3256 {
3257 return oMP.begin();
3258 }
3260 ChildType **end()
3261 {
3262 return oMP.end();
3263 }
3267 const ChildType *const *begin() const
3268 {
3269 return oMP.begin();
3270 }
3272 const ChildType *const *end() const
3273 {
3274 return oMP.end();
3275 }
3276
3277 // IWks Interface.
3278 virtual size_t WkbSize() const override;
3279 virtual const char *getGeometryName() const override;
3280 virtual OGRwkbGeometryType getGeometryType() const override;
3281 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3282 size_t &nBytesConsumedOut) override;
3283 virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
3284 OGRwkbVariant = wkbVariantOldOgc) const override;
3285
3286 #ifndef DOXYGEN_XML
3287 using OGRGeometry::importFromWkt;
3288 #endif
3289
3290 OGRErr importFromWkt(const char **) override;
3291
3292 #ifndef DOXYGEN_XML
3293 using OGRGeometry::exportToWkt;
3294 #endif
3295
3300 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3301 OGRErr *err = nullptr) const override;
3302
3303 // IGeometry methods.
3304 virtual int getDimension() const override;
3305
3306 virtual void empty() override;
3307
3308 virtual OGRPolyhedralSurface *clone() const override;
3309 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
3310 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3311
3312 virtual void flattenTo2D() override;
3313 virtual OGRErr transform(OGRCoordinateTransformation *) override;
3314 virtual OGRBoolean Equals(const OGRGeometry *) const override;
3315 virtual double get_Area() const override;
3316 virtual OGRErr PointOnSurface(OGRPoint *) const override;
3317
3318 static OGRMultiPolygon *CastToMultiPolygon(OGRPolyhedralSurface *poPS);
3319 virtual OGRBoolean
3320 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3321 virtual OGRErr addGeometry(const OGRGeometry *);
3322 OGRErr addGeometryDirectly(OGRGeometry *poNewGeom);
3323 OGRErr addGeometry(std::unique_ptr<OGRGeometry> poNewGeom);
3324
3325 int getNumGeometries() const;
3326 OGRPolygon *getGeometryRef(int i);
3327 const OGRPolygon *getGeometryRef(int i) const;
3328
3329 virtual OGRBoolean IsEmpty() const override;
3330 virtual void setCoordinateDimension(int nDimension) override;
3331 virtual void set3D(OGRBoolean bIs3D) override;
3332 virtual void setMeasured(OGRBoolean bIsMeasured) override;
3333 virtual void swapXY() override;
3334 OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3335
3336 virtual void accept(IOGRGeometryVisitor *visitor) override
3337 {
3338 visitor->visit(this);
3339 }
3340 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3341 {
3342 visitor->visit(this);
3343 }
3344
3345 virtual void
3346 assignSpatialReference(const OGRSpatialReference *poSR) override;
3347
3348 OGR_ALLOW_CAST_TO_THIS(PolyhedralSurface)
3349 OGR_ALLOW_UPCAST_TO(Surface)
3350 };
3351
3353
3354 inline const OGRPolyhedralSurface::ChildType *const *
3355 begin(const OGRPolyhedralSurface *poGeom)
3356 {
3357 return poGeom->begin();
3358 }
3360 inline const OGRPolyhedralSurface::ChildType *const *
3361 end(const OGRPolyhedralSurface *poGeom)
3362 {
3363 return poGeom->end();
3364 }
3365
3367 inline OGRPolyhedralSurface::ChildType **begin(OGRPolyhedralSurface *poGeom)
3368 {
3369 return poGeom->begin();
3370 }
3372 inline OGRPolyhedralSurface::ChildType **end(OGRPolyhedralSurface *poGeom)
3373 {
3374 return poGeom->end();
3375 }
3377
3378 /************************************************************************/
3379 /* OGRTriangulatedSurface */
3380 /************************************************************************/
3381
3388 class CPL_DLL OGRTriangulatedSurface : public OGRPolyhedralSurface
3389 {
3390 protected:
3392 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3393 virtual const char *getSubGeometryName() const override;
3394 virtual OGRwkbGeometryType getSubGeometryType() const override;
3395
3396 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3397 GetCasterToMultiPolygon() const override;
3398 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3400
3401 public:
3402 OGRTriangulatedSurface();
3403 OGRTriangulatedSurface(const OGRTriangulatedSurface &other);
3404 ~OGRTriangulatedSurface();
3405
3407 typedef OGRTriangle ChildType;
3408
3412 ChildType **begin()
3413 {
3414 return reinterpret_cast<ChildType **>(oMP.begin());
3415 }
3417 ChildType **end()
3418 {
3419 return reinterpret_cast<ChildType **>(oMP.end());
3420 }
3424 const ChildType *const *begin() const
3425 {
3426 return reinterpret_cast<const ChildType *const *>(oMP.begin());
3427 }
3429 const ChildType *const *end() const
3430 {
3431 return reinterpret_cast<const ChildType *const *>(oMP.end());
3432 }
3433
3434 OGRTriangulatedSurface &operator=(const OGRTriangulatedSurface &other);
3435 virtual const char *getGeometryName() const override;
3436 virtual OGRwkbGeometryType getGeometryType() const override;
3437 virtual OGRTriangulatedSurface *clone() const override;
3438
3440 OGRTriangle *getGeometryRef(int i)
3441 {
3442 return OGRPolyhedralSurface::getGeometryRef(i)->toTriangle();
3443 }
3445 const OGRTriangle *getGeometryRef(int i) const
3446 {
3447 return OGRPolyhedralSurface::getGeometryRef(i)->toTriangle();
3448 }
3449
3450 // IWks Interface.
3451 virtual OGRErr addGeometry(const OGRGeometry *) override;
3452
3453 #ifndef DOXYGEN_XML
3454 using OGRPolyhedralSurface::addGeometry;
3455 #endif
3456
3458 inline OGRPolyhedralSurface *toUpperClass()
3459 {
3460 return this;
3461 }
3463 inline const OGRPolyhedralSurface *toUpperClass() const
3464 {
3465 return this;
3466 }
3467
3468 virtual void accept(IOGRGeometryVisitor *visitor) override
3469 {
3470 visitor->visit(this);
3471 }
3472 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3473 {
3474 visitor->visit(this);
3475 }
3476
3477 static OGRPolyhedralSurface *
3478 CastToPolyhedralSurface(OGRTriangulatedSurface *poTS);
3479
3480 OGR_ALLOW_CAST_TO_THIS(TriangulatedSurface)
3481 OGR_ALLOW_UPCAST_TO(PolyhedralSurface)
3482 };
3483
3485
3486 inline const OGRTriangulatedSurface::ChildType *const *
3487 begin(const OGRTriangulatedSurface *poGeom)
3488 {
3489 return poGeom->begin();
3490 }
3492 inline const OGRTriangulatedSurface::ChildType *const *
3493 end(const OGRTriangulatedSurface *poGeom)
3494 {
3495 return poGeom->end();
3496 }
3497
3499 inline OGRTriangulatedSurface::ChildType **begin(OGRTriangulatedSurface *poGeom)
3500 {
3501 return poGeom->begin();
3502 }
3504 inline OGRTriangulatedSurface::ChildType **end(OGRTriangulatedSurface *poGeom)
3505 {
3506 return poGeom->end();
3507 }
3509
3510 /************************************************************************/
3511 /* OGRMultiPoint */
3512 /************************************************************************/
3513
3518 class CPL_DLL OGRMultiPoint : public OGRGeometryCollection
3519 {
3520 private:
3521 OGRErr importFromWkt_Bracketed(const char **, int bHasM, int bHasZ);
3522
3523 protected:
3524 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3525
3526 public:
3527 OGRMultiPoint();
3528 OGRMultiPoint(const OGRMultiPoint &other);
3529 ~OGRMultiPoint() override;
3530
3531 OGRMultiPoint &operator=(const OGRMultiPoint &other);
3532
3534 typedef OGRPoint ChildType;
3535
3539 ChildType **begin()
3540 {
3541 return reinterpret_cast<ChildType **>(papoGeoms);
3542 }
3544 ChildType **end()
3545 {
3546 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3547 }
3551 const ChildType *const *begin() const
3552 {
3553 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3554 }
3556 const ChildType *const *end() const
3557 {
3558 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3559 nGeomCount);
3560 }
3561
3562 // IGeometryCollection
3564 OGRPoint *getGeometryRef(int i)
3565 {
3566 return OGRGeometryCollection::getGeometryRef(i)->toPoint();
3567 }
3569 const OGRPoint *getGeometryRef(int i) const
3570 {
3571 return OGRGeometryCollection::getGeometryRef(i)->toPoint();
3572 }
3573
3574 // Non-standard (OGRGeometry).
3575 virtual const char *getGeometryName() const override;
3576 virtual OGRwkbGeometryType getGeometryType() const override;
3577 virtual OGRMultiPoint *clone() const override;
3578
3579 #ifndef DOXYGEN_XML
3580 using OGRGeometry::importFromWkt;
3581 #endif
3582
3583 OGRErr importFromWkt(const char **) override;
3584
3585 #ifndef DOXYGEN_XML
3586 using OGRGeometry::exportToWkt;
3587 #endif
3588
3593 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3594 OGRErr *err = nullptr) const override;
3595
3596 // IGeometry methods.
3597 virtual int getDimension() const override;
3598
3600 inline OGRGeometryCollection *toUpperClass()
3601 {
3602 return this;
3603 }
3605 inline const OGRGeometryCollection *toUpperClass() const
3606 {
3607 return this;
3608 }
3609
3610 virtual void accept(IOGRGeometryVisitor *visitor) override
3611 {
3612 visitor->visit(this);
3613 }
3614 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3615 {
3616 visitor->visit(this);
3617 }
3618
3619 // Non-standard.
3620 virtual OGRBoolean
3621 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3622
3623 OGR_ALLOW_CAST_TO_THIS(MultiPoint)
3624 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3625 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3626 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3627 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3628 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3629 };
3630
3632
3633 inline const OGRMultiPoint::ChildType *const *begin(const OGRMultiPoint *poGeom)
3634 {
3635 return poGeom->begin();
3636 }
3638 inline const OGRMultiPoint::ChildType *const *end(const OGRMultiPoint *poGeom)
3639 {
3640 return poGeom->end();
3641 }
3642
3644 inline OGRMultiPoint::ChildType **begin(OGRMultiPoint *poGeom)
3645 {
3646 return poGeom->begin();
3647 }
3649 inline OGRMultiPoint::ChildType **end(OGRMultiPoint *poGeom)
3650 {
3651 return poGeom->end();
3652 }
3654
3655 /************************************************************************/
3656 /* OGRMultiCurve */
3657 /************************************************************************/
3658
3665 class CPL_DLL OGRMultiCurve : public OGRGeometryCollection
3666 {
3667 protected:
3669 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
3670 OGRCurve *poCurve);
3672 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3673
3674 public:
3675 OGRMultiCurve();
3676 OGRMultiCurve(const OGRMultiCurve &other);
3677 ~OGRMultiCurve() override;
3678
3679 OGRMultiCurve &operator=(const OGRMultiCurve &other);
3680
3682 typedef OGRCurve ChildType;
3683
3687 ChildType **begin()
3688 {
3689 return reinterpret_cast<ChildType **>(papoGeoms);
3690 }
3692 ChildType **end()
3693 {
3694 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3695 }
3699 const ChildType *const *begin() const
3700 {
3701 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3702 }
3704 const ChildType *const *end() const
3705 {
3706 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3707 nGeomCount);
3708 }
3709
3710 // IGeometryCollection
3712 OGRCurve *getGeometryRef(int i)
3713 {
3714 return OGRGeometryCollection::getGeometryRef(i)->toCurve();
3715 }
3717 const OGRCurve *getGeometryRef(int i) const
3718 {
3719 return OGRGeometryCollection::getGeometryRef(i)->toCurve();
3720 }
3721
3722 // Non standard (OGRGeometry).
3723 virtual const char *getGeometryName() const override;
3724 virtual OGRwkbGeometryType getGeometryType() const override;
3725 virtual OGRMultiCurve *clone() const override;
3726
3727 #ifndef DOXYGEN_XML
3728 using OGRGeometry::importFromWkt;
3729 #endif
3730
3731 OGRErr importFromWkt(const char **) override;
3732
3733 #ifndef DOXYGEN_XML
3734 using OGRGeometry::exportToWkt;
3735 #endif
3736
3741 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3742 OGRErr *err = nullptr) const override;
3743
3744 // IGeometry methods.
3745 virtual int getDimension() const override;
3746
3747 // Non-standard.
3748 virtual OGRBoolean
3749 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3750
3752 inline OGRGeometryCollection *toUpperClass()
3753 {
3754 return this;
3755 }
3757 inline const OGRGeometryCollection *toUpperClass() const
3758 {
3759 return this;
3760 }
3761
3762 virtual void accept(IOGRGeometryVisitor *visitor) override
3763 {
3764 visitor->visit(this);
3765 }
3766 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3767 {
3768 visitor->visit(this);
3769 }
3770
3771 static OGRMultiLineString *CastToMultiLineString(OGRMultiCurve *poMC);
3772
3773 OGR_ALLOW_CAST_TO_THIS(MultiCurve)
3774 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3775 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3776 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3777 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3778 };
3779
3781
3782 inline const OGRMultiCurve::ChildType *const *begin(const OGRMultiCurve *poGeom)
3783 {
3784 return poGeom->begin();
3785 }
3787 inline const OGRMultiCurve::ChildType *const *end(const OGRMultiCurve *poGeom)
3788 {
3789 return poGeom->end();
3790 }
3791
3793 inline OGRMultiCurve::ChildType **begin(OGRMultiCurve *poGeom)
3794 {
3795 return poGeom->begin();
3796 }
3798 inline OGRMultiCurve::ChildType **end(OGRMultiCurve *poGeom)
3799 {
3800 return poGeom->end();
3801 }
3803
3804 /************************************************************************/
3805 /* OGRMultiLineString */
3806 /************************************************************************/
3807
3812 class CPL_DLL OGRMultiLineString : public OGRMultiCurve
3813 {
3814 protected:
3815 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3816
3817 public:
3818 OGRMultiLineString();
3819 OGRMultiLineString(const OGRMultiLineString &other);
3820 ~OGRMultiLineString() override;
3821
3822 OGRMultiLineString &operator=(const OGRMultiLineString &other);
3823
3825 typedef OGRLineString ChildType;
3826
3830 ChildType **begin()
3831 {
3832 return reinterpret_cast<ChildType **>(papoGeoms);
3833 }
3835 ChildType **end()
3836 {
3837 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3838 }
3842 const ChildType *const *begin() const
3843 {
3844 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3845 }
3847 const ChildType *const *end() const
3848 {
3849 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3850 nGeomCount);
3851 }
3852
3853 // IGeometryCollection
3855 OGRLineString *getGeometryRef(int i)
3856 {
3857 return OGRGeometryCollection::getGeometryRef(i)->toLineString();
3858 }
3860 const OGRLineString *getGeometryRef(int i) const
3861 {
3862 return OGRGeometryCollection::getGeometryRef(i)->toLineString();
3863 }
3864
3865 // Non standard (OGRGeometry).
3866 virtual const char *getGeometryName() const override;
3867 virtual OGRwkbGeometryType getGeometryType() const override;
3868 virtual OGRMultiLineString *clone() const override;
3869
3870 #ifndef DOXYGEN_XML
3871 using OGRGeometry::exportToWkt;
3872 #endif
3873
3874 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3875 size_t &nBytesConsumedOut) override;
3876
3881 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3882 OGRErr *err = nullptr) const override;
3883
3884 // Non standard
3885 virtual OGRBoolean
3886 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3887
3889 inline OGRGeometryCollection *toUpperClass()
3890 {
3891 return this;
3892 }
3894 inline const OGRGeometryCollection *toUpperClass() const
3895 {
3896 return this;
3897 }
3898
3899 virtual void accept(IOGRGeometryVisitor *visitor) override
3900 {
3901 visitor->visit(this);
3902 }
3903 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3904 {
3905 visitor->visit(this);
3906 }
3907
3908 static OGRMultiCurve *CastToMultiCurve(OGRMultiLineString *poMLS);
3909
3910 OGR_ALLOW_CAST_TO_THIS(MultiLineString)
3911 OGR_ALLOW_UPCAST_TO(MultiCurve)
3912 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3913 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3914 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3915 };
3916
3918
3919 inline const OGRMultiLineString::ChildType *const *
3920 begin(const OGRMultiLineString *poGeom)
3921 {
3922 return poGeom->begin();
3923 }
3925 inline const OGRMultiLineString::ChildType *const *
3926 end(const OGRMultiLineString *poGeom)
3927 {
3928 return poGeom->end();
3929 }
3930
3932 inline OGRMultiLineString::ChildType **begin(OGRMultiLineString *poGeom)
3933 {
3934 return poGeom->begin();
3935 }
3937 inline OGRMultiLineString::ChildType **end(OGRMultiLineString *poGeom)
3938 {
3939 return poGeom->end();
3940 }
3942
3943 /************************************************************************/
3944 /* OGRGeometryFactory */
3945 /************************************************************************/
3946
3951 class CPL_DLL OGRGeometryFactory
3952 {
3953 static OGRErr createFromFgfInternal(const unsigned char *pabyData,
3954 OGRSpatialReference *poSR,
3955 OGRGeometry **ppoReturn, int nBytes,
3956 int *pnBytesConsumed, int nRecLevel);
3957
3958 public:
3959 static OGRErr createFromWkb(const void *, const OGRSpatialReference *,
3960 OGRGeometry **,
3961 size_t = static_cast<size_t>(-1),
3962 OGRwkbVariant = wkbVariantOldOgc);
3963 static OGRErr createFromWkb(const void *pabyData,
3964 const OGRSpatialReference *, OGRGeometry **,
3965 size_t nSize, OGRwkbVariant eVariant,
3966 size_t &nBytesConsumedOut);
3967 static OGRErr createFromWkt(const char *, const OGRSpatialReference *,
3968 OGRGeometry **);
3969 static OGRErr createFromWkt(const char **, const OGRSpatialReference *,
3970 OGRGeometry **);
3974 static OGRErr createFromWkt(char **ppszInput,
3975 const OGRSpatialReference *poSRS,
3976 OGRGeometry **ppoGeom)
3977 CPL_WARN_DEPRECATED("Use createFromWkt(const char**, ...) instead")
3978 {
3979 return createFromWkt(const_cast<const char **>(ppszInput), poSRS,
3980 ppoGeom);
3981 }
3982
3983 static OGRErr createFromFgf(const void *, OGRSpatialReference *,
3984 OGRGeometry **, int = -1, int * = nullptr);
3985 static OGRGeometry *createFromGML(const char *);
3986 static OGRGeometry *createFromGEOS(GEOSContextHandle_t hGEOSCtxt, GEOSGeom);
3987 static OGRGeometry *createFromGeoJson(const char *, int = -1);
3988 static OGRGeometry *createFromGeoJson(const CPLJSONObject &oJSONObject);
3989
3990 static void destroyGeometry(OGRGeometry *);
3991 static OGRGeometry *createGeometry(OGRwkbGeometryType);
3992
3993 static OGRGeometry *forceToPolygon(OGRGeometry *);
3994 static OGRGeometry *forceToLineString(OGRGeometry *,
3995 bool bOnlyInOrder = true);
3996 static OGRGeometry *forceToMultiPolygon(OGRGeometry *);
3997 static OGRGeometry *forceToMultiPoint(OGRGeometry *);
3998 static OGRGeometry *forceToMultiLineString(OGRGeometry *);
3999
4000 static OGRGeometry *forceTo(OGRGeometry *poGeom,
4001 OGRwkbGeometryType eTargetType,
4002 const char *const *papszOptions = nullptr);
4003
4004 static OGRGeometry *removeLowerDimensionSubGeoms(const OGRGeometry *poGeom);
4005
4006 static OGRGeometry *organizePolygons(OGRGeometry **papoPolygons,
4007 int nPolygonCount,
4008 int *pbResultValidGeometry,
4009 const char **papszOptions = nullptr);
4010 static bool haveGEOS();
4011
4013 class CPL_DLL TransformWithOptionsCache
4014 {
4015 friend class OGRGeometryFactory;
4016 struct Private;
4017 std::unique_ptr<Private> d;
4018
4019 public:
4020 TransformWithOptionsCache();
4021 ~TransformWithOptionsCache();
4022 };
4023
4024 static OGRGeometry *transformWithOptions(
4025 const OGRGeometry *poSrcGeom, OGRCoordinateTransformation *poCT,
4026 char **papszOptions,
4027 const TransformWithOptionsCache &cache = TransformWithOptionsCache());
4028
4029 static OGRGeometry *
4030 approximateArcAngles(double dfX, double dfY, double dfZ,
4031 double dfPrimaryRadius, double dfSecondaryAxis,
4032 double dfRotation, double dfStartAngle,
4033 double dfEndAngle, double dfMaxAngleStepSizeDegrees,
4034 const bool bUseMaxGap = false);
4035
4036 static int GetCurveParameters(double x0, double y0, double x1, double y1,
4037 double x2, double y2, double &R, double &cx,
4038 double &cy, double &alpha0, double &alpha1,
4039 double &alpha2);
4040 static OGRLineString *
4041 curveToLineString(double x0, double y0, double z0, double x1, double y1,
4042 double z1, double x2, double y2, double z2, int bHasZ,
4043 double dfMaxAngleStepSizeDegrees,
4044 const char *const *papszOptions = nullptr);
4045 static OGRCurve *
4046 curveFromLineString(const OGRLineString *poLS,
4047 const char *const *papszOptions = nullptr);
4048 };
4049
4050 OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType(const char *pszGeomType);
4051 const char CPL_DLL *OGRToOGCGeomType(OGRwkbGeometryType eGeomType,
4052 bool bCamelCase = false,
4053 bool bAddZM = false,
4054 bool bSpaceBeforeZM = false);
4055
4057 typedef struct _OGRPreparedGeometry OGRPreparedGeometry;
4058
4059 struct CPL_DLL OGRPreparedGeometryUniquePtrDeleter
4060 {
4061 void operator()(OGRPreparedGeometry *) const;
4062 };
4064
4068 typedef std::unique_ptr<OGRPreparedGeometry,
4069 OGRPreparedGeometryUniquePtrDeleter>
4070 OGRPreparedGeometryUniquePtr;
4071
4072 #endif /* ndef OGR_GEOMETRY_H_INCLUDED */
IOGRGeometryVisitor::visit
virtual void visit(OGRPoint *)=0
Visit OGRPoint.
OGRSimpleCurve::getEnvelope
virtual void getEnvelope(OGREnvelope *psEnvelope) const override
Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
Definition: ogrlinestring.cpp:2262
OGRCurvePolygon::getEnvelope
virtual void getEnvelope(OGREnvelope *psEnvelope) const override
Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
Definition: ogrcurvepolygon.cpp:640
OGRGeometry::importFromWkt
OGRErr importFromWkt(char **ppszInput)
Deprecated.
Definition: ogr_geometry.h:439
OGRGeometry::Is3D
OGRBoolean Is3D() const
Definition: ogr_geometry.h:410
OGRGeometry::IsEmpty
virtual OGRBoolean IsEmpty() const =0
Returns TRUE (non-zero) if the object has no points.
OGRGeometry::toMultiPolygon
OGRMultiPolygon * toMultiPolygon()
Down-cast to OGRMultiPolygon*.
Definition: ogr_geometry.h:879
OGRMultiPolygon::ChildType
OGRPolygon ChildType
Type of child elements.
Definition: ogr_geometry.h:3098
OGRMultiLineString::ChildType
OGRLineString ChildType
Type of child elements.
Definition: ogr_geometry.h:3825
OGRMultiPolygon::getGeometryRef
OGRPolygon * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3128
OGRGeometry::setCoordinateDimension
virtual void setCoordinateDimension(int nDimension)
Set the coordinate dimension.
Definition: ogrgeometry.cpp:1064
OGRCurvePolygon::addRingDirectly
virtual OGRErr addRingDirectly(OGRCurve *)
Add a ring to a polygon.
Definition: ogrcurvepolygon.cpp:418
OGRMultiLineString::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:3889
OGRMultiLineString::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3830
OGRMultiCurve
A collection of OGRCurve.
Definition: ogr_geometry.h:3665
OGRCurve::CastToLineString
static OGRLineString * CastToLineString(OGRCurve *poCurve)
Cast to linestring.
Definition: ogrcurve.cpp:353
OGRRawPoint::OGRRawPoint
OGRRawPoint()
Constructor.
Definition: ogr_geometry.h:108
OGRGeometryCollection::isCompatibleSubType
virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const
Returns whether a geometry of the specified geometry type can be a member of this collection.
Definition: ogrgeometrycollection.cpp:1209
ogr_spatialref.h
OGRWktFormat::F
@ F
F-type formatting.
OGRSimpleCurve::getX
double getX(int i) const
Get X at vertex.
Definition: ogr_geometry.h:1583
OGRPolyhedralSurface::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3260
OGRSurface::get_Area
virtual double get_Area() const =0
Get the area of the surface object.
OGRCurve::get_AreaOfCurveSegments
virtual double get_AreaOfCurveSegments() const =0
Get the area of the purely curve portions of a (closed) curve.
OGRGeometry::operator==
bool operator==(const OGRGeometry &other) const
Returns if two geometries are equal.
Definition: ogr_geometry.h:389
OGRTriangulatedSurface::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3424
OGRLineString
Concrete representation of a multi-vertex line.
Definition: ogr_geometry.h:1682
OGRMultiLineString::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3842
OGRPolyhedralSurface::getNumGeometries
int getNumGeometries() const
Fetch number of geometries in PolyhedralSurface.
Definition: ogrpolyhedralsurface.cpp:822
OGRPolyhedralSurface::getGeometryRef
OGRPolygon * getGeometryRef(int i)
Fetch geometry from container.
Definition: ogrpolyhedralsurface.cpp:844
OGRGeometry::Contains
virtual OGRBoolean Contains(const OGRGeometry *) const
Test for containment.
Definition: ogrgeometry.cpp:5445
OGRMultiPolygon
A collection of non-overlapping OGRPolygon.
Definition: ogr_geometry.h:3075
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:196
OGRPolyhedralSurface::CastToMultiPolygon
static OGRMultiPolygon * CastToMultiPolygon(OGRPolyhedralSurface *poPS)
Casts the OGRPolyhedralSurface to an OGRMultiPolygon.
Definition: ogrpolyhedralsurface.cpp:707
OGRPolyhedralSurface::addGeometryDirectly
OGRErr addGeometryDirectly(OGRGeometry *poNewGeom)
Add a geometry directly to the container.
Definition: ogrpolyhedralsurface.cpp:766
OGRMultiPoint::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:3600
OGRGeometryFactory::TransformWithOptionsCache
Opaque class used as argument to transformWithOptions()
Definition: ogr_geometry.h:4013
OGRSimpleCurve::clone
virtual OGRSimpleCurve * clone() const override=0
Make a copy of this object.
OGRPointIterator
Interface for a point iterator.
Definition: ogr_geometry.h:1236
OGRMultiSurface::ChildType
OGRSurface ChildType
Type of child elements.
Definition: ogr_geometry.h:2940
OGRMultiSurface::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:2945
OGRCurvePolygon::flattenTo2D
virtual void flattenTo2D() override
Convert geometry to strictly 2D. In a sense this converts all Z coordinates to 0.0.
Definition: ogrcurvepolygon.cpp:148
OGRGeometry::closeRings
virtual void closeRings()
Force rings to be closed.
Definition: ogrgeometry.cpp:5579
OGRMultiSurface::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3027
OGRCompoundCurve
Utility class to store a collection of curves.
Definition: ogr_geometry.h:2073
OGRPolygon::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:2621
OGRGeometry::clone
virtual OGRGeometry * clone() const =0
Make a copy of this object.
OGRSimpleCurve::getNumPoints
virtual int getNumPoints() const override
Fetch vertex count.
Definition: ogr_geometry.h:1578
OGRGeometry::getGeometryType
virtual OGRwkbGeometryType getGeometryType() const =0
Fetch geometry type.
OGRGeometry::swapXY
virtual void swapXY()
Swap x and y coordinates.
Definition: ogrgeometry.cpp:6261
OGRSimpleCurve::importFromWkt
OGRErr importFromWkt(const char **) override
deprecated
Definition: ogrlinestring.cpp:1737
OGRPolyhedralSurface::getGeometryType
virtual OGRwkbGeometryType getGeometryType() const override
Returns the WKB Type of PolyhedralSurface.
Definition: ogrpolyhedralsurface.cpp:120
OGRLineString::toUpperClass
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:1721
OGRGeometryCollection::hasCurveGeometry
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const override
Returns if this geometry is or has curve geometry.
Definition: ogrgeometrycollection.cpp:1220
OGRGeometry::toCurve
OGRCurve * toCurve()
Down-cast to OGRCurve*.
Definition: ogr_geometry.h:623
OGRWktOptions::format
OGRWktFormat format
Formatting type.
Definition: ogr_geometry.h:79
begin
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:411
OGRMultiLineString::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3847
OGRCurvePolygon::IsEmpty
virtual OGRBoolean IsEmpty() const override
Returns TRUE (non-zero) if the object has no points.
Definition: ogrcurvepolygon.cpp:738
OGRPolygon::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:2554
OGRMultiSurface::getGeometryRef
OGRSurface * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:2998
IOGRConstGeometryVisitor
OGRGeometry visitor interface.
Definition: ogr_geometry.h:238
OGRWktOptions::OGRWktOptions
OGRWktOptions()
Constructor.
Definition: ogr_geometry.h:82
OGRSimpleCurve::exportToWkb
virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc) const override
Convert a geometry into well known binary format.
Definition: ogrlinestring.cpp:1635
OGRPoint::setM
void setM(double mIn)
Set m.
Definition: ogr_geometry.h:1193
OGRTriangulatedSurface::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3417
OGRGeometry::assignSpatialReference
virtual void assignSpatialReference(const OGRSpatialReference *poSR)
Assign spatial reference to this object.
Definition: ogrgeometry.cpp:468
OGRSimpleCurve::WkbSize
virtual size_t WkbSize() const override
Returns size of related binary representation.
Definition: ogrlinestring.cpp:185
OGRLinearRing::toUpperClass
const OGRLineString * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:1825
OGRCurvePolygon::CurvePolyToPoly
virtual OGRPolygon * CurvePolyToPoly(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const
Return a polygon from a curve polygon.
Definition: ogrcurvepolygon.cpp:590
OGRCompoundCurve::begin
ChildType ** begin()
Return begin of curve iterator.
Definition: ogr_geometry.h:2114
OGRGeometry::set3D
virtual void set3D(OGRBoolean bIs3D)
Add or remove the Z coordinate dimension.
Definition: ogrgeometry.cpp:1087
OGRGeometry::toCompoundCurve
const OGRCompoundCurve * toCompoundCurve() const
Down-cast to OGRCompoundCurve*.
Definition: ogr_geometry.h:731
OGRGeometryFactory
Create geometry objects from well known text/binary.
Definition: ogr_geometry.h:3951
OGRGeometryCollection::end
const ChildType *const * end() const
Return end of sub-geometry iterator.
Definition: ogr_geometry.h:2795
OGRGeometry::toMultiSurface
OGRMultiSurface * toMultiSurface()
Down-cast to OGRMultiSurface*.
Definition: ogr_geometry.h:919
OGRMultiPolygon::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:3167
OGRMultiCurve::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3704
OGRPolyhedralSurface::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3340
OGRMultiCurve::isCompatibleSubType
virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override
Returns whether a geometry of the specified geometry type can be a member of this collection.
Definition: ogrmulticurve.cpp:144
OGRTriangle::toUpperClass
const OGRPolygon * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:2710
OGRMultiPoint::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3544
OGRGeometry::FromHandle
static OGRGeometry * FromHandle(OGRGeometryH hGeom)
Convert a OGRGeometryH to a OGRGeometry*.
Definition: ogr_geometry.h:595
OGRMultiSurface::getGeometryRef
const OGRSurface * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3003
OGRPolygon::ChildType
OGRLinearRing ChildType
Type of child elements.
Definition: ogr_geometry.h:2532
OGRCurvePolygon::hasCurveGeometry
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const override
Returns if this geometry is or has curve geometry.
Definition: ogrcurvepolygon.cpp:615
OGRGeometryCollection
A collection of 1 or more geometry objects.
Definition: ogr_geometry.h:2743
OGRGeometry::hasCurveGeometry
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const
Returns if this geometry is or has curve geometry.
Definition: ogrgeometry.cpp:3273
wkbVariantOldOgc
@ wkbVariantOldOgc
Old-style 99-402 extended dimension (Z) WKB types.
Definition: ogr_core.h:542
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:166
OGRPolyhedralSurface::getGeometryName
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition: ogrpolyhedralsurface.cpp:106
OGRGeometryCollection::getGeometryRef
OGRGeometry * getGeometryRef(int)
Fetch geometry from container.
Definition: ogrgeometrycollection.cpp:259
OGRGeometry::toCircularString
OGRCircularString * toCircularString()
Down-cast to OGRCircularString*.
Definition: ogr_geometry.h:701
OGRPolyhedralSurface
PolyhedralSurface class.
Definition: ogr_geometry.h:3223
OGRCurve::isClockwise
virtual int isClockwise() const
Returns TRUE if the ring has clockwise winding (or less than 2 points)
Definition: ogrcurve.cpp:711
OGRGeometry::toCircularString
const OGRCircularString * toCircularString() const
Down-cast to OGRCircularString*.
Definition: ogr_geometry.h:711
OGRMultiPolygon::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3172
OGRCompoundCurve::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:2213
OGRCurve::Value
virtual void Value(double, OGRPoint *) const =0
Fetch point at given distance along curve.
OGRGeometryCollection::getGeometryName
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition: ogrgeometrycollection.cpp:215
OGRGeometry::toTriangulatedSurface
OGRTriangulatedSurface * toTriangulatedSurface()
Down-cast to OGRTriangulatedSurface*.
Definition: ogr_geometry.h:958
OGRGeometry::toTriangle
const OGRTriangle * toTriangle() const
Down-cast to OGRTriangle*.
Definition: ogr_geometry.h:789
OGRGeometry::toPolygon
const OGRPolygon * toPolygon() const
Down-cast to OGRPolygon*.
Definition: ogr_geometry.h:771
OGRGeometry::getLinearGeometry
virtual OGRGeometry * getLinearGeometry(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const
Return, possibly approximate, non-curve version of this geometry.
Definition: ogrgeometry.cpp:3306
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:334
OGRMultiPoint
A collection of OGRPoint.
Definition: ogr_geometry.h:3518
OGRGeometry::IsValid
virtual OGRBoolean IsValid() const
Test if the geometry is valid.
Definition: ogrgeometry.cpp:2177
OGRGeometry::getGeometryName
virtual const char * getGeometryName() const =0
Fetch WKT name for geometry type.
OGRPolygon::getGeometryName
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition: ogrpolygon.cpp:130
OGRPolygon::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:2625
OGRIteratedPoint
Definition: ogr_geometry.h:1397
OGRCurve::toSimpleCurve
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition: ogr_geometry.h:1344
OGRCurvePolygon::clone
virtual OGRCurvePolygon * clone() const override
Make a copy of this object.
Definition: ogrcurvepolygon.cpp:101
OGRPolyhedralSurface::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3255
OGRMultiSurface
A collection of non-overlapping OGRSurface.
Definition: ogr_geometry.h:2927
OGRGeometry::importFromWkb
OGRErr importFromWkb(const GByte *, size_t=static_cast< size_t >(-1), OGRwkbVariant=wkbVariantOldOgc)
Assign geometry from well known binary data.
Definition: ogrgeometry.cpp:1463
OGRPoint
Point class.
Definition: ogr_geometry.h:1083
OGRGeometryFactory::createFromWkt
static OGRErr createFromWkt(char **ppszInput, const OGRSpatialReference *poSRS, OGRGeometry **ppoGeom)
Deprecated.
Definition: ogr_geometry.h:3974
OGRWktOptions::round
bool round
Whether GDAL-special rounding should be applied.
Definition: ogr_geometry.h:77
OGRPolygon::exportToWkb
virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc) const override
Convert a geometry into well known binary format.
Definition: ogrpolygon.cpp:430
OGRMultiCurve::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3762
OGRTriangulatedSurface::addGeometry
virtual OGRErr addGeometry(const OGRGeometry *) override
Add a new geometry to a collection.
Definition: ogrtriangulatedsurface.cpp:188
OGRSimpleCurve::getY
double getY(int i) const
Get Y at vertex.
Definition: ogr_geometry.h:1587
OGRGeometry::exportToWkt
OGRErr exportToWkt(char **ppszDstText, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known text format.
Definition: ogrgeometry.cpp:1863
OGRMultiCurve::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:3757
OGRCurvePolygon::empty
virtual void empty() override
Clear geometry information. This restores the geometry to its initial state after construction,...
Definition: ogrcurvepolygon.cpp:111
OGRCurvePolygon::exportToWkt
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const override
Export a curve polygon to WKT.
Definition: ogrcurvepolygon.cpp:561
OGRGeometry::operator=
OGRGeometry & operator=(const OGRGeometry &other)
Assignment operator.
Definition: ogrgeometry.cpp:150
OGRMultiPolygon::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3176
OGRGeometry::importFromWkt
virtual OGRErr importFromWkt(const char **ppszInput)=0
Assign geometry from well known text data.
OGRMultiCurve::exportToWkt
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const override
Export a multicurve to WKT.
Definition: ogrmulticurve.cpp:183
OGRWktOptions::variant
OGRwkbVariant variant
Type of WKT output to produce.
Definition: ogr_geometry.h:73
OGRPolygon::operator=
OGRPolygon & operator=(const OGRPolygon &other)
Assignment operator.
Definition: ogrpolygon.cpp:90
OGRWktFormat::Default
@ Default
Format as F when abs(value) < 1, otherwise as G.
OGRBoolean
int OGRBoolean
Type for a OGR boolean.
Definition: ogr_core.h:395
OGRMultiPoint::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3556
OGRRawPoint::x
double x
x
Definition: ogr_geometry.h:118
OGRMultiCurve::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3692
OGRPoint::setX
void setX(double xIn)
Set x.
Definition: ogr_geometry.h:1163
OGRLineString::getGeometryName
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition: ogrlinestring.cpp:2779
OGRWktOptions::precision
int precision
Precision of output. Interpretation depends on format.
Definition: ogr_geometry.h:75
OGRGeometry::toLinearRing
const OGRLinearRing * toLinearRing() const
Down-cast to OGRLinearRing*.
Definition: ogr_geometry.h:691
OGRGeometryCollection::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:2873
OGRSurface::PointOnSurface
virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
This method relates to the SFCOM ISurface::get_PointOnSurface() method.
Definition: ogr_geometry.h:2273
OGRPolygon::exportToWkt
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const override
Export a polygon to WKT.
Definition: ogrpolygon.cpp:686
OGRLinearRing::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:1830
OGRGeometry::exportToWkb
virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc) const =0
Convert a geometry into well known binary format.
OGRMultiPolygon::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3103
OGRMultiSurface::clone
virtual OGRMultiSurface * clone() const override
Make a copy of this object.
Definition: ogrmultisurface.cpp:97
OGRRawPoint
Simple container for a position.
Definition: ogr_geometry.h:104
OGRMultiLineString
A collection of OGRLineString.
Definition: ogr_geometry.h:3812
OGRCurvePolygon::ChildType
OGRCurve ChildType
Type of child elements.
Definition: ogr_geometry.h:2343
OGRGeometry::flattenTo2D
virtual void flattenTo2D()=0
Convert geometry to strictly 2D. In a sense this converts all Z coordinates to 0.0.
OGRCurve::StartPoint
virtual void StartPoint(OGRPoint *) const =0
Return the curve start point.
OGRMultiSurface::isCompatibleSubType
virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override
Returns whether a geometry of the specified geometry type can be a member of this collection.
Definition: ogrmultisurface.cpp:145
OGRGeometry::toMultiCurve
OGRMultiCurve * toMultiCurve()
Down-cast to OGRMultiCurve*.
Definition: ogr_geometry.h:899
OGRMultiPoint::ChildType
OGRPoint ChildType
Type of child elements.
Definition: ogr_geometry.h:3534
OGRPolyhedralSurface::addGeometry
virtual OGRErr addGeometry(const OGRGeometry *)
Add a new geometry to a collection.
Definition: ogrpolyhedralsurface.cpp:726
OGRMultiLineString::getGeometryRef
OGRLineString * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3855
OGRSurface
Abstract base class for 2 dimensional objects like polygons or curve polygons.
Definition: ogr_geometry.h:2263
OGRSimpleCurve::operator=
OGRSimpleCurve & operator=(const OGRSimpleCurve &other)
Assignment operator.
Definition: ogrlinestring.cpp:112
OGRMultiSurface::hasCurveGeometry
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const override
Returns if this geometry is or has curve geometry.
Definition: ogrmultisurface.cpp:293
OGRCurve::getNumPoints
virtual int getNumPoints() const =0
Return the number of points of a curve geometry.
OGRPolygon::WkbSize
virtual size_t WkbSize() const override
Returns size of related binary representation.
Definition: ogrpolygon.cpp:329
OGRwkbByteOrder
OGRwkbByteOrder
Enumeration to describe byte order.
Definition: ogr_core.h:610
OGRTriangulatedSurface::toUpperClass
OGRPolyhedralSurface * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:3458
OGRCircularString::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:1944
OGRTriangle::operator=
OGRTriangle & operator=(const OGRTriangle &other)
Assignment operator.
Definition: ogrtriangle.cpp:135
OGRTriangulatedSurface::ChildType
OGRTriangle ChildType
Type of child elements.
Definition: ogr_geometry.h:3407
OGRCircularString
Concrete representation of a circular string, that is to say a curve made of one or several arc circl...
Definition: ogr_geometry.h:1859
OGRCurvePolygon::OGRCurvePolygon
OGRCurvePolygon()
Create an empty curve polygon.
OGRSurface::clone
virtual OGRSurface * clone() const override=0
Make a copy of this object.
OGRMultiCurve::getGeometryType
virtual OGRwkbGeometryType getGeometryType() const override
Fetch geometry type.
Definition: ogrmulticurve.cpp:106
OGRGeometry::Intersects
virtual OGRBoolean Intersects(const OGRGeometry *) const
Do these features intersect?
Definition: ogrgeometry.cpp:538
OGRPolygon::CurvePolyToPoly
virtual OGRPolygon * CurvePolyToPoly(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const override
Return a polygon from a curve polygon.
Definition: ogrpolygon.cpp:802
OGRGeometry::toLineString
const OGRLineString * toLineString() const
Down-cast to OGRLineString*.
Definition: ogr_geometry.h:673
OGRGeometry::toTriangle
OGRTriangle * toTriangle()
Down-cast to OGRTriangle*.
Definition: ogr_geometry.h:780
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1178
CPLJSONObject
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition: cpl_json.h:54
OGRGeometryCollection::operator=
OGRGeometryCollection & operator=(const OGRGeometryCollection &other)
Assignment operator.
Definition: ogrgeometrycollection.cpp:109
OGRSimpleCurve::exportToWkt
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const override
Export a simple curve to WKT.
Definition: ogrlinestring.cpp:1857
OGRTriangulatedSurface::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3468
OGRGeometry::toPoint
OGRPoint * toPoint()
Down-cast to OGRPoint*.
Definition: ogr_geometry.h:604
OGRLineString::clone
virtual OGRLineString * clone() const override
Make a copy of this object.
Definition: ogrlinestring.cpp:2904
OGRCurvePolygon::set3D
virtual void set3D(OGRBoolean bIs3D) override
Add or remove the Z coordinate dimension.
Definition: ogrcurvepolygon.cpp:715
OGRGeometry::toSurface
OGRSurface * toSurface()
Down-cast to OGRSurface*.
Definition: ogr_geometry.h:741
OGRMultiCurve::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3687
OGRMultiSurface::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3023
OGRCompoundCurve::begin
const ChildType *const * begin() const
Return begin of curve iterator.
Definition: ogr_geometry.h:2126
OGRGeometryCollection::ChildType
OGRGeometry ChildType
Type of child elements.
Definition: ogr_geometry.h:2773
OGRCurvePolygon::assignSpatialReference
virtual void assignSpatialReference(const OGRSpatialReference *poSR) override
Assign spatial reference to this object.
Definition: ogrcurvepolygon.cpp:729
OGRMultiCurve::getGeometryRef
OGRCurve * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3712
OGRMultiSurface::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:3018
OGRMultiCurve::clone
virtual OGRMultiCurve * clone() const override
Make a copy of this object.
Definition: ogrmulticurve.cpp:96
OGRGeometry::toPolyhedralSurface
OGRPolyhedralSurface * toPolyhedralSurface()
Down-cast to OGRPolyhedralSurface*.
Definition: ogr_geometry.h:939
OGRCurvePolygon::importFromWkb
virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override
Assign geometry from well known binary data.
Definition: ogrcurvepolygon.cpp:489
sfcgal_geometry_t
void sfcgal_geometry_t
SFCGAL geometry type.
Definition: ogr_geometry.h:128
OGRCurvePolygon::transform
virtual OGRErr transform(OGRCoordinateTransformation *poCT) override
Apply arbitrary coordinate transformation to geometry.
Definition: ogrcurvepolygon.cpp:679
OGRCurve::CurveToLine
virtual OGRLineString * CurveToLine(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const =0
Return a linestring from a curve geometry.
OGRPolyhedralSurface::~OGRPolyhedralSurface
~OGRPolyhedralSurface() override
Destructor.
OGRTriangle::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:2719
OGRMultiLineString::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3899
OGRGeometryCollection::importFromWkt
OGRErr importFromWkt(const char **) override
deprecated
Definition: ogrgeometrycollection.cpp:806
OGRLineString::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:1735
OGRCurve::ContainsPoint
virtual int ContainsPoint(const OGRPoint *p) const
Returns if a point is contained in a (closed) curve.
Definition: ogrcurve.cpp:396
OGRCurvePolygon::setCoordinateDimension
virtual void setCoordinateDimension(int nDimension) override
Set the coordinate dimension.
Definition: ogrcurvepolygon.cpp:709
OGRCurvePolygon::end
ChildType ** end()
Return end of curve iterator.
Definition: ogr_geometry.h:2353
OGRMultiSurface::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:3013
OGRSimpleCurve::ChildType
OGRPoint ChildType
Type of child elements.
Definition: ogr_geometry.h:1513
OGRPoint::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:1213
OGRGeometry::toPoint
const OGRPoint * toPoint() const
Down-cast to OGRPoint*.
Definition: ogr_geometry.h:613
OGRRawPoint::OGRRawPoint
OGRRawPoint(double xIn, double yIn)
Constructor.
Definition: ogr_geometry.h:113
OGRPolyhedralSurface::removeGeometry
OGRErr removeGeometry(int iIndex, int bDelete=TRUE)
Remove a geometry from the container.
Definition: ogrpolyhedralsurface.cpp:980
OGRCurvePolygon::getGeometryType
virtual OGRwkbGeometryType getGeometryType() const override
Fetch geometry type.
Definition: ogrcurvepolygon.cpp:121
OGRMultiCurve::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:3752
OGRCurve::toSimpleCurve
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition: ogr_geometry.h:1336
cpl_conv.h
OGRCurvePolygon::CastToPolygon
static OGRPolygon * CastToPolygon(OGRCurvePolygon *poCP)
Convert to polygon.
Definition: ogrcurvepolygon.cpp:850
OGRTriangulatedSurface::toUpperClass
const OGRPolyhedralSurface * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:3463
OGRPolygon::getGeometryType
virtual OGRwkbGeometryType getGeometryType() const override
Fetch geometry type.
Definition: ogrpolygon.cpp:113
OGRGeometryCollection::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:2877
OGRMultiPoint::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3551
OGRGeometry::toLineString
OGRLineString * toLineString()
Down-cast to OGRLineString*.
Definition: ogr_geometry.h:663
OGRCurve::EndPoint
virtual void EndPoint(OGRPoint *) const =0
Return the curve end point.
OGRGeometry::toSimpleCurve
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition: ogr_geometry.h:643
cpl_json.h
OGRCurvePolygon::end
const ChildType *const * end() const
Return end of curve iterator.
Definition: ogr_geometry.h:2365
OGRGeometry::empty
virtual void empty()=0
Clear geometry information. This restores the geometry to its initial state after construction,...
OGRTriangle::toUpperClass
OGRPolygon * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:2705
OGRGeometry::toCurvePolygon
const OGRCurvePolygon * toCurvePolygon() const
Down-cast to OGRCurvePolygon*.
Definition: ogr_geometry.h:809
OGRGeometry::toTriangulatedSurface
const OGRTriangulatedSurface * toTriangulatedSurface() const
Down-cast to OGRTriangulatedSurface*.
Definition: ogr_geometry.h:967
OGRMultiCurve::ChildType
OGRCurve ChildType
Type of child elements.
Definition: ogr_geometry.h:3682
OGRGeometry::toSimpleCurve
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition: ogr_geometry.h:653
OGRMultiSurface::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:2957
OGRSimpleCurve
Abstract curve base class for OGRLineString and OGRCircularString.
Definition: ogr_geometry.h:1441
OGRFromOGCGeomType
OGRwkbGeometryType OGRFromOGCGeomType(const char *pszGeomType)
Map OGCgeometry format type to corresponding OGR constants.
Definition: ogrgeometry.cpp:2427
OGRGeometryH
void * OGRGeometryH
Opaque type for a geometry.
Definition: ogr_api.h:66
OGRMultiCurve::getGeometryName
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition: ogrmulticurve.cpp:133
OGRMultiLineString::getGeometryRef
const OGRLineString * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3860
OGRMultiPolygon::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3108
OGRMultiCurve::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3699
OGRTriangulatedSurface::getGeometryRef
OGRTriangle * getGeometryRef(int i)
See OGRPolyhedralSurface::getGeometryRef()
Definition: ogr_geometry.h:3440
OGRMultiSurface::getGeometryType
virtual OGRwkbGeometryType getGeometryType() const override
Fetch geometry type.
Definition: ogrmultisurface.cpp:107
OGRMultiPolygon::getGeometryRef
const OGRPolygon * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3133
OGRTriangle::addRingDirectly
virtual OGRErr addRingDirectly(OGRCurve *poNewRing) override
Add a ring to a polygon.
Definition: ogrtriangle.cpp:246
OGRCurvePolygon::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:2452
GEOSGeom
struct GEOSGeom_t * GEOSGeom
GEOS geometry type.
Definition: ogr_geometry.h:124
OGRPoint::IsEmpty
virtual OGRBoolean IsEmpty() const override
Returns TRUE (non-zero) if the object has no points.
Definition: ogr_geometry.h:1131
OGRSimpleCurve::importFromWkb
virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override
Assign geometry from well known binary data.
Definition: ogrlinestring.cpp:1522
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:770
OGRToOGCGeomType
const char * OGRToOGCGeomType(OGRwkbGeometryType eGeomType, bool bCamelCase=false, bool bAddZM=false, bool bSpaceBeforeZM=false)
Map OGR geometry format constants to corresponding OGC geometry type.
Definition: ogrgeometry.cpp:2506
end
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:419
OGRMultiPoint::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3614
OGRCurve::getPointIterator
virtual OGRPointIterator * getPointIterator() const =0
Returns a point iterator over the curve.
OGRCurvePolygon::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:2448
IOGRGeometryVisitor
OGRGeometry visitor interface.
Definition: ogr_geometry.h:163
OGRTriangulatedSurface::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3472
OGRCompoundCurve::end
ChildType ** end()
Return end of curve iterator.
Definition: ogr_geometry.h:2119
OGRCircularString::toUpperClass
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:1935
OGRPoint::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:1209
OGRCircularString::toUpperClass
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:1930
OGRGeometry::getDimension
virtual int getDimension() const =0
Get the dimension of this object.
OGRCurve::clone
virtual OGRCurve * clone() const override=0
Make a copy of this object.
OGRGeometry::toLinearRing
OGRLinearRing * toLinearRing()
Down-cast to OGRLinearRing*.
Definition: ogr_geometry.h:682
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:378
OGRSimpleCurve::segmentize
virtual void segmentize(double dfMaxLength) override
Modify the geometry such it has no segment longer then the given distance.
Definition: ogrlinestring.cpp:2486
OGRPolygon::importFromWkb
virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override
Assign geometry from well known binary data.
Definition: ogrpolygon.cpp:349
OGRGeometry::toCurvePolygon
OGRCurvePolygon * toCurvePolygon()
Down-cast to OGRCurvePolygon*.
Definition: ogr_geometry.h:799
OGRGeometry::segmentize
virtual void segmentize(double dfMaxLength)
Modify the geometry such it has no segment longer then the given distance.
Definition: ogrgeometry.cpp:846
OGRMultiLineString::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:3894
OGRCompoundCurve::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:2217
OGRMultiPoint::getGeometryRef
OGRPoint * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3564
OGRMultiSurface::operator=
OGRMultiSurface & operator=(const OGRMultiSurface &other)
Assignment operator.
Definition: ogrmultisurface.cpp:84
OGRGeometry::toPolygon
OGRPolygon * toPolygon()
Down-cast to OGRPolygon*.
Definition: ogr_geometry.h:761
OGRWktFormat
OGRWktFormat
WKT Output formatting options.
Definition: ogr_geometry.h:61
OGRMultiSurface::exportToWkt
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const override
Export a geometry collection to WKT.
Definition: ogrmultisurface.cpp:281
OGRGeometry::toGeometryCollection
OGRGeometryCollection * toGeometryCollection()
Down-cast to OGRGeometryCollection*.
Definition: ogr_geometry.h:819
OGRCurvePolygon::getExteriorRingCurve
OGRCurve * getExteriorRingCurve()
Fetch reference to external polygon ring.
Definition: ogrcurvepolygon.cpp:184
OGRGeometry::toMultiCurve
const OGRMultiCurve * toMultiCurve() const
Down-cast to OGRMultiCurve*.
Definition: ogr_geometry.h:909
OGRCurvePolygon::getNumInteriorRings
int getNumInteriorRings() const
Fetch the number of internal rings.
Definition: ogrcurvepolygon.cpp:221
OGRMultiPoint::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3610
OGRPolyhedralSurface::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3272
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:406
OGRMultiSurface::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:2950
OGRCurvePolygon::Equals
virtual OGRBoolean Equals(const OGRGeometry *) const override
Returns TRUE if two geometries are equivalent.
Definition: ogrcurvepolygon.cpp:660
OGRMultiCurve::operator=
OGRMultiCurve & operator=(const OGRMultiCurve &other)
Assignment operator.
Definition: ogrmulticurve.cpp:83
OGRTriangulatedSurface::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3412
OGRMultiPolygon::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3115
OGRPolygon::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:2549
CPL_WARN_UNUSED_RESULT
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:976
OGRTriangle
Triangle class.
Definition: ogr_geometry.h:2670
OGRMultiLineString::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3903
OGRPolyhedralSurface::clone
virtual OGRPolyhedralSurface * clone() const override
Make a copy of this object.
Definition: ogrpolyhedralsurface.cpp:96
OGRPolygon::clone
virtual OGRPolygon * clone() const override
Make a copy of this object.
Definition: ogrpolygon.cpp:103
OGRGeometry::toMultiPoint
const OGRMultiPoint * toMultiPoint() const
Down-cast to OGRMultiPoint*.
Definition: ogr_geometry.h:849
OGRPolyhedralSurface::begin
const ChildType *const * begin() const
Return begin of iterator.
Definition: ogr_geometry.h:3267
OGRCurvePolygon::getGeometryName
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition: ogrcurvepolygon.cpp:158
OGRPoint::setY
void setY(double yIn)
Set y.
Definition: ogr_geometry.h:1174
OGRTriangulatedSurface::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3429
OGRPolygon::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:2537
OGRDefaultConstGeometryVisitor
OGRGeometry visitor default implementation.
Definition: ogr_geometry.h:285
OGRCurvePolygon::removeRing
OGRErr removeRing(int iIndex, bool bDelete=true)
Remove a geometry from the container.
Definition: ogrcurvepolygon.cpp:322
OGRCompoundCurve::get_AreaOfCurveSegments
virtual double get_AreaOfCurveSegments() const override
Return area of curve segments.
Definition: ogrcompoundcurve.cpp:931
OGRGeometryCollection::end
ChildType ** end()
Return end of sub-geometry iterator.
Definition: ogr_geometry.h:2783
OGRCurvePolygon::WkbSize
virtual size_t WkbSize() const override
Returns size of related binary representation.
Definition: ogrcurvepolygon.cpp:465
OGRGeometry::toMultiSurface
const OGRMultiSurface * toMultiSurface() const
Down-cast to OGRMultiSurface*.
Definition: ogr_geometry.h:929
OGRGeometryCollection::begin
ChildType ** begin()
Return begin of sub-geometry iterator.
Definition: ogr_geometry.h:2778
OGRPoint::getZ
double getZ() const
Return z.
Definition: ogr_geometry.h:1148
OGRPoint::setZ
void setZ(double zIn)
Set z.
Definition: ogr_geometry.h:1185
OGRGeometry::toSurface
const OGRSurface * toSurface() const
Down-cast to OGRSurface*.
Definition: ogr_geometry.h:751
OGRCurvePolygon::addRing
virtual OGRErr addRing(OGRCurve *)
Add a ring to a polygon.
Definition: ogrcurvepolygon.cpp:345
OGRPolygon::hasCurveGeometry
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const override
Returns if this geometry is or has curve geometry.
Definition: ogrpolygon.cpp:812
OGREnvelope3D
Simple container for a bounding region in 3D.
Definition: ogr_core.h:212
OGRGeometry::WkbSize
virtual size_t WkbSize() const =0
Returns size of related binary representation.
OGRCompoundCurve::end
const ChildType *const * end() const
Return end of curve iterator.
Definition: ogr_geometry.h:2131
OGRGeometry::IsMeasured
OGRBoolean IsMeasured() const
Definition: ogr_geometry.h:415
OGRCurvePolygon::operator=
OGRCurvePolygon & operator=(const OGRCurvePolygon &other)
Assignment operator.
Definition: ogrcurvepolygon.cpp:86
OGRPreparedGeometryUniquePtr
std::unique_ptr< OGRPreparedGeometry, OGRPreparedGeometryUniquePtrDeleter > OGRPreparedGeometryUniquePtr
Unique pointer type for OGRPreparedGeometry.
Definition: ogr_geometry.h:4070
OGRMultiCurve::hasCurveGeometry
virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear=FALSE) const override
Returns if this geometry is or has curve geometry.
Definition: ogrmulticurve.cpp:195
OGRGeometry::getCurveGeometry
virtual OGRGeometry * getCurveGeometry(const char *const *papszOptions=nullptr) const
Return curve version of this geometry.
Definition: ogrgeometry.cpp:3341
OGRCurve
Abstract curve base class for OGRLineString, OGRCircularString and OGRCompoundCurve.
Definition: ogr_geometry.h:1254
OGRSimpleCurve::transform
virtual OGRErr transform(OGRCoordinateTransformation *poCT) override
Apply arbitrary coordinate transformation to geometry.
Definition: ogrlinestring.cpp:2365
OGRSimpleCurve::get_Length
virtual double get_Length() const override
Returns the length of the curve.
Definition: ogrlinestring.cpp:1913
OGRPoint::getY
double getY() const
Return y.
Definition: ogr_geometry.h:1143
OGRDefaultGeometryVisitor::visit
void visit(OGRPoint *) override
Visit OGRPoint.
Definition: ogr_geometry.h:215
OGRMultiPoint::toUpperClass
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:3605
OGRCurvePolygon::segmentize
virtual void segmentize(double dfMaxLength) override
Modify the geometry such it has no segment longer then the given distance.
Definition: ogrcurvepolygon.cpp:747
GEOSContextHandle_t
struct GEOSContextHandle_HS * GEOSContextHandle_t
GEOS context handle type.
Definition: ogr_geometry.h:126
OGRPolygon::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:2542
OGRGeometryCollection::getDimension
virtual int getDimension() const override
Get the dimension of this object.
Definition: ogrgeometrycollection.cpp:176
OGRGeometry::transform
virtual OGRErr transform(OGRCoordinateTransformation *poCT)=0
Apply arbitrary coordinate transformation to geometry.
OGRPolyhedralSurface::operator=
OGRPolyhedralSurface & operator=(const OGRPolyhedralSurface &other)
Assignment operator.
Definition: ogrpolyhedralsurface.cpp:82
OGRWktFormat::G
@ G
G-type formatting.
OGRPolyhedralSurface::OGRPolyhedralSurface
OGRPolyhedralSurface()
Create an empty PolyhedralSurface.
OGRMultiPolygon::toUpperClass
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:3162
OGRLinearRing
Concrete representation of a closed ring.
Definition: ogr_geometry.h:1768
OGRGeometryUniquePtr
std::unique_ptr< OGRGeometry, OGRGeometryUniquePtrDeleter > OGRGeometryUniquePtr
Unique pointer type for OGRGeometry.
Definition: ogr_geometry.h:984
OGREnvelope
Simple container for a bounding region (rectangle)
Definition: ogr_core.h:57
OGRTriangle::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:2715
OGRGeometry::toGeometryCollection
const OGRGeometryCollection * toGeometryCollection() const
Down-cast to OGRGeometryCollection*.
Definition: ogr_geometry.h:829
OGRSimpleCurve::Value
virtual void Value(double, OGRPoint *) const override
Fetch point at given distance along curve.
Definition: ogrlinestring.cpp:1955
OGRCurvePolygon::begin
ChildType ** begin()
Return begin of curve iterator.
Definition: ogr_geometry.h:2348
OGRGeometry::toMultiPolygon
const OGRMultiPolygon * toMultiPolygon() const
Down-cast to OGRMultiPolygon*.
Definition: ogr_geometry.h:889
OGRMultiCurve::getGeometryRef
const OGRCurve * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3717
IOGRConstGeometryVisitor::visit
virtual void visit(const OGRPoint *)=0
Visit OGRPoint.
OGRCurve::CastToLinearRing
static OGRLinearRing * CastToLinearRing(OGRCurve *poCurve)
Cast to linear ring.
Definition: ogrcurve.cpp:375
OGRMultiCurve::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:3766
OGRPolyhedralSurface::ChildType
OGRPolygon ChildType
Type of child elements.
Definition: ogr_geometry.h:3250
OGRMultiPoint::begin
ChildType ** begin()
Return begin of iterator.
Definition: ogr_geometry.h:3539
OGRGeometry::toMultiPoint
OGRMultiPoint * toMultiPoint()
Down-cast to OGRMultiPoint*.
Definition: ogr_geometry.h:839
OGRRawPoint::y
double y
y
Definition: ogr_geometry.h:120
OGRGeometry::toCurve
const OGRCurve * toCurve() const
Down-cast to OGRCurve*.
Definition: ogr_geometry.h:633
OGRWktOptions
Options for formatting WKT output.
Definition: ogr_geometry.h:69
OGRCurvePolygon::importFromWkt
OGRErr importFromWkt(const char **) override
deprecated
Definition: ogrcurvepolygon.cpp:546
OGRGeometry::toMultiLineString
const OGRMultiLineString * toMultiLineString() const
Down-cast to OGRMultiLineString*.
Definition: ogr_geometry.h:869
OGRTriangulatedSurface::getGeometryRef
const OGRTriangle * getGeometryRef(int i) const
See OGRPolyhedralSurface::getGeometryRef()
Definition: ogr_geometry.h:3445
OGRMultiSurface::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:2962
OGRLineString::toUpperClass
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:1726
OGRCurvePolygon::setMeasured
virtual void setMeasured(OGRBoolean bIsMeasured) override
Add or remove the M coordinate dimension.
Definition: ogrcurvepolygon.cpp:720
OGRCurve::IntersectsPoint
virtual int IntersectsPoint(const OGRPoint *p) const
Returns if a point intersects a (closed) curve.
Definition: ogrcurve.cpp:416
OGRPolygon::toUpperClass
const OGRCurvePolygon * toUpperClass() const
Return pointer of this in upper class.
Definition: ogr_geometry.h:2616
OGRLineString::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:1731
OGRPolygon
Concrete class representing polygons.
Definition: ogr_geometry.h:2502
OGRTriangulatedSurface
TriangulatedSurface class.
Definition: ogr_geometry.h:3388
OGRCurvePolygon
Concrete class representing curve polygons.
Definition: ogr_geometry.h:2307
OGRPoint::getM
double getM() const
Return m.
Definition: ogr_geometry.h:1153
OGRGeometry::getEnvelope
virtual void getEnvelope(OGREnvelope *psEnvelope) const =0
Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
OGRPolyhedralSurface::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:3336
OGRCurvePolygon::getInteriorRingCurve
OGRCurve * getInteriorRingCurve(int)
Fetch reference to indicated internal ring.
Definition: ogrcurvepolygon.cpp:249
OGRGeometry::Equals
virtual OGRBoolean Equals(const OGRGeometry *) const =0
Returns TRUE if two geometries are equivalent.
OGRCurvePolygon::begin
const ChildType *const * begin() const
Return begin of curve iterator.
Definition: ogr_geometry.h:2360
OGRCurve::get_Length
virtual double get_Length() const =0
Returns the length of the curve.
ogr_core.h
OGRMultiPoint::getGeometryRef
const OGRPoint * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition: ogr_geometry.h:3569
OGRGeometryCollection::importFromWkb
virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override
Assign geometry from well known binary data.
Definition: ogrgeometrycollection.cpp:598
OGRMultiSurface::getGeometryName
virtual const char * getGeometryName() const override
Fetch WKT name for geometry type.
Definition: ogrmultisurface.cpp:134
OGRGeometry::toPolyhedralSurface
const OGRPolyhedralSurface * toPolyhedralSurface() const
Down-cast to OGRPolyhedralSurface*.
Definition: ogr_geometry.h:949
OGRGeometryCollection::begin
const ChildType *const * begin() const
Return begin of sub-geometry iterator.
Definition: ogr_geometry.h:2790
OGRGeometry::toMultiLineString
OGRMultiLineString * toMultiLineString()
Down-cast to OGRMultiLineString*.
Definition: ogr_geometry.h:859
OGRLineString::operator=
OGRLineString & operator=(const OGRLineString &other)
Assignment operator.
Definition: ogrlinestring.cpp:2749
OGRCurvePolygon::getLinearGeometry
virtual OGRGeometry * getLinearGeometry(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const override
Return, possibly approximate, non-curve version of this geometry.
Definition: ogrcurvepolygon.cpp:630
OGRGeometry::Within
virtual OGRBoolean Within(const OGRGeometry *) const
Test for containment.
Definition: ogrgeometry.cpp:5372
OGRGeometryCollection::getGeometryType
virtual OGRwkbGeometryType getGeometryType() const override
Fetch geometry type.
Definition: ogrgeometrycollection.cpp:159
OGRCircularString::accept
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition: ogr_geometry.h:1940
OGRGeometry::setMeasured
virtual void setMeasured(OGRBoolean bIsMeasured)
Add or remove the M coordinate dimension.
Definition: ogrgeometry.cpp:1110
OGRPolygon::toUpperClass
OGRCurvePolygon * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:2611
OGRCurvePolygon::exportToWkb
virtual OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc) const override
Convert a geometry into well known binary format.
Definition: ogrcurvepolygon.cpp:518
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1042
OGRGeometry::operator!=
bool operator!=(const OGRGeometry &other) const
Returns if two geometries are different.
Definition: ogr_geometry.h:395
OGRDefaultConstGeometryVisitor::visit
void visit(const OGRPoint *) override
Visit OGRPoint.
Definition: ogr_geometry.h:290
OGRwkbVariant
OGRwkbVariant
Output variants of WKB we support.
Definition: ogr_core.h:540
OGRGeometryCollection::exportToWkt
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const override
Export a geometry collection to WKT.
Definition: ogrgeometrycollection.cpp:819
OGRCurvePolygon::stealExteriorRingCurve
OGRCurve * stealExteriorRingCurve()
"Steal" reference to external ring.
Definition: ogrcurvepolygon.cpp:290
OGRCurve::ChildType
OGRPoint ChildType
Type of child elements.
Definition: ogr_geometry.h:1298
OGRCompoundCurve::ChildType
OGRCurve ChildType
Type of child elements.
Definition: ogr_geometry.h:2109
OGRLinearRing::toUpperClass
OGRLineString * toUpperClass()
Return pointer of this in upper class.
Definition: ogr_geometry.h:1820
OGRGeometryCollection::clone
virtual OGRGeometryCollection * clone() const override
Make a copy of this object.
Definition: ogrgeometrycollection.cpp:149
OGRGeometry::toCompoundCurve
OGRCompoundCurve * toCompoundCurve()
Down-cast to OGRCompoundCurve*.
Definition: ogr_geometry.h:721
OGRCurvePolygon::swapXY
virtual void swapXY() override
Swap x and y coordinates.
Definition: ogrcurvepolygon.cpp:762
OGRPoint::getX
double getX() const
Return x.
Definition: ogr_geometry.h:1138
OGRCurve::get_Area
virtual double get_Area() const =0
Get the area of the (closed) curve.
OGRGeometry::ToHandle
static OGRGeometryH ToHandle(OGRGeometry *poGeom)
Convert a OGRGeometry* to a OGRGeometryH.
Definition: ogr_geometry.h:587
OGRMultiLineString::end
ChildType ** end()
Return end of iterator.
Definition: ogr_geometry.h:3835
OGRMultiPolygon::end
const ChildType *const * end() const
Return end of iterator.
Definition: ogr_geometry.h:3120
OGRDefaultGeometryVisitor
OGRGeometry visitor default implementation.
Definition: ogr_geometry.h:210
OGRLinearRing::accept
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition: ogr_geometry.h:1834