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_geomcoordinateprecision.h"
39#include "ogr_spatialref.h"
40
41#include <climits>
42#include <cmath>
43#include <memory>
44
52#ifndef DEFINEH_OGRGeometryH
53#define DEFINEH_OGRGeometryH
54#ifdef DEBUG
55typedef struct OGRGeometryHS *OGRGeometryH;
56#else
57typedef void *OGRGeometryH;
58#endif
59#endif /* DEFINEH_OGRGeometryH */
63enum class OGRWktFormat
64{
65 F,
66 G,
67 Default
68};
69
71struct CPL_DLL OGRWktOptions
72{
73 public:
83 bool round = getDefaultRound();
86
89 : xyPrecision(getDefaultPrecision()), zPrecision(xyPrecision),
90 mPrecision(zPrecision)
91 {
92 }
93
95 OGRWktOptions(const OGRWktOptions &) = default;
96
97 private:
98 static int getDefaultPrecision();
99 static bool getDefaultRound();
100};
101
106{
107 public:
109 OGRRawPoint() : x(0.0), y(0.0)
110 {
111 }
112
114 OGRRawPoint(double xIn, double yIn) : x(xIn), y(yIn)
115 {
116 }
117
119 double x;
121 double y;
122};
123
125typedef struct GEOSGeom_t *GEOSGeom;
127typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
129typedef void sfcgal_geometry_t;
130
131class OGRPoint;
132class OGRCurve;
133class OGRCompoundCurve;
134class OGRSimpleCurve;
135class OGRLinearRing;
136class OGRLineString;
138class OGRSurface;
139class OGRCurvePolygon;
140class OGRPolygon;
141class OGRMultiPoint;
142class OGRMultiSurface;
143class OGRMultiPolygon;
144class OGRMultiCurve;
147class OGRTriangle;
150
152typedef OGRLineString *(*OGRCurveCasterToLineString)(OGRCurve *);
153typedef OGRLinearRing *(*OGRCurveCasterToLinearRing)(OGRCurve *);
154
155typedef OGRPolygon *(*OGRSurfaceCasterToPolygon)(OGRSurface *);
156typedef OGRCurvePolygon *(*OGRSurfaceCasterToCurvePolygon)(OGRSurface *);
157typedef OGRMultiPolygon *(*OGRPolyhedralSurfaceCastToMultiPolygon)(
159
161
166{
167 public:
169 virtual ~IOGRGeometryVisitor() = default;
170
172 virtual void visit(OGRPoint *) = 0;
174 virtual void visit(OGRLineString *) = 0;
176 virtual void visit(OGRLinearRing *) = 0;
178 virtual void visit(OGRPolygon *) = 0;
180 virtual void visit(OGRMultiPoint *) = 0;
182 virtual void visit(OGRMultiLineString *) = 0;
184 virtual void visit(OGRMultiPolygon *) = 0;
186 virtual void visit(OGRGeometryCollection *) = 0;
188 virtual void visit(OGRCircularString *) = 0;
190 virtual void visit(OGRCompoundCurve *) = 0;
192 virtual void visit(OGRCurvePolygon *) = 0;
194 virtual void visit(OGRMultiCurve *) = 0;
196 virtual void visit(OGRMultiSurface *) = 0;
198 virtual void visit(OGRTriangle *) = 0;
200 virtual void visit(OGRPolyhedralSurface *) = 0;
202 virtual void visit(OGRTriangulatedSurface *) = 0;
203};
204
213{
214 void _visit(OGRSimpleCurve *poGeom);
215
216 public:
217 void visit(OGRPoint *) override
218 {
219 }
220
221 void visit(OGRLineString *) override;
222 void visit(OGRLinearRing *) override;
223 void visit(OGRPolygon *) override;
224 void visit(OGRMultiPoint *) override;
225 void visit(OGRMultiLineString *) override;
226 void visit(OGRMultiPolygon *) override;
227 void visit(OGRGeometryCollection *) override;
228 void visit(OGRCircularString *) override;
229 void visit(OGRCompoundCurve *) override;
230 void visit(OGRCurvePolygon *) override;
231 void visit(OGRMultiCurve *) override;
232 void visit(OGRMultiSurface *) override;
233 void visit(OGRTriangle *) override;
234 void visit(OGRPolyhedralSurface *) override;
235 void visit(OGRTriangulatedSurface *) override;
236};
237
242{
243 public:
245 virtual ~IOGRConstGeometryVisitor() = default;
246
248 virtual void visit(const OGRPoint *) = 0;
250 virtual void visit(const OGRLineString *) = 0;
252 virtual void visit(const OGRLinearRing *) = 0;
254 virtual void visit(const OGRPolygon *) = 0;
256 virtual void visit(const OGRMultiPoint *) = 0;
258 virtual void visit(const OGRMultiLineString *) = 0;
260 virtual void visit(const OGRMultiPolygon *) = 0;
262 virtual void visit(const OGRGeometryCollection *) = 0;
264 virtual void visit(const OGRCircularString *) = 0;
266 virtual void visit(const OGRCompoundCurve *) = 0;
268 virtual void visit(const OGRCurvePolygon *) = 0;
270 virtual void visit(const OGRMultiCurve *) = 0;
272 virtual void visit(const OGRMultiSurface *) = 0;
274 virtual void visit(const OGRTriangle *) = 0;
276 virtual void visit(const OGRPolyhedralSurface *) = 0;
278 virtual void visit(const OGRTriangulatedSurface *) = 0;
279};
280
289{
290 void _visit(const OGRSimpleCurve *poGeom);
291
292 public:
293 void visit(const OGRPoint *) override
294 {
295 }
296
297 void visit(const OGRLineString *) override;
298 void visit(const OGRLinearRing *) override;
299 void visit(const OGRPolygon *) override;
300 void visit(const OGRMultiPoint *) override;
301 void visit(const OGRMultiLineString *) override;
302 void visit(const OGRMultiPolygon *) override;
303 void visit(const OGRGeometryCollection *) override;
304 void visit(const OGRCircularString *) override;
305 void visit(const OGRCompoundCurve *) override;
306 void visit(const OGRCurvePolygon *) override;
307 void visit(const OGRMultiCurve *) override;
308 void visit(const OGRMultiSurface *) override;
309 void visit(const OGRTriangle *) override;
310 void visit(const OGRPolyhedralSurface *) override;
311 void visit(const OGRTriangulatedSurface *) override;
312};
313
314/************************************************************************/
315/* OGRGeomCoordinateBinaryPrecision */
316/************************************************************************/
317
323{
324 int nXYBitPrecision =
325 INT_MIN;
327 int nZBitPrecision =
328 INT_MIN;
330 int nMBitPrecision =
331 INT_MIN;
334 void SetFrom(const OGRGeomCoordinatePrecision &);
335};
336
337/************************************************************************/
338/* OGRwkbExportOptions */
339/************************************************************************/
340
351
352/************************************************************************/
353/* OGRGeometry */
354/************************************************************************/
355
376class CPL_DLL OGRGeometry
377{
378 private:
379 const OGRSpatialReference *poSRS = nullptr; // may be NULL
380
381 protected:
383 friend class OGRCurveCollection;
384
385 unsigned int flags = 0;
386
387 OGRErr importPreambleFromWkt(const char **ppszInput, int *pbHasZ,
388 int *pbHasM, bool *pbIsEmpty);
389 OGRErr importCurveCollectionFromWkt(
390 const char **ppszInput, int bAllowEmptyComponent, int bAllowLineString,
391 int bAllowCurve, int bAllowCompoundCurve,
392 OGRErr (*pfnAddCurveDirectly)(OGRGeometry *poSelf, OGRCurve *poCurve));
393 OGRErr importPreambleFromWkb(const unsigned char *pabyData, size_t nSize,
394 OGRwkbByteOrder &eByteOrder,
395 OGRwkbVariant eWkbVariant);
396 OGRErr importPreambleOfCollectionFromWkb(const unsigned char *pabyData,
397 size_t &nSize, size_t &nDataOffset,
398 OGRwkbByteOrder &eByteOrder,
399 size_t nMinSubGeomSize,
400 int &nGeomCount,
401 OGRwkbVariant eWkbVariant);
402 OGRErr PointOnSurfaceInternal(OGRPoint *poPoint) const;
403 OGRBoolean IsSFCGALCompatible() const;
404
405 void HomogenizeDimensionalityWith(OGRGeometry *poOtherGeom);
406 std::string wktTypeString(OGRwkbVariant variant) const;
407
409
410 public:
411 /************************************************************************/
412 /* Bit flags for OGRGeometry */
413 /* The OGR_G_NOT_EMPTY_POINT is used *only* for points. */
414 /* Do not use these outside of the core. */
415 /* Use Is3D, IsMeasured, set3D, and setMeasured instead */
416 /************************************************************************/
417
419 static const unsigned int OGR_G_NOT_EMPTY_POINT = 0x1;
420 static const unsigned int OGR_G_3D = 0x2;
421 static const unsigned int OGR_G_MEASURED = 0x4;
423
424 OGRGeometry();
425 OGRGeometry(const OGRGeometry &other);
426 virtual ~OGRGeometry();
427
428 OGRGeometry &operator=(const OGRGeometry &other);
429
431 bool operator==(const OGRGeometry &other) const
432 {
433 return CPL_TO_BOOL(Equals(&other));
434 }
435
437 bool operator!=(const OGRGeometry &other) const
438 {
439 return !CPL_TO_BOOL(Equals(&other));
440 }
441
442 // Standard IGeometry.
443 virtual int getDimension() const = 0;
444 virtual int getCoordinateDimension() const;
445 int CoordinateDimension() const;
446 virtual OGRBoolean IsEmpty() const = 0;
447 virtual OGRBoolean IsValid() const;
448 virtual OGRGeometry *MakeValid(CSLConstList papszOptions = nullptr) const;
449 virtual OGRGeometry *Normalize() const;
450 virtual OGRBoolean IsSimple() const;
451
454 {
455 return (flags & OGR_G_3D) != 0;
456 }
457
460 {
461 return (flags & OGR_G_MEASURED) != 0;
462 }
463
464 virtual OGRBoolean IsRing() const;
465 virtual void empty() = 0;
467 virtual void getEnvelope(OGREnvelope *psEnvelope) const = 0;
468 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const = 0;
469
470 // IWks Interface.
471 virtual size_t WkbSize() const = 0;
472 OGRErr importFromWkb(const GByte *, size_t = static_cast<size_t>(-1),
474 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
475 size_t &nBytesConsumedOut) = 0;
476 OGRErr exportToWkb(OGRwkbByteOrder, unsigned char *,
478 virtual OGRErr exportToWkb(unsigned char *,
479 const OGRwkbExportOptions * = nullptr) const = 0;
480 virtual OGRErr importFromWkt(const char **ppszInput) = 0;
481
482#ifndef DOXYGEN_XML
486 OGRErr importFromWkt(char **ppszInput)
488 CPL_WARN_DEPRECATED("Use importFromWkt(const char**) instead")
490 {
491 return importFromWkt(const_cast<const char **>(ppszInput));
492 }
493#endif
494
495 OGRErr exportToWkt(char **ppszDstText,
497
502 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
503 OGRErr *err = nullptr) const = 0;
504
505 // Non-standard.
507 OGRwkbGeometryType getIsoGeometryType() const;
508 virtual const char *getGeometryName() const = 0;
509 void dumpReadable(FILE *, const char * = nullptr,
510 CSLConstList papszOptions = nullptr) const;
511 std::string dumpReadable(const char * = nullptr,
512 CSLConstList papszOptions = nullptr) const;
513 virtual void flattenTo2D() = 0;
514 virtual char *exportToGML(const char *const *papszOptions = nullptr) const;
515 virtual char *exportToKML() const;
516 virtual char *exportToJson(CSLConstList papszOptions = nullptr) const;
517
519 virtual void accept(IOGRGeometryVisitor *visitor) = 0;
520
522 virtual void accept(IOGRConstGeometryVisitor *visitor) const = 0;
523
524 static GEOSContextHandle_t createGEOSContext();
525 static void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt);
527 exportToGEOS(GEOSContextHandle_t hGEOSCtxt,
528 bool bRemoveEmptyParts = false) const CPL_WARN_UNUSED_RESULT;
529 virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const;
530 virtual OGRGeometry *getCurveGeometry(
531 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
532 virtual OGRGeometry *getLinearGeometry(
533 double dfMaxAngleStepSizeDegrees = 0,
534 const char *const *papszOptions = nullptr) const CPL_WARN_UNUSED_RESULT;
535
536 void roundCoordinates(const OGRGeomCoordinatePrecision &sPrecision);
537 void
538 roundCoordinatesIEEE754(const OGRGeomCoordinateBinaryPrecision &options);
539
540 // SFCGAL interfacing methods.
542 static sfcgal_geometry_t *OGRexportToSFCGAL(const OGRGeometry *poGeom);
543 static OGRGeometry *SFCGALexportToOGR(const sfcgal_geometry_t *_geometry);
545 virtual void closeRings();
546
547 virtual void setCoordinateDimension(int nDimension);
548 virtual void set3D(OGRBoolean bIs3D);
549 virtual void setMeasured(OGRBoolean bIsMeasured);
550
551 virtual void assignSpatialReference(const OGRSpatialReference *poSR);
552
553 const OGRSpatialReference *getSpatialReference(void) const
554 {
555 return poSRS;
556 }
557
559 OGRErr transformTo(const OGRSpatialReference *poSR);
560
561 virtual void segmentize(double dfMaxLength);
562
563 // ISpatialRelation
564 virtual OGRBoolean Intersects(const OGRGeometry *) const;
565 virtual OGRBoolean Equals(const OGRGeometry *) const = 0;
566 virtual OGRBoolean Disjoint(const OGRGeometry *) const;
567 virtual OGRBoolean Touches(const OGRGeometry *) const;
568 virtual OGRBoolean Crosses(const OGRGeometry *) const;
569 virtual OGRBoolean Within(const OGRGeometry *) const;
570 virtual OGRBoolean Contains(const OGRGeometry *) const;
571 virtual OGRBoolean Overlaps(const OGRGeometry *) const;
572 // virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
573 // virtual OGRGeometry *LocateAlong( double mValue ) const;
574 // virtual OGRGeometry *LocateBetween( double mStart, double mEnd )
575 // const;
576
577 virtual OGRGeometry *Boundary() const CPL_WARN_UNUSED_RESULT;
578 virtual double Distance(const OGRGeometry *) const;
579 virtual OGRGeometry *ConvexHull() const CPL_WARN_UNUSED_RESULT;
580 virtual OGRGeometry *
581 ConcaveHull(double dfRatio, bool bAllowHoles) const CPL_WARN_UNUSED_RESULT;
582 virtual OGRGeometry *
583 Buffer(double dfDist, int nQuadSegs = 30) const CPL_WARN_UNUSED_RESULT;
584 virtual OGRGeometry *
585 BufferEx(double dfDistance,
586 CSLConstList papszOptions) const CPL_WARN_UNUSED_RESULT;
587 virtual OGRGeometry *
588 Intersection(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
589 virtual OGRGeometry *
590 Union(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
591 virtual OGRGeometry *UnionCascaded() const CPL_WARN_UNUSED_RESULT;
592 OGRGeometry *UnaryUnion() const CPL_WARN_UNUSED_RESULT;
593 virtual OGRGeometry *
594 Difference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
595 virtual OGRGeometry *
596 SymDifference(const OGRGeometry *) const CPL_WARN_UNUSED_RESULT;
597 virtual OGRErr Centroid(OGRPoint *poPoint) const;
598 virtual OGRGeometry *
599 Simplify(double dTolerance) const CPL_WARN_UNUSED_RESULT;
601 SimplifyPreserveTopology(double dTolerance) const CPL_WARN_UNUSED_RESULT;
602 virtual OGRGeometry *
603 DelaunayTriangulation(double dfTolerance,
604 int bOnlyEdges) const CPL_WARN_UNUSED_RESULT;
605
606 virtual OGRGeometry *Polygonize() const CPL_WARN_UNUSED_RESULT;
607
608 virtual double Distance3D(const OGRGeometry *poOtherGeom) const;
609
610 OGRGeometry *SetPrecision(double dfGridSize, int nFlags) const;
611
612 virtual bool hasEmptyParts() const;
613 virtual void removeEmptyParts();
614
616 // backward compatibility to non-standard method names.
617 OGRBoolean Intersect(OGRGeometry *) const
618 CPL_WARN_DEPRECATED("Non standard method. "
619 "Use Intersects() instead");
620 OGRBoolean Equal(OGRGeometry *) const
621 CPL_WARN_DEPRECATED("Non standard method. "
622 "Use Equals() instead");
623 OGRGeometry *SymmetricDifference(const OGRGeometry *) const
624 CPL_WARN_DEPRECATED("Non standard method. "
625 "Use SymDifference() instead");
626 OGRGeometry *getBoundary() const
627 CPL_WARN_DEPRECATED("Non standard method. "
628 "Use Boundary() instead");
630
632 // Special HACK for DB2 7.2 support
633 static int bGenerate_DB2_V72_BYTE_ORDER;
635
636 virtual void swapXY();
637
638 bool IsRectangle() const;
639
641 static OGRGeometry *CastToIdentity(OGRGeometry *poGeom)
642 {
643 return poGeom;
644 }
645
646 static OGRGeometry *CastToError(OGRGeometry *poGeom);
647
649
653 static inline OGRGeometryH ToHandle(OGRGeometry *poGeom)
654 {
655 return reinterpret_cast<OGRGeometryH>(poGeom);
656 }
657
661 static inline OGRGeometry *FromHandle(OGRGeometryH hGeom)
662 {
663 return reinterpret_cast<OGRGeometry *>(hGeom);
664 }
665
671 {
672 return cpl::down_cast<OGRPoint *>(this);
673 }
674
679 inline const OGRPoint *toPoint() const
680 {
681 return cpl::down_cast<const OGRPoint *>(this);
682 }
683
690 {
691 return cpl::down_cast<OGRCurve *>(this);
692 }
693
699 inline const OGRCurve *toCurve() const
700 {
701 return cpl::down_cast<const OGRCurve *>(this);
702 }
703
710 {
711 return cpl::down_cast<OGRSimpleCurve *>(this);
712 }
713
719 inline const OGRSimpleCurve *toSimpleCurve() const
720 {
721 return cpl::down_cast<const OGRSimpleCurve *>(this);
722 }
723
730 {
731 return cpl::down_cast<OGRLineString *>(this);
732 }
733
739 inline const OGRLineString *toLineString() const
740 {
741 return cpl::down_cast<const OGRLineString *>(this);
742 }
743
749 {
750 return cpl::down_cast<OGRLinearRing *>(this);
751 }
752
757 inline const OGRLinearRing *toLinearRing() const
758 {
759 return cpl::down_cast<const OGRLinearRing *>(this);
760 }
761
768 {
769 return cpl::down_cast<OGRCircularString *>(this);
770 }
771
778 {
779 return cpl::down_cast<const OGRCircularString *>(this);
780 }
781
788 {
789 return cpl::down_cast<OGRCompoundCurve *>(this);
790 }
791
797 inline const OGRCompoundCurve *toCompoundCurve() const
798 {
799 return cpl::down_cast<const OGRCompoundCurve *>(this);
800 }
801
808 {
809 return cpl::down_cast<OGRSurface *>(this);
810 }
811
817 inline const OGRSurface *toSurface() const
818 {
819 return cpl::down_cast<const OGRSurface *>(this);
820 }
821
828 {
829 return cpl::down_cast<OGRPolygon *>(this);
830 }
831
837 inline const OGRPolygon *toPolygon() const
838 {
839 return cpl::down_cast<const OGRPolygon *>(this);
840 }
841
847 {
848 return cpl::down_cast<OGRTriangle *>(this);
849 }
850
855 inline const OGRTriangle *toTriangle() const
856 {
857 return cpl::down_cast<const OGRTriangle *>(this);
858 }
859
866 {
867 return cpl::down_cast<OGRCurvePolygon *>(this);
868 }
869
875 inline const OGRCurvePolygon *toCurvePolygon() const
876 {
877 return cpl::down_cast<const OGRCurvePolygon *>(this);
878 }
879
886 {
887 return cpl::down_cast<OGRGeometryCollection *>(this);
888 }
889
896 {
897 return cpl::down_cast<const OGRGeometryCollection *>(this);
898 }
899
906 {
907 return cpl::down_cast<OGRMultiPoint *>(this);
908 }
909
915 inline const OGRMultiPoint *toMultiPoint() const
916 {
917 return cpl::down_cast<const OGRMultiPoint *>(this);
918 }
919
926 {
927 return cpl::down_cast<OGRMultiLineString *>(this);
928 }
929
936 {
937 return cpl::down_cast<const OGRMultiLineString *>(this);
938 }
939
946 {
947 return cpl::down_cast<OGRMultiPolygon *>(this);
948 }
949
955 inline const OGRMultiPolygon *toMultiPolygon() const
956 {
957 return cpl::down_cast<const OGRMultiPolygon *>(this);
958 }
959
966 {
967 return cpl::down_cast<OGRMultiCurve *>(this);
968 }
969
975 inline const OGRMultiCurve *toMultiCurve() const
976 {
977 return cpl::down_cast<const OGRMultiCurve *>(this);
978 }
979
986 {
987 return cpl::down_cast<OGRMultiSurface *>(this);
988 }
989
995 inline const OGRMultiSurface *toMultiSurface() const
996 {
997 return cpl::down_cast<const OGRMultiSurface *>(this);
998 }
999
1006 {
1007 return cpl::down_cast<OGRPolyhedralSurface *>(this);
1008 }
1009
1016 {
1017 return cpl::down_cast<const OGRPolyhedralSurface *>(this);
1018 }
1019
1025 {
1026 return cpl::down_cast<OGRTriangulatedSurface *>(this);
1027 }
1028
1034 {
1035 return cpl::down_cast<const OGRTriangulatedSurface *>(this);
1036 }
1037};
1038
1040struct CPL_DLL OGRGeometryUniquePtrDeleter
1041{
1042 void operator()(OGRGeometry *) const;
1043};
1044
1046
1050typedef std::unique_ptr<OGRGeometry, OGRGeometryUniquePtrDeleter>
1052
1054#define OGR_FORBID_DOWNCAST_TO(name) \
1055 inline OGR##name *to##name() = delete; \
1056 inline const OGR##name *to##name() const = delete;
1057
1058#define OGR_FORBID_DOWNCAST_TO_POINT OGR_FORBID_DOWNCAST_TO(Point)
1059#define OGR_FORBID_DOWNCAST_TO_CURVE OGR_FORBID_DOWNCAST_TO(Curve)
1060#define OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE OGR_FORBID_DOWNCAST_TO(SimpleCurve)
1061#define OGR_FORBID_DOWNCAST_TO_LINESTRING OGR_FORBID_DOWNCAST_TO(LineString)
1062#define OGR_FORBID_DOWNCAST_TO_LINEARRING OGR_FORBID_DOWNCAST_TO(LinearRing)
1063#define OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1064 OGR_FORBID_DOWNCAST_TO(CircularString)
1065#define OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE \
1066 OGR_FORBID_DOWNCAST_TO(CompoundCurve)
1067#define OGR_FORBID_DOWNCAST_TO_SURFACE OGR_FORBID_DOWNCAST_TO(Surface)
1068#define OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON OGR_FORBID_DOWNCAST_TO(CurvePolygon)
1069#define OGR_FORBID_DOWNCAST_TO_POLYGON OGR_FORBID_DOWNCAST_TO(Polygon)
1070#define OGR_FORBID_DOWNCAST_TO_TRIANGLE OGR_FORBID_DOWNCAST_TO(Triangle)
1071#define OGR_FORBID_DOWNCAST_TO_MULTIPOINT OGR_FORBID_DOWNCAST_TO(MultiPoint)
1072#define OGR_FORBID_DOWNCAST_TO_MULTICURVE OGR_FORBID_DOWNCAST_TO(MultiCurve)
1073#define OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1074 OGR_FORBID_DOWNCAST_TO(MultiLineString)
1075#define OGR_FORBID_DOWNCAST_TO_MULTISURFACE OGR_FORBID_DOWNCAST_TO(MultiSurface)
1076#define OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON OGR_FORBID_DOWNCAST_TO(MultiPolygon)
1077#define OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1078 OGR_FORBID_DOWNCAST_TO(GeometryCollection)
1079#define OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1080 OGR_FORBID_DOWNCAST_TO(PolyhedralSurface)
1081#define OGR_FORBID_DOWNCAST_TO_TIN OGR_FORBID_DOWNCAST_TO(TriangulatedSurface)
1082
1083#define OGR_ALLOW_UPCAST_TO(name) \
1084 inline OGR##name *to##name() \
1085 { \
1086 return this; \
1087 } \
1088 inline const OGR##name *to##name() const \
1089 { \
1090 return this; \
1091 }
1092
1093#ifndef SUPPRESS_OGR_ALLOW_CAST_TO_THIS_WARNING
1094#define CAST_TO_THIS_WARNING CPL_WARN_DEPRECATED("Casting to this is useless")
1095#else
1096#define CAST_TO_THIS_WARNING
1097#endif
1098
1099#define OGR_ALLOW_CAST_TO_THIS(name) \
1100 inline OGR##name *to##name() CAST_TO_THIS_WARNING \
1101 { \
1102 return this; \
1103 } \
1104 inline const OGR##name *to##name() const CAST_TO_THIS_WARNING \
1105 { \
1106 return this; \
1107 }
1108
1109#define OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1110 OGR_FORBID_DOWNCAST_TO_CURVE \
1111 OGR_FORBID_DOWNCAST_TO_SIMPLE_CURVE \
1112 OGR_FORBID_DOWNCAST_TO_LINESTRING \
1113 OGR_FORBID_DOWNCAST_TO_LINEARRING \
1114 OGR_FORBID_DOWNCAST_TO_CIRCULARSTRING \
1115 OGR_FORBID_DOWNCAST_TO_COMPOUNDCURVE
1116
1117#define OGR_FORBID_DOWNCAST_TO_ALL_SURFACES \
1118 OGR_FORBID_DOWNCAST_TO_SURFACE \
1119 OGR_FORBID_DOWNCAST_TO_CURVEPOLYGON \
1120 OGR_FORBID_DOWNCAST_TO_POLYGON \
1121 OGR_FORBID_DOWNCAST_TO_TRIANGLE \
1122 OGR_FORBID_DOWNCAST_TO_POLYHEDRALSURFACE \
1123 OGR_FORBID_DOWNCAST_TO_TIN
1124
1125#define OGR_FORBID_DOWNCAST_TO_ALL_SINGLES \
1126 OGR_FORBID_DOWNCAST_TO_POINT \
1127 OGR_FORBID_DOWNCAST_TO_ALL_CURVES \
1128 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1129
1130#define OGR_FORBID_DOWNCAST_TO_ALL_MULTI \
1131 OGR_FORBID_DOWNCAST_TO_GEOMETRYCOLLECTION \
1132 OGR_FORBID_DOWNCAST_TO_MULTIPOINT \
1133 OGR_FORBID_DOWNCAST_TO_MULTICURVE \
1134 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING \
1135 OGR_FORBID_DOWNCAST_TO_MULTISURFACE \
1136 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
1137
1139
1140/************************************************************************/
1141/* OGRPoint */
1142/************************************************************************/
1143
1150class CPL_DLL OGRPoint : public OGRGeometry
1151{
1152 double x;
1153 double y;
1154 double z;
1155 double m;
1156
1157 public:
1158 OGRPoint();
1159 OGRPoint(double x, double y);
1160 OGRPoint(double x, double y, double z);
1161 OGRPoint(double x, double y, double z, double m);
1162 OGRPoint(const OGRPoint &other);
1163 static OGRPoint *createXYM(double x, double y, double m);
1164 ~OGRPoint() override;
1165
1166 OGRPoint &operator=(const OGRPoint &other);
1167
1168 // IWks Interface
1169 size_t WkbSize() const override;
1170 OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1171 size_t &nBytesConsumedOut) override;
1172 OGRErr exportToWkb(unsigned char *,
1173 const OGRwkbExportOptions * = nullptr) const override;
1174
1175#ifndef DOXYGEN_XML
1177#endif
1178
1179 OGRErr importFromWkt(const char **) override;
1180
1181#ifndef DOXYGEN_XML
1183#endif
1184
1189 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1190 OGRErr *err = nullptr) const override;
1191
1192 // IGeometry
1193 virtual int getDimension() const override;
1194 virtual OGRPoint *clone() const override;
1195 virtual void empty() override;
1196 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1197 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1198
1199 virtual OGRBoolean IsEmpty() const override
1200 {
1201 return !(flags & OGR_G_NOT_EMPTY_POINT);
1202 }
1203
1204 // IPoint
1206 double getX() const
1207 {
1208 return x;
1209 }
1210
1212 double getY() const
1213 {
1214 return y;
1215 }
1216
1218 double getZ() const
1219 {
1220 return z;
1221 }
1222
1224 double getM() const
1225 {
1226 return m;
1227 }
1228
1229 // Non standard
1230 virtual void setCoordinateDimension(int nDimension) override;
1231
1235 void setX(double xIn)
1236 {
1237 x = xIn;
1238 if (std::isnan(x) || std::isnan(y))
1239 flags &= ~OGR_G_NOT_EMPTY_POINT;
1240 else
1241 flags |= OGR_G_NOT_EMPTY_POINT;
1242 }
1243
1247 void setY(double yIn)
1248 {
1249 y = yIn;
1250 if (std::isnan(x) || std::isnan(y))
1251 flags &= ~OGR_G_NOT_EMPTY_POINT;
1252 else
1253 flags |= OGR_G_NOT_EMPTY_POINT;
1254 }
1255
1259 void setZ(double zIn)
1260 {
1261 z = zIn;
1262 flags |= OGR_G_3D;
1263 }
1264
1268 void setM(double mIn)
1269 {
1270 m = mIn;
1271 flags |= OGR_G_MEASURED;
1272 }
1273
1274 // ISpatialRelation
1275 virtual OGRBoolean Equals(const OGRGeometry *) const override;
1276 virtual OGRBoolean Intersects(const OGRGeometry *) const override;
1277 virtual OGRBoolean Within(const OGRGeometry *) const override;
1278
1279 // Non standard from OGRGeometry
1280 virtual const char *getGeometryName() const override;
1281 virtual OGRwkbGeometryType getGeometryType() const override;
1282 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1283 virtual void flattenTo2D() override;
1284
1285 virtual void accept(IOGRGeometryVisitor *visitor) override
1286 {
1287 visitor->visit(this);
1288 }
1289
1290 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1291 {
1292 visitor->visit(this);
1293 }
1294
1295 virtual void swapXY() override;
1296
1297 OGR_ALLOW_CAST_TO_THIS(Point)
1298 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
1299 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1300 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1301};
1302
1303/************************************************************************/
1304/* OGRPointIterator */
1305/************************************************************************/
1306
1313class CPL_DLL OGRPointIterator
1314{
1315 public:
1316 virtual ~OGRPointIterator();
1318
1319 static void destroy(OGRPointIterator *);
1320};
1321
1322/************************************************************************/
1323/* OGRCurve */
1324/************************************************************************/
1325
1331class CPL_DLL OGRCurve : public OGRGeometry
1332{
1333 protected:
1335 OGRCurve();
1336 OGRCurve(const OGRCurve &other);
1337
1338 virtual OGRCurveCasterToLineString GetCasterToLineString() const = 0;
1339 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const = 0;
1340
1341 friend class OGRCurvePolygon;
1342 friend class OGRCompoundCurve;
1344 virtual int ContainsPoint(const OGRPoint *p) const;
1345 virtual int IntersectsPoint(const OGRPoint *p) const;
1346 virtual double get_AreaOfCurveSegments() const = 0;
1347
1348 private:
1349 class CPL_DLL ConstIterator
1350 {
1351 struct Private;
1352 std::unique_ptr<Private> m_poPrivate;
1353
1354 public:
1355 ConstIterator(const OGRCurve *poSelf, bool bStart);
1356 ConstIterator(ConstIterator &&oOther) noexcept;
1357 ConstIterator &operator=(ConstIterator &&oOther);
1358 ~ConstIterator();
1359 const OGRPoint &operator*() const;
1360 ConstIterator &operator++();
1361 bool operator!=(const ConstIterator &it) const;
1362 };
1363
1364 friend inline ConstIterator begin(const OGRCurve *);
1365 friend inline ConstIterator end(const OGRCurve *);
1366
1367 public:
1368 ~OGRCurve() override;
1369
1371 OGRCurve &operator=(const OGRCurve &other);
1373
1376
1385 ConstIterator begin() const;
1387 ConstIterator end() const;
1388
1389 // IGeometry
1390 virtual OGRCurve *clone() const override = 0;
1391
1392 // ICurve methods
1393 virtual double get_Length() const = 0;
1394 virtual void StartPoint(OGRPoint *) const = 0;
1395 virtual void EndPoint(OGRPoint *) const = 0;
1396 virtual int get_IsClosed() const;
1397 virtual void Value(double, OGRPoint *) const = 0;
1398 virtual OGRLineString *
1399 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1400 const char *const *papszOptions = nullptr) const = 0;
1401 virtual int getDimension() const override;
1402
1403 // non standard
1404 virtual int getNumPoints() const = 0;
1406 virtual OGRBoolean IsConvex() const;
1407 virtual double get_Area() const = 0;
1408 virtual double get_GeodesicArea(
1409 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
1410 virtual int isClockwise() const;
1411 virtual void reversePoints() = 0;
1412
1417 {
1418 return cpl::down_cast<OGRSimpleCurve *>(this);
1419 }
1420
1424 inline const OGRSimpleCurve *toSimpleCurve() const
1425 {
1426 return cpl::down_cast<const OGRSimpleCurve *>(this);
1427 }
1428
1429 static OGRCompoundCurve *CastToCompoundCurve(OGRCurve *puCurve);
1430 static OGRLineString *CastToLineString(OGRCurve *poCurve);
1431 static OGRLinearRing *CastToLinearRing(OGRCurve *poCurve);
1432
1433 OGR_FORBID_DOWNCAST_TO_POINT
1434 OGR_ALLOW_CAST_TO_THIS(Curve)
1435 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
1436 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
1437};
1438
1440
1441inline OGRCurve::ConstIterator begin(const OGRCurve *poCurve)
1442{
1443 return poCurve->begin();
1444}
1445
1447inline OGRCurve::ConstIterator end(const OGRCurve *poCurve)
1448{
1449 return poCurve->end();
1450}
1451
1453
1454/************************************************************************/
1455/* OGRIteratedPoint */
1456/************************************************************************/
1457
1479class CPL_DLL OGRIteratedPoint : public OGRPoint
1480{
1481 private:
1482 friend class OGRSimpleCurve;
1483
1484 OGRSimpleCurve *m_poCurve = nullptr;
1485 int m_nPos = 0;
1486
1487 OGRIteratedPoint() = default;
1488
1490
1491 public:
1495 void setX(double xIn);
1499 void setY(double yIn);
1503 void setZ(double zIn);
1507 void setM(double mIn);
1508};
1509
1510/************************************************************************/
1511/* OGRSimpleCurve */
1512/************************************************************************/
1513
1523class CPL_DLL OGRSimpleCurve : public OGRCurve
1524{
1525 protected:
1527 friend class OGRGeometry;
1528
1529 int nPointCount;
1530 int m_nPointCapacity = 0;
1531 OGRRawPoint *paoPoints;
1532 double *padfZ;
1533 double *padfM;
1534
1535 void Make3D();
1536 void Make2D();
1537 void RemoveM();
1538 void AddM();
1539
1540 OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ, int bHasM,
1541 OGRRawPoint *&paoPointsIn, int &nMaxPoints,
1542 double *&padfZIn);
1544
1545 virtual double get_LinearArea() const;
1546
1548 OGRSimpleCurve(const OGRSimpleCurve &other);
1549
1550 private:
1551 class CPL_DLL Iterator
1552 {
1553 struct Private;
1554 std::unique_ptr<Private> m_poPrivate;
1555 void update();
1556
1557 public:
1558 Iterator(OGRSimpleCurve *poSelf, int nPos);
1559 Iterator(Iterator &&oOther) noexcept; // declared but not defined.
1560 // Needed for gcc 5.4 at least
1561 ~Iterator();
1562 OGRIteratedPoint &operator*();
1563 Iterator &operator++();
1564 bool operator!=(const Iterator &it) const;
1565 };
1566
1567 friend inline Iterator begin(OGRSimpleCurve *);
1568 friend inline Iterator end(OGRSimpleCurve *);
1569
1570 class CPL_DLL ConstIterator
1571 {
1572 struct Private;
1573 std::unique_ptr<Private> m_poPrivate;
1574
1575 public:
1576 ConstIterator(const OGRSimpleCurve *poSelf, int nPos);
1577 ConstIterator(
1578 ConstIterator &&oOther) noexcept; // declared but not defined.
1579 // Needed for gcc 5.4 at least
1580 ~ConstIterator();
1581 const OGRPoint &operator*() const;
1582 ConstIterator &operator++();
1583 bool operator!=(const ConstIterator &it) const;
1584 };
1585
1586 friend inline ConstIterator begin(const OGRSimpleCurve *);
1587 friend inline ConstIterator end(const OGRSimpleCurve *);
1588
1589 public:
1590 ~OGRSimpleCurve() override;
1591
1592 OGRSimpleCurve &operator=(const OGRSimpleCurve &other);
1593
1596
1605 Iterator begin();
1607 Iterator end();
1616 ConstIterator begin() const;
1618 ConstIterator end() const;
1619
1620 // IWks Interface.
1621 virtual size_t WkbSize() const override;
1622 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1623 size_t &nBytesConsumedOut) override;
1624 virtual OGRErr
1625 exportToWkb(unsigned char *,
1626 const OGRwkbExportOptions * = nullptr) const override;
1627
1628#ifndef DOXYGEN_XML
1630#endif
1631
1632 OGRErr importFromWkt(const char **) override;
1633
1634#ifndef DOXYGEN_XML
1636#endif
1637
1642 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
1643 OGRErr *err = nullptr) const override;
1644
1645 // IGeometry interface.
1646 virtual void empty() override;
1647 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
1648 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
1649 virtual OGRBoolean IsEmpty() const override;
1650 virtual OGRSimpleCurve *clone() const override = 0;
1651
1652 // ICurve methods.
1653 virtual double get_Length() const override;
1654 virtual void StartPoint(OGRPoint *) const override;
1655 virtual void EndPoint(OGRPoint *) const override;
1656 virtual void Value(double, OGRPoint *) const override;
1657 virtual double Project(const OGRPoint *) const;
1658 virtual OGRLineString *getSubLine(double, double, int) const;
1659
1660 // ILineString methods.
1661 virtual int getNumPoints() const override
1662 {
1663 return nPointCount;
1664 }
1665
1666 void getPoint(int, OGRPoint *) const;
1667
1668 double getX(int i) const
1669 {
1670 return paoPoints[i].x;
1671 }
1672
1673 double getY(int i) const
1674 {
1675 return paoPoints[i].y;
1676 }
1677
1678 double getZ(int i) const;
1679 double getM(int i) const;
1680
1681 // ISpatialRelation
1682 virtual OGRBoolean Equals(const OGRGeometry *) const override;
1683
1684 // non standard.
1685 virtual void setCoordinateDimension(int nDimension) override;
1686 virtual void set3D(OGRBoolean bIs3D) override;
1687 virtual void setMeasured(OGRBoolean bIsMeasured) override;
1688 void setNumPoints(int nNewPointCount, int bZeroizeNewContent = TRUE);
1689 void setPoint(int, OGRPoint *);
1690 void setPoint(int, double, double);
1691 void setZ(int, double);
1692 void setM(int, double);
1693 void setPoint(int, double, double, double);
1694 void setPointM(int, double, double, double);
1695 void setPoint(int, double, double, double, double);
1696 void setPoints(int, const OGRRawPoint *, const double * = nullptr);
1697 void setPointsM(int, const OGRRawPoint *, const double *);
1698 void setPoints(int, const OGRRawPoint *, const double *, const double *);
1699 void setPoints(int, const double *padfX, const double *padfY,
1700 const double *padfZIn = nullptr);
1701 void setPointsM(int, const double *padfX, const double *padfY,
1702 const double *padfMIn = nullptr);
1703 void setPoints(int, const double *padfX, const double *padfY,
1704 const double *padfZIn, const double *padfMIn);
1705 void addPoint(const OGRPoint *);
1706 void addPoint(double, double);
1707 void addPoint(double, double, double);
1708 void addPointM(double, double, double);
1709 void addPoint(double, double, double, double);
1710
1711 bool removePoint(int);
1712
1713 void getPoints(OGRRawPoint *, double * = nullptr) const;
1714 void getPoints(void *pabyX, int nXStride, void *pabyY, int nYStride,
1715 void *pabyZ = nullptr, int nZStride = 0,
1716 void *pabyM = nullptr, int nMStride = 0) const;
1717
1718 void addSubLineString(const OGRLineString *, int nStartVertex = 0,
1719 int nEndVertex = -1);
1720 void reversePoints() override;
1721 virtual OGRPointIterator *getPointIterator() const override;
1722
1723 // non-standard from OGRGeometry
1724 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1725 virtual void flattenTo2D() override;
1726 virtual void segmentize(double dfMaxLength) override;
1727
1728 virtual void swapXY() override;
1729
1730 OGR_ALLOW_UPCAST_TO(Curve)
1731 OGR_ALLOW_CAST_TO_THIS(SimpleCurve)
1732};
1733
1735
1736inline OGRSimpleCurve::Iterator begin(OGRSimpleCurve *poCurve)
1737{
1738 return poCurve->begin();
1739}
1740
1742inline OGRSimpleCurve::Iterator end(OGRSimpleCurve *poCurve)
1743{
1744 return poCurve->end();
1745}
1746
1748inline OGRSimpleCurve::ConstIterator begin(const OGRSimpleCurve *poCurve)
1749{
1750 return poCurve->begin();
1751}
1752
1754inline OGRSimpleCurve::ConstIterator end(const OGRSimpleCurve *poCurve)
1755{
1756 return poCurve->end();
1757}
1758
1760
1761/************************************************************************/
1762/* OGRLineString */
1763/************************************************************************/
1764
1772class CPL_DLL OGRLineString : public OGRSimpleCurve
1773{
1774 // cppcheck-suppress unusedPrivateFunction
1775 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
1776
1777 protected:
1779 static OGRLineString *TransferMembersAndDestroy(OGRLineString *poSrc,
1780 OGRLineString *poDst);
1781
1782 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1783 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1784
1785 virtual double get_AreaOfCurveSegments() const override;
1787
1788 static OGRLinearRing *CastToLinearRing(OGRLineString *poLS);
1789
1790 public:
1793 ~OGRLineString() override;
1794
1795 OGRLineString &operator=(const OGRLineString &other);
1796
1797 virtual OGRLineString *clone() const override;
1798 virtual OGRLineString *
1799 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
1800 const char *const *papszOptions = nullptr) const override;
1801 virtual OGRGeometry *
1802 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
1803 virtual double get_Area() const override;
1804 virtual double get_GeodesicArea(
1805 const OGRSpatialReference *poSRSOverride = nullptr) const override;
1806
1807 // Non-standard from OGRGeometry.
1808 virtual OGRwkbGeometryType getGeometryType() const override;
1809 virtual const char *getGeometryName() const override;
1810 virtual int isClockwise() const override;
1811
1814 {
1815 return this;
1816 }
1817
1819 inline const OGRSimpleCurve *toUpperClass() const
1820 {
1821 return this;
1822 }
1823
1824 virtual void accept(IOGRGeometryVisitor *visitor) override
1825 {
1826 visitor->visit(this);
1827 }
1828
1829 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1830 {
1831 visitor->visit(this);
1832 }
1833
1834 OGR_ALLOW_UPCAST_TO(SimpleCurve)
1835 OGR_ALLOW_CAST_TO_THIS(LineString)
1836};
1837
1838/************************************************************************/
1839/* OGRLinearRing */
1840/************************************************************************/
1841
1862class CPL_DLL OGRLinearRing : public OGRLineString
1863{
1864 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
1865
1866 // IWks Interface - Note this isn't really a first class object
1867 // for the purposes of WKB form. These methods always fail since this
1868 // object can't be serialized on its own.
1869 virtual size_t WkbSize() const override;
1870 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1871 size_t &nBytesConsumedOut) override;
1872 OGRErr exportToWkb(unsigned char *,
1873 const OGRwkbExportOptions * = nullptr) const override;
1874
1875 protected:
1877 friend class OGRPolygon;
1878 friend class OGRTriangle;
1879
1880 // These are not IWks compatible ... just a convenience for OGRPolygon.
1881 virtual size_t _WkbSize(int _flags) const;
1882 virtual OGRErr _importFromWkb(OGRwkbByteOrder, int _flags,
1883 const unsigned char *, size_t,
1884 size_t &nBytesConsumedOut);
1885 virtual OGRErr _exportToWkb(int _flags, unsigned char *,
1886 const OGRwkbExportOptions *) const;
1887
1888 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1889 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1891
1892 static OGRLineString *CastToLineString(OGRLinearRing *poLR);
1893
1894 public:
1897 explicit OGRLinearRing(OGRLinearRing *);
1898 ~OGRLinearRing() override;
1899
1900 OGRLinearRing &operator=(const OGRLinearRing &other);
1901
1902 // Non standard.
1903 virtual const char *getGeometryName() const override;
1904 virtual OGRLinearRing *clone() const override;
1905
1907 void reverseWindingOrder()
1908 CPL_WARN_DEPRECATED("Use reversePoints() instead");
1910
1911 virtual void closeRings() override;
1912 OGRBoolean isPointInRing(const OGRPoint *pt,
1913 int bTestEnvelope = TRUE) const;
1914 OGRBoolean isPointOnRingBoundary(const OGRPoint *pt,
1915 int bTestEnvelope = TRUE) const;
1916 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
1917
1919 inline OGRLineString *toUpperClass()
1920 {
1921 return this;
1922 }
1923
1925 inline const OGRLineString *toUpperClass() const
1926 {
1927 return this;
1928 }
1929
1930 virtual void accept(IOGRGeometryVisitor *visitor) override
1931 {
1932 visitor->visit(this);
1933 }
1934
1935 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
1936 {
1937 visitor->visit(this);
1938 }
1939
1940 OGR_ALLOW_UPCAST_TO(LineString)
1941 OGR_ALLOW_CAST_TO_THIS(LinearRing)
1942};
1943
1944/************************************************************************/
1945/* OGRCircularString */
1946/************************************************************************/
1947
1960class CPL_DLL OGRCircularString : public OGRSimpleCurve
1961{
1962 private:
1963 void ExtendEnvelopeWithCircular(OGREnvelope *psEnvelope) const;
1964 OGRBoolean IsValidFast() const;
1965 int IsFullCircle(double &cx, double &cy, double &square_R) const;
1966
1967 protected:
1969 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
1970 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
1971 virtual int IntersectsPoint(const OGRPoint *p) const override;
1972 virtual int ContainsPoint(const OGRPoint *p) const override;
1973 virtual double get_AreaOfCurveSegments() const override;
1975
1976 public:
1979 ~OGRCircularString() override;
1980
1981 OGRCircularString &operator=(const OGRCircularString &other);
1982
1983 // IWks Interface.
1984 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
1985 size_t &nBytesConsumedOut) override;
1986 OGRErr exportToWkb(unsigned char *,
1987 const OGRwkbExportOptions * = nullptr) const override;
1988
1989#ifndef DOXYGEN_XML
1991#endif
1992
1993 OGRErr importFromWkt(const char **) override;
1994
1995#ifndef DOXYGEN_XML
1997#endif
1998
2003 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2004 OGRErr *err = nullptr) const override;
2005
2006 // IGeometry interface.
2007 virtual OGRBoolean IsValid() const override;
2008 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2009 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2010 virtual OGRCircularString *clone() const override;
2011
2012 // ICurve methods.
2013 virtual double get_Length() const override;
2014 virtual OGRLineString *
2015 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
2016 const char *const *papszOptions = nullptr) const override;
2017 virtual void Value(double, OGRPoint *) const override;
2018 virtual double get_Area() const override;
2019 virtual double get_GeodesicArea(
2020 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2021
2022 // Non-standard from OGRGeometry.
2023 virtual OGRwkbGeometryType getGeometryType() const override;
2024 virtual const char *getGeometryName() const override;
2025 virtual void segmentize(double dfMaxLength) override;
2026 virtual OGRBoolean
2027 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2028 virtual OGRGeometry *
2029 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2030 const char *const *papszOptions = nullptr) const override;
2031
2034 {
2035 return this;
2036 }
2037
2039 inline const OGRSimpleCurve *toUpperClass() const
2040 {
2041 return this;
2042 }
2043
2044 virtual void accept(IOGRGeometryVisitor *visitor) override
2045 {
2046 visitor->visit(this);
2047 }
2048
2049 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2050 {
2051 visitor->visit(this);
2052 }
2053
2054 OGR_ALLOW_UPCAST_TO(SimpleCurve)
2055 OGR_ALLOW_CAST_TO_THIS(CircularString)
2056};
2057
2058/************************************************************************/
2059/* OGRCurveCollection */
2060/************************************************************************/
2061
2073class CPL_DLL OGRCurveCollection
2074{
2075 protected:
2076 friend class OGRCompoundCurve;
2077 friend class OGRCurvePolygon;
2078 friend class OGRPolygon;
2079 friend class OGRTriangle;
2080
2081 int nCurveCount = 0;
2082 OGRCurve **papoCurves = nullptr;
2083
2084 public:
2085 OGRCurveCollection();
2086 OGRCurveCollection(const OGRCurveCollection &other);
2087 ~OGRCurveCollection();
2088
2089 OGRCurveCollection &operator=(const OGRCurveCollection &other);
2090
2092 typedef OGRCurve ChildType;
2093
2097 OGRCurve **begin()
2098 {
2099 return papoCurves;
2100 }
2101
2103 OGRCurve **end()
2104 {
2105 return papoCurves + nCurveCount;
2106 }
2107
2111 const OGRCurve *const *begin() const
2112 {
2113 return papoCurves;
2114 }
2115
2117 const OGRCurve *const *end() const
2118 {
2119 return papoCurves + nCurveCount;
2120 }
2121
2122 void empty(OGRGeometry *poGeom);
2123 OGRBoolean IsEmpty() const;
2124 void getEnvelope(OGREnvelope *psEnvelope) const;
2125 void getEnvelope(OGREnvelope3D *psEnvelope) const;
2126
2127 OGRErr addCurveDirectly(OGRGeometry *poGeom, OGRCurve *poCurve,
2128 int bNeedRealloc);
2129 size_t WkbSize() const;
2130 OGRErr importPreambleFromWkb(OGRGeometry *poGeom,
2131 const unsigned char *pabyData, size_t &nSize,
2132 size_t &nDataOffset,
2133 OGRwkbByteOrder &eByteOrder,
2134 size_t nMinSubGeomSize,
2135 OGRwkbVariant eWkbVariant);
2136 OGRErr
2137 importBodyFromWkb(OGRGeometry *poGeom, const unsigned char *pabyData,
2138 size_t nSize, bool bAcceptCompoundCurve,
2139 OGRErr (*pfnAddCurveDirectlyFromWkb)(OGRGeometry *poGeom,
2140 OGRCurve *poCurve),
2141 OGRwkbVariant eWkbVariant, size_t &nBytesConsumedOut);
2142 std::string exportToWkt(const OGRGeometry *geom, const OGRWktOptions &opts,
2143 OGRErr *err) const;
2144 OGRErr exportToWkb(const OGRGeometry *poGeom, unsigned char *,
2145 const OGRwkbExportOptions * = nullptr) const;
2146 OGRBoolean Equals(const OGRCurveCollection *poOCC) const;
2147 void setCoordinateDimension(OGRGeometry *poGeom, int nNewDimension);
2148 void set3D(OGRGeometry *poGeom, OGRBoolean bIs3D);
2149 void setMeasured(OGRGeometry *poGeom, OGRBoolean bIsMeasured);
2150 void assignSpatialReference(OGRGeometry *poGeom,
2151 const OGRSpatialReference *poSR);
2152 int getNumCurves() const;
2153 OGRCurve *getCurve(int);
2154 const OGRCurve *getCurve(int) const;
2155 OGRCurve *stealCurve(int);
2156
2157 OGRErr removeCurve(int iIndex, bool bDelete = true);
2158
2159 bool hasEmptyParts() const;
2160 void removeEmptyParts();
2161
2162 void reversePoints();
2163
2164 OGRErr transform(OGRGeometry *poGeom, OGRCoordinateTransformation *poCT);
2165 void flattenTo2D(OGRGeometry *poGeom);
2166 void segmentize(double dfMaxLength);
2167 void swapXY();
2168 OGRBoolean hasCurveGeometry(int bLookForNonLinear) const;
2169};
2170
2172
2173/************************************************************************/
2174/* OGRCompoundCurve */
2175/************************************************************************/
2176
2187class CPL_DLL OGRCompoundCurve : public OGRCurve
2188{
2189 private:
2190 OGRCurveCollection oCC{};
2191
2192 OGRErr addCurveDirectlyInternal(OGRCurve *poCurve, double dfToleranceEps,
2193 int bNeedRealloc);
2194 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2195 OGRCurve *poCurve);
2196 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2197 OGRCurve *poCurve);
2198 OGRLineString *CurveToLineInternal(double dfMaxAngleStepSizeDegrees,
2199 const char *const *papszOptions,
2200 int bIsLinearRing) const;
2201 // cppcheck-suppress unusedPrivateFunction
2202 static OGRLineString *CasterToLineString(OGRCurve *poCurve);
2203 // cppcheck-suppress unusedPrivateFunction
2204 static OGRLinearRing *CasterToLinearRing(OGRCurve *poCurve);
2205
2206 protected:
2208 static OGRLineString *CastToLineString(OGRCompoundCurve *poCC);
2209 static OGRLinearRing *CastToLinearRing(OGRCompoundCurve *poCC);
2210
2211 virtual OGRCurveCasterToLineString GetCasterToLineString() const override;
2212 virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const override;
2214
2215 public:
2218 ~OGRCompoundCurve() override;
2219
2220 OGRCompoundCurve &operator=(const OGRCompoundCurve &other);
2221
2224
2229 {
2230 return oCC.begin();
2231 }
2232
2235 {
2236 return oCC.end();
2237 }
2238
2242 const ChildType *const *begin() const
2243 {
2244 return oCC.begin();
2245 }
2246
2248 const ChildType *const *end() const
2249 {
2250 return oCC.end();
2251 }
2252
2253 // IWks Interface
2254 virtual size_t WkbSize() const override;
2255 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2256 size_t &nBytesConsumedOut) override;
2257 OGRErr exportToWkb(unsigned char *,
2258 const OGRwkbExportOptions * = nullptr) const override;
2259
2260#ifndef DOXYGEN_XML
2262#endif
2263
2264 OGRErr importFromWkt(const char **) override;
2265
2266#ifndef DOXYGEN_XML
2268#endif
2269
2274 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2275 OGRErr *err = nullptr) const override;
2276
2277 // IGeometry interface.
2278 virtual OGRCompoundCurve *clone() const override;
2279 virtual void empty() override;
2280 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2281 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2282 virtual OGRBoolean IsEmpty() const override;
2283
2284 // ICurve methods.
2285 virtual double get_Length() const override;
2286 virtual void StartPoint(OGRPoint *) const override;
2287 virtual void EndPoint(OGRPoint *) const override;
2288 virtual void Value(double, OGRPoint *) const override;
2289 virtual OGRLineString *
2290 CurveToLine(double dfMaxAngleStepSizeDegrees = 0,
2291 const char *const *papszOptions = nullptr) const override;
2292
2293 virtual int getNumPoints() const override;
2294 virtual double get_AreaOfCurveSegments() const override;
2295 virtual double get_Area() const override;
2296 virtual double get_GeodesicArea(
2297 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2298
2299 // ISpatialRelation.
2300 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2301
2302 // ICompoundCurve method.
2303 int getNumCurves() const;
2304 OGRCurve *getCurve(int);
2305 const OGRCurve *getCurve(int) const;
2306
2307 // Non-standard.
2308 virtual void setCoordinateDimension(int nDimension) override;
2309 virtual void set3D(OGRBoolean bIs3D) override;
2310 virtual void setMeasured(OGRBoolean bIsMeasured) override;
2311
2312 virtual void
2313 assignSpatialReference(const OGRSpatialReference *poSR) override;
2314
2318 static constexpr double DEFAULT_TOLERANCE_EPSILON = 1e-14;
2319
2320 OGRErr addCurve(const OGRCurve *,
2321 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2322 OGRErr addCurveDirectly(OGRCurve *,
2323 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2324 OGRErr addCurve(std::unique_ptr<OGRCurve>,
2325 double dfToleranceEps = DEFAULT_TOLERANCE_EPSILON);
2326 OGRCurve *stealCurve(int);
2327 virtual OGRPointIterator *getPointIterator() const override;
2328 void reversePoints() override;
2329
2330 // Non-standard from OGRGeometry.
2331 virtual OGRwkbGeometryType getGeometryType() const override;
2332 virtual const char *getGeometryName() const override;
2333 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2334 virtual void flattenTo2D() override;
2335 virtual void segmentize(double dfMaxLength) override;
2336 virtual OGRBoolean
2337 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2338 virtual OGRGeometry *
2339 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2340 const char *const *papszOptions = nullptr) const override;
2341
2342 virtual void accept(IOGRGeometryVisitor *visitor) override
2343 {
2344 visitor->visit(this);
2345 }
2346
2347 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2348 {
2349 visitor->visit(this);
2350 }
2351
2352 virtual void swapXY() override;
2353
2354 bool hasEmptyParts() const override;
2355 void removeEmptyParts() override;
2356
2357 OGR_ALLOW_UPCAST_TO(Curve)
2358 OGR_ALLOW_CAST_TO_THIS(CompoundCurve)
2359};
2360
2362
2363inline const OGRCompoundCurve::ChildType *const *
2364begin(const OGRCompoundCurve *poCurve)
2365{
2366 return poCurve->begin();
2367}
2368
2370inline const OGRCompoundCurve::ChildType *const *
2371end(const OGRCompoundCurve *poCurve)
2372{
2373 return poCurve->end();
2374}
2375
2378{
2379 return poCurve->begin();
2380}
2381
2384{
2385 return poCurve->end();
2386}
2387
2389
2390/************************************************************************/
2391/* OGRSurface */
2392/************************************************************************/
2393
2399class CPL_DLL OGRSurface : public OGRGeometry
2400{
2401 protected:
2403 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const = 0;
2404 virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const = 0;
2406
2407 public:
2408 virtual double get_Area() const = 0;
2409 virtual double get_GeodesicArea(
2410 const OGRSpatialReference *poSRSOverride = nullptr) const = 0;
2411
2412 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
2413 {
2414 return PointOnSurfaceInternal(poPoint);
2415 }
2416
2417 virtual OGRSurface *clone() const override = 0;
2418
2420 static OGRPolygon *CastToPolygon(OGRSurface *poSurface);
2421 static OGRCurvePolygon *CastToCurvePolygon(OGRSurface *poSurface);
2423
2424 OGR_FORBID_DOWNCAST_TO_POINT
2425 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
2426 OGR_ALLOW_CAST_TO_THIS(Surface)
2427 OGR_FORBID_DOWNCAST_TO_ALL_MULTI
2428};
2429
2430/************************************************************************/
2431/* OGRCurvePolygon */
2432/************************************************************************/
2433
2447class CPL_DLL OGRCurvePolygon : public OGRSurface
2448{
2449 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2450
2451 private:
2452 OGRBoolean IntersectsPoint(const OGRPoint *p) const;
2453 OGRBoolean ContainsPoint(const OGRPoint *p) const;
2454 virtual int checkRing(OGRCurve *poNewRing) const;
2455 OGRErr addRingDirectlyInternal(OGRCurve *poCurve, int bNeedRealloc);
2456 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
2457 OGRCurve *poCurve);
2458 static OGRErr addCurveDirectlyFromWkb(OGRGeometry *poSelf,
2459 OGRCurve *poCurve);
2460
2461 protected:
2463 friend class OGRPolygon;
2464 friend class OGRTriangle;
2465 OGRCurveCollection oCC{};
2466
2467 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2468 virtual OGRSurfaceCasterToCurvePolygon
2469 GetCasterToCurvePolygon() const override;
2470
2472
2473 static OGRPolygon *CastToPolygon(OGRCurvePolygon *poCP);
2474
2475 public:
2478 ~OGRCurvePolygon() override;
2479
2480 OGRCurvePolygon &operator=(const OGRCurvePolygon &other);
2481
2484
2489 {
2490 return oCC.begin();
2491 }
2492
2495 {
2496 return oCC.end();
2497 }
2498
2502 const ChildType *const *begin() const
2503 {
2504 return oCC.begin();
2505 }
2506
2508 const ChildType *const *end() const
2509 {
2510 return oCC.end();
2511 }
2512
2513 // Non standard (OGRGeometry).
2514 virtual const char *getGeometryName() const override;
2515 virtual OGRwkbGeometryType getGeometryType() const override;
2516 virtual OGRCurvePolygon *clone() const override;
2517 virtual void empty() override;
2518 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2519 virtual void flattenTo2D() override;
2520 virtual OGRBoolean IsEmpty() const override;
2521 virtual void segmentize(double dfMaxLength) override;
2522 virtual OGRBoolean
2523 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2524 virtual OGRGeometry *
2525 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2526 const char *const *papszOptions = nullptr) const override;
2527 virtual double get_GeodesicArea(
2528 const OGRSpatialReference *poSRSOverride = nullptr) const override;
2529
2530 // ISurface Interface
2531 virtual double get_Area() const override;
2532
2533 // IWks Interface
2534 virtual size_t WkbSize() const override;
2535 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2536 size_t &nBytesConsumedOut) override;
2537 OGRErr exportToWkb(unsigned char *,
2538 const OGRwkbExportOptions * = nullptr) const override;
2539
2540#ifndef DOXYGEN_XML
2542#endif
2543
2544 OGRErr importFromWkt(const char **) override;
2545
2546#ifndef DOXYGEN_XML
2548#endif
2549
2554 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2555 OGRErr *err = nullptr) const override;
2556
2557 // IGeometry
2558 virtual int getDimension() const override;
2559 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
2560 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
2561
2562 // ICurvePolygon
2563 virtual OGRPolygon *
2564 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2565 const char *const *papszOptions = nullptr) const;
2566
2567 // ISpatialRelation
2568 virtual OGRBoolean Equals(const OGRGeometry *) const override;
2569 virtual OGRBoolean Intersects(const OGRGeometry *) const override;
2570 virtual OGRBoolean Contains(const OGRGeometry *) const override;
2571
2572 // Non standard
2573 virtual void setCoordinateDimension(int nDimension) override;
2574 virtual void set3D(OGRBoolean bIs3D) override;
2575 virtual void setMeasured(OGRBoolean bIsMeasured) override;
2576
2577 virtual void
2578 assignSpatialReference(const OGRSpatialReference *poSR) override;
2579
2580 virtual OGRErr addRing(const OGRCurve *);
2581 virtual OGRErr addRingDirectly(OGRCurve *);
2582 OGRErr addRing(std::unique_ptr<OGRCurve>);
2583
2584 OGRCurve *getExteriorRingCurve();
2585 const OGRCurve *getExteriorRingCurve() const;
2586 int getNumInteriorRings() const;
2587 OGRCurve *getInteriorRingCurve(int);
2588 const OGRCurve *getInteriorRingCurve(int) const;
2589
2590 OGRCurve *stealExteriorRingCurve();
2591
2592 OGRErr removeRing(int iIndex, bool bDelete = true);
2593
2594 virtual void accept(IOGRGeometryVisitor *visitor) override
2595 {
2596 visitor->visit(this);
2597 }
2598
2599 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2600 {
2601 visitor->visit(this);
2602 }
2603
2604 virtual void swapXY() override;
2605
2606 bool hasEmptyParts() const override;
2607 void removeEmptyParts() override;
2608
2609 OGR_ALLOW_UPCAST_TO(Surface)
2610 OGR_ALLOW_CAST_TO_THIS(CurvePolygon)
2611};
2612
2614
2615inline const OGRCurvePolygon::ChildType *const *
2616begin(const OGRCurvePolygon *poGeom)
2617{
2618 return poGeom->begin();
2619}
2620
2622inline const OGRCurvePolygon::ChildType *const *
2623end(const OGRCurvePolygon *poGeom)
2624{
2625 return poGeom->end();
2626}
2627
2630{
2631 return poGeom->begin();
2632}
2633
2636{
2637 return poGeom->end();
2638}
2639
2641
2642/************************************************************************/
2643/* OGRPolygon */
2644/************************************************************************/
2645
2655class CPL_DLL OGRPolygon : public OGRCurvePolygon
2656{
2657 static OGRCurvePolygon *CasterToCurvePolygon(OGRSurface *poSurface);
2658
2659 protected:
2661 friend class OGRMultiSurface;
2662 friend class OGRPolyhedralSurface;
2663 friend class OGRTriangulatedSurface;
2664
2665 virtual int checkRing(OGRCurve *poNewRing) const override;
2666 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2667 int bHasM, OGRRawPoint *&paoPoints,
2668 int &nMaxPoints, double *&padfZ);
2669
2670 static OGRCurvePolygon *CastToCurvePolygon(OGRPolygon *poPoly);
2671
2672 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2673 virtual OGRSurfaceCasterToCurvePolygon
2674 GetCasterToCurvePolygon() const override;
2676
2677 public:
2679 OGRPolygon(const OGRPolygon &other);
2680 ~OGRPolygon() override;
2681
2682 OGRPolygon &operator=(const OGRPolygon &other);
2683
2686
2691 {
2692 return reinterpret_cast<ChildType **>(oCC.begin());
2693 }
2694
2697 {
2698 return reinterpret_cast<ChildType **>(oCC.end());
2699 }
2700
2704 const ChildType *const *begin() const
2705 {
2706 return reinterpret_cast<const ChildType *const *>(oCC.begin());
2707 }
2708
2710 const ChildType *const *end() const
2711 {
2712 return reinterpret_cast<const ChildType *const *>(oCC.end());
2713 }
2714
2715 // Non-standard (OGRGeometry).
2716 virtual const char *getGeometryName() const override;
2717 virtual OGRwkbGeometryType getGeometryType() const override;
2718 virtual OGRPolygon *clone() const override;
2719 virtual OGRBoolean
2720 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2721 virtual OGRGeometry *
2722 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2723 virtual OGRGeometry *
2724 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2725 const char *const *papszOptions = nullptr) const override;
2726
2727 // IWks Interface.
2728 virtual size_t WkbSize() const override;
2729 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2730 size_t &nBytesConsumedOut) override;
2731 OGRErr exportToWkb(unsigned char *,
2732 const OGRwkbExportOptions * = nullptr) const override;
2733
2734#ifndef DOXYGEN_XML
2736#endif
2737
2738 OGRErr importFromWkt(const char **) override;
2739
2740#ifndef DOXYGEN_XML
2742#endif
2743
2748 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
2749 OGRErr *err = nullptr) const override;
2750
2751 // ICurvePolygon.
2752 virtual OGRPolygon *
2753 CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0,
2754 const char *const *papszOptions = nullptr) const override;
2755
2756 OGRLinearRing *getExteriorRing();
2757 const OGRLinearRing *getExteriorRing() const;
2758 virtual OGRLinearRing *getInteriorRing(int);
2759 virtual const OGRLinearRing *getInteriorRing(int) const;
2760
2761 OGRLinearRing *stealExteriorRing();
2762 virtual OGRLinearRing *stealInteriorRing(int);
2763
2764 OGRBoolean IsPointOnSurface(const OGRPoint *) const;
2765
2768 {
2769 return this;
2770 }
2771
2773 inline const OGRCurvePolygon *toUpperClass() const
2774 {
2775 return this;
2776 }
2777
2778 virtual void accept(IOGRGeometryVisitor *visitor) override
2779 {
2780 visitor->visit(this);
2781 }
2782
2783 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2784 {
2785 visitor->visit(this);
2786 }
2787
2788 virtual void closeRings() override;
2789
2790 OGR_ALLOW_UPCAST_TO(CurvePolygon)
2791 OGR_ALLOW_CAST_TO_THIS(Polygon)
2792};
2793
2795
2796inline const OGRPolygon::ChildType *const *begin(const OGRPolygon *poGeom)
2797{
2798 return poGeom->begin();
2799}
2800
2802inline const OGRPolygon::ChildType *const *end(const OGRPolygon *poGeom)
2803{
2804 return poGeom->end();
2805}
2806
2808inline OGRPolygon::ChildType **begin(OGRPolygon *poGeom)
2809{
2810 return poGeom->begin();
2811}
2812
2814inline OGRPolygon::ChildType **end(OGRPolygon *poGeom)
2815{
2816 return poGeom->end();
2817}
2818
2820
2821/************************************************************************/
2822/* OGRTriangle */
2823/************************************************************************/
2824
2831class CPL_DLL OGRTriangle : public OGRPolygon
2832{
2833 private:
2834 // cppcheck-suppress unusedPrivateFunction
2835 static OGRPolygon *CasterToPolygon(OGRSurface *poSurface);
2836 bool quickValidityCheck() const;
2837
2838 protected:
2840 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
2841 virtual OGRErr importFromWKTListOnly(const char **ppszInput, int bHasZ,
2842 int bHasM, OGRRawPoint *&paoPoints,
2843 int &nMaxPoints,
2844 double *&padfZ) override;
2846
2847 public:
2849 OGRTriangle(const OGRPoint &p, const OGRPoint &q, const OGRPoint &r);
2851 OGRTriangle(const OGRPolygon &other, OGRErr &eErr);
2852 OGRTriangle &operator=(const OGRTriangle &other);
2853 ~OGRTriangle() override;
2854 virtual const char *getGeometryName() const override;
2855 virtual OGRwkbGeometryType getGeometryType() const override;
2856 virtual OGRTriangle *clone() const override;
2857
2858 // IWks Interface.
2859 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2860 size_t &nBytesConsumedOut) override;
2861
2862 // New methods rewritten from OGRPolygon/OGRCurvePolygon/OGRGeometry.
2863 virtual OGRErr addRingDirectly(OGRCurve *poNewRing) override;
2864
2867 {
2868 return this;
2869 }
2870
2872 inline const OGRPolygon *toUpperClass() const
2873 {
2874 return this;
2875 }
2876
2877 virtual void accept(IOGRGeometryVisitor *visitor) override
2878 {
2879 visitor->visit(this);
2880 }
2881
2882 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
2883 {
2884 visitor->visit(this);
2885 }
2886
2888 static OGRGeometry *CastToPolygon(OGRGeometry *poGeom);
2890
2891 OGR_ALLOW_UPCAST_TO(Polygon)
2892 OGR_ALLOW_CAST_TO_THIS(Triangle)
2893};
2894
2895/************************************************************************/
2896/* OGRGeometryCollection */
2897/************************************************************************/
2898
2907{
2908 OGRErr importFromWktInternal(const char **ppszInput, int nRecLevel);
2909
2910 protected:
2912 int nGeomCount = 0;
2913 OGRGeometry **papoGeoms = nullptr;
2914
2915 std::string
2916 exportToWktInternal(const OGRWktOptions &opts, OGRErr *err,
2917 const std::string &exclude = std::string()) const;
2918 static OGRGeometryCollection *
2919 TransferMembersAndDestroy(OGRGeometryCollection *poSrc,
2920 OGRGeometryCollection *poDst);
2921
2922 OGRErr importFromWkbInternal(const unsigned char *pabyData, size_t nSize,
2923 int nRecLevel, OGRwkbVariant,
2924 size_t &nBytesConsumedOut);
2926 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
2927
2928 public:
2931 ~OGRGeometryCollection() override;
2932
2933 OGRGeometryCollection &operator=(const OGRGeometryCollection &other);
2934
2937
2942 {
2943 return papoGeoms;
2944 }
2945
2948 {
2949 return papoGeoms + nGeomCount;
2950 }
2951
2955 const ChildType *const *begin() const
2956 {
2957 return papoGeoms;
2958 }
2959
2961 const ChildType *const *end() const
2962 {
2963 return papoGeoms + nGeomCount;
2964 }
2965
2966 // Non standard (OGRGeometry).
2967 virtual const char *getGeometryName() const override;
2968 virtual OGRwkbGeometryType getGeometryType() const override;
2969 virtual OGRGeometryCollection *clone() const override;
2970 virtual void empty() override;
2971 virtual OGRErr transform(OGRCoordinateTransformation *poCT) override;
2972 virtual void flattenTo2D() override;
2973 virtual OGRBoolean IsEmpty() const override;
2974 virtual void segmentize(double dfMaxLength) override;
2975 virtual OGRBoolean
2976 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
2977 virtual OGRGeometry *
2978 getCurveGeometry(const char *const *papszOptions = nullptr) const override;
2979 virtual OGRGeometry *
2980 getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0,
2981 const char *const *papszOptions = nullptr) const override;
2982 virtual double
2983 get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const;
2984
2985 // IWks Interface
2986 virtual size_t WkbSize() const override;
2987 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
2988 size_t &nBytesConsumedOut) override;
2989 OGRErr exportToWkb(unsigned char *,
2990 const OGRwkbExportOptions * = nullptr) const override;
2991
2992#ifndef DOXYGEN_XML
2994#endif
2995
2996 OGRErr importFromWkt(const char **) override;
2997
2998#ifndef DOXYGEN_XML
3000#endif
3001
3006 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3007 OGRErr *err = nullptr) const override;
3008
3009 virtual double get_Length() const;
3010 virtual double get_Area() const;
3011
3012 // IGeometry methods
3013 virtual int getDimension() const override;
3014 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
3015 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3016
3017 // IGeometryCollection
3018 int getNumGeometries() const;
3019 OGRGeometry *getGeometryRef(int);
3020 const OGRGeometry *getGeometryRef(int) const;
3021
3022 // ISpatialRelation
3023 virtual OGRBoolean Equals(const OGRGeometry *) const override;
3024
3025 // Non standard
3026 virtual void setCoordinateDimension(int nDimension) override;
3027 virtual void set3D(OGRBoolean bIs3D) override;
3028 virtual void setMeasured(OGRBoolean bIsMeasured) override;
3029 virtual OGRErr addGeometry(const OGRGeometry *);
3030 virtual OGRErr addGeometryDirectly(OGRGeometry *);
3031 OGRErr addGeometry(std::unique_ptr<OGRGeometry> geom);
3032 virtual OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3033
3034 bool hasEmptyParts() const override;
3035 void removeEmptyParts() override;
3036
3037 virtual void
3038 assignSpatialReference(const OGRSpatialReference *poSR) override;
3039
3040 void closeRings() override;
3041
3042 virtual void swapXY() override;
3043
3044 virtual void accept(IOGRGeometryVisitor *visitor) override
3045 {
3046 visitor->visit(this);
3047 }
3048
3049 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3050 {
3051 visitor->visit(this);
3052 }
3053
3054 static OGRGeometryCollection *
3055 CastToGeometryCollection(OGRGeometryCollection *poSrc);
3056
3057 OGR_FORBID_DOWNCAST_TO_POINT
3058 OGR_FORBID_DOWNCAST_TO_ALL_CURVES
3059 OGR_FORBID_DOWNCAST_TO_ALL_SURFACES
3060 OGR_ALLOW_CAST_TO_THIS(GeometryCollection)
3061};
3062
3064
3065inline const OGRGeometryCollection::ChildType *const *
3066begin(const OGRGeometryCollection *poGeom)
3067{
3068 return poGeom->begin();
3069}
3070
3072inline const OGRGeometryCollection::ChildType *const *
3073end(const OGRGeometryCollection *poGeom)
3074{
3075 return poGeom->end();
3076}
3077
3080{
3081 return poGeom->begin();
3082}
3083
3086{
3087 return poGeom->end();
3088}
3089
3091
3092/************************************************************************/
3093/* OGRMultiSurface */
3094/************************************************************************/
3095
3103{
3104 protected:
3105 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3106
3107 public:
3110 ~OGRMultiSurface() override;
3111
3112 OGRMultiSurface &operator=(const OGRMultiSurface &other);
3113
3116
3121 {
3122 return reinterpret_cast<ChildType **>(papoGeoms);
3123 }
3124
3127 {
3128 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3129 }
3130
3134 const ChildType *const *begin() const
3135 {
3136 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3137 }
3138
3140 const ChildType *const *end() const
3141 {
3142 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3143 nGeomCount);
3144 }
3145
3146 // Non standard (OGRGeometry).
3147 virtual const char *getGeometryName() const override;
3148 virtual OGRwkbGeometryType getGeometryType() const override;
3149 virtual OGRMultiSurface *clone() const override;
3150
3151#ifndef DOXYGEN_XML
3153#endif
3154
3155 OGRErr importFromWkt(const char **) override;
3156
3157#ifndef DOXYGEN_XML
3159#endif
3160
3165 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3166 OGRErr *err = nullptr) const override;
3167
3168 // IMultiSurface methods
3169 virtual OGRErr PointOnSurface(OGRPoint *poPoint) const;
3170
3171 // IGeometry methods
3172 virtual int getDimension() const override;
3173
3174 // IGeometryCollection
3180
3182 const OGRSurface *getGeometryRef(int i) const
3183 {
3185 }
3186
3187 // Non standard
3188 virtual OGRBoolean
3189 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3190
3193 {
3194 return this;
3195 }
3196
3199 {
3200 return this;
3201 }
3202
3203 virtual void accept(IOGRGeometryVisitor *visitor) override
3204 {
3205 visitor->visit(this);
3206 }
3207
3208 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3209 {
3210 visitor->visit(this);
3211 }
3212
3213 static OGRMultiPolygon *CastToMultiPolygon(OGRMultiSurface *poMS);
3214
3215 OGR_ALLOW_CAST_TO_THIS(MultiSurface)
3216 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3217 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
3218 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3219 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3220};
3221
3223
3224inline const OGRMultiSurface::ChildType *const *
3225begin(const OGRMultiSurface *poGeom)
3226{
3227 return poGeom->begin();
3228}
3229
3231inline const OGRMultiSurface::ChildType *const *
3232end(const OGRMultiSurface *poGeom)
3233{
3234 return poGeom->end();
3235}
3236
3239{
3240 return poGeom->begin();
3241}
3242
3245{
3246 return poGeom->end();
3247}
3248
3250
3251/************************************************************************/
3252/* OGRMultiPolygon */
3253/************************************************************************/
3254
3259class CPL_DLL OGRMultiPolygon : public OGRMultiSurface
3260{
3261 protected:
3262 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3263 friend class OGRPolyhedralSurface;
3264 friend class OGRTriangulatedSurface;
3265
3266 private:
3268 OGRErr _addGeometryWithExpectedSubGeometryType(
3269 const OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3270 OGRErr _addGeometryDirectlyWithExpectedSubGeometryType(
3271 OGRGeometry *poNewGeom, OGRwkbGeometryType eSubGeometryType);
3273
3274 public:
3277 ~OGRMultiPolygon() override;
3278
3279 OGRMultiPolygon &operator=(const OGRMultiPolygon &other);
3280
3283
3288 {
3289 return reinterpret_cast<ChildType **>(papoGeoms);
3290 }
3291
3294 {
3295 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3296 }
3297
3301 const ChildType *const *begin() const
3302 {
3303 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3304 }
3305
3307 const ChildType *const *end() const
3308 {
3309 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3310 nGeomCount);
3311 }
3312
3313 // IGeometryCollection
3319
3321 const OGRPolygon *getGeometryRef(int i) const
3322 {
3324 }
3325
3326 // Non-standard (OGRGeometry).
3327 virtual const char *getGeometryName() const override;
3328 virtual OGRwkbGeometryType getGeometryType() const override;
3329 virtual OGRMultiPolygon *clone() const override;
3330
3331#ifndef DOXYGEN_XML
3333#endif
3334
3335 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3336 size_t &nBytesConsumedOut) override;
3337
3342 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3343 OGRErr *err = nullptr) const override;
3344
3345 // Non standard
3346 virtual OGRBoolean
3347 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3348
3351 {
3352 return this;
3353 }
3354
3357 {
3358 return this;
3359 }
3360
3361 virtual void accept(IOGRGeometryVisitor *visitor) override
3362 {
3363 visitor->visit(this);
3364 }
3365
3366 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3367 {
3368 visitor->visit(this);
3369 }
3370
3371 static OGRMultiSurface *CastToMultiSurface(OGRMultiPolygon *poMP);
3372
3373 OGR_ALLOW_CAST_TO_THIS(MultiPolygon)
3374 OGR_ALLOW_UPCAST_TO(MultiSurface)
3375};
3376
3378
3379inline const OGRMultiPolygon::ChildType *const *
3380begin(const OGRMultiPolygon *poGeom)
3381{
3382 return poGeom->begin();
3383}
3384
3386inline const OGRMultiPolygon::ChildType *const *
3387end(const OGRMultiPolygon *poGeom)
3388{
3389 return poGeom->end();
3390}
3391
3394{
3395 return poGeom->begin();
3396}
3397
3400{
3401 return poGeom->end();
3402}
3403
3405
3406/************************************************************************/
3407/* OGRPolyhedralSurface */
3408/************************************************************************/
3409
3416class CPL_DLL OGRPolyhedralSurface : public OGRSurface
3417{
3418 protected:
3420 friend class OGRTriangulatedSurface;
3421 OGRMultiPolygon oMP{};
3422 virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const override;
3423 virtual OGRSurfaceCasterToCurvePolygon
3424 GetCasterToCurvePolygon() const override;
3425 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const;
3426 virtual const char *getSubGeometryName() const;
3427 virtual OGRwkbGeometryType getSubGeometryType() const;
3428 std::string exportToWktInternal(const OGRWktOptions &opts,
3429 OGRErr *err) const;
3430
3431 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3432 GetCasterToMultiPolygon() const;
3433 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3435
3436 public:
3440 OGRPolyhedralSurface &operator=(const OGRPolyhedralSurface &other);
3441
3444
3449 {
3450 return oMP.begin();
3451 }
3452
3455 {
3456 return oMP.end();
3457 }
3458
3462 const ChildType *const *begin() const
3463 {
3464 return oMP.begin();
3465 }
3466
3468 const ChildType *const *end() const
3469 {
3470 return oMP.end();
3471 }
3472
3473 // IWks Interface.
3474 virtual size_t WkbSize() const override;
3475 virtual const char *getGeometryName() const override;
3476 virtual OGRwkbGeometryType getGeometryType() const override;
3477 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
3478 size_t &nBytesConsumedOut) override;
3479 OGRErr exportToWkb(unsigned char *,
3480 const OGRwkbExportOptions * = nullptr) const override;
3481
3482#ifndef DOXYGEN_XML
3484#endif
3485
3486 OGRErr importFromWkt(const char **) override;
3487
3488#ifndef DOXYGEN_XML
3490#endif
3491
3496 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3497 OGRErr *err = nullptr) const override;
3498
3499 // IGeometry methods.
3500 virtual int getDimension() const override;
3501
3502 virtual void empty() override;
3503
3504 virtual OGRPolyhedralSurface *clone() const override;
3505 virtual void getEnvelope(OGREnvelope *psEnvelope) const override;
3506 virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override;
3507
3508 virtual void flattenTo2D() override;
3509 virtual OGRErr transform(OGRCoordinateTransformation *) override;
3510 virtual OGRBoolean Equals(const OGRGeometry *) const override;
3511 virtual double get_Area() const override;
3512 virtual double get_GeodesicArea(
3513 const OGRSpatialReference *poSRSOverride = nullptr) const override;
3514 virtual OGRErr PointOnSurface(OGRPoint *) const override;
3515
3516 static OGRMultiPolygon *CastToMultiPolygon(OGRPolyhedralSurface *poPS);
3517 virtual OGRBoolean
3518 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3519 virtual OGRErr addGeometry(const OGRGeometry *);
3520 OGRErr addGeometryDirectly(OGRGeometry *poNewGeom);
3521 OGRErr addGeometry(std::unique_ptr<OGRGeometry> poNewGeom);
3522
3523 int getNumGeometries() const;
3524 OGRPolygon *getGeometryRef(int i);
3525 const OGRPolygon *getGeometryRef(int i) const;
3526
3527 virtual OGRBoolean IsEmpty() const override;
3528 virtual void setCoordinateDimension(int nDimension) override;
3529 virtual void set3D(OGRBoolean bIs3D) override;
3530 virtual void setMeasured(OGRBoolean bIsMeasured) override;
3531 virtual void swapXY() override;
3532 OGRErr removeGeometry(int iIndex, int bDelete = TRUE);
3533
3534 bool hasEmptyParts() const override;
3535 void removeEmptyParts() override;
3536
3537 virtual void accept(IOGRGeometryVisitor *visitor) override
3538 {
3539 visitor->visit(this);
3540 }
3541
3542 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3543 {
3544 visitor->visit(this);
3545 }
3546
3547 virtual void
3548 assignSpatialReference(const OGRSpatialReference *poSR) override;
3549
3550 OGR_ALLOW_CAST_TO_THIS(PolyhedralSurface)
3551 OGR_ALLOW_UPCAST_TO(Surface)
3552};
3553
3555
3556inline const OGRPolyhedralSurface::ChildType *const *
3557begin(const OGRPolyhedralSurface *poGeom)
3558{
3559 return poGeom->begin();
3560}
3561
3563inline const OGRPolyhedralSurface::ChildType *const *
3564end(const OGRPolyhedralSurface *poGeom)
3565{
3566 return poGeom->end();
3567}
3568
3571{
3572 return poGeom->begin();
3573}
3574
3577{
3578 return poGeom->end();
3579}
3580
3582
3583/************************************************************************/
3584/* OGRTriangulatedSurface */
3585/************************************************************************/
3586
3594{
3595 protected:
3597 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3598 virtual const char *getSubGeometryName() const override;
3599 virtual OGRwkbGeometryType getSubGeometryType() const override;
3600
3601 virtual OGRPolyhedralSurfaceCastToMultiPolygon
3602 GetCasterToMultiPolygon() const override;
3603 static OGRMultiPolygon *CastToMultiPolygonImpl(OGRPolyhedralSurface *poPS);
3605
3606 public:
3610
3613
3618 {
3619 return reinterpret_cast<ChildType **>(oMP.begin());
3620 }
3621
3624 {
3625 return reinterpret_cast<ChildType **>(oMP.end());
3626 }
3627
3631 const ChildType *const *begin() const
3632 {
3633 return reinterpret_cast<const ChildType *const *>(oMP.begin());
3634 }
3635
3637 const ChildType *const *end() const
3638 {
3639 return reinterpret_cast<const ChildType *const *>(oMP.end());
3640 }
3641
3642 OGRTriangulatedSurface &operator=(const OGRTriangulatedSurface &other);
3643 virtual const char *getGeometryName() const override;
3644 virtual OGRwkbGeometryType getGeometryType() const override;
3645 virtual OGRTriangulatedSurface *clone() const override;
3646
3652
3654 const OGRTriangle *getGeometryRef(int i) const
3655 {
3657 }
3658
3659 // IWks Interface.
3660 virtual OGRErr addGeometry(const OGRGeometry *) override;
3661
3662#ifndef DOXYGEN_XML
3664#endif
3665
3668 {
3669 return this;
3670 }
3671
3674 {
3675 return this;
3676 }
3677
3678 virtual void accept(IOGRGeometryVisitor *visitor) override
3679 {
3680 visitor->visit(this);
3681 }
3682
3683 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3684 {
3685 visitor->visit(this);
3686 }
3687
3688 static OGRPolyhedralSurface *
3689 CastToPolyhedralSurface(OGRTriangulatedSurface *poTS);
3690
3691 OGR_ALLOW_CAST_TO_THIS(TriangulatedSurface)
3692 OGR_ALLOW_UPCAST_TO(PolyhedralSurface)
3693};
3694
3696
3697inline const OGRTriangulatedSurface::ChildType *const *
3698begin(const OGRTriangulatedSurface *poGeom)
3699{
3700 return poGeom->begin();
3701}
3702
3704inline const OGRTriangulatedSurface::ChildType *const *
3705end(const OGRTriangulatedSurface *poGeom)
3706{
3707 return poGeom->end();
3708}
3709
3712{
3713 return poGeom->begin();
3714}
3715
3718{
3719 return poGeom->end();
3720}
3721
3723
3724/************************************************************************/
3725/* OGRMultiPoint */
3726/************************************************************************/
3727
3733{
3734 private:
3735 OGRErr importFromWkt_Bracketed(const char **, int bHasM, int bHasZ);
3736
3737 protected:
3738 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3739
3740 public:
3743 ~OGRMultiPoint() override;
3744
3745 OGRMultiPoint &operator=(const OGRMultiPoint &other);
3746
3749
3754 {
3755 return reinterpret_cast<ChildType **>(papoGeoms);
3756 }
3757
3760 {
3761 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3762 }
3763
3767 const ChildType *const *begin() const
3768 {
3769 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3770 }
3771
3773 const ChildType *const *end() const
3774 {
3775 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3776 nGeomCount);
3777 }
3778
3779 // IGeometryCollection
3785
3787 const OGRPoint *getGeometryRef(int i) const
3788 {
3790 }
3791
3792 // Non-standard (OGRGeometry).
3793 virtual const char *getGeometryName() const override;
3794 virtual OGRwkbGeometryType getGeometryType() const override;
3795 virtual OGRMultiPoint *clone() const override;
3796
3797#ifndef DOXYGEN_XML
3799#endif
3800
3801 OGRErr importFromWkt(const char **) override;
3802
3803#ifndef DOXYGEN_XML
3805#endif
3806
3811 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3812 OGRErr *err = nullptr) const override;
3813
3814 // IGeometry methods.
3815 virtual int getDimension() const override;
3816
3819 {
3820 return this;
3821 }
3822
3825 {
3826 return this;
3827 }
3828
3829 virtual void accept(IOGRGeometryVisitor *visitor) override
3830 {
3831 visitor->visit(this);
3832 }
3833
3834 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3835 {
3836 visitor->visit(this);
3837 }
3838
3839 // Non-standard.
3840 virtual OGRBoolean
3841 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3842
3843 OGR_ALLOW_CAST_TO_THIS(MultiPoint)
3844 OGR_ALLOW_UPCAST_TO(GeometryCollection)
3845 OGR_FORBID_DOWNCAST_TO_MULTILINESTRING
3846 OGR_FORBID_DOWNCAST_TO_MULTICURVE
3847 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
3848 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
3849};
3850
3852
3853inline const OGRMultiPoint::ChildType *const *begin(const OGRMultiPoint *poGeom)
3854{
3855 return poGeom->begin();
3856}
3857
3859inline const OGRMultiPoint::ChildType *const *end(const OGRMultiPoint *poGeom)
3860{
3861 return poGeom->end();
3862}
3863
3866{
3867 return poGeom->begin();
3868}
3869
3872{
3873 return poGeom->end();
3874}
3875
3877
3878/************************************************************************/
3879/* OGRMultiCurve */
3880/************************************************************************/
3881
3889{
3890 protected:
3892 static OGRErr addCurveDirectlyFromWkt(OGRGeometry *poSelf,
3893 OGRCurve *poCurve);
3895 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
3896
3897 public:
3900 ~OGRMultiCurve() override;
3901
3902 OGRMultiCurve &operator=(const OGRMultiCurve &other);
3903
3906
3911 {
3912 return reinterpret_cast<ChildType **>(papoGeoms);
3913 }
3914
3917 {
3918 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
3919 }
3920
3924 const ChildType *const *begin() const
3925 {
3926 return reinterpret_cast<const ChildType *const *>(papoGeoms);
3927 }
3928
3930 const ChildType *const *end() const
3931 {
3932 return reinterpret_cast<const ChildType *const *>(papoGeoms +
3933 nGeomCount);
3934 }
3935
3936 // IGeometryCollection
3942
3944 const OGRCurve *getGeometryRef(int i) const
3945 {
3947 }
3948
3949 // Non standard (OGRGeometry).
3950 virtual const char *getGeometryName() const override;
3951 virtual OGRwkbGeometryType getGeometryType() const override;
3952 virtual OGRMultiCurve *clone() const override;
3953
3954#ifndef DOXYGEN_XML
3956#endif
3957
3958 OGRErr importFromWkt(const char **) override;
3959
3960#ifndef DOXYGEN_XML
3962#endif
3963
3968 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
3969 OGRErr *err = nullptr) const override;
3970
3971 // IGeometry methods.
3972 virtual int getDimension() const override;
3973
3974 // Non-standard.
3975 virtual OGRBoolean
3976 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
3977
3980 {
3981 return this;
3982 }
3983
3986 {
3987 return this;
3988 }
3989
3990 virtual void accept(IOGRGeometryVisitor *visitor) override
3991 {
3992 visitor->visit(this);
3993 }
3994
3995 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
3996 {
3997 visitor->visit(this);
3998 }
3999
4000 static OGRMultiLineString *CastToMultiLineString(OGRMultiCurve *poMC);
4001
4002 OGR_ALLOW_CAST_TO_THIS(MultiCurve)
4003 OGR_ALLOW_UPCAST_TO(GeometryCollection)
4004 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
4005 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
4006 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
4007};
4008
4010
4011inline const OGRMultiCurve::ChildType *const *begin(const OGRMultiCurve *poGeom)
4012{
4013 return poGeom->begin();
4014}
4015
4017inline const OGRMultiCurve::ChildType *const *end(const OGRMultiCurve *poGeom)
4018{
4019 return poGeom->end();
4020}
4021
4024{
4025 return poGeom->begin();
4026}
4027
4030{
4031 return poGeom->end();
4032}
4033
4035
4036/************************************************************************/
4037/* OGRMultiLineString */
4038/************************************************************************/
4039
4044class CPL_DLL OGRMultiLineString : public OGRMultiCurve
4045{
4046 protected:
4047 virtual OGRBoolean isCompatibleSubType(OGRwkbGeometryType) const override;
4048
4049 public:
4052 ~OGRMultiLineString() override;
4053
4054 OGRMultiLineString &operator=(const OGRMultiLineString &other);
4055
4058
4063 {
4064 return reinterpret_cast<ChildType **>(papoGeoms);
4065 }
4066
4069 {
4070 return reinterpret_cast<ChildType **>(papoGeoms + nGeomCount);
4071 }
4072
4076 const ChildType *const *begin() const
4077 {
4078 return reinterpret_cast<const ChildType *const *>(papoGeoms);
4079 }
4080
4082 const ChildType *const *end() const
4083 {
4084 return reinterpret_cast<const ChildType *const *>(papoGeoms +
4085 nGeomCount);
4086 }
4087
4088 // IGeometryCollection
4094
4096 const OGRLineString *getGeometryRef(int i) const
4097 {
4099 }
4100
4101 // Non standard (OGRGeometry).
4102 virtual const char *getGeometryName() const override;
4103 virtual OGRwkbGeometryType getGeometryType() const override;
4104 virtual OGRMultiLineString *clone() const override;
4105
4106#ifndef DOXYGEN_XML
4108#endif
4109
4110 virtual OGRErr importFromWkb(const unsigned char *, size_t, OGRwkbVariant,
4111 size_t &nBytesConsumedOut) override;
4112
4117 virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(),
4118 OGRErr *err = nullptr) const override;
4119
4120 // Non standard
4121 virtual OGRBoolean
4122 hasCurveGeometry(int bLookForNonLinear = FALSE) const override;
4123
4126 {
4127 return this;
4128 }
4129
4132 {
4133 return this;
4134 }
4135
4136 virtual void accept(IOGRGeometryVisitor *visitor) override
4137 {
4138 visitor->visit(this);
4139 }
4140
4141 virtual void accept(IOGRConstGeometryVisitor *visitor) const override
4142 {
4143 visitor->visit(this);
4144 }
4145
4146 static OGRMultiCurve *CastToMultiCurve(OGRMultiLineString *poMLS);
4147
4148 OGR_ALLOW_CAST_TO_THIS(MultiLineString)
4149 OGR_ALLOW_UPCAST_TO(MultiCurve)
4150 OGR_FORBID_DOWNCAST_TO_MULTIPOINT
4151 OGR_FORBID_DOWNCAST_TO_MULTISURFACE
4152 OGR_FORBID_DOWNCAST_TO_MULTIPOLYGON
4153};
4154
4156
4157inline const OGRMultiLineString::ChildType *const *
4158begin(const OGRMultiLineString *poGeom)
4159{
4160 return poGeom->begin();
4161}
4162
4164inline const OGRMultiLineString::ChildType *const *
4165end(const OGRMultiLineString *poGeom)
4166{
4167 return poGeom->end();
4168}
4169
4172{
4173 return poGeom->begin();
4174}
4175
4178{
4179 return poGeom->end();
4180}
4181
4183
4184/************************************************************************/
4185/* OGRGeometryFactory */
4186/************************************************************************/
4187
4193{
4194 static OGRErr createFromFgfInternal(const unsigned char *pabyData,
4195 OGRSpatialReference *poSR,
4196 OGRGeometry **ppoReturn, int nBytes,
4197 int *pnBytesConsumed, int nRecLevel);
4198
4199 public:
4200 static OGRErr createFromWkb(const void *, const OGRSpatialReference *,
4201 OGRGeometry **,
4202 size_t = static_cast<size_t>(-1),
4204 static OGRErr createFromWkb(const void *pabyData,
4205 const OGRSpatialReference *, OGRGeometry **,
4206 size_t nSize, OGRwkbVariant eVariant,
4207 size_t &nBytesConsumedOut);
4208 static OGRErr createFromWkt(const char *, const OGRSpatialReference *,
4209 OGRGeometry **);
4210 static OGRErr createFromWkt(const char **, const OGRSpatialReference *,
4211 OGRGeometry **);
4212
4216 static OGRErr createFromWkt(char **ppszInput,
4217 const OGRSpatialReference *poSRS,
4218 OGRGeometry **ppoGeom)
4219 CPL_WARN_DEPRECATED("Use createFromWkt(const char**, ...) instead")
4220 {
4221 return createFromWkt(const_cast<const char **>(ppszInput), poSRS,
4222 ppoGeom);
4223 }
4224
4225 static OGRErr createFromFgf(const void *, OGRSpatialReference *,
4226 OGRGeometry **, int = -1, int * = nullptr);
4227 static OGRGeometry *createFromGML(const char *);
4228 static OGRGeometry *createFromGEOS(GEOSContextHandle_t hGEOSCtxt, GEOSGeom);
4229 static OGRGeometry *createFromGeoJson(const char *, int = -1);
4230 static OGRGeometry *createFromGeoJson(const CPLJSONObject &oJSONObject);
4231
4232 static void destroyGeometry(OGRGeometry *);
4233 static OGRGeometry *createGeometry(OGRwkbGeometryType);
4234
4235 static OGRGeometry *forceToPolygon(OGRGeometry *);
4236 static OGRGeometry *forceToLineString(OGRGeometry *,
4237 bool bOnlyInOrder = true);
4238 static OGRGeometry *forceToMultiPolygon(OGRGeometry *);
4239 static OGRGeometry *forceToMultiPoint(OGRGeometry *);
4240 static OGRGeometry *forceToMultiLineString(OGRGeometry *);
4241
4242 static OGRGeometry *forceTo(OGRGeometry *poGeom,
4243 OGRwkbGeometryType eTargetType,
4244 const char *const *papszOptions = nullptr);
4245
4246 static OGRGeometry *removeLowerDimensionSubGeoms(const OGRGeometry *poGeom);
4247
4248 static OGRGeometry *organizePolygons(OGRGeometry **papoPolygons,
4249 int nPolygonCount,
4250 int *pbResultValidGeometry,
4251 const char **papszOptions = nullptr);
4252 static bool haveGEOS();
4253
4256 {
4257 friend class OGRGeometryFactory;
4258 struct Private;
4259 std::unique_ptr<Private> d;
4260
4261 public:
4264 };
4265
4266 static OGRGeometry *transformWithOptions(
4267 const OGRGeometry *poSrcGeom, OGRCoordinateTransformation *poCT,
4268 char **papszOptions,
4270
4271 static OGRGeometry *
4272 approximateArcAngles(double dfX, double dfY, double dfZ,
4273 double dfPrimaryRadius, double dfSecondaryAxis,
4274 double dfRotation, double dfStartAngle,
4275 double dfEndAngle, double dfMaxAngleStepSizeDegrees,
4276 const bool bUseMaxGap = false);
4277
4278 static int GetCurveParameters(double x0, double y0, double x1, double y1,
4279 double x2, double y2, double &R, double &cx,
4280 double &cy, double &alpha0, double &alpha1,
4281 double &alpha2);
4282 static OGRLineString *
4283 curveToLineString(double x0, double y0, double z0, double x1, double y1,
4284 double z1, double x2, double y2, double z2, int bHasZ,
4285 double dfMaxAngleStepSizeDegrees,
4286 const char *const *papszOptions = nullptr);
4287 static OGRCurve *
4288 curveFromLineString(const OGRLineString *poLS,
4289 const char *const *papszOptions = nullptr);
4290};
4291
4292OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType(const char *pszGeomType);
4293const char CPL_DLL *OGRToOGCGeomType(OGRwkbGeometryType eGeomType,
4294 bool bCamelCase = false,
4295 bool bAddZM = false,
4296 bool bSpaceBeforeZM = false);
4297
4299typedef struct _OGRPreparedGeometry OGRPreparedGeometry;
4300
4301struct CPL_DLL OGRPreparedGeometryUniquePtrDeleter
4302{
4303 void operator()(OGRPreparedGeometry *) const;
4304};
4305
4307
4311typedef std::unique_ptr<OGRPreparedGeometry,
4312 OGRPreparedGeometryUniquePtrDeleter>
4314
4315#endif /* ndef OGR_GEOMETRY_H_INCLUDED */
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition cpl_json.h:57
OGRGeometry visitor interface.
Definition ogr_geometry.h:242
virtual void visit(const OGRCurvePolygon *)=0
Visit OGRCurvePolygon.
virtual void visit(const OGRPolyhedralSurface *)=0
Visit OGRPolyhedralSurface.
virtual void visit(const OGRCompoundCurve *)=0
Visit OGRCompoundCurve.
virtual void visit(const OGRMultiLineString *)=0
Visit OGRMultiLineString.
virtual void visit(const OGRTriangulatedSurface *)=0
Visit OGRTriangulatedSurface.
virtual void visit(const OGRPolygon *)=0
Visit OGRPolygon.
virtual void visit(const OGRMultiPolygon *)=0
Visit OGRMultiPolygon.
virtual void visit(const OGRTriangle *)=0
Visit OGRTriangle.
virtual void visit(const OGRLineString *)=0
Visit OGRLineString.
virtual void visit(const OGRMultiPoint *)=0
Visit OGRMultiPoint.
virtual void visit(const OGRMultiCurve *)=0
Visit OGRMultiCurve.
virtual void visit(const OGRGeometryCollection *)=0
Visit OGRGeometryCollection.
virtual void visit(const OGRPoint *)=0
Visit OGRPoint.
virtual ~IOGRConstGeometryVisitor()=default
Destructor/.
virtual void visit(const OGRMultiSurface *)=0
Visit OGRMultiSurface.
virtual void visit(const OGRLinearRing *)=0
Visit OGRLinearRing.
virtual void visit(const OGRCircularString *)=0
Visit OGRCircularString.
OGRGeometry visitor interface.
Definition ogr_geometry.h:166
virtual void visit(OGRMultiSurface *)=0
Visit OGRMultiSurface.
virtual void visit(OGRLinearRing *)=0
Visit OGRLinearRing.
virtual void visit(OGRTriangle *)=0
Visit OGRTriangle.
virtual void visit(OGRCircularString *)=0
Visit OGRCircularString.
virtual void visit(OGRPolygon *)=0
Visit OGRPolygon.
virtual void visit(OGRLineString *)=0
Visit OGRLineString.
virtual void visit(OGRCompoundCurve *)=0
Visit OGRCompoundCurve.
virtual void visit(OGRTriangulatedSurface *)=0
Visit OGRTriangulatedSurface.
virtual void visit(OGRPoint *)=0
Visit OGRPoint.
virtual void visit(OGRCurvePolygon *)=0
Visit OGRCurvePolygon.
virtual void visit(OGRGeometryCollection *)=0
Visit OGRGeometryCollection.
virtual void visit(OGRPolyhedralSurface *)=0
Visit OGRPolyhedralSurface.
virtual void visit(OGRMultiPolygon *)=0
Visit OGRMultiPolygon.
virtual ~IOGRGeometryVisitor()=default
Destructor/.
virtual void visit(OGRMultiLineString *)=0
Visit OGRMultiLineString.
virtual void visit(OGRMultiPoint *)=0
Visit OGRMultiPoint.
virtual void visit(OGRMultiCurve *)=0
Visit OGRMultiCurve.
Concrete representation of a circular string, that is to say a curve made of one or several arc circl...
Definition ogr_geometry.h:1961
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2044
OGRCircularString()
Create an empty circular string.
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2039
OGRCircularString(const OGRCircularString &other)
Copy constructor.
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2033
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2049
Utility class to store a collection of curves.
Definition ogr_geometry.h:2188
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2347
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:2248
const ChildType *const * begin() const
Return begin of curve iterator.
Definition ogr_geometry.h:2242
OGRCompoundCurve(const OGRCompoundCurve &other)
Copy constructor.
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:2223
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:2234
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:2228
OGRCompoundCurve()
Create an empty compound curve.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2342
Interface for transforming between coordinate systems.
Definition ogr_spatialref.h:787
Concrete class representing curve polygons.
Definition ogr_geometry.h:2448
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2594
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:2483
OGRCurvePolygon()
Create an empty curve polygon.
const ChildType *const * end() const
Return end of curve iterator.
Definition ogr_geometry.h:2508
const ChildType *const * begin() const
Return begin of curve iterator.
Definition ogr_geometry.h:2502
ChildType ** begin()
Return begin of curve iterator.
Definition ogr_geometry.h:2488
ChildType ** end()
Return end of curve iterator.
Definition ogr_geometry.h:2494
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2599
OGRCurvePolygon(const OGRCurvePolygon &)
Copy constructor.
Abstract curve base class for OGRLineString, OGRCircularString and OGRCompoundCurve.
Definition ogr_geometry.h:1332
virtual OGRLineString * CurveToLine(double dfMaxAngleStepSizeDegrees=0, const char *const *papszOptions=nullptr) const =0
Return a linestring from a curve geometry.
virtual double get_Length() const =0
Returns the length of the curve.
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:1424
virtual void StartPoint(OGRPoint *) const =0
Return the curve start point.
virtual void EndPoint(OGRPoint *) const =0
Return the curve end point.
virtual int getNumPoints() const =0
Return the number of points of a curve geometry.
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:1375
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:1416
virtual void Value(double, OGRPoint *) const =0
Fetch point at given distance along curve.
virtual OGRPointIterator * getPointIterator() const =0
Returns a point iterator over the curve.
virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride=nullptr) const =0
Get the area of the (closed) curve, considered as a surface on the underlying ellipsoid of the SRS at...
virtual double get_AreaOfCurveSegments() const =0
Get the area of the purely curve portions of a (closed) curve.
virtual double get_Area() const =0
Get the area of the (closed) curve.
virtual void reversePoints()=0
Reverse point order.
virtual OGRCurve * clone() const override=0
Make a copy of this object.
OGRGeometry visitor default implementation.
Definition ogr_geometry.h:289
void visit(const OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:293
OGRGeometry visitor default implementation.
Definition ogr_geometry.h:213
void visit(OGRPoint *) override
Visit OGRPoint.
Definition ogr_geometry.h:217
Simple container for a bounding region in 3D.
Definition ogr_core.h:216
Simple container for a bounding region (rectangle)
Definition ogr_core.h:61
A collection of 1 or more geometry objects.
Definition ogr_geometry.h:2907
ChildType ** end()
Return end of sub-geometry iterator.
Definition ogr_geometry.h:2947
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3044
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3049
const ChildType *const * begin() const
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:2955
const ChildType *const * end() const
Return end of sub-geometry iterator.
Definition ogr_geometry.h:2961
ChildType ** begin()
Return begin of sub-geometry iterator.
Definition ogr_geometry.h:2941
OGRGeometry * getGeometryRef(int)
Fetch geometry from container.
Definition ogrgeometrycollection.cpp:260
OGRGeometryCollection()
Create an empty geometry collection.
OGRGeometry ChildType
Type of child elements.
Definition ogr_geometry.h:2936
Opaque class used as argument to transformWithOptions()
Definition ogr_geometry.h:4256
Create geometry objects from well known text/binary.
Definition ogr_geometry.h:4193
static OGRErr createFromWkt(char **ppszInput, const OGRSpatialReference *poSRS, OGRGeometry **ppoGeom)
Deprecated.
Definition ogr_geometry.h:4216
Abstract base class for all geometry classes.
Definition ogr_geometry.h:377
const OGRSurface * toSurface() const
Down-cast to OGRSurface*.
Definition ogr_geometry.h:817
const OGRCurvePolygon * toCurvePolygon() const
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:875
const OGRMultiCurve * toMultiCurve() const
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:975
const OGRPolyhedralSurface * toPolyhedralSurface() const
Down-cast to OGRPolyhedralSurface*.
Definition ogr_geometry.h:1015
const OGRMultiPoint * toMultiPoint() const
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:915
virtual void empty()=0
Clear geometry information.
const OGRMultiPolygon * toMultiPolygon() const
Down-cast to OGRMultiPolygon*.
Definition ogr_geometry.h:955
virtual OGRBoolean Equals(const OGRGeometry *) const =0
Returns TRUE if two geometries are equivalent.
OGRPolyhedralSurface * toPolyhedralSurface()
Down-cast to OGRPolyhedralSurface*.
Definition ogr_geometry.h:1005
const OGRMultiSurface * toMultiSurface() const
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:995
OGRPoint * toPoint()
Down-cast to OGRPoint*.
Definition ogr_geometry.h:670
bool operator!=(const OGRGeometry &other) const
Returns if two geometries are different.
Definition ogr_geometry.h:437
OGRTriangle * toTriangle()
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:846
OGRLineString * toLineString()
Down-cast to OGRLineString*.
Definition ogr_geometry.h:729
const OGRLinearRing * toLinearRing() const
Down-cast to OGRLinearRing*.
Definition ogr_geometry.h:757
const OGRPoint * toPoint() const
Down-cast to OGRPoint*.
Definition ogr_geometry.h:679
OGRMultiLineString * toMultiLineString()
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:925
OGRMultiSurface * toMultiSurface()
Down-cast to OGRMultiSurface*.
Definition ogr_geometry.h:985
static OGRGeometry * FromHandle(OGRGeometryH hGeom)
Convert a OGRGeometryH to a OGRGeometry*.
Definition ogr_geometry.h:661
virtual OGRwkbGeometryType getGeometryType() const =0
Fetch geometry type.
virtual void accept(IOGRConstGeometryVisitor *visitor) const =0
Accept a visitor.
const OGRGeometryCollection * toGeometryCollection() const
Down-cast to OGRGeometryCollection*.
Definition ogr_geometry.h:895
const OGRMultiLineString * toMultiLineString() const
Down-cast to OGRMultiLineString*.
Definition ogr_geometry.h:935
const OGRCircularString * toCircularString() const
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:777
OGRPolygon * toPolygon()
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:827
bool operator==(const OGRGeometry &other) const
Returns if two geometries are equal.
Definition ogr_geometry.h:431
OGRLinearRing * toLinearRing()
Down-cast to OGRLinearRing*.
Definition ogr_geometry.h:748
OGRBoolean IsMeasured() const
Definition ogr_geometry.h:459
virtual void accept(IOGRGeometryVisitor *visitor)=0
Accept a visitor.
OGRMultiCurve * toMultiCurve()
Down-cast to OGRMultiCurve*.
Definition ogr_geometry.h:965
const OGRCompoundCurve * toCompoundCurve() const
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:797
virtual OGRErr transform(OGRCoordinateTransformation *poCT)=0
Apply arbitrary coordinate transformation to geometry.
virtual void flattenTo2D()=0
Convert geometry to strictly 2D.
virtual int getDimension() const =0
Get the dimension of this object.
OGRGeometryCollection * toGeometryCollection()
Down-cast to OGRGeometryCollection*.
Definition ogr_geometry.h:885
virtual const char * getGeometryName() const =0
Fetch WKT name for geometry type.
OGRMultiPolygon * toMultiPolygon()
Down-cast to OGRMultiPolygon*.
Definition ogr_geometry.h:945
const OGRPolygon * toPolygon() const
Down-cast to OGRPolygon*.
Definition ogr_geometry.h:837
OGRCompoundCurve * toCompoundCurve()
Down-cast to OGRCompoundCurve*.
Definition ogr_geometry.h:787
OGRErr importFromWkt(char **ppszInput)
Deprecated.
Definition ogr_geometry.h:486
virtual OGRBoolean IsEmpty() const =0
Returns TRUE (non-zero) if the object has no points.
const OGRLineString * toLineString() const
Down-cast to OGRLineString*.
Definition ogr_geometry.h:739
OGRErr exportToWkt(char **ppszDstText, OGRwkbVariant=wkbVariantOldOgc) const
Convert a geometry into well known text format.
Definition ogrgeometry.cpp:1954
OGRCircularString * toCircularString()
Down-cast to OGRCircularString*.
Definition ogr_geometry.h:767
const OGRCurve * toCurve() const
Down-cast to OGRCurve*.
Definition ogr_geometry.h:699
OGRCurvePolygon * toCurvePolygon()
Down-cast to OGRCurvePolygon*.
Definition ogr_geometry.h:865
const OGRSimpleCurve * toSimpleCurve() const
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:719
static OGRGeometryH ToHandle(OGRGeometry *poGeom)
Convert a OGRGeometry* to a OGRGeometryH.
Definition ogr_geometry.h:653
OGRBoolean Is3D() const
Definition ogr_geometry.h:453
OGRMultiPoint * toMultiPoint()
Down-cast to OGRMultiPoint*.
Definition ogr_geometry.h:905
const OGRTriangulatedSurface * toTriangulatedSurface() const
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:1033
const OGRTriangle * toTriangle() const
Down-cast to OGRTriangle*.
Definition ogr_geometry.h:855
virtual OGRErr importFromWkt(const char **ppszInput)=0
Assign geometry from well known text data.
virtual OGRGeometry * clone() const =0
Make a copy of this object.
OGRSurface * toSurface()
Down-cast to OGRSurface*.
Definition ogr_geometry.h:807
OGRSimpleCurve * toSimpleCurve()
Down-cast to OGRSimpleCurve*.
Definition ogr_geometry.h:709
OGRTriangulatedSurface * toTriangulatedSurface()
Down-cast to OGRTriangulatedSurface*.
Definition ogr_geometry.h:1024
virtual std::string exportToWkt(const OGRWktOptions &opts=OGRWktOptions(), OGRErr *err=nullptr) const =0
Export a WKT geometry.
OGRCurve * toCurve()
Down-cast to OGRCurve*.
Definition ogr_geometry.h:689
Definition ogr_geometry.h:1480
Concrete representation of a multi-vertex line.
Definition ogr_geometry.h:1773
OGRSimpleCurve * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:1813
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1829
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1824
OGRLineString(const OGRLineString &other)
Copy constructor.
virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride=nullptr) const override
Get the area of the (closed) curve, considered as a surface on the underlying ellipsoid of the SRS at...
virtual int isClockwise() const override
Returns TRUE if the ring has clockwise winding (or less than 2 points)
OGRLineString()
Create an empty line string.
virtual double get_Area() const override
Get the area of the (closed) curve.
const OGRSimpleCurve * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1819
Concrete representation of a closed ring.
Definition ogr_geometry.h:1863
const OGRLineString * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:1925
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1935
OGRLinearRing(const OGRLinearRing &other)
Copy constructor.
OGRLinearRing()
Constructor.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1930
A collection of OGRCurve.
Definition ogr_geometry.h:3889
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3924
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3930
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3995
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3916
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3985
const OGRCurve * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3944
OGRCurve * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3938
OGRMultiCurve()
Create an empty multi curve collection.
OGRMultiCurve(const OGRMultiCurve &other)
Copy constructor.
OGRCurve ChildType
Type of child elements.
Definition ogr_geometry.h:3905
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3910
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3979
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3990
A collection of OGRLineString.
Definition ogr_geometry.h:4045
OGRLineString ChildType
Type of child elements.
Definition ogr_geometry.h:4057
OGRLineString * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:4090
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:4125
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:4068
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:4082
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:4141
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:4076
OGRMultiLineString()
Create an empty multi line string collection.
const OGRLineString * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:4096
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:4136
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:4062
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:4131
OGRMultiLineString(const OGRMultiLineString &other)
Copy constructor.
A collection of OGRPoint.
Definition ogr_geometry.h:3733
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3818
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3829
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3773
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3753
OGRMultiPoint()
Create an empty multi point collection.
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3834
OGRMultiPoint(const OGRMultiPoint &other)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3767
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3824
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:3748
const OGRPoint * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3787
OGRPoint * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3781
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3759
A collection of non-overlapping OGRPolygon.
Definition ogr_geometry.h:3260
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:3282
OGRMultiPolygon(const OGRMultiPolygon &other)
Copy constructor.
OGRPolygon * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3315
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3366
const OGRPolygon * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3321
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3307
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3293
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3361
OGRMultiPolygon()
Create an empty multi polygon collection.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3287
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3350
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3301
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3356
A collection of non-overlapping OGRSurface.
Definition ogr_geometry.h:3103
OGRMultiSurface()
Create an empty multi surface collection.
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3203
const OGRSurface * getGeometryRef(int i) const
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3182
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3120
OGRSurface ChildType
Type of child elements.
Definition ogr_geometry.h:3115
const OGRGeometryCollection * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3198
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3134
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3140
OGRMultiSurface(const OGRMultiSurface &other)
Copy constructor.
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3126
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3208
OGRGeometryCollection * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3192
OGRSurface * getGeometryRef(int i)
See OGRGeometryCollection::getGeometryRef()
Definition ogr_geometry.h:3176
Interface for a point iterator.
Definition ogr_geometry.h:1314
virtual OGRBoolean getNextPoint(OGRPoint *p)=0
Returns the next point followed by the iterator.
Point class.
Definition ogr_geometry.h:1151
double getM() const
Return m.
Definition ogr_geometry.h:1224
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:1285
void setX(double xIn)
Set x.
Definition ogr_geometry.h:1235
OGRPoint(const OGRPoint &other)
Copy constructor.
void setZ(double zIn)
Set z.
Definition ogr_geometry.h:1259
void setM(double mIn)
Set m.
Definition ogr_geometry.h:1268
double getX() const
Return x.
Definition ogr_geometry.h:1206
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:1290
void setY(double yIn)
Set y.
Definition ogr_geometry.h:1247
virtual OGRBoolean IsEmpty() const override
Returns TRUE (non-zero) if the object has no points.
Definition ogr_geometry.h:1199
double getZ() const
Return z.
Definition ogr_geometry.h:1218
double getY() const
Return y.
Definition ogr_geometry.h:1212
Concrete class representing polygons.
Definition ogr_geometry.h:2656
OGRLinearRing ChildType
Type of child elements.
Definition ogr_geometry.h:2685
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:2690
const OGRCurvePolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2773
OGRPolygon()
Create an empty polygon.
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:2696
OGRPolygon(const OGRPolygon &other)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:2704
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2783
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:2710
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2778
OGRCurvePolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2767
PolyhedralSurface class.
Definition ogr_geometry.h:3417
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3454
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3468
OGRPolygon * getGeometryRef(int i)
Fetch geometry from container.
Definition ogrpolyhedralsurface.cpp:871
OGRPolyhedralSurface(const OGRPolyhedralSurface &poGeom)
Copy constructor.
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3462
~OGRPolyhedralSurface() override
Destructor.
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3448
virtual OGRErr addGeometry(const OGRGeometry *)
Add a new geometry to a collection.
Definition ogrpolyhedralsurface.cpp:753
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3537
OGRPolygon ChildType
Type of child elements.
Definition ogr_geometry.h:3443
OGRPolyhedralSurface()
Create an empty PolyhedralSurface.
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3542
Simple container for a position.
Definition ogr_geometry.h:106
OGRRawPoint(double xIn, double yIn)
Constructor.
Definition ogr_geometry.h:114
double x
x
Definition ogr_geometry.h:119
double y
y
Definition ogr_geometry.h:121
OGRRawPoint()
Constructor.
Definition ogr_geometry.h:109
Abstract curve base class for OGRLineString and OGRCircularString.
Definition ogr_geometry.h:1524
double getY(int i) const
Get Y at vertex.
Definition ogr_geometry.h:1673
double getX(int i) const
Get X at vertex.
Definition ogr_geometry.h:1668
OGRPoint ChildType
Type of child elements.
Definition ogr_geometry.h:1595
virtual OGRSimpleCurve * clone() const override=0
Make a copy of this object.
virtual int getNumPoints() const override
Fetch vertex count.
Definition ogr_geometry.h:1661
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:169
Abstract base class for 2 dimensional objects like polygons or curve polygons.
Definition ogr_geometry.h:2400
virtual double get_Area() const =0
Get the area of the surface object.
virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride=nullptr) const =0
Get the area of the surface object, considered as a surface on the underlying ellipsoid of the SRS at...
virtual OGRSurface * clone() const override=0
Make a copy of this object.
virtual OGRErr PointOnSurface(OGRPoint *poPoint) const
This method relates to the SFCOM ISurface::get_PointOnSurface() method.
Definition ogr_geometry.h:2412
Triangle class.
Definition ogr_geometry.h:2832
const OGRPolygon * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:2872
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:2877
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:2882
OGRTriangle()
Constructor.
~OGRTriangle() override
Destructor.
OGRPolygon * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:2866
OGRTriangle(const OGRTriangle &other)
Copy constructor.
TriangulatedSurface class.
Definition ogr_geometry.h:3594
const OGRTriangle * getGeometryRef(int i) const
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:3654
~OGRTriangulatedSurface()
Destructor.
OGRTriangle * getGeometryRef(int i)
See OGRPolyhedralSurface::getGeometryRef()
Definition ogr_geometry.h:3648
const ChildType *const * end() const
Return end of iterator.
Definition ogr_geometry.h:3637
const ChildType *const * begin() const
Return begin of iterator.
Definition ogr_geometry.h:3631
OGRPolyhedralSurface * toUpperClass()
Return pointer of this in upper class.
Definition ogr_geometry.h:3667
virtual void accept(IOGRGeometryVisitor *visitor) override
Accept a visitor.
Definition ogr_geometry.h:3678
const OGRPolyhedralSurface * toUpperClass() const
Return pointer of this in upper class.
Definition ogr_geometry.h:3673
OGRTriangle ChildType
Type of child elements.
Definition ogr_geometry.h:3612
virtual void accept(IOGRConstGeometryVisitor *visitor) const override
Accept a visitor.
Definition ogr_geometry.h:3683
ChildType ** begin()
Return begin of iterator.
Definition ogr_geometry.h:3617
ChildType ** end()
Return end of iterator.
Definition ogr_geometry.h:3623
OGRTriangulatedSurface()
Constructor.
Various convenience functions for CPL.
Interface for read and write JSON documents.
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:1042
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1191
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition cpl_port.h:976
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:185
void * OGRGeometryH
Opaque type for a geometry.
Definition ogr_api.h:66
Core portability services for cross-platform OGR code.
int OGRBoolean
Type for a OGR boolean.
Definition ogr_core.h:404
OGRwkbByteOrder
Enumeration to describe byte order.
Definition ogr_core.h:620
@ wkbNDR
LSB/Intel/Vax: Least Significant Byte First
Definition ogr_core.h:622
OGRwkbVariant
Output variants of WKB we support.
Definition ogr_core.h:550
@ wkbVariantOldOgc
Old-style 99-402 extended dimension (Z) WKB types.
Definition ogr_core.h:551
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:416
int OGRErr
Type for a OGR error.
Definition ogr_core.h:387
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:2597
OGRWktFormat
WKT Output formatting options.
Definition ogr_geometry.h:64
@ Default
Format as F when abs(value) < 1, otherwise as G.
@ F
F-type formatting.
@ G
G-type formatting.
std::unique_ptr< OGRPreparedGeometry, OGRPreparedGeometryUniquePtrDeleter > OGRPreparedGeometryUniquePtr
Unique pointer type for OGRPreparedGeometry.
Definition ogr_geometry.h:4313
struct GEOSContextHandle_HS * GEOSContextHandle_t
GEOS context handle type.
Definition ogr_geometry.h:127
OGRwkbGeometryType OGRFromOGCGeomType(const char *pszGeomType)
Map OGCgeometry format type to corresponding OGR constants.
Definition ogrgeometry.cpp:2518
std::unique_ptr< OGRGeometry, OGRGeometryUniquePtrDeleter > OGRGeometryUniquePtr
Unique pointer type for OGRGeometry.
Definition ogr_geometry.h:1051
struct GEOSGeom_t * GEOSGeom
GEOS geometry type.
Definition ogr_geometry.h:125
void sfcgal_geometry_t
SFCGAL geometry type.
Definition ogr_geometry.h:129
Coordinate systems services.
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition ogrsf_frmts.h:434
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition ogrsf_frmts.h:442
Geometry coordinate precision for a binary representation.
Definition ogr_geometry.h:323
Geometry coordinate precision.
Definition ogr_geomcoordinateprecision.h:50
Options for formatting WKT output.
Definition ogr_geometry.h:72
int mPrecision
Precision of output for M coordinates. Interpretation depends on format.
Definition ogr_geometry.h:81
int zPrecision
Precision of output for Z coordinates. Interpretation depends on format.
Definition ogr_geometry.h:79
OGRWktOptions()
Constructor.
Definition ogr_geometry.h:88
OGRWktOptions(const OGRWktOptions &)=default
Copy constructor.
int xyPrecision
Precision of output for X,Y coordinates. Interpretation depends on format.
Definition ogr_geometry.h:77
WKB export options.
Definition ogr_geometry.h:346