OGRGeometry C++ API¶
Include file: ogr_geometry.h
OGRGeometryFactory class¶

class
OGRGeometryFactory
¶ Create geometry objects from well known text/binary.
Public Static Functions

OGRErr
createFromWkb
(const void *pabyData, OGRSpatialReference *poSR, OGRGeometry **ppoReturn, int nBytes = 1, OGRwkbVariant eWkbVariant = wkbVariantOldOgc)¶ Create a geometry object of the appropriate type from its well known binary representation.
Note that if nBytes is passed as zero, no checking can be done on whether the pabyData is sufficient. This can result in a crash if the input data is corrupt. This function returns no indication of the number of bytes from the data source actually used to represent the returned geometry object. Use OGRGeometry::WkbSize() on the returned geometry to establish the number of bytes it required in WKB format.
Also note that this is a static method, and that there is no need to instantiate an OGRGeometryFactory object.
The C function OGR_G_CreateFromWkb() is the same as this method.
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Parameters
pabyData
: pointer to the input BLOB data.poSR
: pointer to the spatial reference to be assigned to the created geometry object. This may be NULL.ppoReturn
: the newly created geometry object will be assigned to the indicated pointer on return. This will be NULL in case of failure. If not NULL, *ppoReturn should be freed with OGRGeometryFactory::destroyGeometry() after use.nBytes
: the number of bytes available in pabyData, or 1 if it isn’t known.eWkbVariant
: WKB variant.

OGRErr
createFromWkb
(const void *pabyData, OGRSpatialReference *poSR, OGRGeometry **ppoReturn, int nSize, OGRwkbVariant eVariant, int &nBytesConsumedOut)¶ Create a geometry object of the appropriate type from its well known binary representation.
Note that if nBytes is passed as zero, no checking can be done on whether the pabyData is sufficient. This can result in a crash if the input data is corrupt. This function returns no indication of the number of bytes from the data source actually used to represent the returned geometry object. Use OGRGeometry::WkbSize() on the returned geometry to establish the number of bytes it required in WKB format.
Also note that this is a static method, and that there is no need to instantiate an OGRGeometryFactory object.
The C function OGR_G_CreateFromWkb() is the same as this method.
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Since
GDAL 2.3
 Parameters
pabyData
: pointer to the input BLOB data.poSR
: pointer to the spatial reference to be assigned to the created geometry object. This may be NULL.ppoReturn
: the newly created geometry object will be assigned to the indicated pointer on return. This will be NULL in case of failure. If not NULL, *ppoReturn should be freed with OGRGeometryFactory::destroyGeometry() after use.nBytes
: the number of bytes available in pabyData, or 1 if it isn’t known.eWkbVariant
: WKB variant.nBytesConsumedOut
: output parameter. Number of bytes consumed.

OGRErr
createFromWkt
(const char *pszData, OGRSpatialReference *poSR, OGRGeometry **ppoReturn)¶ Create a geometry object of the appropriate type from its well known text representation.
The C function OGR_G_CreateFromWkt() is the same as this method.
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Since
GDAL 2.3
 Parameters
pszData
: input zero terminated string containing well known text representation of the geometry to be created.poSR
: pointer to the spatial reference to be assigned to the created geometry object. This may be NULL.ppoReturn
: the newly created geometry object will be assigned to the indicated pointer on return. This will be NULL if the method fails. If not NULL, *ppoReturn should be freed with OGRGeometryFactory::destroyGeometry() after use.

OGRErr
createFromWkt
(const char **ppszData, OGRSpatialReference *poSR, OGRGeometry **ppoReturn)¶ Create a geometry object of the appropriate type from its well known text representation.
The C function OGR_G_CreateFromWkt() is the same as this method.
Example:
 Parameters
ppszData
: input zero terminated string containing well known text representation of the geometry to be created. The pointer is updated to point just beyond that last character consumed.poSR
: pointer to the spatial reference to be assigned to the created geometry object. This may be NULL.ppoReturn
: the newly created geometry object will be assigned to the indicated pointer on return. This will be NULL if the method fails. If not NULL, *ppoReturn should be freed with OGRGeometryFactory::destroyGeometry() after use.
const char* wkt= "POINT(0 0)"; // cast because OGR_G_CreateFromWkt will move the pointer char* pszWkt = (char*) wkt; OGRSpatialReferenceH ref = OSRNewSpatialReference(NULL); OGRGeometryH new_geom; OSRSetAxisMappingStrategy(poSR, OAMS_TRADITIONAL_GIS_ORDER); OGRErr err = OGR_G_CreateFromWkt(&pszWkt, ref, &new_geom);
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

static OGRErr
createFromWkt
(char **ppszInput, OGRSpatialReference *poSRS, OGRGeometry **ppoGeom)¶ Deprecated.

OGRErr
createFromFgf
(const void *pabyData, OGRSpatialReference *poSR, OGRGeometry **ppoReturn, int nBytes = 1, int *pnBytesConsumed = nullptr)¶ Create a geometry object of the appropriate type from its FGF (FDO Geometry Format) binary representation.
Also note that this is a static method, and that there is no need to instantiate an OGRGeometryFactory object.
The C function OGR_G_CreateFromFgf() is the same as this method.
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Parameters
pabyData
: pointer to the input BLOB data.poSR
: pointer to the spatial reference to be assigned to the created geometry object. This may be NULL.ppoReturn
: the newly created geometry object will be assigned to the indicated pointer on return. This will be NULL in case of failure, but NULL might be a valid return for a NULL shape.nBytes
: the number of bytes available in pabyData.pnBytesConsumed
: if not NULL, it will be set to the number of bytes consumed (at most nBytes).

OGRGeometry *
createFromGML
(const char *pszData)¶ Create geometry from GML.
This method translates a fragment of GML containing only the geometry portion into a corresponding OGRGeometry. There are many limitations on the forms of GML geometries supported by this parser, but they are too numerous to list here.
The following GML2 elements are parsed : Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, MultiGeometry.
(OGR >= 1.8.0) The following GML3 elements are parsed : Surface, MultiSurface, PolygonPatch, Triangle, Rectangle, Curve, MultiCurve, LineStringSegment, Arc, Circle, CompositeSurface, OrientableSurface, Solid, Tin, TriangulatedSurface.
Arc and Circle elements are stroked to linestring, by using a 4 degrees step, unless the user has overridden the value with the OGR_ARC_STEPSIZE configuration variable.
The C function OGR_G_CreateFromGML() is the same as this method.
 Return
a geometry on success, or NULL on error.
 Parameters
pszData
: The GML fragment for the geometry.

OGRGeometry *
createFromGEOS
(GEOSContextHandle_t hGEOSCtxt, GEOSGeom geosGeom)¶ Builds a OGRGeometry* from a GEOSGeom.
 Return
a OGRGeometry*
 Parameters
hGEOSCtxt
: GEOS contextgeosGeom
: GEOS geometry

OGRGeometry *
createFromGeoJson
(const char *pszJsonString)¶ Create geometry from GeoJson fragment.
 Return
a geometry on success, or NULL on error.
 Since
GDAL 2.3
 Parameters
pszJsonString
: The GeoJSON fragment for the geometry.

OGRGeometry *
createFromGeoJson
(const CPLJSONObject &oJSONObject)¶ Create geometry from GeoJson fragment.
 Return
a geometry on success, or NULL on error.
 Since
GDAL 2.3
 Parameters
oJsonObject
: The JSONObject class describes the GeoJSON geometry.

void
destroyGeometry
(OGRGeometry *poGeom)¶ Destroy geometry object.
Equivalent to invoking delete on a geometry, but it guaranteed to take place within the context of the GDAL/OGR heap.
This method is the same as the C function OGR_G_DestroyGeometry().
 Parameters
poGeom
: the geometry to deallocate.

OGRGeometry *
createGeometry
(OGRwkbGeometryType eGeometryType)¶ Create an empty geometry of desired type.
This is equivalent to allocating the desired geometry with new, but the allocation is guaranteed to take place in the context of the GDAL/OGR heap.
This method is the same as the C function OGR_G_CreateGeometry().
 Return
the newly create geometry or NULL on failure. Should be freed with OGRGeometryFactory::destroyGeometry() after use.
 Parameters
eGeometryType
: the type code of the geometry class to be instantiated.

OGRGeometry *
forceToPolygon
(OGRGeometry *poGeom)¶ Convert to polygon.
Tries to force the provided geometry to be a polygon. This effects a change on multipolygons. Starting with GDAL 2.0, curve polygons or closed curves will be changed to polygons. The passed in geometry is consumed and a new one returned (or potentially the same one).
Note: the resulting polygon may break the Simple Features rules for polygons, for example when converting from a multipart multipolygon.
 Return
new geometry.
 Parameters
poGeom
: the input geometry  ownership is passed to the method.

OGRGeometry *
forceToLineString
(OGRGeometry *poGeom, bool bOnlyInOrder = true)¶ Convert to line string.
Tries to force the provided geometry to be a line string. This nominally effects a change on multilinestrings. In GDAL 2.0, for polygons or curvepolygons that have a single exterior ring, it will return the ring. For circular strings or compound curves, it will return an approximated line string.
The passed in geometry is consumed and a new one returned (or potentially the same one).
 Return
new geometry.
 Parameters
poGeom
: the input geometry  ownership is passed to the method.bOnlyInOrder
: flag that, if set to FALSE, indicate that the order of points in a linestring might be reversed if it enables to match the extremity of another linestring. If set to TRUE, the start of a linestring must match the end of another linestring.

OGRGeometry *
forceToMultiPolygon
(OGRGeometry *poGeom)¶ Convert to multipolygon.
Tries to force the provided geometry to be a multipolygon. Currently this just effects a change on polygons. The passed in geometry is consumed and a new one returned (or potentially the same one).
 Return
new geometry.

OGRGeometry *
forceToMultiPoint
(OGRGeometry *poGeom)¶ Convert to multipoint.
Tries to force the provided geometry to be a multipoint. Currently this just effects a change on points or collection of points. The passed in geometry is consumed and a new one returned (or potentially the same one).
 Return
new geometry.

OGRGeometry *
forceToMultiLineString
(OGRGeometry *poGeom)¶ Convert to multilinestring.
Tries to force the provided geometry to be a multilinestring.
linestrings are placed in a multilinestring.
circularstrings and compoundcurves will be approximated and placed in a multilinestring.
geometry collections will be converted to multilinestring if they only contain linestrings.
polygons will be changed to a collection of linestrings (one per ring).
curvepolygons will be approximated and changed to a collection of ( linestrings (one per ring).
The passed in geometry is consumed and a new one returned (or potentially the same one).
 Return
new geometry.

OGRGeometry *
forceTo
(OGRGeometry *poGeom, OGRwkbGeometryType eTargetType, const char *const *papszOptions = nullptr)¶ Convert to another geometry type.
Tries to force the provided geometry to the specified geometry type.
It can promote ‘single’ geometry type to their corresponding collection type (see OGR_GT_GetCollection()) or the reverse. nonlinear geometry type to their corresponding linear geometry type (see OGR_GT_GetLinear()), by possibly approximating circular arcs they may contain. Regarding conversion from linear geometry types to curve geometry types, only “wrapping” will be done. No attempt to retrieve potential circular arcs by deapproximating stroking will be done. For that, OGRGeometry::getCurveGeometry() can be used.
The passed in geometry is consumed and a new one returned (or potentially the same one).
 Return
new geometry.
 Since
GDAL 2.0
 Parameters
poGeom
: the input geometry  ownership is passed to the method.eTargetType
: target output geometry type.papszOptions
: options as a nullterminated list of strings or NULL.

OGRGeometry *
organizePolygons
(OGRGeometry **papoPolygons, int nPolygonCount, int *pbResultValidGeometry, const char **papszOptions = nullptr)¶ Organize polygons based on geometries.
Analyse a set of rings (passed as simple polygons), and based on a geometric analysis convert them into a polygon with inner rings, (or a MultiPolygon if dealing with more than one polygon) that follow the OGC Simple Feature specification.
All the input geometries must be OGRPolygon/OGRCurvePolygon with only a valid exterior ring (at least 4 points) and no interior rings.
The passed in geometries become the responsibility of the method, but the papoPolygons “pointer array” remains owned by the caller.
For faster computation, a polygon is considered to be inside another one if a single point of its external ring is included into the other one. (unless ‘OGR_DEBUG_ORGANIZE_POLYGONS’ configuration option is set to TRUE. In that case, a slower algorithm that tests exact topological relationships is used if GEOS is available.)
In cases where a big number of polygons is passed to this function, the default processing may be really slow. You can skip the processing by adding METHOD=SKIP to the option list (the result of the function will be a multipolygon with all polygons as toplevel polygons) or only make it analyze counterclockwise polygons by adding METHOD=ONLY_CCW to the option list if you can assume that the outline of holes is counterclockwise defined (this is the convention for example in shapefiles, Personal Geodatabases or File Geodatabases).
For FileGDB, in most cases, but not always, a faster method than ONLY_CCW can be used. It is CCW_INNER_JUST_AFTER_CW_OUTER. When using it, inner rings are assumed to be counterclockwise oriented, and following immediately the outer ring (clockwise oriented) that they belong to. If that assumption is not met, an inner ring could be attached to the wrong outer ring, so this method must be used with care.
If the OGR_ORGANIZE_POLYGONS configuration option is defined, its value will override the value of the METHOD option of papszOptions (useful to modify the behaviour of the shapefile driver)
 Return
a single resulting geometry (either OGRPolygon, OGRCurvePolygon, OGRMultiPolygon, OGRMultiSurface or OGRGeometryCollection). Returns a POLYGON EMPTY in the case of nPolygonCount being 0.
 Parameters
papoPolygons
: array of geometry pointers  should all be OGRPolygons. Ownership of the geometries is passed, but not of the array itself.nPolygonCount
: number of items in papoPolygonspbIsValidGeometry
: value will be set TRUE if result is valid or FALSE otherwise.papszOptions
: a list of strings for passing options

bool
haveGEOS
()¶ Test if GEOS enabled.
This static method returns TRUE if GEOS support is built into OGR, otherwise it returns FALSE.
 Return
TRUE if available, otherwise FALSE.

OGRGeometry *
transformWithOptions
(const OGRGeometry *poSrcGeom, OGRCoordinateTransformation *poCT, char **papszOptions, const TransformWithOptionsCache &cache = TransformWithOptionsCache())¶ Transform a geometry.
 Return
(new) transformed geometry.
 Parameters
poSrcGeom
: source geometrypoCT
: coordinate transformation object.papszOptions
: options. Including WRAPDATELINE=YES.cache
: Cache. May increase performance if persisted between invokations

OGRGeometry *
approximateArcAngles
(double dfX, double dfY, double dfZ, double dfPrimaryRadius, double dfSecondaryAxis, double dfRotation, double dfStartAngle, double dfEndAngle, double dfMaxAngleStepSizeDegrees, const bool bUseMaxGap = false)¶ Stroke arc to linestring.
Stroke an arc of a circle to a linestring based on a center point, radius, start angle and end angle, all angles in degrees.
If the dfMaxAngleStepSizeDegrees is zero, then a default value will be used. This is currently 4 degrees unless the user has overridden the value with the OGR_ARC_STEPSIZE configuration variable.
If the OGR_ARC_MAX_GAP configuration variable is set, the straightline distance between adjacent pairs of interpolated points will be limited to the specified distance. If the distance between a pair of points exceeds this maximum, additional points are interpolated between the two points.
 See
 Return
OGRLineString geometry representing an approximation of the arc.
 Since
OGR 1.8.0
 Parameters
dfCenterX
: center XdfCenterY
: center YdfZ
: center ZdfPrimaryRadius
: X radius of ellipse.dfSecondaryRadius
: Y radius of ellipse.dfRotation
: rotation of the ellipse clockwise.dfStartAngle
: angle to first point on arc (clockwise of Xpositive)dfEndAngle
: angle to last point on arc (clockwise of Xpositive)dfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.bUseMaxGap
: Optional: whether to honor OGR_ARC_MAX_GAP.

int
GetCurveParmeters
(double x0, double y0, double x1, double y1, double x2, double y2, double &R, double &cx, double &cy, double &alpha0, double &alpha1, double &alpha2)¶ Returns the parameter of an arc circle.
Angles are return in radians, with trigonometic convention (counter clock wise)
 Return
TRUE if the points are not aligned and define an arc circle.
 Since
GDAL 2.0
 Parameters
x0
: x of first pointy0
: y of first pointx1
: x of intermediate pointy1
: y of intermediate pointx2
: x of final pointy2
: y of final pointR
: radius (output)cx
: x of arc center (output)cy
: y of arc center (output)alpha0
: angle between center and first point, in radians (output)alpha1
: angle between center and intermediate point, in radians (output)alpha2
: angle between center and final point, in radians (output)

OGRLineString *
curveToLineString
(double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, int bHasZ, double dfMaxAngleStepSizeDegrees, const char *const *papszOptions = nullptr)¶ Converts an arc circle into an approximate line string.
The arc circle is defined by a first point, an intermediate point and a final point.
The provided dfMaxAngleStepSizeDegrees is a hint. The discretization algorithm may pick a slightly different value.
So as to avoid gaps when rendering curve polygons that share common arcs, this method is guaranteed to return a line with reversed vertex if called with inverted first and final point, and identical intermediate point.
 Return
the converted geometry (ownership to caller).
 Since
GDAL 2.0
 Parameters
x0
: x of first pointy0
: y of first pointz0
: z of first pointx1
: x of intermediate pointy1
: y of intermediate pointz1
: z of intermediate pointx2
: x of final pointy2
: y of final pointz2
: z of final pointbHasZ
: TRUE if z must be taken into accountdfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.papszOptions
: options as a nullterminated list of strings or NULL. Recognized options:ADD_INTERMEDIATE_POINT=STEALTH/YES/NO (Default to STEALTH). Determine if and how the intermediate point must be output in the linestring. If set to STEALTH, no explicit intermediate point is added but its properties are encoded in low significant bits of intermediate points and OGRGeometryFactory::curveFromLineString() can decode them. This is the best compromise for roundtripping in OGR and better results with PostGIS ST_LineToCurve() If set to YES, the intermediate point is explicitly added to the linestring. If set to NO, the intermediate point is not explicitly added.

OGRCurve *
curveFromLineString
(const OGRLineString *poLS, const char *const *papszOptions = nullptr)¶ Try to convert a linestring approximating curves into a curve.
This method can return a COMPOUNDCURVE, a CIRCULARSTRING or a LINESTRING.
This method is the reverse of curveFromLineString().
 Return
the converted geometry (ownership to caller).
 Since
GDAL 2.0
 Parameters
poLS
: handle to the geometry to convert.papszOptions
: options as a nullterminated list of strings. Unused for now. Must be set to NULL.

class
TransformWithOptionsCache
¶ Opaque class used as argument to transformWithOptions()

OGRErr
OGRGeometry class¶

class
OGRGeometry
¶ Abstract base class for all geometry classes.
Some spatial analysis methods require that OGR is built on the GEOS library to work properly. The precise meaning of methods that describe spatial relationships between geometries is described in the SFCOM, or other simple features interface specifications, like “OpenGIS® Implementation Specification for Geographic information  Simple feature access  Part 1: Common architecture”:
<a href=”
http://www.opengeospatial.org/standards/sfa”>OGC 06103r4In GDAL 2.0, the hierarchy of classes has been extended with (working draft) ISO SQL/MM Part 3 (ISO/IEC 132493) curve geometries : CIRCULARSTRING (OGRCircularString), COMPOUNDCURVE (OGRCompoundCurve), CURVEPOLYGON (OGRCurvePolygon), MULTICURVE (OGRMultiCurve) and MULTISURFACE (OGRMultiSurface).
Subclassed by OGRCurve, OGRGeometryCollection, OGRPoint, OGRSurface
Public Functions

OGRGeometry
(const OGRGeometry &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRGeometry &
operator=
(const OGRGeometry &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

bool
operator==
(const OGRGeometry &other) const¶ Returns if two geometries are equal.

bool
operator!=
(const OGRGeometry &other) const¶ Returns if two geometries are different.

int
getDimension
() const = 0¶ Get the dimension of this object.
This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).
This method is the same as the C function OGR_G_GetDimension().
 Return
0 for points, 1 for lines and 2 for surfaces.

int
getCoordinateDimension
() const¶ Get the dimension of the coordinates in this object.
This method is the same as the C function OGR_G_GetCoordinateDimension().
 Return
this will return 2 or 3.

int
CoordinateDimension
() const¶ Get the dimension of the coordinates in this object.
This method is the same as the C function OGR_G_CoordinateDimension().
 Return
this will return 2 for XY, 3 for XYZ and XYM, and 4 for XYZM data.
 Since
GDAL 2.1

OGRBoolean
IsEmpty
() const = 0¶ Returns TRUE (nonzero) if the object has no points.
Normally this returns FALSE except between when an object is instantiated and points have been assigned.
This method relates to the SFCOM IGeometry::IsEmpty() method.
 Return
TRUE if object is empty, otherwise FALSE.

OGRBoolean
IsValid
() const¶ Test if the geometry is valid.
This method is the same as the C function OGR_G_IsValid().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always return FALSE.
 Return
TRUE if the geometry has no points, otherwise FALSE.

OGRGeometry *
MakeValid
() const¶ Attempts to make an invalid geometry valid without losing vertices.
Alreadyvalid geometries are cloned without further intervention.
This method is the same as the C function OGR_G_MakeValid().
This function is built on the GEOS >= 3.8 library, check it for the definition of the geometry operation. If OGR is built without the GEOS >= 3.8 library, this function will return a clone of the input geometry if it is valid, or NULL if it is invalid
 Return
a newly allocated geometry now owned by the caller, or NULL on failure.
 Since
GDAL 3.0

OGRBoolean
IsSimple
() const¶ Test if the geometry is simple.
This method is the same as the C function OGR_G_IsSimple().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always return FALSE.
 Return
TRUE if the geometry has no points, otherwise FALSE.

OGRBoolean
Is3D
() const¶ Returns whether the geometry has a Z component.

OGRBoolean
IsMeasured
() const¶ Returns whether the geometry has a M component.

OGRBoolean
IsRing
() const¶ Test if the geometry is a ring.
This method is the same as the C function OGR_G_IsRing().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always return FALSE.
 Return
TRUE if the geometry has no points, otherwise FALSE.

void
empty
() = 0¶ Clear geometry information.
This restores the geometry to its initial state after construction, and before assignment of actual geometry.
This method relates to the SFCOM IGeometry::Empty() method.
This method is the same as the C function OGR_G_Empty().

OGRGeometry *
clone
() const = 0¶ Make a copy of this object.
This method relates to the SFCOM IGeometry::clone() method.
This method is the same as the C function OGR_G_Clone().
 Return
a new object instance with the same geometry, and spatial reference system as the original.

void
getEnvelope
(OGREnvelope *psEnvelope) const = 0¶ Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope().
 Parameters
psEnvelope
: the structure in which to place the results.

void
getEnvelope
(OGREnvelope3D *psEnvelope) const = 0¶ Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope3D().
 Since
OGR 1.9.0
 Parameters
psEnvelope
: the structure in which to place the results.

int
WkbSize
() const = 0¶ Returns size of related binary representation.
This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.
This method relates to the SFCOM IWks::WkbSize() method.
This method is the same as the C function OGR_G_WkbSize().
 Return
size of binary representation in bytes.

OGRErr
importFromWkb
(const GByte *pabyData, int nSize = 1, OGRwkbVariant eWkbVariant = wkbVariantOldOgc)¶ Assign geometry from well known binary data.
The object must have already been instantiated as the correct derived type of geometry object to match the binaries type. This method is used by the OGRGeometryFactory class, but not normally called by application code.
This method relates to the SFCOM IWks::ImportFromWKB() method.
This method is the same as the C function OGR_G_ImportFromWkb().
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Parameters
pabyData
: the binary input data.nSize
: the size of pabyData in bytes, or 1 if not known.eWkbVariant
: if wkbVariantPostGIS1, special interpretation is done for curve geometries code

OGRErr
importFromWkb
(const unsigned char *pabyData, int nSize, OGRwkbVariant eWkbVariant, int &nBytesConsumedOut) = 0¶ Assign geometry from well known binary data.
The object must have already been instantiated as the correct derived type of geometry object to match the binaries type. This method is used by the OGRGeometryFactory class, but not normally called by application code.
This method relates to the SFCOM IWks::ImportFromWKB() method.
This method is the same as the C function OGR_G_ImportFromWkb().
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Since
GDAL 2.3
 Parameters
pabyData
: the binary input data.nSize
: the size of pabyData in bytes, or 1 if not known.eWkbVariant
: if wkbVariantPostGIS1, special interpretation is done for curve geometries codenBytesConsumedOut
: output parameter. Number of bytes consumed.

OGRErr
exportToWkb
(OGRwkbByteOrder eByteOrder, unsigned char *pabyData, OGRwkbVariant eWkbVariant = wkbVariantOldOgc) const = 0¶ Convert a geometry into well known binary format.
This method relates to the SFCOM IWks::ExportToWKB() method.
This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.
 Return
Currently OGRERR_NONE is always returned.
 Parameters
eByteOrder
: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.pabyData
: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.eWkbVariant
: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

OGRErr
importFromWkt
(const char **ppszInput) = 0¶ Assign geometry from well known text data.
The object must have already been instantiated as the correct derived type of geometry object to match the text type. This method is used by the OGRGeometryFactory class, but not normally called by application code.
This method relates to the SFCOM IWks::ImportFromWKT() method.
This method is the same as the C function OGR_G_ImportFromWkt().
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Parameters
ppszInput
: pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

OGRErr
importFromWkt
(char **ppszInput) const¶ Deprecated.

OGRErr
exportToWkt
(char **ppszDstText, OGRwkbVariant variant = wkbVariantOldOgc) const¶ Convert a geometry into well known text format.
This method relates to the SFCOM IWks::ExportToWKT() method.
This method is the same as the C function OGR_G_ExportToWkt().
 Return
Currently OGRERR_NONE is always returned.
 Parameters
ppszDstText
: a text buffer is allocated by the program, and assigned to the passed pointer. After use, *ppszDstText should be freed with CPLFree().variant
: the specification that must be conformed too :wbkVariantOgc for oldstyle 99402 extended dimension (Z) WKB types
wbkVariantIso for SFSQL 1.2 and ISO SQL/MM Part 3

virtual std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const = 0¶ Export a WKT geometry.
 Return
WKT string representing this geometry.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

OGRwkbGeometryType
getGeometryType
() const = 0¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

OGRwkbGeometryType
getIsoGeometryType
() const¶ Get the geometry type that conforms with ISO SQL/MM Part3.
 Return
the geometry type that conforms with ISO SQL/MM Part3

const char *
getGeometryName
() const = 0¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

void
dumpReadable
(FILE *fp, const char *pszPrefix = nullptr, char **papszOptions = nullptr) const¶ Dump geometry in well known text format to indicated output file.
A few options can be defined to change the default dump :
DISPLAY_GEOMETRY=NO : to hide the dump of the geometry
DISPLAY_GEOMETRY=WKT or YES (default) : dump the geometry as a WKT
DISPLAY_GEOMETRY=SUMMARY : to get only a summary of the geometry
This method is the same as the C function OGR_G_DumpReadable().
 Parameters
fp
: the text file to write the geometry to.pszPrefix
: the prefix to put on each line of output.papszOptions
: NULL terminated list of options (may be NULL)

void
flattenTo2D
() = 0¶ Convert geometry to strictly 2D.
In a sense this converts all Z coordinates to 0.0.
This method is the same as the C function OGR_G_FlattenTo2D().

char *
exportToGML
(const char *const *papszOptions = nullptr) const¶ Convert a geometry into GML format.
The GML geometry is expressed directly in terms of GML basic data types assuming the this is available in the gml namespace. The returned string should be freed with CPLFree() when no longer required.
The supported options in OGR 1.8.0 are :
FORMAT=GML3. Otherwise it will default to GML 2.1.2 output.
GML3_LINESTRING_ELEMENT=curve. (Only valid for FORMAT=GML3) To use gml:Curve element for linestrings. Otherwise gml:LineString will be used .
GML3_LONGSRS=YES/NO. (Only valid for FORMAT=GML3) Default to YES. If YES, SRS with EPSG authority will be written with the “urn:ogc:def:crs:EPSG::” prefix. In the case, if the SRS is a geographic SRS without explicit AXIS order, but that the same SRS authority code imported with ImportFromEPSGA() should be treated as lat/long, then the function will take care of coordinate order swapping. If set to NO, SRS with EPSG authority will be written with the “EPSG:” prefix, even if they are in lat/long order.
This method is the same as the C function OGR_G_ExportToGMLEx().
 Return
A GML fragment or NULL in case of error.
 Parameters
papszOptions
: NULLterminated list of options.

char *
exportToKML
() const¶ Convert a geometry into KML format.
The returned string should be freed with CPLFree() when no longer required.
This method is the same as the C function OGR_G_ExportToKML().
 Return
A KML fragment or NULL in case of error.

char *
exportToJson
() const¶ Convert a geometry into GeoJSON format.
The returned string should be freed with CPLFree() when no longer required.
This method is the same as the C function OGR_G_ExportToJson().
 Return
A GeoJSON fragment or NULL in case of error.

virtual void
accept
(IOGRGeometryVisitor *visitor) = 0¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const = 0¶ Accept a visitor.

GEOSGeom
exportToGEOS
(GEOSContextHandle_t hGEOSCtxt) const¶ Returns a GEOSGeom object corresponding to the geometry.
 Return
a GEOSGeom object corresponding to the geometry.
 Parameters
hGEOSCtxt
: GEOS context

OGRBoolean
hasCurveGeometry
(int bLookForNonLinear = FALSE) const¶ Returns if this geometry is or has curve geometry.
Returns if a geometry is, contains or may contain a CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE.
If bLookForNonLinear is set to TRUE, it will be actually looked if the geometry or its subgeometries are or contain a nonlinear geometry in them. In which case, if the method returns TRUE, it means that getLinearGeometry() would return an approximate version of the geometry. Otherwise, getLinearGeometry() would do a conversion, but with just converting container type, like COMPOUNDCURVE > LINESTRING, MULTICURVE > MULTILINESTRING or MULTISURFACE > MULTIPOLYGON, resulting in a “lossless” conversion.
This method is the same as the C function OGR_G_HasCurveGeometry().
 Return
TRUE if this geometry is or has curve geometry.
 Since
GDAL 2.0
 Parameters
bLookForNonLinear
: set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

OGRGeometry *
getCurveGeometry
(const char *const *papszOptions = nullptr) const¶ Return curve version of this geometry.
Returns a geometry that has possibly CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by deapproximating curve geometries.
If the geometry has no curve portion, the returned geometry will be a clone of it.
The ownership of the returned geometry belongs to the caller.
The reverse method is OGRGeometry::getLinearGeometry().
This function is the same as C function OGR_G_GetCurveGeometry().
 Return
a new geometry.
 Since
GDAL 2.0
 Parameters
papszOptions
: options as a nullterminated list of strings. Unused for now. Must be set to NULL.

OGRGeometry *
getLinearGeometry
(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const¶ Return, possibly approximate, noncurve version of this geometry.
Returns a geometry that has no CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by approximating curve geometries.
The ownership of the returned geometry belongs to the caller.
The reverse method is OGRGeometry::getCurveGeometry().
This method is the same as the C function OGR_G_GetLinearGeometry().
 Return
a new geometry.
 Since
GDAL 2.0
 Parameters
dfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.papszOptions
: options as a nullterminated list of strings. See OGRGeometryFactory::curveToLineString() for valid options.

void
closeRings
()¶ Force rings to be closed.
If this geometry, or any contained geometries has polygon rings that are not closed, they will be closed by adding the starting point at the end.

void
setCoordinateDimension
(int nDimension)¶ Set the coordinate dimension.
This method sets the explicit coordinate dimension. Setting the coordinate dimension of a geometry to 2 should zero out any existing Z values. Setting the dimension of a geometry collection, a compound curve, a polygon, etc. will affect the children geometries. This will also remove the M dimension if present before this call.
 Parameters
nNewDimension
: New coordinate dimension value, either 2 or 3.

void
set3D
(OGRBoolean bIs3D)¶ Add or remove the Z coordinate dimension.
This method adds or removes the explicit Z coordinate dimension. Removing the Z coordinate dimension of a geometry will remove any existing Z values. Adding the Z dimension to a geometry collection, a compound curve, a polygon, etc. will affect the children geometries.
 Since
GDAL 2.1
 Parameters
bIs3D
: Should the geometry have a Z dimension, either TRUE or FALSE.

void
setMeasured
(OGRBoolean bIsMeasured)¶ Add or remove the M coordinate dimension.
This method adds or removes the explicit M coordinate dimension. Removing the M coordinate dimension of a geometry will remove any existing M values. Adding the M dimension to a geometry collection, a compound curve, a polygon, etc. will affect the children geometries.
 Since
GDAL 2.1
 Parameters
bIsMeasured
: Should the geometry have a M dimension, either TRUE or FALSE.

void
assignSpatialReference
(OGRSpatialReference *poSR)¶ Assign spatial reference to this object.
Any existing spatial reference is replaced, but under no circumstances does this result in the object being reprojected. It is just changing the interpretation of the existing geometry. Note that assigning a spatial reference increments the reference count on the OGRSpatialReference, but does not copy it.
Starting with GDAL 2.3, this will also assign the spatial reference to potential subgeometries of the geometry (OGRGeometryCollection, OGRCurvePolygon/OGRPolygon, OGRCompoundCurve, OGRPolyhedralSurface and their derived classes).
This is similar to the SFCOM IGeometry::put_SpatialReference() method.
This method is the same as the C function OGR_G_AssignSpatialReference().
 Parameters
poSR
: new spatial reference system to apply.

OGRSpatialReference *
getSpatialReference
(void) const¶ Returns spatial reference system for object.
This method relates to the SFCOM IGeometry::get_SpatialReference() method.
This method is the same as the C function OGR_G_GetSpatialReference().
 Return
a reference to the spatial reference object. The object may be shared with many geometry objects, and should not be modified.

OGRErr
transform
(OGRCoordinateTransformation *poCT) = 0¶ Apply arbitrary coordinate transformation to geometry.
This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.
Note that this method does not require that the geometry already have a spatial reference system. It will be assumed that they can be treated as having the source spatial reference system of the OGRCoordinateTransformation object, and the actual SRS of the geometry will be ignored. On successful completion the output OGRSpatialReference of the OGRCoordinateTransformation will be assigned to the geometry.
This method is the same as the C function OGR_G_Transform().
 Return
OGRERR_NONE on success or an error code.
 Parameters
poCT
: the transformation to apply.

OGRErr
transformTo
(OGRSpatialReference *poSR)¶ Transform geometry to new spatial reference system.
This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.
This method will only work if the geometry already has an assigned spatial reference system, and if it is transformable to the target coordinate system.
Because this method requires internal creation and initialization of an OGRCoordinateTransformation object it is significantly more expensive to use this method to transform many geometries than it is to create the OGRCoordinateTransformation in advance, and call transform() with that transformation. This method exists primarily for convenience when only transforming a single geometry.
This method is the same as the C function OGR_G_TransformTo().
 Return
OGRERR_NONE on success, or an error code.
 Parameters
poSR
: spatial reference system to transform to.

void
segmentize
(double dfMaxLength)¶ Modify the geometry such it has no segment longer then the given distance.
Add intermediate vertices to a geometry.
Interpolated points will have Z and M values (if needed) set to 0. Distance computation is performed in 2d only
This function is the same as the C function OGR_G_Segmentize()
This method modifies the geometry to add intermediate vertices if necessary so that the maximum length between 2 consecutive vertices is lower than dfMaxLength.
 Parameters
dfMaxLength
: the maximum distance between 2 points after segmentization
 Parameters
dfMaxLength
: maximum length between 2 consecutive vertices.

OGRBoolean
Intersects
(const OGRGeometry *poOtherGeom) const¶ Do these features intersect?
Determines whether two geometries intersect. If GEOS is enabled, then this is done in rigorous fashion otherwise TRUE is returned if the envelopes (bounding boxes) of the two geometries overlap.
The poOtherGeom argument may be safely NULL, but in this case the method will always return TRUE. That is, a NULL geometry is treated as being everywhere.
This method is the same as the C function OGR_G_Intersects().
 Return
TRUE if the geometries intersect, otherwise FALSE.
 Parameters
poOtherGeom
: the other geometry to test against.

int
Equals
(const OGRGeometry *) const = 0¶ Returns TRUE if two geometries are equivalent.
This operation implements the SQL/MM ST_OrderingEquals() operation.
The comparison is done in a structural way, that is to say that the geometry types must be identical, as well as the number and ordering of subgeometries and vertices. Or equivalently, two geometries are considered equal by this method if their WKT/WKB representation is equal. Note: this must be distinguished for equality in a spatial way (which is the purpose of the ST_Equals() operation).
This method is the same as the C function OGR_G_Equals().
 Return
TRUE if equivalent or FALSE otherwise.

OGRBoolean
Disjoint
(const OGRGeometry *poOtherGeom) const¶ Test for disjointness.
Tests if this geometry and the other passed into the method are disjoint.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_Disjoint().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
TRUE if they are disjoint, otherwise FALSE.
 Parameters
poOtherGeom
: the geometry to compare to this geometry.

OGRBoolean
Touches
(const OGRGeometry *poOtherGeom) const¶ Test for touching.
Tests if this geometry and the other passed into the method are touching.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_Touches().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
TRUE if they are touching, otherwise FALSE.
 Parameters
poOtherGeom
: the geometry to compare to this geometry.

OGRBoolean
Crosses
(const OGRGeometry *poOtherGeom) const¶ Test for crossing.
Tests if this geometry and the other passed into the method are crossing.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_Crosses().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
TRUE if they are crossing, otherwise FALSE.
 Parameters
poOtherGeom
: the geometry to compare to this geometry.

OGRBoolean
Within
(const OGRGeometry *poOtherGeom) const¶ Test for containment.
Tests if actual geometry object is within the passed geometry.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_Within().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
TRUE if poOtherGeom is within this geometry, otherwise FALSE.
 Parameters
poOtherGeom
: the geometry to compare to this geometry.

OGRBoolean
Contains
(const OGRGeometry *poOtherGeom) const¶ Test for containment.
Tests if actual geometry object contains the passed geometry.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_Contains().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
TRUE if poOtherGeom contains this geometry, otherwise FALSE.
 Parameters
poOtherGeom
: the geometry to compare to this geometry.

OGRBoolean
Overlaps
(const OGRGeometry *poOtherGeom) const¶ Test for overlap.
Tests if this geometry and the other passed into the method overlap, that is their intersection has a nonzero area.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_Overlaps().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
TRUE if they are overlapping, otherwise FALSE.
 Parameters
poOtherGeom
: the geometry to compare to this geometry.

OGRGeometry *
Boundary
() const¶ Compute boundary.
A new geometry object is created and returned containing the boundary of the geometry on which the method is invoked.
This method is the same as the C function OGR_G_Boundary().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
a newly allocated geometry now owned by the caller, or NULL on failure.
 Since
OGR 1.8.0

double
Distance
(const OGRGeometry *poOtherGeom) const¶ Compute distance between two geometries.
Returns the shortest distance between the two geometries. The distance is expressed into the same unit as the coordinates of the geometries.
This method is the same as the C function OGR_G_Distance().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
the distance between the geometries or 1 if an error occurs.
 Parameters
poOtherGeom
: the other geometry to compare against.

OGRGeometry *
ConvexHull
() const¶ Compute convex hull.
A new geometry object is created and returned containing the convex hull of the geometry on which the method is invoked.
This method is the same as the C function OGR_G_ConvexHull().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
a newly allocated geometry now owned by the caller, or NULL on failure.

OGRGeometry *
Buffer
(double dfDist, int nQuadSegs = 30) const¶ Compute buffer of geometry.
Builds a new geometry containing the buffer region around the geometry on which it is invoked. The buffer is a polygon containing the region within the buffer distance of the original geometry.
Some buffer sections are properly described as curves, but are converted to approximate polygons. The nQuadSegs parameter can be used to control how many segments should be used to define a 90 degree curve  a quadrant of a circle. A value of 30 is a reasonable default. Large values result in large numbers of vertices in the resulting buffer geometry while small numbers reduce the accuracy of the result.
This method is the same as the C function OGR_G_Buffer().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
the newly created geometry, or NULL if an error occurs.
 Parameters
dfDist
: the buffer distance to be applied. Should be expressed into the same unit as the coordinates of the geometry.nQuadSegs
: the number of segments used to approximate a 90 degree (quadrant) of curvature.

OGRGeometry *
Intersection
(const OGRGeometry *poOtherGeom) const¶ Compute intersection.
Generates a new geometry which is the region of intersection of the two geometries operated on. The Intersects() method can be used to test if two geometries intersect.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_Intersection().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
a new geometry representing the intersection or NULL if there is no intersection or an error occurs.
 Parameters
poOtherGeom
: the other geometry intersected with “this” geometry.

OGRGeometry *
Union
(const OGRGeometry *poOtherGeom) const¶ Compute union.
Generates a new geometry which is the region of union of the two geometries operated on.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_Union().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
a new geometry representing the union or NULL if an error occurs.
 Parameters
poOtherGeom
: the other geometry unioned with “this” geometry.

OGRGeometry *
UnionCascaded
() const¶ Compute union using cascading.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_UnionCascaded().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
a new geometry representing the union or NULL if an error occurs.
 Since
OGR 1.8.0

OGRGeometry *
Difference
(const OGRGeometry *poOtherGeom) const¶ Compute difference.
Generates a new geometry which is the region of this geometry with the region of the second geometry removed.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_Difference().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
a new geometry representing the difference or NULL if the difference is empty or an error occurs.
 Parameters
poOtherGeom
: the other geometry removed from “this” geometry.

OGRGeometry *
SymDifference
(const OGRGeometry *poOtherGeom) const¶ Compute symmetric difference.
Generates a new geometry which is the symmetric difference of this geometry and the second geometry passed into the method.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_SymDifference().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
a new geometry representing the symmetric difference or NULL if the difference is empty or an error occurs.
 Since
OGR 1.8.0
 Parameters
poOtherGeom
: the other geometry.

OGRErr
Centroid
(OGRPoint *poPoint) const¶ Compute the geometry centroid.
The centroid location is applied to the passed in OGRPoint object. The centroid is not necessarily within the geometry.
This method relates to the SFCOM ISurface::get_Centroid() method however the current implementation based on GEOS can operate on other geometry types such as multipoint, linestring, geometrycollection such as multipolygons. OGC SF SQL 1.1 defines the operation for surfaces (polygons). SQL/MMPart 3 defines the operation for surfaces and multisurfaces (multipolygons).
This function is the same as the C function OGR_G_Centroid().
This function is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this function will always fail, issuing a CPLE_NotSupported error.
 Return
OGRERR_NONE on success or OGRERR_FAILURE on error.
 Since
OGR 1.8.0 as a OGRGeometry method (previously was restricted to OGRPolygon)

OGRGeometry *
Simplify
(double dTolerance) const¶ Simplify the geometry.
This function is the same as the C function OGR_G_Simplify().
This function is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this function will always fail, issuing a CPLE_NotSupported error.
 Return
the simplified geometry or NULL if an error occurs.
 Since
OGR 1.8.0
 Parameters
dTolerance
: the distance tolerance for the simplification.

OGRGeometry *
SimplifyPreserveTopology
(double dTolerance) const¶ Simplify the geometry while preserving topology.
This function is the same as the C function OGR_G_SimplifyPreserveTopology().
This function is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this function will always fail, issuing a CPLE_NotSupported error.
 Return
the simplified geometry or NULL if an error occurs.
 Since
OGR 1.9.0
 Parameters
dTolerance
: the distance tolerance for the simplification.

OGRGeometry *
DelaunayTriangulation
(double dfTolerance, int bOnlyEdges) const¶ Return a Delaunay triangulation of the vertices of the geometry.
This function is the same as the C function OGR_G_DelaunayTriangulation().
This function is built on the GEOS library, v3.4 or above. If OGR is built without the GEOS library, this function will always fail, issuing a CPLE_NotSupported error.
 Return
the geometry resulting from the Delaunay triangulation or NULL if an error occurs.
 Since
OGR 2.1
 Parameters
dfTolerance
: optional snapping tolerance to use for improved robustnessbOnlyEdges
: if TRUE, will return a MULTILINESTRING, otherwise it will return a GEOMETRYCOLLECTION containing triangular POLYGONs.

OGRGeometry *
Polygonize
() const¶ Polygonizes a set of sparse edges.
A new geometry object is created and returned containing a collection of reassembled Polygons: NULL will be returned if the input collection doesn’t corresponds to a MultiLinestring, or when reassembling Edges into Polygons is impossible due to topological inconsistencies.
This method is the same as the C function OGR_G_Polygonize().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
a newly allocated geometry now owned by the caller, or NULL on failure.
 Since
OGR 1.9.0

double
Distance3D
(const OGRGeometry *poOtherGeom) const¶ Returns the 3D distance between two geometries.
The distance is expressed into the same unit as the coordinates of the geometries.
This method is built on the SFCGAL library, check it for the definition of the geometry operation. If OGR is built without the SFCGAL library, this method will always return 1.0
This function is the same as the C function OGR_G_Distance3D().
 Return
distance between the two geometries
 Since
GDAL 2.2

void
swapXY
()¶ Swap x and y coordinates.
 Since
OGR 1.8.0

OGRPoint *
toPoint
()¶ Downcast to OGRPoint*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbPoint.
 Since
GDAL 2.3

const OGRPoint *
toPoint
() const¶ Downcast to OGRPoint*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbPoint.
 Since
GDAL 2.3

OGRCurve *
toCurve
()¶ Downcast to OGRCurve*.
Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbCurve).
 Since
GDAL 2.3

const OGRCurve *
toCurve
() const¶ Downcast to OGRCurve*.
Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbCurve).
 Since
GDAL 2.3

OGRSimpleCurve *
toSimpleCurve
()¶ Downcast to OGRSimpleCurve*.
Implies prior checking that getGeometryType() is wkbLineString, wkbCircularString or a derived type.
 Since
GDAL 2.3

const OGRSimpleCurve *
toSimpleCurve
() const¶ Downcast to OGRSimpleCurve*.
Implies prior checking that getGeometryType() is wkbLineString, wkbCircularString or a derived type.
 Since
GDAL 2.3

OGRLineString *
toLineString
()¶ Downcast to OGRLineString*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbLineString.
 Since
GDAL 2.3

const OGRLineString *
toLineString
() const¶ Downcast to OGRLineString*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbLineString.
 Since
GDAL 2.3

OGRLinearRing *
toLinearRing
()¶ Downcast to OGRLinearRing*.
Implies prior checking that EQUAL(getGeometryName(), “LINEARRING”).
 Since
GDAL 2.3

const OGRLinearRing *
toLinearRing
() const¶ Downcast to OGRLinearRing*.
Implies prior checking that EQUAL(getGeometryName(), “LINEARRING”).
 Since
GDAL 2.3

OGRCircularString *
toCircularString
()¶ Downcast to OGRCircularString*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbCircularString.
 Since
GDAL 2.3

const OGRCircularString *
toCircularString
() const¶ Downcast to OGRCircularString*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbCircularString.
 Since
GDAL 2.3

OGRCompoundCurve *
toCompoundCurve
()¶ Downcast to OGRCompoundCurve*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbCompoundCurve.
 Since
GDAL 2.3

const OGRCompoundCurve *
toCompoundCurve
() const¶ Downcast to OGRCompoundCurve*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbCompoundCurve.
 Since
GDAL 2.3

OGRSurface *
toSurface
()¶ Downcast to OGRSurface*.
Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbSurface).
 Since
GDAL 2.3

const OGRSurface *
toSurface
() const¶ Downcast to OGRSurface*.
Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbSurface).
 Since
GDAL 2.3

OGRPolygon *
toPolygon
()¶ Downcast to OGRPolygon*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbPolygon or wkbTriangle.
 Since
GDAL 2.3

const OGRPolygon *
toPolygon
() const¶ Downcast to OGRPolygon*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbPolygon or wkbTriangle.
 Since
GDAL 2.3

OGRTriangle *
toTriangle
()¶ Downcast to OGRTriangle*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbTriangle.
 Since
GDAL 2.3

const OGRTriangle *
toTriangle
() const¶ Downcast to OGRTriangle*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbTriangle.
 Since
GDAL 2.3

OGRCurvePolygon *
toCurvePolygon
()¶ Downcast to OGRCurvePolygon*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbCurvePolygon or wkbPolygon or wkbTriangle.
 Since
GDAL 2.3

const OGRCurvePolygon *
toCurvePolygon
() const¶ Downcast to OGRCurvePolygon*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbCurvePolygon or wkbPolygon or wkbTriangle.
 Since
GDAL 2.3

OGRGeometryCollection *
toGeometryCollection
()¶ Downcast to OGRGeometryCollection*.
Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbGeometryCollection).
 Since
GDAL 2.3

const OGRGeometryCollection *
toGeometryCollection
() const¶ Downcast to OGRGeometryCollection*.
Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbGeometryCollection).
 Since
GDAL 2.3

OGRMultiPoint *
toMultiPoint
()¶ Downcast to OGRMultiPoint*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiPoint.
 Since
GDAL 2.3

const OGRMultiPoint *
toMultiPoint
() const¶ Downcast to OGRMultiPoint*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiPoint.
 Since
GDAL 2.3

OGRMultiLineString *
toMultiLineString
()¶ Downcast to OGRMultiLineString*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiLineString.
 Since
GDAL 2.3

const OGRMultiLineString *
toMultiLineString
() const¶ Downcast to OGRMultiLineString*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiLineString.
 Since
GDAL 2.3

OGRMultiPolygon *
toMultiPolygon
()¶ Downcast to OGRMultiPolygon*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiPolygon.
 Since
GDAL 2.3

const OGRMultiPolygon *
toMultiPolygon
() const¶ Downcast to OGRMultiPolygon*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiPolygon.
 Since
GDAL 2.3

OGRMultiCurve *
toMultiCurve
()¶ Downcast to OGRMultiCurve*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiCurve and derived types.
 Since
GDAL 2.3

const OGRMultiCurve *
toMultiCurve
() const¶ Downcast to OGRMultiCurve*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiCurve and derived types.
 Since
GDAL 2.3

OGRMultiSurface *
toMultiSurface
()¶ Downcast to OGRMultiSurface*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiSurface and derived types.
 Since
GDAL 2.3

const OGRMultiSurface *
toMultiSurface
() const¶ Downcast to OGRMultiSurface*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiSurface and derived types.
 Since
GDAL 2.3

OGRPolyhedralSurface *
toPolyhedralSurface
()¶ Downcast to OGRPolyhedralSurface*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbPolyhedralSurface or wkbTIN.
 Since
GDAL 2.3

const OGRPolyhedralSurface *
toPolyhedralSurface
() const¶ Downcast to OGRPolyhedralSurface*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbPolyhedralSurface or wkbTIN.
 Since
GDAL 2.3

OGRTriangulatedSurface *
toTriangulatedSurface
()¶ Downcast to OGRTriangulatedSurface*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbTIN.
 Since
GDAL 2.3

const OGRTriangulatedSurface *
toTriangulatedSurface
() const¶ Downcast to OGRTriangulatedSurface*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbTIN.
 Since
GDAL 2.3
Public Static Functions

GEOSContextHandle_t
createGEOSContext
()¶ Create a new GEOS context.
 Return
a new GEOS context.

void
freeGEOSContext
(GEOSContextHandle_t hGEOSCtxt)¶ Destroy a GEOS context.
 Parameters
hGEOSCtxt
: GEOS context

static OGRGeometryH
ToHandle
(OGRGeometry *poGeom)¶ Convert a OGRGeometry* to a OGRGeometryH.
 Since
GDAL 2.3

static OGRGeometry *
FromHandle
(OGRGeometryH hGeom)¶ Convert a OGRGeometryH to a OGRGeometry*.
 Since
GDAL 2.3

OGRPoint class¶

class
OGRPoint
: public OGRGeometry¶ Point class.
Implements SFCOM IPoint methods.
Public Functions

OGRPoint
()¶ Create an empty point.

OGRPoint
(double x, double y)¶ Create a point.
 Parameters
xIn
: xyIn
: y

OGRPoint
(double x, double y, double z)¶ Create a point.
 Parameters
xIn
: xyIn
: yzIn
: z

OGRPoint
(double x, double y, double z, double m)¶ Create a point.
 Parameters
xIn
: xyIn
: yzIn
: zmIn
: m

OGRPoint
(const OGRPoint &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRPoint &
operator=
(const OGRPoint &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

int
WkbSize
() const¶ Returns size of related binary representation.
This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.
This method relates to the SFCOM IWks::WkbSize() method.
This method is the same as the C function OGR_G_WkbSize().
 Return
size of binary representation in bytes.

OGRErr
importFromWkb
(const unsigned char *pabyData, int nSize, OGRwkbVariant eWkbVariant, int &nBytesConsumedOut)¶ Assign geometry from well known binary data.
The object must have already been instantiated as the correct derived type of geometry object to match the binaries type. This method is used by the OGRGeometryFactory class, but not normally called by application code.
This method relates to the SFCOM IWks::ImportFromWKB() method.
This method is the same as the C function OGR_G_ImportFromWkb().
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Since
GDAL 2.3
 Parameters
pabyData
: the binary input data.nSize
: the size of pabyData in bytes, or 1 if not known.eWkbVariant
: if wkbVariantPostGIS1, special interpretation is done for curve geometries codenBytesConsumedOut
: output parameter. Number of bytes consumed.

OGRErr
exportToWkb
(OGRwkbByteOrder eByteOrder, unsigned char *pabyData, OGRwkbVariant eWkbVariant = wkbVariantOldOgc) const¶ Convert a geometry into well known binary format.
This method relates to the SFCOM IWks::ExportToWKB() method.
This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.
 Return
Currently OGRERR_NONE is always returned.
 Parameters
eByteOrder
: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.pabyData
: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.eWkbVariant
: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

OGRErr
importFromWkt
(const char **ppszInput)¶ deprecated

std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const¶ Export a point to WKT.
 Return
WKT string representing this point.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

int
getDimension
() const¶ Get the dimension of this object.
This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).
This method is the same as the C function OGR_G_GetDimension().
 Return
0 for points, 1 for lines and 2 for surfaces.

OGRGeometry *
clone
() const¶ Make a copy of this object.
This method relates to the SFCOM IGeometry::clone() method.
This method is the same as the C function OGR_G_Clone().
 Return
a new object instance with the same geometry, and spatial reference system as the original.

void
empty
()¶ Clear geometry information.
This restores the geometry to its initial state after construction, and before assignment of actual geometry.
This method relates to the SFCOM IGeometry::Empty() method.
This method is the same as the C function OGR_G_Empty().

void
getEnvelope
(OGREnvelope *psEnvelope) const¶ Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope().
 Parameters
psEnvelope
: the structure in which to place the results.

void
getEnvelope
(OGREnvelope3D *psEnvelope) const¶ Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope3D().
 Since
OGR 1.9.0
 Parameters
psEnvelope
: the structure in which to place the results.

virtual OGRBoolean
IsEmpty
() const¶ Returns TRUE (nonzero) if the object has no points.
Normally this returns FALSE except between when an object is instantiated and points have been assigned.
This method relates to the SFCOM IGeometry::IsEmpty() method.
 Return
TRUE if object is empty, otherwise FALSE.

double
getX
() const¶ Return x.
Fetch X coordinate.
Relates to the SFCOM IPoint::get_X() method.
 Return
the X coordinate of this point.

double
getY
() const¶ Return y.
Fetch Y coordinate.
Relates to the SFCOM IPoint::get_Y() method.
 Return
the Y coordinate of this point.

double
getZ
() const¶ Return z.
Fetch Z coordinate.
Relates to the SFCOM IPoint::get_Z() method.
 Return
the Z coordinate of this point, or zero if it is a 2D point.

double
getM
() const¶ Return m.

void
setCoordinateDimension
(int nDimension)¶ Set the coordinate dimension.
This method sets the explicit coordinate dimension. Setting the coordinate dimension of a geometry to 2 should zero out any existing Z values. Setting the dimension of a geometry collection, a compound curve, a polygon, etc. will affect the children geometries. This will also remove the M dimension if present before this call.
 Parameters
nNewDimension
: New coordinate dimension value, either 2 or 3.

void
setX
(double xIn)¶ Set x.
Assign point X coordinate.
There is no corresponding SFCOM method.
 Parameters
xIn
: x

void
setY
(double yIn)¶ Set y.
Assign point Y coordinate.
There is no corresponding SFCOM method.
 Parameters
yIn
: y

void
setZ
(double zIn)¶ Set z.
Assign point Z coordinate.
Calling this method will force the geometry coordinate dimension to 3D (wkbPointwkbZ).
 Parameters
zIn
: z
There is no corresponding SFCOM method.

void
setM
(double mIn)¶ Set m.
 Parameters
mIn
: m

OGRBoolean
Equals
(const OGRGeometry *) const¶ Returns TRUE if two geometries are equivalent.
This operation implements the SQL/MM ST_OrderingEquals() operation.
The comparison is done in a structural way, that is to say that the geometry types must be identical, as well as the number and ordering of subgeometries and vertices. Or equivalently, two geometries are considered equal by this method if their WKT/WKB representation is equal. Note: this must be distinguished for equality in a spatial way (which is the purpose of the ST_Equals() operation).
This method is the same as the C function OGR_G_Equals().
 Return
TRUE if equivalent or FALSE otherwise.

OGRBoolean
Intersects
(const OGRGeometry *poOtherGeom) const¶ Do these features intersect?
Determines whether two geometries intersect. If GEOS is enabled, then this is done in rigorous fashion otherwise TRUE is returned if the envelopes (bounding boxes) of the two geometries overlap.
The poOtherGeom argument may be safely NULL, but in this case the method will always return TRUE. That is, a NULL geometry is treated as being everywhere.
This method is the same as the C function OGR_G_Intersects().
 Return
TRUE if the geometries intersect, otherwise FALSE.
 Parameters
poOtherGeom
: the other geometry to test against.

OGRBoolean
Within
(const OGRGeometry *poOtherGeom) const¶ Test for containment.
Tests if actual geometry object is within the passed geometry.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_Within().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
TRUE if poOtherGeom is within this geometry, otherwise FALSE.
 Parameters
poOtherGeom
: the geometry to compare to this geometry.

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

OGRErr
transform
(OGRCoordinateTransformation *poCT)¶ Apply arbitrary coordinate transformation to geometry.
This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.
Note that this method does not require that the geometry already have a spatial reference system. It will be assumed that they can be treated as having the source spatial reference system of the OGRCoordinateTransformation object, and the actual SRS of the geometry will be ignored. On successful completion the output OGRSpatialReference of the OGRCoordinateTransformation will be assigned to the geometry.
This method is the same as the C function OGR_G_Transform().
 Return
OGRERR_NONE on success or an error code.
 Parameters
poCT
: the transformation to apply.

void
flattenTo2D
()¶ Convert geometry to strictly 2D.
In a sense this converts all Z coordinates to 0.0.
This method is the same as the C function OGR_G_FlattenTo2D().

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.

void
swapXY
()¶ Swap x and y coordinates.
 Since
OGR 1.8.0

OGRLineString class¶

class
OGRLineString
: public OGRSimpleCurve¶ Concrete representation of a multivertex line.
Note: for implementation convenience, we make it inherit from OGRSimpleCurve whereas SFSQL and SQL/MM only make it inherits from OGRCurve.
Subclassed by OGRLinearRing
Public Functions

OGRLineString
()¶ Create an empty line string.

OGRLineString
(const OGRLineString &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRLineString &
operator=
(const OGRLineString &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRLineString *
CurveToLine
(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const¶ Return a linestring from a curve geometry.
The returned geometry is a new instance whose ownership belongs to the caller.
If the dfMaxAngleStepSizeDegrees is zero, then a default value will be used. This is currently 4 degrees unless the user has overridden the value with the OGR_ARC_STEPSIZE configuration variable.
This method relates to the ISO SQL/MM Part 3 ICurve::CurveToLine() method.
This function is the same as C function OGR_G_CurveToLine().
 Return
a line string approximating the curve
 Since
GDAL 2.0
 Parameters
dfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.papszOptions
: options as a nullterminated list of strings or NULL. See OGRGeometryFactory::curveToLineString() for valid options.

OGRGeometry *
getCurveGeometry
(const char *const *papszOptions = nullptr) const¶ Return curve version of this geometry.
Returns a geometry that has possibly CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by deapproximating curve geometries.
If the geometry has no curve portion, the returned geometry will be a clone of it.
The ownership of the returned geometry belongs to the caller.
The reverse method is OGRGeometry::getLinearGeometry().
This function is the same as C function OGR_G_GetCurveGeometry().
 Return
a new geometry.
 Since
GDAL 2.0
 Parameters
papszOptions
: options as a nullterminated list of strings. Unused for now. Must be set to NULL.

virtual double
get_Area
() const¶ Get the area of the (closed) curve.
This method is designed to be used by OGRCurvePolygon::get_Area().
 Return
the area of the feature in square units of the spatial reference system in use.
 Since
GDAL 2.0

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRSimpleCurve *
toUpperClass
()¶ Return pointer of this in upper class.

const OGRSimpleCurve *
toUpperClass
() const¶ Return pointer of this in upper class.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.

OGRLinearRing class¶

class
OGRLinearRing
: public OGRLineString¶ Concrete representation of a closed ring.
This class is functionally equivalent to an OGRLineString, but has a separate identity to maintain alignment with the OpenGIS simple feature data model. It exists to serve as a component of an OGRPolygon.
The OGRLinearRing has no corresponding free standing well known binary representation, so importFromWkb() and exportToWkb() will not actually work. There is a nonstandard GDAL WKT representation though.
Because OGRLinearRing is not a “proper” free standing simple features object, it cannot be directly used on a feature via SetGeometry(), and cannot generally be used with GEOS for operations like Intersects(). Instead the polygon should be used, or the OGRLinearRing should be converted to an OGRLineString for such operations.
Note: this class exists in SFSQL 1.2, but not in ISO SQL/MM Part 3.
Public Functions

OGRLinearRing
()¶ Constructor.

OGRLinearRing
(const OGRLinearRing &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRLinearRing
(OGRLinearRing *poSrcRing)¶ Constructor.
 Parameters
poSrcRing
: source ring.

OGRLinearRing &
operator=
(const OGRLinearRing &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRGeometry *
clone
() const¶ Make a copy of this object.
This method relates to the SFCOM IGeometry::clone() method.
This method is the same as the C function OGR_G_Clone().
 Return
a new object instance with the same geometry, and spatial reference system as the original.

int
isClockwise
() const¶ Returns TRUE if the ring has clockwise winding (or less than 2 points)
 Return
TRUE if clockwise otherwise FALSE.

void
reverseWindingOrder
()¶ Reverse order of points.

void
closeRings
()¶ Force rings to be closed.
If this geometry, or any contained geometries has polygon rings that are not closed, they will be closed by adding the starting point at the end.

OGRBoolean
isPointInRing
(const OGRPoint *pt, int bTestEnvelope = TRUE) const¶ Returns whether the point is inside the ring.
 Return
TRUE or FALSE.
 Parameters
poPoint
: pointbTestEnvelope
: set to TRUE if the presence of the point inside the ring envelope must be checked first.

OGRBoolean
isPointOnRingBoundary
(const OGRPoint *pt, int bTestEnvelope = TRUE) const¶ Returns whether the point is on the ring boundary.
 Return
TRUE or FALSE.
 Parameters
poPoint
: pointbTestEnvelope
: set to TRUE if the presence of the point inside the ring envelope must be checked first.

OGRErr
transform
(OGRCoordinateTransformation *poCT)¶ Apply arbitrary coordinate transformation to geometry.
This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.
Note that this method does not require that the geometry already have a spatial reference system. It will be assumed that they can be treated as having the source spatial reference system of the OGRCoordinateTransformation object, and the actual SRS of the geometry will be ignored. On successful completion the output OGRSpatialReference of the OGRCoordinateTransformation will be assigned to the geometry.
This method is the same as the C function OGR_G_Transform().
 Return
OGRERR_NONE on success or an error code.
 Parameters
poCT
: the transformation to apply.

OGRLineString *
toUpperClass
()¶ Return pointer of this in upper class.

const OGRLineString *
toUpperClass
() const¶ Return pointer of this in upper class.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.

int
WkbSize
() const¶ Returns size of related binary representation.
This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.
This method relates to the SFCOM IWks::WkbSize() method.
This method is the same as the C function OGR_G_WkbSize().
 Return
size of binary representation in bytes.

OGRErr
importFromWkb
(const unsigned char *pabyData, int nSize, OGRwkbVariant eWkbVariant, int &nBytesConsumedOut)¶ Assign geometry from well known binary data.
The object must have already been instantiated as the correct derived type of geometry object to match the binaries type. This method is used by the OGRGeometryFactory class, but not normally called by application code.
This method relates to the SFCOM IWks::ImportFromWKB() method.
This method is the same as the C function OGR_G_ImportFromWkb().
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Since
GDAL 2.3
 Parameters
pabyData
: the binary input data.nSize
: the size of pabyData in bytes, or 1 if not known.eWkbVariant
: if wkbVariantPostGIS1, special interpretation is done for curve geometries codenBytesConsumedOut
: output parameter. Number of bytes consumed.

OGRErr
exportToWkb
(OGRwkbByteOrder eByteOrder, unsigned char *pabyData, OGRwkbVariant eWkbVariant = wkbVariantOldOgc) const¶ Convert a geometry into well known binary format.
This method relates to the SFCOM IWks::ExportToWKB() method.
This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.
 Return
Currently OGRERR_NONE is always returned.
 Parameters
eByteOrder
: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.pabyData
: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.eWkbVariant
: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

OGRCircularString class¶

class
OGRCircularString
: public OGRSimpleCurve¶ Concrete representation of a circular string, that is to say a curve made of one or several arc circles.
Note: for implementation convenience, we make it inherit from OGRSimpleCurve whereas SQL/MM only makes it inherits from OGRCurve.
Compatibility: ISO SQL/MM Part 3.
 Since
GDAL 2.0
Public Functions

OGRCircularString
()¶ Create an empty circular string.

OGRCircularString
(const OGRCircularString &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRCircularString &
operator=
(const OGRCircularString &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRErr
importFromWkb
(const unsigned char *pabyData, int nSize, OGRwkbVariant eWkbVariant, int &nBytesConsumedOut)¶ Assign geometry from well known binary data.
The object must have already been instantiated as the correct derived type of geometry object to match the binaries type. This method is used by the OGRGeometryFactory class, but not normally called by application code.
This method relates to the SFCOM IWks::ImportFromWKB() method.
This method is the same as the C function OGR_G_ImportFromWkb().
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Since
GDAL 2.3
 Parameters
pabyData
: the binary input data.nSize
: the size of pabyData in bytes, or 1 if not known.eWkbVariant
: if wkbVariantPostGIS1, special interpretation is done for curve geometries codenBytesConsumedOut
: output parameter. Number of bytes consumed.

OGRErr
exportToWkb
(OGRwkbByteOrder eByteOrder, unsigned char *pabyData, OGRwkbVariant eWkbVariant = wkbVariantOldOgc) const¶ Convert a geometry into well known binary format.
This method relates to the SFCOM IWks::ExportToWKB() method.
This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.
 Return
Currently OGRERR_NONE is always returned.
 Parameters
eByteOrder
: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.pabyData
: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.eWkbVariant
: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

OGRErr
importFromWkt
(const char **ppszInput)¶ deprecated

std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const¶ Export a circular string to WKT.
 Return
WKT string representing this circular string.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

OGRBoolean
IsValid
() const¶ Test if the geometry is valid.
This method is the same as the C function OGR_G_IsValid().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always return FALSE.
 Return
TRUE if the geometry has no points, otherwise FALSE.

void
getEnvelope
(OGREnvelope *psEnvelope) const¶ Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope().
 Parameters
psEnvelope
: the structure in which to place the results.

void
getEnvelope
(OGREnvelope3D *psEnvelope) const¶ Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope3D().
 Since
OGR 1.9.0
 Parameters
psEnvelope
: the structure in which to place the results.

double
get_Length
() const¶ Returns the length of the curve.
This method relates to the SFCOM ICurve::get_Length() method.
 Return
the length of the curve, zero if the curve hasn’t been initialized.

OGRLineString *
CurveToLine
(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const¶ Return a linestring from a curve geometry.
The returned geometry is a new instance whose ownership belongs to the caller.
If the dfMaxAngleStepSizeDegrees is zero, then a default value will be used. This is currently 4 degrees unless the user has overridden the value with the OGR_ARC_STEPSIZE configuration variable.
This method relates to the ISO SQL/MM Part 3 ICurve::CurveToLine() method.
This function is the same as C function OGR_G_CurveToLine().
 Return
a line string approximating the curve
 Since
GDAL 2.0
 Parameters
dfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.papszOptions
: options as a nullterminated list of strings or NULL. See OGRGeometryFactory::curveToLineString() for valid options.

void
Value
(double dfDistance, OGRPoint *poPoint) const¶ Fetch point at given distance along curve.
This method relates to the SF COM ICurve::get_Value() method.
This function is the same as the C function OGR_G_Value().
 Parameters
dfDistance
: distance along the curve at which to sample position. This distance should be between zero and get_Length() for this curve.poPoint
: the point to be assigned the curve position.

double
get_Area
() const¶ Get the area of the (closed) curve.
This method is designed to be used by OGRCurvePolygon::get_Area().
 Return
the area of the feature in square units of the spatial reference system in use.
 Since
GDAL 2.0

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

void
segmentize
(double dfMaxLength)¶ Modify the geometry such it has no segment longer then the given distance.
Add intermediate vertices to a geometry.
Interpolated points will have Z and M values (if needed) set to 0. Distance computation is performed in 2d only
This function is the same as the C function OGR_G_Segmentize()
This method modifies the geometry to add intermediate vertices if necessary so that the maximum length between 2 consecutive vertices is lower than dfMaxLength.
 Parameters
dfMaxLength
: the maximum distance between 2 points after segmentization
 Parameters
dfMaxLength
: maximum length between 2 consecutive vertices.

OGRBoolean
hasCurveGeometry
(int bLookForNonLinear = FALSE) const¶ Returns if this geometry is or has curve geometry.
Returns if a geometry is, contains or may contain a CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE.
If bLookForNonLinear is set to TRUE, it will be actually looked if the geometry or its subgeometries are or contain a nonlinear geometry in them. In which case, if the method returns TRUE, it means that getLinearGeometry() would return an approximate version of the geometry. Otherwise, getLinearGeometry() would do a conversion, but with just converting container type, like COMPOUNDCURVE > LINESTRING, MULTICURVE > MULTILINESTRING or MULTISURFACE > MULTIPOLYGON, resulting in a “lossless” conversion.
This method is the same as the C function OGR_G_HasCurveGeometry().
 Return
TRUE if this geometry is or has curve geometry.
 Since
GDAL 2.0
 Parameters
bLookForNonLinear
: set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

OGRGeometry *
getLinearGeometry
(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const¶ Return, possibly approximate, noncurve version of this geometry.
Returns a geometry that has no CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by approximating curve geometries.
The ownership of the returned geometry belongs to the caller.
The reverse method is OGRGeometry::getCurveGeometry().
This method is the same as the C function OGR_G_GetLinearGeometry().
 Return
a new geometry.
 Since
GDAL 2.0
 Parameters
dfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.papszOptions
: options as a nullterminated list of strings. See OGRGeometryFactory::curveToLineString() for valid options.

OGRSimpleCurve *
toUpperClass
()¶ Return pointer of this in upper class.

const OGRSimpleCurve *
toUpperClass
() const¶ Return pointer of this in upper class.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.
OGRCurve class¶

class
OGRCurve
: public OGRGeometry¶ Abstract curve base class for OGRLineString, OGRCircularString and OGRCompoundCurve.
Subclassed by OGRCompoundCurve, OGRSimpleCurve
Public Functions

OGRCurve::ConstIterator
begin
() const¶ Return begin of a point iterator.
Using this iterator for standard rangebased loops is safe, but due to implementation limitations, you shouldn’t try to access (dereference) more than one iterator step at a time, since you will get a reference to the same OGRPoint& object.
 Since
GDAL 2.3

double
get_Length
() const = 0¶ Returns the length of the curve.
This method relates to the SFCOM ICurve::get_Length() method.
 Return
the length of the curve, zero if the curve hasn’t been initialized.

void
StartPoint
(OGRPoint *poPoint) const = 0¶ Return the curve start point.
This method relates to the SF COM ICurve::get_StartPoint() method.
 Parameters
poPoint
: the point to be assigned the start location.

void
EndPoint
(OGRPoint *poPoint) const = 0¶ Return the curve end point.
This method relates to the SF COM ICurve::get_EndPoint() method.
 Parameters
poPoint
: the point to be assigned the end location.

int
get_IsClosed
() const¶ Return TRUE if curve is closed.
Tests if a curve is closed. A curve is closed if its start point is equal to its end point.
For equality tests, the M dimension is ignored.
This method relates to the SFCOM ICurve::get_IsClosed() method.
 Return
TRUE if closed, else FALSE.

void
Value
(double dfDistance, OGRPoint *poPoint) const = 0¶ Fetch point at given distance along curve.
This method relates to the SF COM ICurve::get_Value() method.
This function is the same as the C function OGR_G_Value().
 Parameters
dfDistance
: distance along the curve at which to sample position. This distance should be between zero and get_Length() for this curve.poPoint
: the point to be assigned the curve position.

OGRLineString *
CurveToLine
(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const = 0¶ Return a linestring from a curve geometry.
The returned geometry is a new instance whose ownership belongs to the caller.
If the dfMaxAngleStepSizeDegrees is zero, then a default value will be used. This is currently 4 degrees unless the user has overridden the value with the OGR_ARC_STEPSIZE configuration variable.
This method relates to the ISO SQL/MM Part 3 ICurve::CurveToLine() method.
This function is the same as C function OGR_G_CurveToLine().
 Return
a line string approximating the curve
 Since
GDAL 2.0
 Parameters
dfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.papszOptions
: options as a nullterminated list of strings or NULL. See OGRGeometryFactory::curveToLineString() for valid options.

int
getDimension
() const¶ Get the dimension of this object.
This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).
This method is the same as the C function OGR_G_GetDimension().
 Return
0 for points, 1 for lines and 2 for surfaces.

int
getNumPoints
() const = 0¶ Return the number of points of a curve geometry.
This method, as a method of OGRCurve, does not relate to a standard. For circular strings or linestrings, it returns the number of points, conforming to SF COM NumPoints(). For compound curves, it returns the sum of the number of points of each of its components (non including intermediate starting/ending points of the different parts).
 Return
the number of points of the curve.
 Since
GDAL 2.0

OGRPointIterator *
getPointIterator
() const = 0¶ Returns a point iterator over the curve.
The curve must not be modified while an iterator exists on it.
The iterator must be destroyed with OGRPointIterator::destroy().
 Return
a point iterator over the curve.
 Since
GDAL 2.0

OGRBoolean
IsConvex
() const¶ Returns if a (closed) curve forms a convex shape.
 Return
TRUE if the curve forms a convex shape.
 Since
GDAL 2.0

double
get_Area
() const = 0¶ Get the area of the (closed) curve.
This method is designed to be used by OGRCurvePolygon::get_Area().
 Return
the area of the feature in square units of the spatial reference system in use.
 Since
GDAL 2.0

OGRSimpleCurve *
toSimpleCurve
()¶ Downcast to OGRSimpleCurve*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbLineString or wkbCircularString.

const OGRSimpleCurve *
toSimpleCurve
() const¶ Downcast to OGRSimpleCurve*.
Implies prior checking that wkbFlatten(getGeometryType()) == wkbLineString or wkbCircularString.
Public Static Functions

OGRCompoundCurve *
CastToCompoundCurve
(OGRCurve *puCurve)¶ Cast to compound curve.
The passed in geometry is consumed and a new one returned (or NULL in case of failure)
 Return
new geometry
 Since
GDAL 2.0
 Parameters
poCurve
: the input geometry  ownership is passed to the method.

OGRLineString *
CastToLineString
(OGRCurve *poCurve)¶ Cast to linestring.
The passed in geometry is consumed and a new one returned (or NULL in case of failure)
 Return
new geometry.
 Since
GDAL 2.0
 Parameters
poCurve
: the input geometry  ownership is passed to the method.

OGRLinearRing *
CastToLinearRing
(OGRCurve *poCurve)¶ Cast to linear ring.
The passed in geometry is consumed and a new one returned (or NULL in case of failure)
 Return
new geometry.
 Since
GDAL 2.0
 Parameters
poCurve
: the input geometry  ownership is passed to the method.

OGRCurve::ConstIterator
OGRSurface class¶

class
OGRSurface
: public OGRGeometry¶ Abstract base class for 2 dimensional objects like polygons or curve polygons.
Subclassed by OGRCurvePolygon, OGRPolyhedralSurface
Public Functions

double
get_Area
() const = 0¶ Get the area of the surface object.
For polygons the area is computed as the area of the outer ring less the area of all internal rings.
This method relates to the SFCOM ISurface::get_Area() method.
 Return
the area of the feature in square units of the spatial reference system in use.

double
OGRPolygon class¶

class
OGRPolygon
: public OGRCurvePolygon¶ Concrete class representing polygons.
Note that the OpenGIS simple features polygons consist of one outer ring (linearring), and zero or more inner rings. A polygon cannot represent disconnected regions (such as multiple islands in a political body). The OGRMultiPolygon must be used for this.
Subclassed by OGRTriangle
Public Types

typedef OGRLinearRing
ChildType
¶ Type of child elements.
Public Functions

OGRPolygon
()¶ Create an empty polygon.

OGRPolygon
(const OGRPolygon &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRPolygon &
operator=
(const OGRPolygon &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

OGRBoolean
hasCurveGeometry
(int bLookForNonLinear = FALSE) const¶ Returns if this geometry is or has curve geometry.
Returns if a geometry is, contains or may contain a CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE.
If bLookForNonLinear is set to TRUE, it will be actually looked if the geometry or its subgeometries are or contain a nonlinear geometry in them. In which case, if the method returns TRUE, it means that getLinearGeometry() would return an approximate version of the geometry. Otherwise, getLinearGeometry() would do a conversion, but with just converting container type, like COMPOUNDCURVE > LINESTRING, MULTICURVE > MULTILINESTRING or MULTISURFACE > MULTIPOLYGON, resulting in a “lossless” conversion.
This method is the same as the C function OGR_G_HasCurveGeometry().
 Return
TRUE if this geometry is or has curve geometry.
 Since
GDAL 2.0
 Parameters
bLookForNonLinear
: set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

OGRGeometry *
getCurveGeometry
(const char *const *papszOptions = nullptr) const¶ Return curve version of this geometry.
Returns a geometry that has possibly CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by deapproximating curve geometries.
If the geometry has no curve portion, the returned geometry will be a clone of it.
The ownership of the returned geometry belongs to the caller.
The reverse method is OGRGeometry::getLinearGeometry().
This function is the same as C function OGR_G_GetCurveGeometry().
 Return
a new geometry.
 Since
GDAL 2.0
 Parameters
papszOptions
: options as a nullterminated list of strings. Unused for now. Must be set to NULL.

OGRGeometry *
getLinearGeometry
(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const¶ Return, possibly approximate, noncurve version of this geometry.
Returns a geometry that has no CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by approximating curve geometries.
The ownership of the returned geometry belongs to the caller.
The reverse method is OGRGeometry::getCurveGeometry().
This method is the same as the C function OGR_G_GetLinearGeometry().
 Return
a new geometry.
 Since
GDAL 2.0
 Parameters
dfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.papszOptions
: options as a nullterminated list of strings. See OGRGeometryFactory::curveToLineString() for valid options.

int
WkbSize
() const¶ Returns size of related binary representation.
This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.
This method relates to the SFCOM IWks::WkbSize() method.
This method is the same as the C function OGR_G_WkbSize().
 Return
size of binary representation in bytes.

OGRErr
importFromWkb
(const unsigned char *pabyData, int nSize, OGRwkbVariant eWkbVariant, int &nBytesConsumedOut)¶ Assign geometry from well known binary data.
The object must have already been instantiated as the correct derived type of geometry object to match the binaries type. This method is used by the OGRGeometryFactory class, but not normally called by application code.
This method relates to the SFCOM IWks::ImportFromWKB() method.
This method is the same as the C function OGR_G_ImportFromWkb().
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Since
GDAL 2.3
 Parameters
pabyData
: the binary input data.nSize
: the size of pabyData in bytes, or 1 if not known.eWkbVariant
: if wkbVariantPostGIS1, special interpretation is done for curve geometries codenBytesConsumedOut
: output parameter. Number of bytes consumed.

OGRErr
exportToWkb
(OGRwkbByteOrder eByteOrder, unsigned char *pabyData, OGRwkbVariant eWkbVariant = wkbVariantOldOgc) const¶ Convert a geometry into well known binary format.
This method relates to the SFCOM IWks::ExportToWKB() method.
This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.
 Return
Currently OGRERR_NONE is always returned.
 Parameters
eByteOrder
: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.pabyData
: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.eWkbVariant
: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

OGRErr
importFromWkt
(const char **ppszInput)¶ deprecated

std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const¶ Export a polygon to WKT.
 Return
WKT representation of the polygon.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

OGRPolygon *
CurvePolyToPoly
(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const¶ Return a polygon from a curve polygon.
This method is the same as C function OGR_G_CurvePolyToPoly().
The returned geometry is a new instance whose ownership belongs to the caller.
 Return
a linestring
 Since
OGR 2.0
 Parameters
dfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.papszOptions
: options as a nullterminated list of strings. Unused for now. Must be set to NULL.

OGRLinearRing *
getExteriorRing
()¶ Fetch reference to external polygon ring.
Note that the returned ring pointer is to an internal data object of the OGRPolygon. It should not be modified or deleted by the application, and the pointer is only valid till the polygon is next modified. Use the OGRGeometry::clone() method to make a separate copy within the application.
Relates to the SFCOM IPolygon::get_ExteriorRing() method.
 Return
pointer to external ring. May be NULL if the OGRPolygon is empty.

const OGRLinearRing *
getExteriorRing
() const¶ Fetch reference to external polygon ring.
Note that the returned ring pointer is to an internal data object of the OGRPolygon. It should not be modified or deleted by the application, and the pointer is only valid till the polygon is next modified. Use the OGRGeometry::clone() method to make a separate copy within the application.
Relates to the SFCOM IPolygon::get_ExteriorRing() method.
 Return
pointer to external ring. May be NULL if the OGRPolygon is empty.

OGRLinearRing *
getInteriorRing
(int iRing)¶ Fetch reference to indicated internal ring.
Note that the returned ring pointer is to an internal data object of the OGRPolygon. It should not be modified or deleted by the application, and the pointer is only valid till the polygon is next modified. Use the OGRGeometry::clone() method to make a separate copy within the application.
Relates to the SFCOM IPolygon::get_InternalRing() method.
 Return
pointer to interior ring. May be NULL.
 Parameters
iRing
: internal ring index from 0 to getNumInteriorRings()  1.

const OGRLinearRing *
getInteriorRing
(int iRing) const¶ Fetch reference to indicated internal ring.
Note that the returned ring pointer is to an internal data object of the OGRPolygon. It should not be modified or deleted by the application, and the pointer is only valid till the polygon is next modified. Use the OGRGeometry::clone() method to make a separate copy within the application.
Relates to the SFCOM IPolygon::get_InternalRing() method.
 Return
pointer to interior ring. May be NULL.
 Parameters
iRing
: internal ring index from 0 to getNumInteriorRings()  1.

OGRLinearRing *
stealExteriorRing
()¶ “Steal” reference to external polygon ring.
After the call to that function, only call to stealInteriorRing() or destruction of the OGRPolygon is valid. Other operations may crash.
 Return
pointer to external ring. May be NULL if the OGRPolygon is empty.

OGRLinearRing *
stealInteriorRing
(int iRing)¶ “Steal” reference to indicated interior ring.
After the call to that function, only call to stealInteriorRing() or destruction of the OGRPolygon is valid. Other operations may crash.
 Return
pointer to interior ring. May be NULL.
 Parameters
iRing
: internal ring index from 0 to getNumInteriorRings()  1.

OGRBoolean
IsPointOnSurface
(const OGRPoint *pt) const¶ Return whether the point is on the surface.
 Return
TRUE or FALSE

OGRCurvePolygon *
toUpperClass
()¶ Return pointer of this in upper class.

const OGRCurvePolygon *
toUpperClass
() const¶ Return pointer of this in upper class.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.

void
closeRings
()¶ Force rings to be closed.
If this geometry, or any contained geometries has polygon rings that are not closed, they will be closed by adding the starting point at the end.

typedef OGRLinearRing
OGRCurvePolygon class¶

class
OGRCurvePolygon
: public OGRSurface¶ Concrete class representing curve polygons.
Note that curve polygons consist of one outer (curve) ring, and zero or more inner rings. A curve polygon cannot represent disconnected regions (such as multiple islands in a political body). The OGRMultiSurface must be used for this.
Compatibility: ISO SQL/MM Part 3.
 Since
GDAL 2.0
Subclassed by OGRPolygon
Public Functions

OGRCurvePolygon
()¶ Create an empty curve polygon.

OGRCurvePolygon
(const OGRCurvePolygon&)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRCurvePolygon &
operator=
(const OGRCurvePolygon &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

OGRGeometry *
clone
() const¶ Make a copy of this object.
This method relates to the SFCOM IGeometry::clone() method.
This method is the same as the C function OGR_G_Clone().
 Return
a new object instance with the same geometry, and spatial reference system as the original.

void
empty
()¶ Clear geometry information.
This restores the geometry to its initial state after construction, and before assignment of actual geometry.
This method relates to the SFCOM IGeometry::Empty() method.
This method is the same as the C function OGR_G_Empty().

OGRErr
transform
(OGRCoordinateTransformation *poCT)¶ Apply arbitrary coordinate transformation to geometry.
This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.
Note that this method does not require that the geometry already have a spatial reference system. It will be assumed that they can be treated as having the source spatial reference system of the OGRCoordinateTransformation object, and the actual SRS of the geometry will be ignored. On successful completion the output OGRSpatialReference of the OGRCoordinateTransformation will be assigned to the geometry.
This method is the same as the C function OGR_G_Transform().
 Return
OGRERR_NONE on success or an error code.
 Parameters
poCT
: the transformation to apply.

void
flattenTo2D
()¶ Convert geometry to strictly 2D.
In a sense this converts all Z coordinates to 0.0.
This method is the same as the C function OGR_G_FlattenTo2D().

OGRBoolean
IsEmpty
() const¶ Returns TRUE (nonzero) if the object has no points.
Normally this returns FALSE except between when an object is instantiated and points have been assigned.
This method relates to the SFCOM IGeometry::IsEmpty() method.
 Return
TRUE if object is empty, otherwise FALSE.

void
segmentize
(double dfMaxLength)¶ Modify the geometry such it has no segment longer then the given distance.
Add intermediate vertices to a geometry.
Interpolated points will have Z and M values (if needed) set to 0. Distance computation is performed in 2d only
This function is the same as the C function OGR_G_Segmentize()
This method modifies the geometry to add intermediate vertices if necessary so that the maximum length between 2 consecutive vertices is lower than dfMaxLength.
 Parameters
dfMaxLength
: the maximum distance between 2 points after segmentization
 Parameters
dfMaxLength
: maximum length between 2 consecutive vertices.

OGRBoolean
hasCurveGeometry
(int bLookForNonLinear = FALSE) const¶ Returns if this geometry is or has curve geometry.
Returns if a geometry is, contains or may contain a CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE.
If bLookForNonLinear is set to TRUE, it will be actually looked if the geometry or its subgeometries are or contain a nonlinear geometry in them. In which case, if the method returns TRUE, it means that getLinearGeometry() would return an approximate version of the geometry. Otherwise, getLinearGeometry() would do a conversion, but with just converting container type, like COMPOUNDCURVE > LINESTRING, MULTICURVE > MULTILINESTRING or MULTISURFACE > MULTIPOLYGON, resulting in a “lossless” conversion.
This method is the same as the C function OGR_G_HasCurveGeometry().
 Return
TRUE if this geometry is or has curve geometry.
 Since
GDAL 2.0
 Parameters
bLookForNonLinear
: set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

OGRGeometry *
getLinearGeometry
(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const¶ Return, possibly approximate, noncurve version of this geometry.
Returns a geometry that has no CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by approximating curve geometries.
The ownership of the returned geometry belongs to the caller.
The reverse method is OGRGeometry::getCurveGeometry().
This method is the same as the C function OGR_G_GetLinearGeometry().
 Return
a new geometry.
 Since
GDAL 2.0
 Parameters
dfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.papszOptions
: options as a nullterminated list of strings. See OGRGeometryFactory::curveToLineString() for valid options.

double
get_Area
() const¶ Get the area of the surface object.
For polygons the area is computed as the area of the outer ring less the area of all internal rings.
This method relates to the SFCOM ISurface::get_Area() method.
 Return
the area of the feature in square units of the spatial reference system in use.

int
WkbSize
() const¶ Returns size of related binary representation.
This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.
This method relates to the SFCOM IWks::WkbSize() method.
This method is the same as the C function OGR_G_WkbSize().
 Return
size of binary representation in bytes.

OGRErr
importFromWkb
(const unsigned char *pabyData, int nSize, OGRwkbVariant eWkbVariant, int &nBytesConsumedOut)¶ Assign geometry from well known binary data.
The object must have already been instantiated as the correct derived type of geometry object to match the binaries type. This method is used by the OGRGeometryFactory class, but not normally called by application code.
This method relates to the SFCOM IWks::ImportFromWKB() method.
This method is the same as the C function OGR_G_ImportFromWkb().
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Since
GDAL 2.3
 Parameters
pabyData
: the binary input data.nSize
: the size of pabyData in bytes, or 1 if not known.eWkbVariant
: if wkbVariantPostGIS1, special interpretation is done for curve geometries codenBytesConsumedOut
: output parameter. Number of bytes consumed.

OGRErr
exportToWkb
(OGRwkbByteOrder eByteOrder, unsigned char *pabyData, OGRwkbVariant eWkbVariant = wkbVariantOldOgc) const¶ Convert a geometry into well known binary format.
This method relates to the SFCOM IWks::ExportToWKB() method.
This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.
 Return
Currently OGRERR_NONE is always returned.
 Parameters
eByteOrder
: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.pabyData
: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.eWkbVariant
: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

OGRErr
importFromWkt
(const char **ppszInput)¶ deprecated

std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const¶ Export a curve polygon to WKT.
 Return
WKT representation of the curve polygon.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

int
getDimension
() const¶ Get the dimension of this object.
This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).
This method is the same as the C function OGR_G_GetDimension().
 Return
0 for points, 1 for lines and 2 for surfaces.

void
getEnvelope
(OGREnvelope *psEnvelope) const¶ Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope().
 Parameters
psEnvelope
: the structure in which to place the results.

void
getEnvelope
(OGREnvelope3D *psEnvelope) const¶ Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope3D().
 Since
OGR 1.9.0
 Parameters
psEnvelope
: the structure in which to place the results.

OGRPolygon *
CurvePolyToPoly
(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const¶ Return a polygon from a curve polygon.
This method is the same as C function OGR_G_CurvePolyToPoly().
The returned geometry is a new instance whose ownership belongs to the caller.
 Return
a linestring
 Since
OGR 2.0
 Parameters
dfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.papszOptions
: options as a nullterminated list of strings. Unused for now. Must be set to NULL.

OGRBoolean
Equals
(const OGRGeometry *) const¶ Returns TRUE if two geometries are equivalent.
This operation implements the SQL/MM ST_OrderingEquals() operation.
The comparison is done in a structural way, that is to say that the geometry types must be identical, as well as the number and ordering of subgeometries and vertices. Or equivalently, two geometries are considered equal by this method if their WKT/WKB representation is equal. Note: this must be distinguished for equality in a spatial way (which is the purpose of the ST_Equals() operation).
This method is the same as the C function OGR_G_Equals().
 Return
TRUE if equivalent or FALSE otherwise.

OGRBoolean
Intersects
(const OGRGeometry *poOtherGeom) const¶ Do these features intersect?
Determines whether two geometries intersect. If GEOS is enabled, then this is done in rigorous fashion otherwise TRUE is returned if the envelopes (bounding boxes) of the two geometries overlap.
The poOtherGeom argument may be safely NULL, but in this case the method will always return TRUE. That is, a NULL geometry is treated as being everywhere.
This method is the same as the C function OGR_G_Intersects().
 Return
TRUE if the geometries intersect, otherwise FALSE.
 Parameters
poOtherGeom
: the other geometry to test against.

OGRBoolean
Contains
(const OGRGeometry *poOtherGeom) const¶ Test for containment.
Tests if actual geometry object contains the passed geometry.
Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.
This method is the same as the C function OGR_G_Contains().
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
 Return
TRUE if poOtherGeom contains this geometry, otherwise FALSE.
 Parameters
poOtherGeom
: the geometry to compare to this geometry.

void
setCoordinateDimension
(int nDimension)¶ Set the coordinate dimension.
This method sets the explicit coordinate dimension. Setting the coordinate dimension of a geometry to 2 should zero out any existing Z values. Setting the dimension of a geometry collection, a compound curve, a polygon, etc. will affect the children geometries. This will also remove the M dimension if present before this call.
 Parameters
nNewDimension
: New coordinate dimension value, either 2 or 3.

void
set3D
(OGRBoolean bIs3D)¶ Add or remove the Z coordinate dimension.
This method adds or removes the explicit Z coordinate dimension. Removing the Z coordinate dimension of a geometry will remove any existing Z values. Adding the Z dimension to a geometry collection, a compound curve, a polygon, etc. will affect the children geometries.
 Since
GDAL 2.1
 Parameters
bIs3D
: Should the geometry have a Z dimension, either TRUE or FALSE.

void
setMeasured
(OGRBoolean bIsMeasured)¶ Add or remove the M coordinate dimension.
This method adds or removes the explicit M coordinate dimension. Removing the M coordinate dimension of a geometry will remove any existing M values. Adding the M dimension to a geometry collection, a compound curve, a polygon, etc. will affect the children geometries.
 Since
GDAL 2.1
 Parameters
bIsMeasured
: Should the geometry have a M dimension, either TRUE or FALSE.

void
assignSpatialReference
(OGRSpatialReference *poSR)¶ Assign spatial reference to this object.
Any existing spatial reference is replaced, but under no circumstances does this result in the object being reprojected. It is just changing the interpretation of the existing geometry. Note that assigning a spatial reference increments the reference count on the OGRSpatialReference, but does not copy it.
Starting with GDAL 2.3, this will also assign the spatial reference to potential subgeometries of the geometry (OGRGeometryCollection, OGRCurvePolygon/OGRPolygon, OGRCompoundCurve, OGRPolyhedralSurface and their derived classes).
This is similar to the SFCOM IGeometry::put_SpatialReference() method.
This method is the same as the C function OGR_G_AssignSpatialReference().
 Parameters
poSR
: new spatial reference system to apply.

OGRErr
addRing
(OGRCurve *poNewRing)¶ Add a ring to a polygon.
If the polygon has no external ring (it is empty) this will be used as the external ring, otherwise it is used as an internal ring. The passed OGRCurve remains the responsibility of the caller (an internal copy is made).
This method has no SFCOM analog.
 Return
OGRERR_NONE in case of success
 Parameters
poNewRing
: ring to be added to the polygon.

OGRErr
addRingDirectly
(OGRCurve *poNewRing)¶ Add a ring to a polygon.
If the polygon has no external ring (it is empty) this will be used as the external ring, otherwise it is used as an internal ring. Ownership of the passed ring is assumed by the OGRCurvePolygon, but otherwise this method operates the same as OGRCurvePolygon::AddRing().
This method has no SFCOM analog.
 Return
OGRERR_NONE in case of success
 Parameters
poNewRing
: ring to be added to the polygon.

OGRCurve *
getExteriorRingCurve
()¶ Fetch reference to external polygon ring.
Note that the returned ring pointer is to an internal data object of the OGRCurvePolygon. It should not be modified or deleted by the application, and the pointer is only valid till the polygon is next modified. Use the OGRGeometry::clone() method to make a separate copy within the application.
Relates to the Simple Features for COM (SFCOM) IPolygon::get_ExteriorRing() method. TODO(rouault): What does that mean?
 Return
pointer to external ring. May be NULL if the OGRCurvePolygon is empty.

const OGRCurve *
getExteriorRingCurve
() const¶ Fetch reference to external polygon ring.
Note that the returned ring pointer is to an internal data object of the OGRCurvePolygon. It should not be modified or deleted by the application, and the pointer is only valid till the polygon is next modified. Use the OGRGeometry::clone() method to make a separate copy within the application.
Relates to the SFCOM IPolygon::get_ExteriorRing() method.
 Return
pointer to external ring. May be NULL if the OGRCurvePolygon is empty.

int
getNumInteriorRings
() const¶ Fetch the number of internal rings.
Relates to the SFCOM IPolygon::get_NumInteriorRings() method.
 Return
count of internal rings, zero or more.

OGRCurve *
getInteriorRingCurve
(int iRing)¶ Fetch reference to indicated internal ring.
Note that the returned ring pointer is to an internal data object of the OGRCurvePolygon. It should not be modified or deleted by the application, and the pointer is only valid till the polygon is next modified. Use the OGRGeometry::clone() method to make a separate copy within the application.
Relates to the SFCOM IPolygon::get_InternalRing() method.
 Return
pointer to interior ring. May be NULL.
 Parameters
iRing
: internal ring index from 0 to getNumInteriorRings()  1.

const OGRCurve *
getInteriorRingCurve
(int iRing) const¶ Fetch reference to indicated internal ring.
Note that the returned ring pointer is to an internal data object of the OGRCurvePolygon. It should not be modified or deleted by the application, and the pointer is only valid till the polygon is next modified. Use the OGRGeometry::clone() method to make a separate copy within the application.
Relates to the SFCOM IPolygon::get_InternalRing() method.
 Return
pointer to interior ring. May be NULL.
 Parameters
iRing
: internal ring index from 0 to getNumInteriorRings()  1.

OGRCurve *
stealExteriorRingCurve
()¶ “Steal” reference to external ring.
After the call to that function, only call to stealInteriorRing() or destruction of the OGRCurvePolygon is valid. Other operations may crash.
 Return
pointer to external ring. May be NULL if the OGRCurvePolygon is empty.

OGRErr
removeRing
(int iIndex, bool bDelete = true)¶ Remove a geometry from the container.
Removing a geometry will cause the geometry count to drop by one, and all “higher” geometries will shuffle down one in index.
There is no SFCOM analog to this method.
 Return
OGRERR_NONE if successful, or OGRERR_FAILURE if the index is out of range.
 Parameters
iIndex
: the index of the geometry to delete. A value of 1 is a special flag meaning that all geometries should be removed.bDelete
: if true the geometry will be deallocated, otherwise it will not. The default is true as the container is considered to own the geometries in it.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.

void
swapXY
()¶ Swap x and y coordinates.
 Since
OGR 1.8.0
OGRMultiPoint class¶

class
OGRMultiPoint
: public OGRGeometryCollection¶ A collection of OGRPoint.
Public Functions

OGRMultiPoint
()¶ Create an empty multi point collection.

OGRMultiPoint
(const OGRMultiPoint &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRMultiPoint &
operator=
(const OGRMultiPoint &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

OGRErr
importFromWkt
(const char **ppszInput)¶ deprecated

std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const¶ Export a multipoint to WKT.
 Return
WKT representation of the multipoint.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

int
getDimension
() const¶ Get the dimension of this object.
This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).
This method is the same as the C function OGR_G_GetDimension().
 Return
0 for points, 1 for lines and 2 for surfaces.

OGRGeometryCollection *
toUpperClass
()¶ Return pointer of this in upper class.

const OGRGeometryCollection *
toUpperClass
() const¶ Return pointer of this in upper class.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.

OGRBoolean
hasCurveGeometry
(int bLookForNonLinear = FALSE) const¶ Returns if this geometry is or has curve geometry.
Returns if a geometry is, contains or may contain a CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE.
If bLookForNonLinear is set to TRUE, it will be actually looked if the geometry or its subgeometries are or contain a nonlinear geometry in them. In which case, if the method returns TRUE, it means that getLinearGeometry() would return an approximate version of the geometry. Otherwise, getLinearGeometry() would do a conversion, but with just converting container type, like COMPOUNDCURVE > LINESTRING, MULTICURVE > MULTILINESTRING or MULTISURFACE > MULTIPOLYGON, resulting in a “lossless” conversion.
This method is the same as the C function OGR_G_HasCurveGeometry().
 Return
TRUE if this geometry is or has curve geometry.
 Since
GDAL 2.0
 Parameters
bLookForNonLinear
: set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

OGRMultiLineString class¶

class
OGRMultiLineString
: public OGRMultiCurve¶ A collection of OGRLineString.
Public Types

typedef OGRLineString
ChildType
¶ Type of child elements.
Public Functions

OGRMultiLineString
()¶ Create an empty multi line string collection.

OGRMultiLineString
(const OGRMultiLineString &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRMultiLineString &
operator=
(const OGRMultiLineString &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const¶ Export a multilinestring to WKT.
 Return
WKT representation of the multilinestring.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

OGRBoolean
hasCurveGeometry
(int bLookForNonLinear = FALSE) const¶ Returns if this geometry is or has curve geometry.
Returns if a geometry is, contains or may contain a CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE.
If bLookForNonLinear is set to TRUE, it will be actually looked if the geometry or its subgeometries are or contain a nonlinear geometry in them. In which case, if the method returns TRUE, it means that getLinearGeometry() would return an approximate version of the geometry. Otherwise, getLinearGeometry() would do a conversion, but with just converting container type, like COMPOUNDCURVE > LINESTRING, MULTICURVE > MULTILINESTRING or MULTISURFACE > MULTIPOLYGON, resulting in a “lossless” conversion.
This method is the same as the C function OGR_G_HasCurveGeometry().
 Return
TRUE if this geometry is or has curve geometry.
 Since
GDAL 2.0
 Parameters
bLookForNonLinear
: set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

OGRGeometryCollection *
toUpperClass
()¶ Return pointer of this in upper class.

const OGRGeometryCollection *
toUpperClass
() const¶ Return pointer of this in upper class.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.
Public Static Functions

OGRMultiCurve *
CastToMultiCurve
(OGRMultiLineString *poMLS)¶ Cast to multicurve.
The passed in geometry is consumed and a new one returned.
 Return
new geometry.
 Parameters
poMLS
: the input geometry  ownership is passed to the method.

typedef OGRLineString
OGRMultiPolygon class¶

class
OGRMultiPolygon
: public OGRMultiSurface¶ A collection of nonoverlapping OGRPolygon.
Public Types

typedef OGRPolygon
ChildType
¶ Type of child elements.
Public Functions

OGRMultiPolygon
()¶ Create an empty multi polygon collection.

OGRMultiPolygon
(const OGRMultiPolygon &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRMultiPolygon &
operator=
(const OGRMultiPolygon &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const¶ Export a multipolygon to WKT.
 Return
WKT representation of the multipolygon.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

OGRBoolean
hasCurveGeometry
(int bLookForNonLinear = FALSE) const¶ Returns if this geometry is or has curve geometry.
Returns if a geometry is, contains or may contain a CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE.
If bLookForNonLinear is set to TRUE, it will be actually looked if the geometry or its subgeometries are or contain a nonlinear geometry in them. In which case, if the method returns TRUE, it means that getLinearGeometry() would return an approximate version of the geometry. Otherwise, getLinearGeometry() would do a conversion, but with just converting container type, like COMPOUNDCURVE > LINESTRING, MULTICURVE > MULTILINESTRING or MULTISURFACE > MULTIPOLYGON, resulting in a “lossless” conversion.
This method is the same as the C function OGR_G_HasCurveGeometry().
 Return
TRUE if this geometry is or has curve geometry.
 Since
GDAL 2.0
 Parameters
bLookForNonLinear
: set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

OGRGeometryCollection *
toUpperClass
()¶ Return pointer of this in upper class.

const OGRGeometryCollection *
toUpperClass
() const¶ Return pointer of this in upper class.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.
Public Static Functions

OGRMultiSurface *
CastToMultiSurface
(OGRMultiPolygon *poMP)¶ Cast to multisurface.
The passed in geometry is consumed and a new one returned .
 Return
new geometry.
 Parameters
poMP
: the input geometry  ownership is passed to the method.

typedef OGRPolygon
OGRGeometryCollection class¶

class
OGRGeometryCollection
: public OGRGeometry¶ A collection of 1 or more geometry objects.
All geometries must share a common spatial reference system, and Subclasses may impose additional restrictions on the contents.
Subclassed by OGRMultiCurve, OGRMultiPoint, OGRMultiSurface
Public Types

typedef OGRGeometry
ChildType
¶ Type of child elements.
Public Functions

OGRGeometryCollection
()¶ Create an empty geometry collection.

OGRGeometryCollection
(const OGRGeometryCollection &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRGeometryCollection &
operator=
(const OGRGeometryCollection &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

OGRGeometry *
clone
() const¶ Make a copy of this object.
This method relates to the SFCOM IGeometry::clone() method.
This method is the same as the C function OGR_G_Clone().
 Return
a new object instance with the same geometry, and spatial reference system as the original.

void
empty
()¶ Clear geometry information.
This restores the geometry to its initial state after construction, and before assignment of actual geometry.
This method relates to the SFCOM IGeometry::Empty() method.
This method is the same as the C function OGR_G_Empty().

OGRErr
transform
(OGRCoordinateTransformation *poCT)¶ Apply arbitrary coordinate transformation to geometry.
This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.
Note that this method does not require that the geometry already have a spatial reference system. It will be assumed that they can be treated as having the source spatial reference system of the OGRCoordinateTransformation object, and the actual SRS of the geometry will be ignored. On successful completion the output OGRSpatialReference of the OGRCoordinateTransformation will be assigned to the geometry.
This method is the same as the C function OGR_G_Transform().
 Return
OGRERR_NONE on success or an error code.
 Parameters
poCT
: the transformation to apply.

void
flattenTo2D
()¶ Convert geometry to strictly 2D.
In a sense this converts all Z coordinates to 0.0.
This method is the same as the C function OGR_G_FlattenTo2D().

OGRBoolean
IsEmpty
() const¶ Returns TRUE (nonzero) if the object has no points.
Normally this returns FALSE except between when an object is instantiated and points have been assigned.
This method relates to the SFCOM IGeometry::IsEmpty() method.
 Return
TRUE if object is empty, otherwise FALSE.

void
segmentize
(double dfMaxLength)¶ Modify the geometry such it has no segment longer then the given distance.
Add intermediate vertices to a geometry.
Interpolated points will have Z and M values (if needed) set to 0. Distance computation is performed in 2d only
This function is the same as the C function OGR_G_Segmentize()
This method modifies the geometry to add intermediate vertices if necessary so that the maximum length between 2 consecutive vertices is lower than dfMaxLength.
 Parameters
dfMaxLength
: the maximum distance between 2 points after segmentization
 Parameters
dfMaxLength
: maximum length between 2 consecutive vertices.

OGRBoolean
hasCurveGeometry
(int bLookForNonLinear = FALSE) const¶ Returns if this geometry is or has curve geometry.
Returns if a geometry is, contains or may contain a CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE.
If bLookForNonLinear is set to TRUE, it will be actually looked if the geometry or its subgeometries are or contain a nonlinear geometry in them. In which case, if the method returns TRUE, it means that getLinearGeometry() would return an approximate version of the geometry. Otherwise, getLinearGeometry() would do a conversion, but with just converting container type, like COMPOUNDCURVE > LINESTRING, MULTICURVE > MULTILINESTRING or MULTISURFACE > MULTIPOLYGON, resulting in a “lossless” conversion.
This method is the same as the C function OGR_G_HasCurveGeometry().
 Return
TRUE if this geometry is or has curve geometry.
 Since
GDAL 2.0
 Parameters
bLookForNonLinear
: set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

OGRGeometry *
getCurveGeometry
(const char *const *papszOptions = nullptr) const¶ Return curve version of this geometry.
Returns a geometry that has possibly CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by deapproximating curve geometries.
If the geometry has no curve portion, the returned geometry will be a clone of it.
The ownership of the returned geometry belongs to the caller.
The reverse method is OGRGeometry::getLinearGeometry().
This function is the same as C function OGR_G_GetCurveGeometry().
 Return
a new geometry.
 Since
GDAL 2.0
 Parameters
papszOptions
: options as a nullterminated list of strings. Unused for now. Must be set to NULL.

OGRGeometry *
getLinearGeometry
(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const¶ Return, possibly approximate, noncurve version of this geometry.
Returns a geometry that has no CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by approximating curve geometries.
The ownership of the returned geometry belongs to the caller.
The reverse method is OGRGeometry::getCurveGeometry().
This method is the same as the C function OGR_G_GetLinearGeometry().
 Return
a new geometry.
 Since
GDAL 2.0
 Parameters
dfMaxAngleStepSizeDegrees
: the largest step in degrees along the arc, zero to use the default setting.papszOptions
: options as a nullterminated list of strings. See OGRGeometryFactory::curveToLineString() for valid options.

int
WkbSize
() const¶ Returns size of related binary representation.
This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.
This method relates to the SFCOM IWks::WkbSize() method.
This method is the same as the C function OGR_G_WkbSize().
 Return
size of binary representation in bytes.

OGRErr
importFromWkb
(const unsigned char *pabyData, int nSize, OGRwkbVariant eWkbVariant, int &nBytesConsumedOut)¶ Assign geometry from well known binary data.
The object must have already been instantiated as the correct derived type of geometry object to match the binaries type. This method is used by the OGRGeometryFactory class, but not normally called by application code.
This method relates to the SFCOM IWks::ImportFromWKB() method.
This method is the same as the C function OGR_G_ImportFromWkb().
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Since
GDAL 2.3
 Parameters
pabyData
: the binary input data.nSize
: the size of pabyData in bytes, or 1 if not known.eWkbVariant
: if wkbVariantPostGIS1, special interpretation is done for curve geometries codenBytesConsumedOut
: output parameter. Number of bytes consumed.

OGRErr
exportToWkb
(OGRwkbByteOrder eByteOrder, unsigned char *pabyData, OGRwkbVariant eWkbVariant = wkbVariantOldOgc) const¶ Convert a geometry into well known binary format.
This method relates to the SFCOM IWks::ExportToWKB() method.
This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.
 Return
Currently OGRERR_NONE is always returned.
 Parameters
eByteOrder
: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.pabyData
: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.eWkbVariant
: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

OGRErr
importFromWkt
(const char **ppszInput)¶ deprecated

std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const¶ Export a geometry collection to WKT.
 Return
WKT representation of the geometry collection.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

double
get_Length
() const¶ Compute the length of a multicurve.
The length is computed as the sum of the length of all members in this collection.
 Note
No warning will be issued if a member of the collection does not support the get_Length method.
 Return
computed length.

double
get_Area
() const¶ Compute area of geometry collection.
The area is computed as the sum of the areas of all members in this collection.
 Note
No warning will be issued if a member of the collection does not support the get_Area method.
 Return
computed area.

int
getDimension
() const¶ Get the dimension of this object.
This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).
This method is the same as the C function OGR_G_GetDimension().
 Return
0 for points, 1 for lines and 2 for surfaces.

void
getEnvelope
(OGREnvelope *psEnvelope) const¶ Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope().
 Parameters
psEnvelope
: the structure in which to place the results.

void
getEnvelope
(OGREnvelope3D *psEnvelope) const¶ Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope3D().
 Since
OGR 1.9.0
 Parameters
psEnvelope
: the structure in which to place the results.

int
getNumGeometries
() const¶ Fetch number of geometries in container.
This method relates to the SFCOM IGeometryCollect::get_NumGeometries() method.
 Return
count of children geometries. May be zero.

OGRGeometry *
getGeometryRef
(int i)¶ Fetch geometry from container.
This method returns a pointer to a geometry within the container. The returned geometry remains owned by the container, and should not be modified. The pointer is only valid until the next change to the geometry container. Use IGeometry::clone() to make a copy.
This method relates to the SFCOM IGeometryCollection::get_Geometry() method.
 Return
pointer to requested geometry.
 Parameters
i
: the index of the geometry to fetch, between 0 and getNumGeometries()  1.

const OGRGeometry *
getGeometryRef
(int i) const¶ Fetch geometry from container.
This method returns a pointer to a geometry within the container. The returned geometry remains owned by the container, and should not be modified. The pointer is only valid until the next change to the geometry container. Use IGeometry::clone() to make a copy.
This method relates to the SFCOM IGeometryCollection::get_Geometry() method.
 Return
pointer to requested geometry.
 Parameters
i
: the index of the geometry to fetch, between 0 and getNumGeometries()  1.

OGRBoolean
Equals
(const OGRGeometry *) const¶ Returns TRUE if two geometries are equivalent.
This operation implements the SQL/MM ST_OrderingEquals() operation.
The comparison is done in a structural way, that is to say that the geometry types must be identical, as well as the number and ordering of subgeometries and vertices. Or equivalently, two geometries are considered equal by this method if their WKT/WKB representation is equal. Note: this must be distinguished for equality in a spatial way (which is the purpose of the ST_Equals() operation).
This method is the same as the C function OGR_G_Equals().
 Return
TRUE if equivalent or FALSE otherwise.

void
setCoordinateDimension
(int nDimension)¶ Set the coordinate dimension.
This method sets the explicit coordinate dimension. Setting the coordinate dimension of a geometry to 2 should zero out any existing Z values. Setting the dimension of a geometry collection, a compound curve, a polygon, etc. will affect the children geometries. This will also remove the M dimension if present before this call.
 Parameters
nNewDimension
: New coordinate dimension value, either 2 or 3.

void
set3D
(OGRBoolean bIs3D)¶ Add or remove the Z coordinate dimension.
This method adds or removes the explicit Z coordinate dimension. Removing the Z coordinate dimension of a geometry will remove any existing Z values. Adding the Z dimension to a geometry collection, a compound curve, a polygon, etc. will affect the children geometries.
 Since
GDAL 2.1
 Parameters
bIs3D
: Should the geometry have a Z dimension, either TRUE or FALSE.

void
setMeasured
(OGRBoolean bIsMeasured)¶ Add or remove the M coordinate dimension.
This method adds or removes the explicit M coordinate dimension. Removing the M coordinate dimension of a geometry will remove any existing M values. Adding the M dimension to a geometry collection, a compound curve, a polygon, etc. will affect the children geometries.
 Since
GDAL 2.1
 Parameters
bIsMeasured
: Should the geometry have a M dimension, either TRUE or FALSE.

OGRErr
addGeometry
(const OGRGeometry *poNewGeom)¶ Add a geometry to the container.
Some subclasses of OGRGeometryCollection restrict the types of geometry that can be added, and may return an error. The passed geometry is cloned to make an internal copy.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_AddGeometry().
 Return
OGRERR_NONE if successful, or OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the type of geometry container.
 Parameters
poNewGeom
: geometry to add to the container.

OGRErr
addGeometryDirectly
(OGRGeometry *poNewGeom)¶ Add a geometry directly to the container.
Some subclasses of OGRGeometryCollection restrict the types of geometry that can be added, and may return an error. Ownership of the passed geometry is taken by the container rather than cloning as addGeometry() does.
This method is the same as the C function OGR_G_AddGeometryDirectly().
There is no SFCOM analog to this method.
 Return
OGRERR_NONE if successful, or OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the type of geometry container.
 Parameters
poNewGeom
: geometry to add to the container.

OGRErr
removeGeometry
(int iIndex, int bDelete = TRUE)¶ Remove a geometry from the container.
Removing a geometry will cause the geometry count to drop by one, and all “higher” geometries will shuffle down one in index.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_RemoveGeometry().
 Return
OGRERR_NONE if successful, or OGRERR_FAILURE if the index is out of range.
 Parameters
iGeom
: the index of the geometry to delete. A value of 1 is a special flag meaning that all geometries should be removed.bDelete
: if TRUE the geometry will be deallocated, otherwise it will not. The default is TRUE as the container is considered to own the geometries in it.

void
assignSpatialReference
(OGRSpatialReference *poSR)¶ Assign spatial reference to this object.
Any existing spatial reference is replaced, but under no circumstances does this result in the object being reprojected. It is just changing the interpretation of the existing geometry. Note that assigning a spatial reference increments the reference count on the OGRSpatialReference, but does not copy it.
Starting with GDAL 2.3, this will also assign the spatial reference to potential subgeometries of the geometry (OGRGeometryCollection, OGRCurvePolygon/OGRPolygon, OGRCompoundCurve, OGRPolyhedralSurface and their derived classes).
This is similar to the SFCOM IGeometry::put_SpatialReference() method.
This method is the same as the C function OGR_G_AssignSpatialReference().
 Parameters
poSR
: new spatial reference system to apply.

void
closeRings
()¶ Force rings to be closed.
If this geometry, or any contained geometries has polygon rings that are not closed, they will be closed by adding the starting point at the end.

void
swapXY
()¶ Swap x and y coordinates.
 Since
OGR 1.8.0

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.
Public Static Functions

OGRGeometryCollection *
CastToGeometryCollection
(OGRGeometryCollection *poSrc)¶ Cast to geometry collection.
This methods cast a derived class of geometry collection to a plain geometry collection.
The passed in geometry is consumed and a new one returned (or NULL in case of failure).
 Return
new geometry.
 Since
GDAL 2.2
 Parameters
poSrc
: the input geometry  ownership is passed to the method.

typedef OGRGeometry
OGRMultiCurve class¶

class
OGRMultiCurve
: public OGRGeometryCollection¶ A collection of OGRCurve.
 Since
GDAL 2.0
Subclassed by OGRMultiLineString
Public Functions

OGRMultiCurve
()¶ Create an empty multi curve collection.

OGRMultiCurve
(const OGRMultiCurve &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRMultiCurve &
operator=
(const OGRMultiCurve &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

OGRErr
importFromWkt
(const char **ppszInput)¶ deprecated

std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const¶ Export a multicurve to WKT.
 Return
WKT representation of the multicurve.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

int
getDimension
() const¶ Get the dimension of this object.
This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).
This method is the same as the C function OGR_G_GetDimension().
 Return
0 for points, 1 for lines and 2 for surfaces.

OGRBoolean
hasCurveGeometry
(int bLookForNonLinear = FALSE) const¶ Returns if this geometry is or has curve geometry.
Returns if a geometry is, contains or may contain a CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE.
If bLookForNonLinear is set to TRUE, it will be actually looked if the geometry or its subgeometries are or contain a nonlinear geometry in them. In which case, if the method returns TRUE, it means that getLinearGeometry() would return an approximate version of the geometry. Otherwise, getLinearGeometry() would do a conversion, but with just converting container type, like COMPOUNDCURVE > LINESTRING, MULTICURVE > MULTILINESTRING or MULTISURFACE > MULTIPOLYGON, resulting in a “lossless” conversion.
This method is the same as the C function OGR_G_HasCurveGeometry().
 Return
TRUE if this geometry is or has curve geometry.
 Since
GDAL 2.0
 Parameters
bLookForNonLinear
: set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

OGRGeometryCollection *
toUpperClass
()¶ Return pointer of this in upper class.

const OGRGeometryCollection *
toUpperClass
() const¶ Return pointer of this in upper class.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.
Public Static Functions

OGRMultiLineString *
CastToMultiLineString
(OGRMultiCurve *poMC)¶ Cast to multi line string.
This method should only be called if the multicurve actually only contains instances of OGRLineString. This can be verified if hasCurveGeometry(TRUE) returns FALSE. It is not intended to approximate circular curves. For that use getLinearGeometry().
The passed in geometry is consumed and a new one returned (or NULL in case of failure).
 Return
new geometry.
 Parameters
poMC
: the input geometry  ownership is passed to the method.
OGRMultiSurface class¶

class
OGRMultiSurface
: public OGRGeometryCollection¶ A collection of nonoverlapping OGRSurface.
 Since
GDAL 2.0
Subclassed by OGRMultiPolygon
Public Types

typedef OGRSurface
ChildType
¶ Type of child elements.
Public Functions

OGRMultiSurface
()¶ Create an empty multi surface collection.

OGRMultiSurface
(const OGRMultiSurface &other)¶ Copy constructor.
Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.
 Since
GDAL 2.1

OGRMultiSurface &
operator=
(const OGRMultiSurface &other)¶ Assignment operator.
Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.
 Since
GDAL 2.1

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

OGRErr
importFromWkt
(const char **ppszInput)¶ deprecated

std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const¶ Export a geometry collection to WKT.
 Return
WKT representation of the geometry collection.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

OGRErr
PointOnSurface
(OGRPoint *poPoint) const¶ This method relates to the SFCOM IMultiSurface::get_PointOnSurface() method.
NOTE: Only implemented when GEOS included in build.
 Return
OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise.
 Parameters
poPoint
: point to be set with an internal point.

int
getDimension
() const¶ Get the dimension of this object.
This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).
This method is the same as the C function OGR_G_GetDimension().
 Return
0 for points, 1 for lines and 2 for surfaces.

OGRBoolean
hasCurveGeometry
(int bLookForNonLinear = FALSE) const¶ Returns if this geometry is or has curve geometry.
Returns if a geometry is, contains or may contain a CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE.
If bLookForNonLinear is set to TRUE, it will be actually looked if the geometry or its subgeometries are or contain a nonlinear geometry in them. In which case, if the method returns TRUE, it means that getLinearGeometry() would return an approximate version of the geometry. Otherwise, getLinearGeometry() would do a conversion, but with just converting container type, like COMPOUNDCURVE > LINESTRING, MULTICURVE > MULTILINESTRING or MULTISURFACE > MULTIPOLYGON, resulting in a “lossless” conversion.
This method is the same as the C function OGR_G_HasCurveGeometry().
 Return
TRUE if this geometry is or has curve geometry.
 Since
GDAL 2.0
 Parameters
bLookForNonLinear
: set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

OGRGeometryCollection *
toUpperClass
()¶ Return pointer of this in upper class.

const OGRGeometryCollection *
toUpperClass
() const¶ Return pointer of this in upper class.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.
Public Static Functions

OGRMultiPolygon *
CastToMultiPolygon
(OGRMultiSurface *poMS)¶ Cast to multipolygon.
This method should only be called if the multisurface actually only contains instances of OGRPolygon. This can be verified if hasCurveGeometry(TRUE) returns FALSE. It is not intended to approximate curve polygons. For that use getLinearGeometry().
The passed in geometry is consumed and a new one returned (or NULL in case of failure).
 Return
new geometry.
 Parameters
poMS
: the input geometry  ownership is passed to the method.
OGRPolyhedralSurface class¶

class
OGRPolyhedralSurface
: public OGRSurface¶ PolyhedralSurface class.
 Since
GDAL 2.2
Subclassed by OGRTriangulatedSurface
Public Types

typedef OGRPolygon
ChildType
¶ Type of child elements.
Public Functions

OGRPolyhedralSurface
()¶ Create an empty PolyhedralSurface.

OGRPolyhedralSurface
(const OGRPolyhedralSurface &poGeom)¶ Copy constructor.

~OGRPolyhedralSurface
()¶ Destructor.

OGRPolyhedralSurface &
operator=
(const OGRPolyhedralSurface &other)¶ Assignment operator.

int
WkbSize
() const¶ Returns size of related binary representation.
This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.
This method relates to the SFCOM IWks::WkbSize() method.
This method is the same as the C function OGR_G_WkbSize().
 Return
size of binary representation in bytes.

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryType
getGeometryType
() const¶ Returns the WKB Type of PolyhedralSurface.

OGRErr
importFromWkb
(const unsigned char *pabyData, int nSize, OGRwkbVariant eWkbVariant, int &nBytesConsumedOut)¶ Assign geometry from well known binary data.
The object must have already been instantiated as the correct derived type of geometry object to match the binaries type. This method is used by the OGRGeometryFactory class, but not normally called by application code.
This method relates to the SFCOM IWks::ImportFromWKB() method.
This method is the same as the C function OGR_G_ImportFromWkb().
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Since
GDAL 2.3
 Parameters
pabyData
: the binary input data.nSize
: the size of pabyData in bytes, or 1 if not known.eWkbVariant
: if wkbVariantPostGIS1, special interpretation is done for curve geometries codenBytesConsumedOut
: output parameter. Number of bytes consumed.

OGRErr
exportToWkb
(OGRwkbByteOrder eByteOrder, unsigned char *pabyData, OGRwkbVariant eWkbVariant = wkbVariantOldOgc) const¶ Convert a geometry into well known binary format.
This method relates to the SFCOM IWks::ExportToWKB() method.
This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.
 Return
Currently OGRERR_NONE is always returned.
 Parameters
eByteOrder
: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.pabyData
: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.eWkbVariant
: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

OGRErr
importFromWkt
(const char **ppszInput)¶ deprecated

std::string
exportToWkt
(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const¶ Export a polyhedral surface to WKT.
 Return
WKT representation of the polyhedral surface.
 Parameters
opts
: Output options.err
: Pointer to error code, if desired.

int
getDimension
() const¶ Get the dimension of this object.
This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).
This method is the same as the C function OGR_G_GetDimension().
 Return
0 for points, 1 for lines and 2 for surfaces.

void
empty
()¶ Clear geometry information.
This restores the geometry to its initial state after construction, and before assignment of actual geometry.
This method relates to the SFCOM IGeometry::Empty() method.
This method is the same as the C function OGR_G_Empty().

OGRGeometry *
clone
() const¶ Make a copy of this object.
This method relates to the SFCOM IGeometry::clone() method.
This method is the same as the C function OGR_G_Clone().
 Return
a new object instance with the same geometry, and spatial reference system as the original.

void
getEnvelope
(OGREnvelope *psEnvelope) const¶ Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope().
 Parameters
psEnvelope
: the structure in which to place the results.

void
getEnvelope
(OGREnvelope3D *psEnvelope) const¶ Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.
This method is the same as the C function OGR_G_GetEnvelope3D().
 Since
OGR 1.9.0
 Parameters
psEnvelope
: the structure in which to place the results.

void
flattenTo2D
()¶ Convert geometry to strictly 2D.
In a sense this converts all Z coordinates to 0.0.
This method is the same as the C function OGR_G_FlattenTo2D().

OGRErr
transform
(OGRCoordinateTransformation *poCT)¶ Apply arbitrary coordinate transformation to geometry.
This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.
Note that this method does not require that the geometry already have a spatial reference system. It will be assumed that they can be treated as having the source spatial reference system of the OGRCoordinateTransformation object, and the actual SRS of the geometry will be ignored. On successful completion the output OGRSpatialReference of the OGRCoordinateTransformation will be assigned to the geometry.
This method is the same as the C function OGR_G_Transform().
 Return
OGRERR_NONE on success or an error code.
 Parameters
poCT
: the transformation to apply.

OGRBoolean
Equals
(const OGRGeometry *) const¶ Returns TRUE if two geometries are equivalent.
This operation implements the SQL/MM ST_OrderingEquals() operation.
The comparison is done in a structural way, that is to say that the geometry types must be identical, as well as the number and ordering of subgeometries and vertices. Or equivalently, two geometries are considered equal by this method if their WKT/WKB representation is equal. Note: this must be distinguished for equality in a spatial way (which is the purpose of the ST_Equals() operation).
This method is the same as the C function OGR_G_Equals().
 Return
TRUE if equivalent or FALSE otherwise.

double
get_Area
() const¶ Returns the area enclosed.
This method is built on the SFCGAL library, check it for the definition of the geometry operation. If OGR is built without the SFCGAL library, this method will always return 1.0
 Return
area enclosed by the PolyhedralSurface

OGRErr
PointOnSurface
(OGRPoint *poPoint) const¶ This method relates to the SFCOM ISurface::get_PointOnSurface() method.
NOTE: Only implemented when GEOS included in build.
 Return
OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise.
 Parameters
poPoint
: point to be set with an internal point.

OGRBoolean
hasCurveGeometry
(int bLookForNonLinear = FALSE) const¶ Returns if this geometry is or has curve geometry.
Returns if a geometry is, contains or may contain a CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE.
If bLookForNonLinear is set to TRUE, it will be actually looked if the geometry or its subgeometries are or contain a nonlinear geometry in them. In which case, if the method returns TRUE, it means that getLinearGeometry() would return an approximate version of the geometry. Otherwise, getLinearGeometry() would do a conversion, but with just converting container type, like COMPOUNDCURVE > LINESTRING, MULTICURVE > MULTILINESTRING or MULTISURFACE > MULTIPOLYGON, resulting in a “lossless” conversion.
This method is the same as the C function OGR_G_HasCurveGeometry().
 Return
TRUE if this geometry is or has curve geometry.
 Since
GDAL 2.0
 Parameters
bLookForNonLinear
: set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

OGRErr
addGeometry
(const OGRGeometry *poNewGeom)¶ Add a new geometry to a collection.
Only a POLYGON can be added to a POLYHEDRALSURFACE.
 Return
OGRErr OGRERR_NONE if the polygon is successfully added

OGRErr
addGeometryDirectly
(OGRGeometry *poNewGeom)¶ Add a geometry directly to the container.
This method is the same as the C function OGR_G_AddGeometryDirectly().
There is no SFCOM analog to this method.
 Return
OGRERR_NONE if successful, or OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the type of geometry container.
 Parameters
poNewGeom
: geometry to add to the container.

int
getNumGeometries
() const¶ Fetch number of geometries in PolyhedralSurface.
 Return
count of children geometries. May be zero.

OGRGeometry *
getGeometryRef
(int i)¶ Fetch geometry from container.
This method returns a pointer to an geometry within the container. The returned geometry remains owned by the container, and should not be modified. The pointer is only valid until the next change to the geometry container. Use IGeometry::clone() to make a copy.
 Return
pointer to requested geometry.
 Parameters
i
: the index of the geometry to fetch, between 0 and getNumGeometries()  1.

const OGRGeometry *
getGeometryRef
(int i) const¶ Fetch geometry from container.
This method returns a pointer to an geometry within the container. The returned geometry remains owned by the container, and should not be modified. The pointer is only valid until the next change to the geometry container. Use IGeometry::clone() to make a copy.
 Return
pointer to requested geometry.
 Parameters
i
: the index of the geometry to fetch, between 0 and getNumGeometries()  1.

OGRBoolean
IsEmpty
() const¶ Checks if the PolyhedralSurface is empty.
 Return
TRUE if the PolyhedralSurface is empty, FALSE otherwise

void
setCoordinateDimension
(int nDimension)¶ Set the coordinate dimension.
This method sets the explicit coordinate dimension. Setting the coordinate dimension of a geometry to 2 should zero out any existing Z values. This will also remove the M dimension if present before this call.
 Parameters
nNewDimension
: New coordinate dimension value, either 2 or 3.

void
set3D
(OGRBoolean bIs3D)¶ Set the type as 3D geometry.

void
setMeasured
(OGRBoolean bIsMeasured)¶ Set the type as Measured.

void
swapXY
()¶ Swap x and y coordinates.

OGRErr
removeGeometry
(int iIndex, int bDelete = TRUE)¶ Remove a geometry from the container.
Removing a geometry will cause the geometry count to drop by one, and all “higher” geometries will shuffle down one in index.
 Return
OGRERR_NONE if successful, or OGRERR_FAILURE if the index is out of range.
 Parameters
iGeom
: the index of the geometry to delete. A value of 1 is a special flag meaning that all geometries should be removed.bDelete
: if TRUE the geometry will be deallocated, otherwise it will not. The default is TRUE as the container is considered to own the geometries in it.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.

void
assignSpatialReference
(OGRSpatialReference *poSR)¶ Assign spatial reference to this object.
Any existing spatial reference is replaced, but under no circumstances does this result in the object being reprojected. It is just changing the interpretation of the existing geometry. Note that assigning a spatial reference increments the reference count on the OGRSpatialReference, but does not copy it.
Starting with GDAL 2.3, this will also assign the spatial reference to potential subgeometries of the geometry (OGRGeometryCollection, OGRCurvePolygon/OGRPolygon, OGRCompoundCurve, OGRPolyhedralSurface and their derived classes).
This is similar to the SFCOM IGeometry::put_SpatialReference() method.
This method is the same as the C function OGR_G_AssignSpatialReference().
 Parameters
poSR
: new spatial reference system to apply.
Public Static Functions

OGRMultiPolygon *
CastToMultiPolygon
(OGRPolyhedralSurface *poPS)¶ Casts the OGRPolyhedralSurface to an OGRMultiPolygon.
The passed in geometry is consumed and a new one returned (or NULL in case of failure)
 Return
new geometry.
 Parameters
poPS
: the input geometry  ownership is passed to the method.
OGRTriangle class¶

class
OGRTriangle
: public OGRPolygon¶ Triangle class.
 Since
GDAL 2.2
Public Functions

OGRTriangle
()¶ Constructor.

OGRTriangle
(const OGRPoint &p, const OGRPoint &q, const OGRPoint &r)¶ Construct a triangle from points.
 Parameters
p
: Point 1q
: Point 2r
: Point 3

OGRTriangle
(const OGRTriangle &other)¶ Copy constructor.

OGRTriangle
(const OGRPolygon &other, OGRErr &eErr)¶ Constructs an OGRTriangle from a valid OGRPolygon.
In case of error, NULL is returned.
 Parameters
other
: the Polygon we wish to construct a triangle fromeErr
: encapsulates an error code; contains OGRERR_NONE if the triangle is constructed successfully

OGRTriangle &
operator=
(const OGRTriangle &other)¶ Assignment operator.
 Return
OGRTriangle A copy of other
 Parameters
other
: A triangle passed as a parameter

~OGRTriangle
()¶ Destructor.

const char *
getGeometryName
() const¶ Fetch WKT name for geometry type.
There is no SFCOM analog to this method.
This method is the same as the C function OGR_G_GetGeometryName().
 Return
name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryType
getGeometryType
() const¶ Fetch geometry type.
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
This method is the same as the C function OGR_G_GetGeometryType().
 Return
the geometry type code.

OGRErr
importFromWkb
(const unsigned char *pabyData, int nSize, OGRwkbVariant eWkbVariant, int &nBytesConsumedOut)¶ Assign geometry from well known binary data.
The object must have already been instantiated as the correct derived type of geometry object to match the binaries type. This method is used by the OGRGeometryFactory class, but not normally called by application code.
This method relates to the SFCOM IWks::ImportFromWKB() method.
This method is the same as the C function OGR_G_ImportFromWkb().
 Return
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.
 Since
GDAL 2.3
 Parameters
pabyData
: the binary input data.nSize
: the size of pabyData in bytes, or 1 if not known.eWkbVariant
: if wkbVariantPostGIS1, special interpretation is done for curve geometries codenBytesConsumedOut
: output parameter. Number of bytes consumed.

OGRErr
addRingDirectly
(OGRCurve *poNewRing)¶ Add a ring to a polygon.
If the polygon has no external ring (it is empty) this will be used as the external ring, otherwise it is used as an internal ring. Ownership of the passed ring is assumed by the OGRCurvePolygon, but otherwise this method operates the same as OGRCurvePolygon::AddRing().
This method has no SFCOM analog.
 Return
OGRERR_NONE in case of success
 Parameters
poNewRing
: ring to be added to the polygon.

OGRPolygon *
toUpperClass
()¶ Return pointer of this in upper class.

const OGRPolygon *
toUpperClass
() const¶ Return pointer of this in upper class.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.
OGRTriangulatedSurface class¶

class
OGRTriangulatedSurface
: public OGRPolyhedralSurface¶ TriangulatedSurface class.
 Since
GDAL 2.2
Public Types

typedef OGRTriangle
ChildType
¶ Type of child elements.
Public Functions

OGRTriangulatedSurface
()¶ Constructor.

OGRTriangulatedSurface
(const OGRTriangulatedSurface &other)¶ Copy constructor.

~OGRTriangulatedSurface
()¶ Destructor.

OGRTriangulatedSurface &
operator=
(const OGRTriangulatedSurface &other)¶ Assignment operator.

const char *
getGeometryName
() const¶ Returns the geometry name of the TriangulatedSurface.
 Return
”TIN”

OGRwkbGeometryType
getGeometryType
() const¶ Returns the WKB Type of TriangulatedSurface.

OGRErr
addGeometry
(const OGRGeometry *poNewGeom)¶ Add a new geometry to a collection.
Only a POLYGON can be added to a POLYHEDRALSURFACE.
 Return
OGRErr OGRERR_NONE if the polygon is successfully added

OGRPolyhedralSurface *
toUpperClass
()¶ Return pointer of this in upper class.

const OGRPolyhedralSurface *
toUpperClass
() const¶ Return pointer of this in upper class.

virtual void
accept
(IOGRGeometryVisitor *visitor)¶ Accept a visitor.

virtual void
accept
(IOGRConstGeometryVisitor *visitor) const¶ Accept a visitor.
Public Static Functions

OGRPolyhedralSurface *
CastToPolyhedralSurface
(OGRTriangulatedSurface *poTS)¶ Casts the OGRTriangulatedSurface to an OGRPolyhedralSurface.
The passed in geometry is consumed and a new one returned (or NULL in case of failure)
 Return
new geometry.
 Parameters
poTS
: the input geometry  ownership is passed to the method.