OGRGeometry C++ API

Include file

ogr_geometry.h

OGRGeometryFactory class

class OGRGeometryFactory

Create geometry objects from well known text/binary.

Public Static Functions

static OGRErr createFromWkb(const void*, const OGRSpatialReference*, OGRGeometry**, size_t = static_cast<size_t>(-1), OGRwkbVariant = 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.

パラメータ:
  • 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_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 createFromWkb(const void *pabyData, const OGRSpatialReference*, OGRGeometry**, size_t nSize, OGRwkbVariant eVariant, size_t &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.

Since

GDAL 2.3

パラメータ:
  • 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_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(const char*, const OGRSpatialReference*, OGRGeometry**)

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.

Since

GDAL 2.3

パラメータ:
  • 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_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(const char**, const OGRSpatialReference*, OGRGeometry**)

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:

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);
パラメータ:
  • 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.

戻り値:

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 inline OGRErr createFromWkt(char **ppszInput, const OGRSpatialReference *poSRS, OGRGeometry **ppoGeom)

Deprecated.

Deprecated:

in GDAL 2.3

static OGRErr createFromFgf(const void*, OGRSpatialReference*, OGRGeometry**, int = -1, int* = 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.

パラメータ:
  • 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).

戻り値:

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 OGRGeometry *createFromGML(const char*)

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.

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 returned as curves by default. Stroking to linestrings can be done with OGR_G_ForceTo(hGeom, OGR_GT_GetLinear(OGR_G_GetGeometryType(hGeom)), NULL). A 4 degrees step is used by default, 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.

パラメータ:

pszData -- The GML fragment for the geometry.

戻り値:

a geometry on success, or NULL on error.

static OGRGeometry *createFromGEOS(GEOSContextHandle_t hGEOSCtxt, GEOSGeom)

Builds a OGRGeometry* from a GEOSGeom.

パラメータ:
  • hGEOSCtxt -- GEOS context

  • geosGeom -- GEOS geometry

戻り値:

a OGRGeometry*

static OGRGeometry *createFromGeoJson(const char*, int = -1)

Create geometry from GeoJson fragment.

Since

GDAL 2.3

パラメータ:
  • pszJsonString -- The GeoJSON fragment for the geometry.

  • nSize -- (new in GDAL 3.4) Optional length of the string if it is not null-terminated

戻り値:

a geometry on success, or NULL on error.

static OGRGeometry *createFromGeoJson(const CPLJSONObject &oJSONObject)

Create geometry from GeoJson fragment.

Since

GDAL 2.3

パラメータ:

oJsonObject -- The JSONObject class describes the GeoJSON geometry.

戻り値:

a geometry on success, or NULL on error.

static void destroyGeometry(OGRGeometry*)

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().

パラメータ:

poGeom -- the geometry to deallocate.

static OGRGeometry *createGeometry(OGRwkbGeometryType)

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().

パラメータ:

eGeometryType -- the type code of the geometry class to be instantiated.

戻り値:

the newly create geometry or NULL on failure. Should be freed with OGRGeometryFactory::destroyGeometry() after use.

static OGRGeometry *forceToPolygon(OGRGeometry*)

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 multi-part multipolygon.

パラメータ:

poGeom -- the input geometry - ownership is passed to the method.

戻り値:

new geometry.

static OGRGeometry *forceToLineString(OGRGeometry*, 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).

パラメータ:
  • 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.

戻り値:

new geometry.

static OGRGeometry *forceToMultiPolygon(OGRGeometry*)

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).

戻り値:

new geometry.

static OGRGeometry *forceToMultiPoint(OGRGeometry*)

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).

戻り値:

new geometry.

static OGRGeometry *forceToMultiLineString(OGRGeometry*)

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).

戻り値:

new geometry.

static 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. non-linear 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 de-approximating 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).

Starting with GDAL 3.9, this method honours the dimensionality of eTargetType.

Since

GDAL 2.0

パラメータ:
  • poGeom -- the input geometry - ownership is passed to the method.

  • eTargetType -- target output geometry type.

  • papszOptions -- options as a null-terminated list of strings or NULL.

戻り値:

new geometry, or nullptr in case of error.

static OGRGeometry *removeLowerDimensionSubGeoms(const OGRGeometry *poGeom)

Remove sub-geometries from a geometry collection that do not have the maximum topological dimensionality of the collection.

This is typically to be used as a cleanup phase after running OGRGeometry::MakeValid()

For example, MakeValid() on a polygon can return a geometry collection of polygons and linestrings. Calling this method will return either a polygon or multipolygon by dropping those linestrings.

On a non-geometry collection, this will return a clone of the passed geometry.

Since

GDAL 3.1.0

パラメータ:

poGeom -- input geometry

戻り値:

a new geometry.

static 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 multi-polygon 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 behavior of the shapefile driver)

パラメータ:
  • papoPolygons -- array of geometry pointers - should all be OGRPolygons or OGRCurvePolygons. Ownership of the geometries is passed, but not of the array itself.

  • nPolygonCount -- number of items in papoPolygons

  • pbIsValidGeometry -- value may be set to FALSE if an invalid result is detected. Validity checks vary according to the method used and are are limited to what is needed to link inner rings to outer rings, so a result of TRUE does not mean that OGRGeometry::IsValid() returns TRUE.

  • papszOptions -- a list of strings for passing options

戻り値:

a single resulting geometry (either OGRPolygon, OGRCurvePolygon, OGRMultiPolygon, OGRMultiSurface or OGRGeometryCollection). Returns a POLYGON EMPTY in the case of nPolygonCount being 0.

static bool haveGEOS()

Test if GEOS enabled.

This static method returns TRUE if GEOS support is built into OGR, otherwise it returns FALSE.

戻り値:

TRUE if available, otherwise FALSE.

static OGRGeometry *transformWithOptions(const OGRGeometry *poSrcGeom, OGRCoordinateTransformation *poCT, char **papszOptions, const TransformWithOptionsCache &cache = TransformWithOptionsCache())

Transform a geometry.

パラメータ:
  • poSrcGeom -- source geometry

  • poCT -- coordinate transformation object, or NULL.

  • papszOptions -- options. Including WRAPDATELINE=YES and DATELINEOFFSET=.

  • cache -- Cache. May increase performance if persisted between invocations

戻り値:

(new) transformed geometry.

static 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 straight-line 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.

Since

OGR 1.8.0

パラメータ:
  • dfCenterX -- center X

  • dfCenterY -- center Y

  • dfZ -- center Z

  • dfPrimaryRadius -- X radius of ellipse.

  • dfSecondaryRadius -- Y radius of ellipse.

  • dfRotation -- rotation of the ellipse clockwise.

  • dfStartAngle -- angle to first point on arc (clockwise of X-positive)

  • dfEndAngle -- angle to last point on arc (clockwise of X-positive)

  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • bUseMaxGap -- Optional: whether to honor OGR_ARC_MAX_GAP.

戻り値:

OGRLineString geometry representing an approximation of the arc.

static int GetCurveParameters(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)

Since

GDAL 2.0

パラメータ:
  • x0 -- x of first point

  • y0 -- y of first point

  • x1 -- x of intermediate point

  • y1 -- y of intermediate point

  • x2 -- x of final point

  • y2 -- y of final point

  • R -- 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)

戻り値:

TRUE if the points are not aligned and define an arc circle.

static 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.

Since

GDAL 2.0

パラメータ:
  • x0 -- x of first point

  • y0 -- y of first point

  • z0 -- z of first point

  • x1 -- x of intermediate point

  • y1 -- y of intermediate point

  • z1 -- z of intermediate point

  • x2 -- x of final point

  • y2 -- y of final point

  • z2 -- z of final point

  • bHasZ -- TRUE if z must be taken into account

  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • papszOptions -- options as a null-terminated 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 round-tripping 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.

戻り値:

the converted geometry (ownership to caller).

static 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().

Since

GDAL 2.0

パラメータ:
  • poLS -- handle to the geometry to convert.

  • papszOptions -- options as a null-terminated list of strings. Unused for now. Must be set to NULL.

戻り値:

the converted geometry (ownership to caller).

class TransformWithOptionsCache

Opaque class used as argument to transformWithOptions()

struct Private

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 06-103r4

In GDAL 2.0, the hierarchy of classes has been extended with (working draft) ISO SQL/MM Part 3 (ISO/IEC 13249-3) 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

inline bool operator==(const OGRGeometry &other) const

Returns if two geometries are equal.

inline bool operator!=(const OGRGeometry &other) const

Returns if two geometries are different.

virtual 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().

戻り値:

0 for points, 1 for lines and 2 for surfaces.

virtual int getCoordinateDimension() const

Get the dimension of the coordinates in this object.

This method is the same as the C function OGR_G_GetCoordinateDimension().

Deprecated:

use CoordinateDimension().

戻り値:

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().

Since

GDAL 2.1

戻り値:

this will return 2 for XY, 3 for XYZ and XYM, and 4 for XYZM data.

virtual OGRBoolean IsEmpty() const = 0

Returns TRUE (non-zero) 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.

戻り値:

TRUE if object is empty, otherwise FALSE.

virtual 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.

戻り値:

TRUE if the geometry has no points, otherwise FALSE.

virtual OGRGeometry *MakeValid(CSLConstList papszOptions = nullptr) const

Attempts to make an invalid geometry valid without losing vertices.

Already-valid geometries are cloned without further intervention.

Running OGRGeometryFactory::removeLowerDimensionSubGeoms() as a post-processing step is often desired.

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

Since

GDAL 3.0

パラメータ:

papszOptions -- NULL terminated list of options, or NULL. The following options are available:

  • METHOD=LINEWORK/STRUCTURE. LINEWORK is the default method, which combines all rings into a set of noded lines and then extracts valid polygons from that linework. The STRUCTURE method (requires GEOS >= 3.10 and GDAL >= 3.4) first makes all rings valid, then merges shells and subtracts holes from shells to generate valid result. Assumes that holes and shells are correctly categorized.

  • KEEP_COLLAPSED=YES/NO. Only for METHOD=STRUCTURE. NO (default): collapses are converted to empty geometries YES: collapses are converted to a valid geometry of lower dimension.

戻り値:

a newly allocated geometry now owned by the caller, or NULL on failure.

virtual OGRGeometry *Normalize() const

Attempts to bring geometry into normalized/canonical form.

This method is the same as the C function OGR_G_Normalize().

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.

Since

GDAL 3.3

戻り値:

a newly allocated geometry now owned by the caller, or NULL on failure.

virtual 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.

戻り値:

TRUE if the geometry has no points, otherwise FALSE.

inline OGRBoolean Is3D() const

Returns whether the geometry has a Z component.

inline OGRBoolean IsMeasured() const

Returns whether the geometry has a M component.

virtual 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.

戻り値:

TRUE if the geometry has no points, otherwise FALSE.

virtual 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().

virtual 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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual 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().

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual 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

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual size_t 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().

戻り値:

size of binary representation in bytes.

OGRErr importFromWkb(const GByte*, size_t = static_cast<size_t>(-1), OGRwkbVariant = 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().

パラメータ:
  • 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_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual OGRErr importFromWkb(const unsigned char*, size_t, OGRwkbVariant, size_t &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().

Since

GDAL 2.3

パラメータ:
  • 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

  • nBytesConsumedOut -- output parameter. Number of bytes consumed.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

OGRErr exportToWkb(OGRwkbByteOrder, unsigned char*, OGRwkbVariant = 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.

パラメータ:
  • 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.

戻り値:

Currently OGRERR_NONE is always returned.

virtual OGRErr exportToWkb(unsigned char*, const OGRwkbExportOptions* = nullptr) const = 0

Convert a geometry into well known binary format.

This function relates to the SFCOM IWks::ExportToWKB() method.

This function is the same as the C function OGR_G_ExportToWkbEx().

Since

GDAL 3.9

パラメータ:
  • pabyDstBuffer -- a buffer into which the binary representation is written. This buffer must be at least OGR_G_WkbSize() byte in size.

  • psOptions -- WKB export options.

戻り値:

Currently OGRERR_NONE is always returned.

virtual 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().

パラメータ:

ppszInput -- pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

OGRErr exportToWkt(char **ppszDstText, OGRwkbVariant = 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().

パラメータ:
  • 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 :

    • wkbVariantOgc for old-style 99-402 extended dimension (Z) WKB types

    • wkbVariantIso for SFSQL 1.2 and ISO SQL/MM Part 3

戻り値:

Currently OGRERR_NONE is always returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const = 0

Export a WKT geometry.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT string representing this geometry.

virtual 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().

戻り値:

the geometry type code.

OGRwkbGeometryType getIsoGeometryType() const

Get the geometry type that conforms with ISO SQL/MM Part3.

戻り値:

the geometry type that conforms with ISO SQL/MM Part3

virtual 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().

戻り値:

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*, const char* = nullptr, CSLConstList 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().

パラメータ:
  • 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)

std::string dumpReadable(const char* = nullptr, CSLConstList 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

  • XY_COORD_PRECISION=integer: number of decimal figures for X,Y coordinates in WKT (added in GDAL 3.9)

  • Z_COORD_PRECISION=integer: number of decimal figures for Z coordinates in WKT (added in GDAL 3.9)

Since

GDAL 3.7

パラメータ:
  • pszPrefix -- the prefix to put on each line of output.

  • papszOptions -- NULL terminated list of options (may be NULL)

戻り値:

a string with the geometry representation.

virtual 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().

virtual 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 are :

  • FORMAT=GML2/GML3/GML32 (GML2 or GML32 added in GDAL 2.1). If not set, 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, deprecated by SRSNAME_FORMAT in GDAL >=2.2). Defaults to YES. If YES, SRS with EPSG authority will be written with the "urn:ogc:def:crs:EPSG::" prefix. In the case the SRS should be treated as lat/long or northing/easting, then the function will take care of coordinate order swapping if the data axis to CRS axis mapping indicates it. If set to NO, SRS with EPSG authority will be written with the "EPSG:" prefix, even if they are in lat/long order.

  • SRSNAME_FORMAT=SHORT/OGC_URN/OGC_URL (Only valid for FORMAT=GML3, added in GDAL 2.2). Defaults to OGC_URN. If SHORT, then srsName will be in the form AUTHORITY_NAME:AUTHORITY_CODE. If OGC_URN, then srsName will be in the form urn:ogc:def:crs:AUTHORITY_NAME::AUTHORITY_CODE. If OGC_URL, then srsName will be in the form http://www.opengis.net/def/crs/AUTHORITY_NAME/0/AUTHORITY_CODE. For OGC_URN and OGC_URL, in the case the SRS should be treated as lat/long or northing/easting, then the function will take care of coordinate order swapping if the data axis to CRS axis mapping indicates it.

  • GMLID=astring. If specified, a gml:id attribute will be written in the top-level geometry element with the provided value. Required for GML 3.2 compatibility.

  • SRSDIMENSION_LOC=POSLIST/GEOMETRY/GEOMETRY,POSLIST. (Only valid for FORMAT=GML3/GML32, GDAL >= 2.0) Default to POSLIST. For 2.5D geometries, define the location where to attach the srsDimension attribute. There are diverging implementations. Some put in on the <gml:posList> element, other on the top geometry element.

  • NAMESPACE_DECL=YES/NO. If set to YES, xmlns:gml="http://www.opengis.net/gml" will be added to the root node for GML < 3.2 or xmlns:gml="http://www.opengis.net/gml/3.2" for GML 3.2

  • XY_COORD_RESOLUTION=double (added in GDAL 3.9): Resolution for the coordinate precision of the X and Y coordinates. Expressed in the units of the X and Y axis of the SRS. eg 1e-5 for up to 5 decimal digits. 0 for the default behavior.

  • Z_COORD_RESOLUTION=double (added in GDAL 3.9): Resolution for the coordinate precision of the Z coordinates. Expressed in the units of the Z axis of the SRS. 0 for the default behavior.

This method is the same as the C function OGR_G_ExportToGMLEx().

パラメータ:

papszOptions -- NULL-terminated list of options.

戻り値:

A GML fragment or NULL in case of error.

virtual 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().

戻り値:

A KML fragment or NULL in case of error.

virtual char *exportToJson(CSLConstList papszOptions = nullptr) const

Convert a geometry into GeoJSON format.

The returned string should be freed with CPLFree() when no longer required.

The following options are supported :

  • XY_COORD_PRECISION=integer: number of decimal figures for X,Y coordinates (added in GDAL 3.9)

  • Z_COORD_PRECISION=integer: number of decimal figures for Z coordinates (added in GDAL 3.9)

This method is the same as the C function OGR_G_ExportToJson().

パラメータ:

papszOptions -- Null terminated list of options, or null (added in 3.9)

戻り値:

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, bool bRemoveEmptyParts = false) const

Returns a GEOSGeom object corresponding to the geometry.

パラメータ:
  • hGEOSCtxt -- GEOS context

  • bRemoveEmptyParts -- Whether empty parts of the geometry should be removed before exporting to GEOS (GDAL >= 3.10)

戻り値:

a GEOSGeom object corresponding to the geometry.

virtual 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 non-linear 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 "loss-less" conversion.

This method is the same as the C function OGR_G_HasCurveGeometry().

Since

GDAL 2.0

パラメータ:

bLookForNonLinear -- set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

戻り値:

TRUE if this geometry is or has curve geometry.

virtual 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 de-approximating 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().

Since

GDAL 2.0

パラメータ:

papszOptions -- options as a null-terminated list of strings. Unused for now. Must be set to NULL.

戻り値:

a new geometry.

virtual OGRGeometry *getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const

Return, possibly approximate, non-curve 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().

Since

GDAL 2.0

パラメータ:
  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • papszOptions -- options as a null-terminated list of strings. See OGRGeometryFactory::curveToLineString() for valid options.

戻り値:

a new geometry.

void roundCoordinates(const OGRGeomCoordinatePrecision &sPrecision)

Round coordinates of the geometry to the specified precision.

Note that this is not the same as OGRGeometry::SetPrecision(). The later will return valid geometries, whereas roundCoordinates() does not make such guarantee and may return geometries with invalidities, if they are not compatible of the specified precision. roundCoordinates() supports curve geometries, whereas SetPrecision() does not currently.

One use case for roundCoordinates() is to undo the effect of quantizeCoordinates().

Since

GDAL 3.9

パラメータ:

sPrecision -- Contains the precision requirements.

void roundCoordinatesIEEE754(const OGRGeomCoordinateBinaryPrecision &options)

Round coordinates of a geometry, exploiting characteristics of the IEEE-754 double-precision binary representation.

Determines the number of bits (N) required to represent a coordinate value with a specified number of digits after the decimal point, and then sets all but the N most significant bits to zero. The resulting coordinate value will still round to the original value (e.g. after roundCoordinates()), but will have improved compressiblity.

Since

GDAL 3.9

パラメータ:

options -- Contains the precision requirements.

virtual 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.

virtual 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.

Deprecated:

use set3D() or setMeasured().

パラメータ:

nNewDimension -- New coordinate dimension value, either 2 or 3.

virtual 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

パラメータ:

bIs3D -- Should the geometry have a Z dimension, either TRUE or FALSE.

virtual 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

パラメータ:

bIsMeasured -- Should the geometry have a M dimension, either TRUE or FALSE.

virtual void assignSpatialReference(const 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 sub-geometries 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().

パラメータ:

poSR -- new spatial reference system to apply.

inline const 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().

戻り値:

a reference to the spatial reference object. The object may be shared with many geometry objects, and should not be modified.

virtual 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 only does reprojection on a point-by-point basis. It does not include advanced logic to deal with discontinuities at poles or antimeridian. For that, use the OGRGeometryFactory::transformWithOptions() method.

This method is the same as the C function OGR_G_Transform().

パラメータ:

poCT -- the transformation to apply.

戻り値:

OGRERR_NONE on success or an error code.

OGRErr transformTo(const 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().

パラメータ:

poSR -- spatial reference system to transform to.

戻り値:

OGRERR_NONE on success, or an error code.

virtual void segmentize(double dfMaxLength)

Modify the geometry such it has no segment longer then the given distance.

This method modifies the geometry to add intermediate vertices if necessary so that the maximum length between 2 consecutive vertices is lower than dfMaxLength.

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()

パラメータ:

dfMaxLength -- the maximum distance between 2 points after segmentization

virtual OGRBoolean Intersects(const OGRGeometry*) 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().

パラメータ:

poOtherGeom -- the other geometry to test against.

戻り値:

TRUE if the geometries intersect, otherwise FALSE.

virtual OGRBoolean 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 sub-geometries 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().

戻り値:

TRUE if equivalent or FALSE otherwise.

virtual OGRBoolean Disjoint(const OGRGeometry*) 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.

パラメータ:

poOtherGeom -- the geometry to compare to this geometry.

戻り値:

TRUE if they are disjoint, otherwise FALSE.

virtual OGRBoolean Touches(const OGRGeometry*) 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.

パラメータ:

poOtherGeom -- the geometry to compare to this geometry.

戻り値:

TRUE if they are touching, otherwise FALSE.

virtual OGRBoolean Crosses(const OGRGeometry*) 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.

パラメータ:

poOtherGeom -- the geometry to compare to this geometry.

戻り値:

TRUE if they are crossing, otherwise FALSE.

virtual OGRBoolean Within(const OGRGeometry*) 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.

パラメータ:

poOtherGeom -- the geometry to compare to this geometry.

戻り値:

TRUE if poOtherGeom is within this geometry, otherwise FALSE.

virtual OGRBoolean Contains(const OGRGeometry*) 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.

パラメータ:

poOtherGeom -- the geometry to compare to this geometry.

戻り値:

TRUE if poOtherGeom contains this geometry, otherwise FALSE.

virtual OGRBoolean Overlaps(const OGRGeometry*) const

Test for overlap.

Tests if this geometry and the other passed into the method overlap, that is their intersection has a non-zero 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.

パラメータ:

poOtherGeom -- the geometry to compare to this geometry.

戻り値:

TRUE if they are overlapping, otherwise FALSE.

virtual 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.

Since

OGR 1.8.0

戻り値:

a newly allocated geometry now owned by the caller, or NULL on failure.

virtual double Distance(const OGRGeometry*) 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.

パラメータ:

poOtherGeom -- the other geometry to compare against.

戻り値:

the distance between the geometries or -1 if an error occurs.

virtual 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.

戻り値:

a newly allocated geometry now owned by the caller, or NULL on failure.

virtual OGRGeometry *ConcaveHull(double dfRatio, bool bAllowHoles) const

Compute "concave hull" of a geometry.

The concave hull is fully contained within the convex hull and also contains all the points of the input, but in a smaller area. The area ratio is the ratio of the area of the convex hull and the concave hull. Frequently used to convert a multi-point into a polygonal area. that contains all the points in the input Geometry.

A new geometry object is created and returned containing the concave hull of the geometry on which the method is invoked.

This method is the same as the C function OGR_G_ConcaveHull().

This method is built on the GEOS >= 3.11 library If OGR is built without the GEOS >= 3.11 librray, this method will always fail, issuing a CPLE_NotSupported error.

Since

GDAL 3.6

パラメータ:
  • dfRatio -- Ratio of the area of the convex hull and the concave hull.

  • bAllowHoles -- Whether holes are allowed.

戻り値:

a newly allocated geometry now owned by the caller, or NULL on failure.

virtual 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.

パラメータ:
  • 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.

戻り値:

the newly created geometry, or NULL if an error occurs.

virtual OGRGeometry *BufferEx(double dfDistance, CSLConstList papszOptions) 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.

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.

The following options are supported. See the GEOS library for more detailed descriptions.

  • ENDCAP_STYLE=ROUND/FLAT/SQUARE

  • JOIN_STYLE=ROUND/MITRE/BEVEL

  • MITRE_LIMIT=double

  • QUADRANT_SEGMENTS=double

  • SINGLE_SIDED=YES/NO

This function is the same as the C function OGR_G_BufferEx().

Since

GDAL 3.10

パラメータ:
  • dfDist -- the buffer distance to be applied. Should be expressed into the same unit as the coordinates of the geometry.

  • papszOptions -- NULL terminated list of options (may be NULL)

戻り値:

the newly created geometry, or NULL if an error occurs.

virtual OGRGeometry *Intersection(const OGRGeometry*) 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.

パラメータ:

poOtherGeom -- the other geometry intersected with "this" geometry.

戻り値:

a new geometry representing the intersection or NULL if there is no intersection or an error occurs.

virtual OGRGeometry *Union(const OGRGeometry*) 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.

パラメータ:

poOtherGeom -- the other geometry unioned with "this" geometry.

戻り値:

a new geometry representing the union or NULL if an error occurs.

virtual 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.

The input geometry must be a MultiPolygon.

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.

Deprecated:

Use UnaryUnion() instead

Since

OGR 1.8.0

戻り値:

a new geometry representing the union or NULL if an error occurs.

OGRGeometry *UnaryUnion() const

Returns the union of all components of a single geometry.

Usually used to convert a collection into the smallest set of polygons that cover the same area.

See https://postgis.net/docs/ST_UnaryUnion.html for more details.

This method is the same as the C function OGR_G_UnaryUnion().

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.

Since

GDAL 3.7

戻り値:

a new geometry representing the union or NULL if an error occurs.

virtual OGRGeometry *Difference(const OGRGeometry*) 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.

パラメータ:

poOtherGeom -- the other geometry removed from "this" geometry.

戻り値:

a new geometry representing the difference or NULL if the difference is empty or an error occurs.

virtual OGRGeometry *SymDifference(const OGRGeometry*) 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.

Since

OGR 1.8.0

パラメータ:

poOtherGeom -- the other geometry.

戻り値:

a new geometry representing the symmetric difference or NULL if the difference is empty or an error occurs.

virtual 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/MM-Part 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.

Since

OGR 1.8.0 as a OGRGeometry method (previously was restricted to OGRPolygon)

戻り値:

OGRERR_NONE on success or OGRERR_FAILURE on error.

virtual 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.

Since

OGR 1.8.0

パラメータ:

dTolerance -- the distance tolerance for the simplification.

戻り値:

the simplified geometry or NULL if an error occurs.

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.

Since

OGR 1.9.0

パラメータ:

dTolerance -- the distance tolerance for the simplification.

戻り値:

the simplified geometry or NULL if an error occurs.

virtual 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.

Since

OGR 2.1

パラメータ:
  • dfTolerance -- optional snapping tolerance to use for improved robustness

  • bOnlyEdges -- if TRUE, will return a MULTILINESTRING, otherwise it will return a GEOMETRYCOLLECTION containing triangular POLYGONs.

戻り値:

the geometry resulting from the Delaunay triangulation or NULL if an error occurs.

virtual 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.

Since

OGR 1.9.0

戻り値:

a newly allocated geometry now owned by the caller, or NULL on failure.

virtual 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().

Since

GDAL 2.2

戻り値:

distance between the two geometries

OGRGeometry *SetPrecision(double dfGridSize, int nFlags) const

Set the geometry's precision, rounding all its coordinates to the precision grid, and making sure the geometry is still valid.

This is a stronger version of roundCoordinates().

Note that at time of writing GEOS does no supported curve geometries. So currently if this function is called on such a geometry, OGR will first call getLinearGeometry() on the input and getCurveGeometry() on the output, but that it is unlikely to yield to the expected result.

This function is the same as the C function OGR_G_SetPrecision().

This function is built on the GEOSGeom_setPrecision_r() function of 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.

Since

GDAL 3.9

パラメータ:
  • dfGridSize -- size of the precision grid, or 0 for FLOATING precision.

  • nFlags -- The bitwise OR of zero, one or several of OGR_GEOS_PREC_NO_TOPO and OGR_GEOS_PREC_KEEP_COLLAPSED

戻り値:

a new geometry or NULL if an error occurs.

virtual bool hasEmptyParts() const

Returns whether a geometry has empty parts/rings.

Returns true if removeEmptyParts() will modify the geometry.

This is different from IsEmpty().

Since

GDAL 3.10

virtual void removeEmptyParts()

Remove empty parts/rings from this geometry.

Since

GDAL 3.10

virtual void swapXY()

Swap x and y coordinates.

Since

OGR 1.8.0

bool IsRectangle() const

Returns whether the geometry is a polygon with 4 corners forming a rectangle.

Since

GDAL 3.10

inline OGRPoint *toPoint()

Down-cast to OGRPoint*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbPoint.

Since

GDAL 2.3

inline const OGRPoint *toPoint() const

Down-cast to OGRPoint*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbPoint.

Since

GDAL 2.3

inline OGRCurve *toCurve()

Down-cast to OGRCurve*.

Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbCurve).

Since

GDAL 2.3

inline const OGRCurve *toCurve() const

Down-cast to OGRCurve*.

Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbCurve).

Since

GDAL 2.3

inline OGRSimpleCurve *toSimpleCurve()

Down-cast to OGRSimpleCurve*.

Implies prior checking that getGeometryType() is wkbLineString, wkbCircularString or a derived type.

Since

GDAL 2.3

inline const OGRSimpleCurve *toSimpleCurve() const

Down-cast to OGRSimpleCurve*.

Implies prior checking that getGeometryType() is wkbLineString, wkbCircularString or a derived type.

Since

GDAL 2.3

inline OGRLineString *toLineString()

Down-cast to OGRLineString*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbLineString.

Since

GDAL 2.3

inline const OGRLineString *toLineString() const

Down-cast to OGRLineString*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbLineString.

Since

GDAL 2.3

inline OGRLinearRing *toLinearRing()

Down-cast to OGRLinearRing*.

Implies prior checking that EQUAL(getGeometryName(), "LINEARRING").

Since

GDAL 2.3

inline const OGRLinearRing *toLinearRing() const

Down-cast to OGRLinearRing*.

Implies prior checking that EQUAL(getGeometryName(), "LINEARRING").

Since

GDAL 2.3

inline OGRCircularString *toCircularString()

Down-cast to OGRCircularString*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbCircularString.

Since

GDAL 2.3

inline const OGRCircularString *toCircularString() const

Down-cast to OGRCircularString*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbCircularString.

Since

GDAL 2.3

inline OGRCompoundCurve *toCompoundCurve()

Down-cast to OGRCompoundCurve*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbCompoundCurve.

Since

GDAL 2.3

inline const OGRCompoundCurve *toCompoundCurve() const

Down-cast to OGRCompoundCurve*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbCompoundCurve.

Since

GDAL 2.3

inline OGRSurface *toSurface()

Down-cast to OGRSurface*.

Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbSurface).

Since

GDAL 2.3

inline const OGRSurface *toSurface() const

Down-cast to OGRSurface*.

Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbSurface).

Since

GDAL 2.3

inline OGRPolygon *toPolygon()

Down-cast to OGRPolygon*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbPolygon or wkbTriangle.

Since

GDAL 2.3

inline const OGRPolygon *toPolygon() const

Down-cast to OGRPolygon*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbPolygon or wkbTriangle.

Since

GDAL 2.3

inline OGRTriangle *toTriangle()

Down-cast to OGRTriangle*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbTriangle.

Since

GDAL 2.3

inline const OGRTriangle *toTriangle() const

Down-cast to OGRTriangle*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbTriangle.

Since

GDAL 2.3

inline OGRCurvePolygon *toCurvePolygon()

Down-cast to OGRCurvePolygon*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbCurvePolygon or wkbPolygon or wkbTriangle.

Since

GDAL 2.3

inline const OGRCurvePolygon *toCurvePolygon() const

Down-cast to OGRCurvePolygon*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbCurvePolygon or wkbPolygon or wkbTriangle.

Since

GDAL 2.3

inline OGRGeometryCollection *toGeometryCollection()

Down-cast to OGRGeometryCollection*.

Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbGeometryCollection).

Since

GDAL 2.3

inline const OGRGeometryCollection *toGeometryCollection() const

Down-cast to OGRGeometryCollection*.

Implies prior checking that OGR_GT_IsSubClass(getGeometryType(), wkbGeometryCollection).

Since

GDAL 2.3

inline OGRMultiPoint *toMultiPoint()

Down-cast to OGRMultiPoint*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiPoint.

Since

GDAL 2.3

inline const OGRMultiPoint *toMultiPoint() const

Down-cast to OGRMultiPoint*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiPoint.

Since

GDAL 2.3

inline OGRMultiLineString *toMultiLineString()

Down-cast to OGRMultiLineString*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiLineString.

Since

GDAL 2.3

inline const OGRMultiLineString *toMultiLineString() const

Down-cast to OGRMultiLineString*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiLineString.

Since

GDAL 2.3

inline OGRMultiPolygon *toMultiPolygon()

Down-cast to OGRMultiPolygon*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiPolygon.

Since

GDAL 2.3

inline const OGRMultiPolygon *toMultiPolygon() const

Down-cast to OGRMultiPolygon*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiPolygon.

Since

GDAL 2.3

inline OGRMultiCurve *toMultiCurve()

Down-cast to OGRMultiCurve*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiCurve and derived types.

Since

GDAL 2.3

inline const OGRMultiCurve *toMultiCurve() const

Down-cast to OGRMultiCurve*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiCurve and derived types.

Since

GDAL 2.3

inline OGRMultiSurface *toMultiSurface()

Down-cast to OGRMultiSurface*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiSurface and derived types.

Since

GDAL 2.3

inline const OGRMultiSurface *toMultiSurface() const

Down-cast to OGRMultiSurface*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbMultiSurface and derived types.

Since

GDAL 2.3

inline OGRPolyhedralSurface *toPolyhedralSurface()

Down-cast to OGRPolyhedralSurface*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbPolyhedralSurface or wkbTIN.

Since

GDAL 2.3

inline const OGRPolyhedralSurface *toPolyhedralSurface() const

Down-cast to OGRPolyhedralSurface*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbPolyhedralSurface or wkbTIN.

Since

GDAL 2.3

inline OGRTriangulatedSurface *toTriangulatedSurface()

Down-cast to OGRTriangulatedSurface*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbTIN.

Since

GDAL 2.3

inline const OGRTriangulatedSurface *toTriangulatedSurface() const

Down-cast to OGRTriangulatedSurface*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbTIN.

Since

GDAL 2.3

Public Static Functions

static GEOSContextHandle_t createGEOSContext()

Create a new GEOS context.

戻り値:

a new GEOS context.

static void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt)

Destroy a GEOS context.

パラメータ:

hGEOSCtxt -- GEOS context

static inline OGRGeometryH ToHandle(OGRGeometry *poGeom)

Convert a OGRGeometry* to a OGRGeometryH.

Since

GDAL 2.3

static inline 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.

Subclassed by OGRIteratedPoint

Public Functions

OGRPoint()

Create an empty point.

OGRPoint(double x, double y)

Create a point.

パラメータ:
  • xIn -- x

  • yIn -- y

OGRPoint(double x, double y, double z)

Create a point.

パラメータ:
  • xIn -- x

  • yIn -- y

  • zIn -- z

OGRPoint(double x, double y, double z, double m)

Create a point.

パラメータ:
  • xIn -- x

  • yIn -- y

  • zIn -- z

  • mIn -- 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

virtual size_t WkbSize() const override

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().

戻り値:

size of binary representation in bytes.

virtual OGRErr importFromWkb(const unsigned char*, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override

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().

Since

GDAL 2.3

パラメータ:
  • 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

  • nBytesConsumedOut -- output parameter. Number of bytes consumed.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual OGRErr exportToWkb(unsigned char*, const OGRwkbExportOptions* = nullptr) const override

Convert a geometry into well known binary format.

This function relates to the SFCOM IWks::ExportToWKB() method.

This function is the same as the C function OGR_G_ExportToWkbEx().

Since

GDAL 3.9

パラメータ:
  • pabyDstBuffer -- a buffer into which the binary representation is written. This buffer must be at least OGR_G_WkbSize() byte in size.

  • psOptions -- WKB export options.

戻り値:

Currently OGRERR_NONE is always returned.

virtual OGRErr importFromWkt(const char**) override

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().

パラメータ:

ppszInput -- pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a point to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT string representing this point.

virtual int getDimension() const override

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().

戻り値:

0 for points, 1 for lines and 2 for surfaces.

virtual OGRPoint *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual void empty() override

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().

virtual void getEnvelope(OGREnvelope *psEnvelope) const override

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().

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override

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

パラメータ:

psEnvelope -- the structure in which to place the results.

inline virtual OGRBoolean IsEmpty() const override

Returns TRUE (non-zero) 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.

戻り値:

TRUE if object is empty, otherwise FALSE.

inline double getX() const

Return x.

Fetch X coordinate.

Relates to the SFCOM IPoint::get_X() method.

戻り値:

the X coordinate of this point.

inline double getY() const

Return y.

Fetch Y coordinate.

Relates to the SFCOM IPoint::get_Y() method.

戻り値:

the Y coordinate of this point.

inline double getZ() const

Return z.

Fetch Z coordinate.

Relates to the SFCOM IPoint::get_Z() method.

戻り値:

the Z coordinate of this point, or zero if it is a 2D point.

inline double getM() const

Return m.

virtual void setCoordinateDimension(int nDimension) override

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.

Deprecated:

use set3D() or setMeasured().

パラメータ:

nNewDimension -- New coordinate dimension value, either 2 or 3.

inline void setX(double xIn)

Set x.

Assign point X coordinate.

There is no corresponding SFCOM method.

パラメータ:

xIn -- x

inline void setY(double yIn)

Set y.

Assign point Y coordinate.

There is no corresponding SFCOM method.

パラメータ:

yIn -- y

inline void setZ(double zIn)

Set z.

Assign point Z coordinate.

Calling this method will force the geometry coordinate dimension to 3D (wkbPoint|wkbZ).

There is no corresponding SFCOM method.

パラメータ:

zIn -- z

inline void setM(double mIn)

Set m.

パラメータ:

mIn -- m

virtual OGRBoolean Equals(const OGRGeometry*) const override

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 sub-geometries 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().

戻り値:

TRUE if equivalent or FALSE otherwise.

virtual OGRBoolean Intersects(const OGRGeometry*) const override

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().

パラメータ:

poOtherGeom -- the other geometry to test against.

戻り値:

TRUE if the geometries intersect, otherwise FALSE.

virtual OGRBoolean Within(const OGRGeometry*) const override

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.

パラメータ:

poOtherGeom -- the geometry to compare to this geometry.

戻り値:

TRUE if poOtherGeom is within this geometry, otherwise FALSE.

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual OGRErr transform(OGRCoordinateTransformation *poCT) override

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 only does reprojection on a point-by-point basis. It does not include advanced logic to deal with discontinuities at poles or antimeridian. For that, use the OGRGeometryFactory::transformWithOptions() method.

This method is the same as the C function OGR_G_Transform().

パラメータ:

poCT -- the transformation to apply.

戻り値:

OGRERR_NONE on success or an error code.

virtual void flattenTo2D() override

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().

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

virtual void swapXY() override

Swap x and y coordinates.

Since

OGR 1.8.0

Public Static Functions

static OGRPoint *createXYM(double x, double y, double m)

Create a XYM point.

Since

GDAL 3.1

パラメータ:
  • x -- x

  • y -- y

  • m -- m

OGRSimpleCurve class

class OGRSimpleCurve : public OGRCurve

Abstract curve base class for OGRLineString and OGRCircularString.

Note: this class does not exist in SQL/MM standard and exists for implementation convenience.

Since

GDAL 2.0

Subclassed by OGRCircularString, OGRLineString

Public Types

typedef OGRPoint ChildType

Type of child elements.

Public Functions

OGRSimpleCurve &operator=(const OGRSimpleCurve &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

Iterator begin()

Return begin of point iterator.

Using this iterator for standard range-based 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

Iterator end()

Return end of point iterator.

ConstIterator begin() const

Return begin of point iterator.

Using this iterator for standard range-based 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

ConstIterator end() const

Return end of point iterator.

virtual size_t WkbSize() const override

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().

戻り値:

size of binary representation in bytes.

virtual OGRErr importFromWkb(const unsigned char*, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override

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().

Since

GDAL 2.3

パラメータ:
  • 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

  • nBytesConsumedOut -- output parameter. Number of bytes consumed.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual OGRErr exportToWkb(unsigned char*, const OGRwkbExportOptions* = nullptr) const override

Convert a geometry into well known binary format.

This function relates to the SFCOM IWks::ExportToWKB() method.

This function is the same as the C function OGR_G_ExportToWkbEx().

Since

GDAL 3.9

パラメータ:
  • pabyDstBuffer -- a buffer into which the binary representation is written. This buffer must be at least OGR_G_WkbSize() byte in size.

  • psOptions -- WKB export options.

戻り値:

Currently OGRERR_NONE is always returned.

virtual OGRErr importFromWkt(const char**) override

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().

パラメータ:

ppszInput -- pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a simple curve to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT string representing this simple curve.

virtual void empty() override

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().

virtual void getEnvelope(OGREnvelope *psEnvelope) const override

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().

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override

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

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual OGRBoolean IsEmpty() const override

Returns TRUE (non-zero) 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.

戻り値:

TRUE if object is empty, otherwise FALSE.

virtual OGRSimpleCurve *clone() const override = 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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual double get_Length() const override

Returns the length of the curve.

This method relates to the SFCOM ICurve::get_Length() method.

戻り値:

the length of the curve, zero if the curve hasn't been initialized.

virtual void StartPoint(OGRPoint*) const override

Return the curve start point.

This method relates to the SF COM ICurve::get_StartPoint() method.

パラメータ:

poPoint -- the point to be assigned the start location.

virtual void EndPoint(OGRPoint*) const override

Return the curve end point.

This method relates to the SF COM ICurve::get_EndPoint() method.

パラメータ:

poPoint -- the point to be assigned the end location.

virtual void Value(double, OGRPoint*) const override

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().

パラメータ:
  • 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.

virtual double Project(const OGRPoint*) const

Project point on linestring.

The input point projected on linestring. This is the shortest distance from point to the linestring. The distance from begin of linestring to the point projection returned.

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 -1, issuing a CPLE_NotSupported error.

戻り値:

a distance from the begin of the linestring to the projected point.

virtual OGRLineString *getSubLine(double, double, int) const

Get the portion of linestring.

The portion of the linestring extracted to new one. The input distances (maybe present as ratio of length of linestring) set begin and end of extracted portion.

Since

OGR 1.11.0

パラメータ:
  • dfDistanceFrom -- The distance from the origin of linestring, where the subline should begins

  • dfDistanceTo -- The distance from the origin of linestring, where the subline should ends

  • bAsRatio -- The flag indicating that distances are the ratio of the linestring length.

戻り値:

a newly allocated linestring now owned by the caller, or NULL on failure.

inline virtual int getNumPoints() const override

Fetch vertex count.

Returns the number of vertices in the line string.

戻り値:

vertex count.

void getPoint(int, OGRPoint*) const

Fetch a point in line string.

This method relates to the SFCOM ILineString::get_Point() method.

パラメータ:
  • i -- the vertex to fetch, from 0 to getNumPoints()-1.

  • poPoint -- a point to initialize with the fetched point.

inline double getX(int i) const

Get X at vertex.

Returns the X value at the indicated vertex. If iVertex is out of range a crash may occur, no internal range checking is performed.

パラメータ:

iVertex -- the vertex to return, between 0 and getNumPoints()-1.

戻り値:

X value.

inline double getY(int i) const

Get Y at vertex.

Returns the Y value at the indicated vertex. If iVertex is out of range a crash may occur, no internal range checking is performed.

パラメータ:

iVertex -- the vertex to return, between 0 and getNumPoints()-1.

戻り値:

X value.

double getZ(int i) const

Get Z at vertex.

Returns the Z (elevation) value at the indicated vertex. If no Z value is available, 0.0 is returned. If iVertex is out of range a crash may occur, no internal range checking is performed.

パラメータ:

iVertex -- the vertex to return, between 0 and getNumPoints()-1.

戻り値:

Z value.

double getM(int i) const

Get measure at vertex.

Returns the M (measure) value at the indicated vertex. If no M value is available, 0.0 is returned.

パラメータ:

iVertex -- the vertex to return, between 0 and getNumPoints()-1.

戻り値:

M value.

virtual OGRBoolean Equals(const OGRGeometry*) const override

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 sub-geometries 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().

戻り値:

TRUE if equivalent or FALSE otherwise.

virtual void setCoordinateDimension(int nDimension) override

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.

Deprecated:

use set3D() or setMeasured().

パラメータ:

nNewDimension -- New coordinate dimension value, either 2 or 3.

virtual void set3D(OGRBoolean bIs3D) override

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

パラメータ:

bIs3D -- Should the geometry have a Z dimension, either TRUE or FALSE.

virtual void setMeasured(OGRBoolean bIsMeasured) override

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

パラメータ:

bIsMeasured -- Should the geometry have a M dimension, either TRUE or FALSE.

void setNumPoints(int nNewPointCount, int bZeroizeNewContent = TRUE)

Set number of points in geometry.

This method primary exists to preset the number of points in a linestring geometry before setPoint() is used to assign them to avoid reallocating the array larger with each call to addPoint().

This method has no SFCOM analog.

パラメータ:
  • nNewPointCount -- the new number of points for geometry.

  • bZeroizeNewContent -- whether to set to zero the new elements of arrays that are extended.

void setPoint(int, OGRPoint*)

Set the location of a vertex in line string.

If iPoint is larger than the number of necessary the number of existing points in the line string, the point count will be increased to accommodate the request.

There is no SFCOM analog to this method.

パラメータ:
  • iPoint -- the index of the vertex to assign (zero based).

  • poPoint -- the value to assign to the vertex.

void setPoint(int, double, double)

Set the location of a vertex in line string.

If iPoint is larger than the number of necessary the number of existing points in the line string, the point count will be increased to accommodate the request.

There is no SFCOM analog to this method.

パラメータ:
  • iPoint -- the index of the vertex to assign (zero based).

  • xIn -- input X coordinate to assign.

  • yIn -- input Y coordinate to assign.

void setZ(int, double)

Set the Z of a vertex in line string.

If iPoint is larger than the number of necessary the number of existing points in the line string, the point count will be increased to accommodate the request.

There is no SFCOM analog to this method.

パラメータ:
  • iPoint -- the index of the vertex to assign (zero based).

  • zIn -- input Z coordinate to assign.

void setM(int, double)

Set the M of a vertex in line string.

If iPoint is larger than the number of necessary the number of existing points in the line string, the point count will be increased to accommodate the request.

There is no SFCOM analog to this method.

パラメータ:
  • iPoint -- the index of the vertex to assign (zero based).

  • mIn -- input M coordinate to assign.

void setPoint(int, double, double, double)

Set the location of a vertex in line string.

If iPoint is larger than the number of necessary the number of existing points in the line string, the point count will be increased to accommodate the request.

There is no SFCOM analog to this method.

パラメータ:
  • iPoint -- the index of the vertex to assign (zero based).

  • xIn -- input X coordinate to assign.

  • yIn -- input Y coordinate to assign.

  • zIn -- input Z coordinate to assign (defaults to zero).

void setPointM(int, double, double, double)

Set the location of a vertex in line string.

If iPoint is larger than the number of necessary the number of existing points in the line string, the point count will be increased to accommodate the request.

There is no SFCOM analog to this method.

パラメータ:
  • iPoint -- the index of the vertex to assign (zero based).

  • xIn -- input X coordinate to assign.

  • yIn -- input Y coordinate to assign.

  • mIn -- input M coordinate to assign (defaults to zero).

void setPoint(int, double, double, double, double)

Set the location of a vertex in line string.

If iPoint is larger than the number of necessary the number of existing points in the line string, the point count will be increased to accommodate the request.

There is no SFCOM analog to this method.

パラメータ:
  • iPoint -- the index of the vertex to assign (zero based).

  • xIn -- input X coordinate to assign.

  • yIn -- input Y coordinate to assign.

  • zIn -- input Z coordinate to assign (defaults to zero).

  • mIn -- input M coordinate to assign (defaults to zero).

void setPoints(int, const OGRRawPoint*, const double* = nullptr)

Assign all points in a line string.

This method clears any existing points assigned to this line string, and assigns a whole new set. It is the most efficient way of assigning the value of a line string.

There is no SFCOM analog to this method.

パラメータ:
  • nPointsIn -- number of points being passed in paoPointsIn

  • paoPointsIn -- list of points being assigned.

  • padfZIn -- the Z values that go with the points (optional, may be NULL).

void setPointsM(int, const OGRRawPoint*, const double*)

Assign all points in a line string.

This method clears any existing points assigned to this line string, and assigns a whole new set. It is the most efficient way of assigning the value of a line string.

There is no SFCOM analog to this method.

パラメータ:
  • nPointsIn -- number of points being passed in paoPointsIn

  • paoPointsIn -- list of points being assigned.

  • padfMIn -- the M values that go with the points.

void setPoints(int, const OGRRawPoint*, const double*, const double*)

Assign all points in a line string.

This method clears any existing points assigned to this line string, and assigns a whole new set. It is the most efficient way of assigning the value of a line string.

There is no SFCOM analog to this method.

パラメータ:
  • nPointsIn -- number of points being passed in paoPointsIn

  • paoPointsIn -- list of points being assigned.

  • padfZIn -- the Z values that go with the points.

  • padfMIn -- the M values that go with the points.

void setPoints(int, const double *padfX, const double *padfY, const double *padfZIn = nullptr)

Assign all points in a line string.

This method clear any existing points assigned to this line string, and assigns a whole new set.

There is no SFCOM analog to this method.

パラメータ:
  • nPointsIn -- number of points being passed in padfX and padfY.

  • padfX -- list of X coordinates of points being assigned.

  • padfY -- list of Y coordinates of points being assigned.

  • padfZIn -- list of Z coordinates of points being assigned (defaults to NULL for 2D objects).

void setPointsM(int, const double *padfX, const double *padfY, const double *padfMIn = nullptr)

Assign all points in a line string.

This method clear any existing points assigned to this line string, and assigns a whole new set.

There is no SFCOM analog to this method.

パラメータ:
  • nPointsIn -- number of points being passed in padfX and padfY.

  • padfX -- list of X coordinates of points being assigned.

  • padfY -- list of Y coordinates of points being assigned.

  • padfMIn -- list of M coordinates of points being assigned.

void setPoints(int, const double *padfX, const double *padfY, const double *padfZIn, const double *padfMIn)

Assign all points in a line string.

This method clear any existing points assigned to this line string, and assigns a whole new set.

There is no SFCOM analog to this method.

パラメータ:
  • nPointsIn -- number of points being passed in padfX and padfY.

  • padfX -- list of X coordinates of points being assigned.

  • padfY -- list of Y coordinates of points being assigned.

  • padfZIn -- list of Z coordinates of points being assigned.

  • padfMIn -- list of M coordinates of points being assigned.

void addPoint(const OGRPoint*)

Add a point to a line string.

The vertex count of the line string is increased by one, and assigned from the passed location value.

There is no SFCOM analog to this method.

パラメータ:

poPoint -- the point to assign to the new vertex.

void addPoint(double, double)

Add a point to a line string.

The vertex count of the line string is increased by one, and assigned from the passed location value.

There is no SFCOM analog to this method.

パラメータ:
  • x -- the X coordinate to assign to the new point.

  • y -- the Y coordinate to assign to the new point.

void addPoint(double, double, double)

Add a point to a line string.

The vertex count of the line string is increased by one, and assigned from the passed location value.

There is no SFCOM analog to this method.

パラメータ:
  • x -- the X coordinate to assign to the new point.

  • y -- the Y coordinate to assign to the new point.

  • z -- the Z coordinate to assign to the new point (defaults to zero).

void addPointM(double, double, double)

Add a point to a line string.

The vertex count of the line string is increased by one, and assigned from the passed location value.

There is no SFCOM analog to this method.

パラメータ:
  • x -- the X coordinate to assign to the new point.

  • y -- the Y coordinate to assign to the new point.

  • m -- the M coordinate to assign to the new point.

void addPoint(double, double, double, double)

Add a point to a line string.

The vertex count of the line string is increased by one, and assigned from the passed location value.

There is no SFCOM analog to this method.

パラメータ:
  • x -- the X coordinate to assign to the new point.

  • y -- the Y coordinate to assign to the new point.

  • z -- the Z coordinate to assign to the new point (defaults to zero).

  • m -- the M coordinate to assign to the new point (defaults to zero).

bool removePoint(int)

Remove a point from a line string.

There is no SFCOM analog to this method.

Since

GDAL 3.3

パラメータ:

nIndex -- Point index

void getPoints(OGRRawPoint*, double* = nullptr) const

Returns all points of line string.

This method copies all points into user list. This list must be at least sizeof(OGRRawPoint) * OGRGeometry::getNumPoints() byte in size. It also copies all Z coordinates.

There is no SFCOM analog to this method.

パラメータ:
  • paoPointsOut -- a buffer into which the points is written.

  • padfZOut -- the Z values that go with the points (optional, may be NULL).

void getPoints(void *pabyX, int nXStride, void *pabyY, int nYStride, void *pabyZ = nullptr, int nZStride = 0, void *pabyM = nullptr, int nMStride = 0) const

Returns all points of line string.

This method copies all points into user arrays. The user provides the stride between 2 consecutive elements of the array.

On some CPU architectures, care must be taken so that the arrays are properly aligned.

There is no SFCOM analog to this method.

Since

OGR 2.1.0

パラメータ:
  • pabyX -- a buffer of at least (nXStride * nPointCount) bytes, may be NULL.

  • nXStride -- the number of bytes between 2 elements of pabyX.

  • pabyY -- a buffer of at least (nYStride * nPointCount) bytes, may be NULL.

  • nYStride -- the number of bytes between 2 elements of pabyY.

  • pabyZ -- a buffer of at last size (nZStride * nPointCount) bytes, may be NULL.

  • nZStride -- the number of bytes between 2 elements of pabyZ.

  • pabyM -- a buffer of at last size (nMStride * nPointCount) bytes, may be NULL.

  • nMStride -- the number of bytes between 2 elements of pabyM.

void addSubLineString(const OGRLineString*, int nStartVertex = 0, int nEndVertex = -1)

Add a segment of another linestring to this one.

Adds the request range of vertices to the end of this line string in an efficient manner. If the nStartVertex is larger than the nEndVertex then the vertices will be reversed as they are copied.

パラメータ:
  • poOtherLine -- the other OGRLineString.

  • nStartVertex -- the first vertex to copy, defaults to 0 to start with the first vertex in the other linestring.

  • nEndVertex -- the last vertex to copy, defaults to -1 indicating the last vertex of the other line string.

virtual void reversePoints() override

Reverse point order.

This method updates the points in this line string in place reversing the point ordering (first for last, etc).

virtual OGRPointIterator *getPointIterator() const override

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().

Since

GDAL 2.0

戻り値:

a point iterator over the curve.

virtual OGRErr transform(OGRCoordinateTransformation *poCT) override

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 only does reprojection on a point-by-point basis. It does not include advanced logic to deal with discontinuities at poles or antimeridian. For that, use the OGRGeometryFactory::transformWithOptions() method.

This method is the same as the C function OGR_G_Transform().

パラメータ:

poCT -- the transformation to apply.

戻り値:

OGRERR_NONE on success or an error code.

virtual void flattenTo2D() override

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 segmentize(double dfMaxLength) override

Modify the geometry such it has no segment longer then the given distance.

This method modifies the geometry to add intermediate vertices if necessary so that the maximum length between 2 consecutive vertices is lower than dfMaxLength.

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()

パラメータ:

dfMaxLength -- the maximum distance between 2 points after segmentization

virtual void swapXY() override

Swap x and y coordinates.

Since

OGR 1.8.0

OGRLineString class

class OGRLineString : public OGRSimpleCurve

Concrete representation of a multi-vertex 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

virtual OGRLineString *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual OGRLineString *CurveToLine(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const override

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().

Since

GDAL 2.0

パラメータ:
  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • papszOptions -- options as a null-terminated list of strings or NULL. See OGRGeometryFactory::curveToLineString() for valid options.

戻り値:

a line string approximating the curve

virtual OGRGeometry *getCurveGeometry(const char *const *papszOptions = nullptr) const override

Return curve version of this geometry.

Returns a geometry that has possibly CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by de-approximating 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().

Since

GDAL 2.0

パラメータ:

papszOptions -- options as a null-terminated list of strings. Unused for now. Must be set to NULL.

戻り値:

a new geometry.

virtual double get_Area() const override

Get the area of the (closed) curve.

This method is designed to be used by OGRCurvePolygon::get_Area().

参考

get_GeodesicArea() for an alternative method returning areas computed on the ellipsoid, an in square meters.

Since

GDAL 2.0

戻り値:

the area of the geometry in square units of the spatial reference system in use.

virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const override

Get the area of the (closed) curve, considered as a surface on the underlying ellipsoid of the SRS attached to the geometry.

This method is designed to be used by OGRCurvePolygon::get_GeodesicArea().

The returned area will always be in square meters, and assumes that polygon edges describe geodesic lines on the ellipsoid.

Note that geometries with circular arcs will be linearized in their original coordinate space first, so the resulting geodesic area will be an approximation.

参考

get_Area() for an alternative method returning areas computed in 2D Cartesian space.

Since

GDAL 3.9

パラメータ:

poSRSOverride -- If not null, overrides OGRGeometry::getSpatialReference()

戻り値:

the area of the geometry in square meters, or a negative value in case of error.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual int isClockwise() const override

Returns TRUE if the ring has clockwise winding (or less than 2 points)

Assumes that the line is closed.

戻り値:

TRUE if clockwise otherwise FALSE.

inline OGRSimpleCurve *toUpperClass()

Return pointer of this in upper class.

inline const OGRSimpleCurve *toUpperClass() const

Return pointer of this in upper class.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

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 non-standard 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

explicit OGRLinearRing(OGRLinearRing*)

Constructor.

パラメータ:

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

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRLinearRing *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual void closeRings() override

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.

パラメータ:
  • poPoint -- point

  • bTestEnvelope -- set to TRUE if the presence of the point inside the ring envelope must be checked first.

戻り値:

TRUE or FALSE.

OGRBoolean isPointOnRingBoundary(const OGRPoint *pt, int bTestEnvelope = TRUE) const

Returns whether the point is on the ring boundary.

パラメータ:
  • poPoint -- point

  • bTestEnvelope -- set to TRUE if the presence of the point inside the ring envelope must be checked first.

戻り値:

TRUE or FALSE.

virtual OGRErr transform(OGRCoordinateTransformation *poCT) override

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 only does reprojection on a point-by-point basis. It does not include advanced logic to deal with discontinuities at poles or antimeridian. For that, use the OGRGeometryFactory::transformWithOptions() method.

This method is the same as the C function OGR_G_Transform().

パラメータ:

poCT -- the transformation to apply.

戻り値:

OGRERR_NONE on success or an error code.

inline OGRLineString *toUpperClass()

Return pointer of this in upper class.

inline const OGRLineString *toUpperClass() const

Return pointer of this in upper class.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

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

virtual OGRErr importFromWkb(const unsigned char*, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override

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().

Since

GDAL 2.3

パラメータ:
  • 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

  • nBytesConsumedOut -- output parameter. Number of bytes consumed.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual OGRErr exportToWkb(unsigned char*, const OGRwkbExportOptions* = nullptr) const override

Convert a geometry into well known binary format.

This function relates to the SFCOM IWks::ExportToWKB() method.

This function is the same as the C function OGR_G_ExportToWkbEx().

Since

GDAL 3.9

パラメータ:
  • pabyDstBuffer -- a buffer into which the binary representation is written. This buffer must be at least OGR_G_WkbSize() byte in size.

  • psOptions -- WKB export options.

戻り値:

Currently OGRERR_NONE is always returned.

virtual OGRErr importFromWkt(const char**) override

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().

パラメータ:

ppszInput -- pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a circular string to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT string representing this circular string.

virtual OGRBoolean IsValid() const override

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.

戻り値:

TRUE if the geometry has no points, otherwise FALSE.

virtual void getEnvelope(OGREnvelope *psEnvelope) const override

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().

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override

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

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual OGRCircularString *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual double get_Length() const override

Returns the length of the curve.

This method relates to the SFCOM ICurve::get_Length() method.

戻り値:

the length of the curve, zero if the curve hasn't been initialized.

virtual OGRLineString *CurveToLine(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const override

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().

Since

GDAL 2.0

パラメータ:
  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • papszOptions -- options as a null-terminated list of strings or NULL. See OGRGeometryFactory::curveToLineString() for valid options.

戻り値:

a line string approximating the curve

virtual void Value(double, OGRPoint*) const override

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().

パラメータ:
  • 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.

virtual double get_Area() const override

Get the area of the (closed) curve.

This method is designed to be used by OGRCurvePolygon::get_Area().

参考

get_GeodesicArea() for an alternative method returning areas computed on the ellipsoid, an in square meters.

Since

GDAL 2.0

戻り値:

the area of the geometry in square units of the spatial reference system in use.

virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const override

Get the area of the (closed) curve, considered as a surface on the underlying ellipsoid of the SRS attached to the geometry.

This method is designed to be used by OGRCurvePolygon::get_GeodesicArea().

The returned area will always be in square meters, and assumes that polygon edges describe geodesic lines on the ellipsoid.

Note that geometries with circular arcs will be linearized in their original coordinate space first, so the resulting geodesic area will be an approximation.

参考

get_Area() for an alternative method returning areas computed in 2D Cartesian space.

Since

GDAL 3.9

パラメータ:

poSRSOverride -- If not null, overrides OGRGeometry::getSpatialReference()

戻り値:

the area of the geometry in square meters, or a negative value in case of error.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual void segmentize(double dfMaxLength) override

Modify the geometry such it has no segment longer then the given distance.

This method modifies the geometry to add intermediate vertices if necessary so that the maximum length between 2 consecutive vertices is lower than dfMaxLength.

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()

パラメータ:

dfMaxLength -- the maximum distance between 2 points after segmentization

virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const override

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 non-linear 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 "loss-less" conversion.

This method is the same as the C function OGR_G_HasCurveGeometry().

Since

GDAL 2.0

パラメータ:

bLookForNonLinear -- set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

戻り値:

TRUE if this geometry is or has curve geometry.

virtual OGRGeometry *getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const override

Return, possibly approximate, non-curve 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().

Since

GDAL 2.0

パラメータ:
  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • papszOptions -- options as a null-terminated list of strings. See OGRGeometryFactory::curveToLineString() for valid options.

戻り値:

a new geometry.

inline OGRSimpleCurve *toUpperClass()

Return pointer of this in upper class.

inline const OGRSimpleCurve *toUpperClass() const

Return pointer of this in upper class.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

OGRCurve class

class OGRCurve : public OGRGeometry

Abstract curve base class for OGRLineString, OGRCircularString and OGRCompoundCurve.

Subclassed by OGRCompoundCurve, OGRSimpleCurve

Public Types

typedef OGRPoint ChildType

Type of child elements.

Public Functions

ConstIterator begin() const

Return begin of a point iterator.

Using this iterator for standard range-based 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

ConstIterator end() const

Return end of a point iterator.

virtual OGRCurve *clone() const override = 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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual double get_Length() const = 0

Returns the length of the curve.

This method relates to the SFCOM ICurve::get_Length() method.

戻り値:

the length of the curve, zero if the curve hasn't been initialized.

virtual void StartPoint(OGRPoint*) const = 0

Return the curve start point.

This method relates to the SF COM ICurve::get_StartPoint() method.

パラメータ:

poPoint -- the point to be assigned the start location.

virtual void EndPoint(OGRPoint*) const = 0

Return the curve end point.

This method relates to the SF COM ICurve::get_EndPoint() method.

パラメータ:

poPoint -- the point to be assigned the end location.

virtual 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.

戻り値:

TRUE if closed, else FALSE.

virtual void Value(double, OGRPoint*) 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().

パラメータ:
  • 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.

virtual 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().

Since

GDAL 2.0

パラメータ:
  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • papszOptions -- options as a null-terminated list of strings or NULL. See OGRGeometryFactory::curveToLineString() for valid options.

戻り値:

a line string approximating the curve

virtual int getDimension() const override

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().

戻り値:

0 for points, 1 for lines and 2 for surfaces.

virtual 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).

Since

GDAL 2.0

戻り値:

the number of points of the curve.

virtual 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().

Since

GDAL 2.0

戻り値:

a point iterator over the curve.

virtual OGRBoolean IsConvex() const

Returns if a (closed) curve forms a convex shape.

Since

GDAL 2.0

戻り値:

TRUE if the curve forms a convex shape.

virtual double get_Area() const = 0

Get the area of the (closed) curve.

This method is designed to be used by OGRCurvePolygon::get_Area().

参考

get_GeodesicArea() for an alternative method returning areas computed on the ellipsoid, an in square meters.

Since

GDAL 2.0

戻り値:

the area of the geometry in square units of the spatial reference system in use.

virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const = 0

Get the area of the (closed) curve, considered as a surface on the underlying ellipsoid of the SRS attached to the geometry.

This method is designed to be used by OGRCurvePolygon::get_GeodesicArea().

The returned area will always be in square meters, and assumes that polygon edges describe geodesic lines on the ellipsoid.

Note that geometries with circular arcs will be linearized in their original coordinate space first, so the resulting geodesic area will be an approximation.

参考

get_Area() for an alternative method returning areas computed in 2D Cartesian space.

Since

GDAL 3.9

パラメータ:

poSRSOverride -- If not null, overrides OGRGeometry::getSpatialReference()

戻り値:

the area of the geometry in square meters, or a negative value in case of error.

virtual int isClockwise() const

Returns TRUE if the ring has clockwise winding (or less than 2 points)

Assumes that the line is closed.

戻り値:

TRUE if clockwise otherwise FALSE.

virtual void reversePoints() = 0

Reverse point order.

This method updates the points in this curve in place reversing the point ordering (first for last, etc) and component ordering for a compound curve.

Since

3.10

inline OGRSimpleCurve *toSimpleCurve()

Down-cast to OGRSimpleCurve*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbLineString or wkbCircularString.

inline const OGRSimpleCurve *toSimpleCurve() const

Down-cast to OGRSimpleCurve*.

Implies prior checking that wkbFlatten(getGeometryType()) == wkbLineString or wkbCircularString.

Public Static Functions

static 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)

Since

GDAL 2.0

パラメータ:

poCurve -- the input geometry - ownership is passed to the method.

戻り値:

new geometry

static OGRLineString *CastToLineString(OGRCurve *poCurve)

Cast to linestring.

The passed in geometry is consumed and a new one returned (or NULL in case of failure)

Since

GDAL 2.0

パラメータ:

poCurve -- the input geometry - ownership is passed to the method.

戻り値:

new geometry.

static 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)

Since

GDAL 2.0

パラメータ:

poCurve -- the input geometry - ownership is passed to the method.

戻り値:

new geometry.

OGRSurface class

class OGRSurface : public OGRGeometry

Abstract base class for 2 dimensional objects like polygons or curve polygons.

Subclassed by OGRCurvePolygon, OGRPolyhedralSurface

Public Functions

virtual double get_Area() const = 0

Get the area of the surface object.

The returned area is a 2D Cartesian (planar) area in square units of the spatial reference system in use, so potentially "square degrees" for a geometry expressed in a geographic SRS.

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.

参考

get_GeodesicArea() for an alternative method returning areas computed on the ellipsoid, an in square meters.

戻り値:

the area of the geometry in square units of the spatial reference system in use.

virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const = 0

Get the area of the surface object, considered as a surface on the underlying ellipsoid of the SRS attached to the geometry.

The returned area will always be in square meters, and assumes that polygon edges describe geodesic lines on the ellipsoid.

If the geometry' SRS is not a geographic one, geometries are reprojected to the underlying geographic SRS of the geometry' SRS. OGRSpatialReference::GetDataAxisToSRSAxisMapping() is honored.

For polygons the area is computed as the area of the outer ring less the area of all internal rings.

Note that geometries with circular arcs will be linearized in their original coordinate space first, so the resulting geodesic area will be an approximation.

参考

get_Area() for an alternative method returning areas computed in 2D Cartesian space.

Since

GDAL 3.9

パラメータ:

poSRSOverride -- If not null, overrides OGRGeometry::getSpatialReference()

戻り値:

the area of the geometry in square meters, or a negative value in case of error.

inline virtual OGRErr PointOnSurface(OGRPoint *poPoint) const

This method relates to the SFCOM ISurface::get_PointOnSurface() method.

NOTE: Only implemented when GEOS included in build.

パラメータ:

poPoint -- point to be set with an internal point.

戻り値:

OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise.

virtual OGRSurface *clone() const override = 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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

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

inline ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

inline ChildType **end()

Return end of iterator.

inline const ChildType *const *begin() const

Return begin of iterator.

Since

GDAL 2.3

inline const ChildType *const *end() const

Return end of iterator.

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual OGRPolygon *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const override

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 non-linear 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 "loss-less" conversion.

This method is the same as the C function OGR_G_HasCurveGeometry().

Since

GDAL 2.0

パラメータ:

bLookForNonLinear -- set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

戻り値:

TRUE if this geometry is or has curve geometry.

virtual OGRGeometry *getCurveGeometry(const char *const *papszOptions = nullptr) const override

Return curve version of this geometry.

Returns a geometry that has possibly CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by de-approximating 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().

Since

GDAL 2.0

パラメータ:

papszOptions -- options as a null-terminated list of strings. Unused for now. Must be set to NULL.

戻り値:

a new geometry.

virtual OGRGeometry *getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const override

Return, possibly approximate, non-curve 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().

Since

GDAL 2.0

パラメータ:
  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • papszOptions -- options as a null-terminated list of strings. See OGRGeometryFactory::curveToLineString() for valid options.

戻り値:

a new geometry.

virtual size_t WkbSize() const override

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().

戻り値:

size of binary representation in bytes.

virtual OGRErr importFromWkb(const unsigned char*, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override

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().

Since

GDAL 2.3

パラメータ:
  • 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

  • nBytesConsumedOut -- output parameter. Number of bytes consumed.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual OGRErr exportToWkb(unsigned char*, const OGRwkbExportOptions* = nullptr) const override

Convert a geometry into well known binary format.

This function relates to the SFCOM IWks::ExportToWKB() method.

This function is the same as the C function OGR_G_ExportToWkbEx().

Since

GDAL 3.9

パラメータ:
  • pabyDstBuffer -- a buffer into which the binary representation is written. This buffer must be at least OGR_G_WkbSize() byte in size.

  • psOptions -- WKB export options.

戻り値:

Currently OGRERR_NONE is always returned.

virtual OGRErr importFromWkt(const char**) override

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().

パラメータ:

ppszInput -- pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a polygon to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT representation of the polygon.

virtual OGRPolygon *CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const override

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.

Since

OGR 2.0

パラメータ:
  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • papszOptions -- options as a null-terminated list of strings. Unused for now. Must be set to NULL.

戻り値:

a linestring

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.

戻り値:

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.

戻り値:

pointer to external ring. May be NULL if the OGRPolygon is empty.

virtual OGRLinearRing *getInteriorRing(int)

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.

パラメータ:

iRing -- internal ring index from 0 to getNumInteriorRings() - 1.

戻り値:

pointer to interior ring. May be NULL.

virtual const OGRLinearRing *getInteriorRing(int) 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.

パラメータ:

iRing -- internal ring index from 0 to getNumInteriorRings() - 1.

戻り値:

pointer to interior ring. May be NULL.

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.

戻り値:

pointer to external ring. May be NULL if the OGRPolygon is empty.

virtual OGRLinearRing *stealInteriorRing(int)

"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.

パラメータ:

iRing -- internal ring index from 0 to getNumInteriorRings() - 1.

戻り値:

pointer to interior ring. May be NULL.

OGRBoolean IsPointOnSurface(const OGRPoint*) const

Return whether the point is on the surface.

戻り値:

TRUE or FALSE

inline OGRCurvePolygon *toUpperClass()

Return pointer of this in upper class.

inline const OGRCurvePolygon *toUpperClass() const

Return pointer of this in upper class.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

virtual void closeRings() override

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.

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 Types

typedef OGRCurve ChildType

Type of child elements.

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

inline ChildType **begin()

Return begin of curve iterator.

Since

GDAL 2.3

inline ChildType **end()

Return end of curve iterator.

inline const ChildType *const *begin() const

Return begin of curve iterator.

Since

GDAL 2.3

inline const ChildType *const *end() const

Return end of curve iterator.

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual OGRCurvePolygon *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual void empty() override

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().

virtual OGRErr transform(OGRCoordinateTransformation *poCT) override

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 only does reprojection on a point-by-point basis. It does not include advanced logic to deal with discontinuities at poles or antimeridian. For that, use the OGRGeometryFactory::transformWithOptions() method.

This method is the same as the C function OGR_G_Transform().

パラメータ:

poCT -- the transformation to apply.

戻り値:

OGRERR_NONE on success or an error code.

virtual void flattenTo2D() override

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 OGRBoolean IsEmpty() const override

Returns TRUE (non-zero) 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.

戻り値:

TRUE if object is empty, otherwise FALSE.

virtual void segmentize(double dfMaxLength) override

Modify the geometry such it has no segment longer then the given distance.

This method modifies the geometry to add intermediate vertices if necessary so that the maximum length between 2 consecutive vertices is lower than dfMaxLength.

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()

パラメータ:

dfMaxLength -- the maximum distance between 2 points after segmentization

virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const override

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 non-linear 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 "loss-less" conversion.

This method is the same as the C function OGR_G_HasCurveGeometry().

Since

GDAL 2.0

パラメータ:

bLookForNonLinear -- set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

戻り値:

TRUE if this geometry is or has curve geometry.

virtual OGRGeometry *getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const override

Return, possibly approximate, non-curve 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().

Since

GDAL 2.0

パラメータ:
  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • papszOptions -- options as a null-terminated list of strings. See OGRGeometryFactory::curveToLineString() for valid options.

戻り値:

a new geometry.

virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const override

Get the area of the surface object, considered as a surface on the underlying ellipsoid of the SRS attached to the geometry.

The returned area will always be in square meters, and assumes that polygon edges describe geodesic lines on the ellipsoid.

If the geometry' SRS is not a geographic one, geometries are reprojected to the underlying geographic SRS of the geometry' SRS. OGRSpatialReference::GetDataAxisToSRSAxisMapping() is honored.

For polygons the area is computed as the area of the outer ring less the area of all internal rings.

Note that geometries with circular arcs will be linearized in their original coordinate space first, so the resulting geodesic area will be an approximation.

参考

get_Area() for an alternative method returning areas computed in 2D Cartesian space.

Since

GDAL 3.9

パラメータ:

poSRSOverride -- If not null, overrides OGRGeometry::getSpatialReference()

戻り値:

the area of the geometry in square meters, or a negative value in case of error.

virtual double get_Area() const override

Get the area of the surface object.

The returned area is a 2D Cartesian (planar) area in square units of the spatial reference system in use, so potentially "square degrees" for a geometry expressed in a geographic SRS.

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.

参考

get_GeodesicArea() for an alternative method returning areas computed on the ellipsoid, an in square meters.

戻り値:

the area of the geometry in square units of the spatial reference system in use.

virtual size_t WkbSize() const override

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().

戻り値:

size of binary representation in bytes.

virtual OGRErr importFromWkb(const unsigned char*, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override

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().

Since

GDAL 2.3

パラメータ:
  • 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

  • nBytesConsumedOut -- output parameter. Number of bytes consumed.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual OGRErr exportToWkb(unsigned char*, const OGRwkbExportOptions* = nullptr) const override

Convert a geometry into well known binary format.

This function relates to the SFCOM IWks::ExportToWKB() method.

This function is the same as the C function OGR_G_ExportToWkbEx().

Since

GDAL 3.9

パラメータ:
  • pabyDstBuffer -- a buffer into which the binary representation is written. This buffer must be at least OGR_G_WkbSize() byte in size.

  • psOptions -- WKB export options.

戻り値:

Currently OGRERR_NONE is always returned.

virtual OGRErr importFromWkt(const char**) override

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().

パラメータ:

ppszInput -- pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a curve polygon to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT representation of the curve polygon.

virtual int getDimension() const override

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().

戻り値:

0 for points, 1 for lines and 2 for surfaces.

virtual void getEnvelope(OGREnvelope *psEnvelope) const override

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().

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override

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

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual 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.

Since

OGR 2.0

パラメータ:
  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • papszOptions -- options as a null-terminated list of strings. Unused for now. Must be set to NULL.

戻り値:

a linestring

virtual OGRBoolean Equals(const OGRGeometry*) const override

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 sub-geometries 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().

戻り値:

TRUE if equivalent or FALSE otherwise.

virtual OGRBoolean Intersects(const OGRGeometry*) const override

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().

パラメータ:

poOtherGeom -- the other geometry to test against.

戻り値:

TRUE if the geometries intersect, otherwise FALSE.

virtual OGRBoolean Contains(const OGRGeometry*) const override

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.

パラメータ:

poOtherGeom -- the geometry to compare to this geometry.

戻り値:

TRUE if poOtherGeom contains this geometry, otherwise FALSE.

virtual void setCoordinateDimension(int nDimension) override

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.

Deprecated:

use set3D() or setMeasured().

パラメータ:

nNewDimension -- New coordinate dimension value, either 2 or 3.

virtual void set3D(OGRBoolean bIs3D) override

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

パラメータ:

bIs3D -- Should the geometry have a Z dimension, either TRUE or FALSE.

virtual void setMeasured(OGRBoolean bIsMeasured) override

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

パラメータ:

bIsMeasured -- Should the geometry have a M dimension, either TRUE or FALSE.

virtual void assignSpatialReference(const OGRSpatialReference *poSR) override

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 sub-geometries 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().

パラメータ:

poSR -- new spatial reference system to apply.

virtual OGRErr addRing(OGRCurve*)

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.

パラメータ:

poNewRing -- ring to be added to the polygon.

戻り値:

OGRERR_NONE in case of success

virtual OGRErr addRingDirectly(OGRCurve*)

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.

パラメータ:

poNewRing -- ring to be added to the polygon.

戻り値:

OGRERR_NONE in case of success

OGRErr addRing(std::unique_ptr<OGRCurve>)

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.

This method has no SFCOM analog.

パラメータ:

poNewRing -- ring to be added to the polygon.

戻り値:

OGRERR_NONE in case of success

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?

戻り値:

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.

戻り値:

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.

戻り値:

count of internal rings, zero or more.

OGRCurve *getInteriorRingCurve(int)

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.

パラメータ:

iRing -- internal ring index from 0 to getNumInteriorRings() - 1.

戻り値:

pointer to interior ring. May be NULL.

const OGRCurve *getInteriorRingCurve(int) 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.

パラメータ:

iRing -- internal ring index from 0 to getNumInteriorRings() - 1.

戻り値:

pointer to interior ring. May be NULL.

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.

戻り値:

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.

パラメータ:
  • 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.

戻り値:

OGRERR_NONE if successful, or OGRERR_FAILURE if the index is out of range.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

virtual void swapXY() override

Swap x and y coordinates.

Since

OGR 1.8.0

virtual bool hasEmptyParts() const override

Returns whether a geometry has empty parts/rings.

Returns true if removeEmptyParts() will modify the geometry.

This is different from IsEmpty().

Since

GDAL 3.10

virtual void removeEmptyParts() override

Remove empty parts/rings from this geometry.

Since

GDAL 3.10

OGRMultiPoint class

class OGRMultiPoint : public OGRGeometryCollection

A collection of OGRPoint.

Public Types

typedef OGRPoint ChildType

Type of child elements.

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

inline ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

inline ChildType **end()

Return end of iterator.

inline const ChildType *const *begin() const

Return begin of iterator.

Since

GDAL 2.3

inline const ChildType *const *end() const

Return end of iterator.

inline OGRPoint *getGeometryRef(int i)

See OGRGeometryCollection::getGeometryRef()

inline const OGRPoint *getGeometryRef(int i) const

See OGRGeometryCollection::getGeometryRef()

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual OGRMultiPoint *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual OGRErr importFromWkt(const char**) override

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().

パラメータ:

ppszInput -- pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a multipoint to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT representation of the multipoint.

virtual int getDimension() const override

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().

戻り値:

0 for points, 1 for lines and 2 for surfaces.

inline OGRGeometryCollection *toUpperClass()

Return pointer of this in upper class.

inline const OGRGeometryCollection *toUpperClass() const

Return pointer of this in upper class.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const override

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 non-linear 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 "loss-less" conversion.

This method is the same as the C function OGR_G_HasCurveGeometry().

Since

GDAL 2.0

パラメータ:

bLookForNonLinear -- set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

戻り値:

TRUE if this geometry is or has curve geometry.

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

inline ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

inline ChildType **end()

Return end of iterator.

inline const ChildType *const *begin() const

Return begin of iterator.

Since

GDAL 2.3

inline const ChildType *const *end() const

Return end of iterator.

inline OGRLineString *getGeometryRef(int i)

See OGRGeometryCollection::getGeometryRef()

inline const OGRLineString *getGeometryRef(int i) const

See OGRGeometryCollection::getGeometryRef()

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual OGRMultiLineString *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual OGRErr importFromWkb(const unsigned char*, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override

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().

Since

GDAL 2.3

パラメータ:
  • 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

  • nBytesConsumedOut -- output parameter. Number of bytes consumed.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a multilinestring to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT representation of the multilinestring.

virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const override

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 non-linear 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 "loss-less" conversion.

This method is the same as the C function OGR_G_HasCurveGeometry().

Since

GDAL 2.0

パラメータ:

bLookForNonLinear -- set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

戻り値:

TRUE if this geometry is or has curve geometry.

inline OGRGeometryCollection *toUpperClass()

Return pointer of this in upper class.

inline const OGRGeometryCollection *toUpperClass() const

Return pointer of this in upper class.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

Public Static Functions

static OGRMultiCurve *CastToMultiCurve(OGRMultiLineString *poMLS)

Cast to multicurve.

The passed in geometry is consumed and a new one returned.

パラメータ:

poMLS -- the input geometry - ownership is passed to the method.

戻り値:

new geometry.

OGRMultiPolygon class

class OGRMultiPolygon : public OGRMultiSurface

A collection of non-overlapping 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

inline ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

inline ChildType **end()

Return end of iterator.

inline const ChildType *const *begin() const

Return begin of iterator.

Since

GDAL 2.3

inline const ChildType *const *end() const

Return end of iterator.

inline OGRPolygon *getGeometryRef(int i)

See OGRGeometryCollection::getGeometryRef()

inline const OGRPolygon *getGeometryRef(int i) const

See OGRGeometryCollection::getGeometryRef()

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual OGRMultiPolygon *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual OGRErr importFromWkb(const unsigned char*, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override

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().

Since

GDAL 2.3

パラメータ:
  • 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

  • nBytesConsumedOut -- output parameter. Number of bytes consumed.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a multipolygon to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT representation of the multipolygon.

virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const override

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 non-linear 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 "loss-less" conversion.

This method is the same as the C function OGR_G_HasCurveGeometry().

Since

GDAL 2.0

パラメータ:

bLookForNonLinear -- set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

戻り値:

TRUE if this geometry is or has curve geometry.

inline OGRGeometryCollection *toUpperClass()

Return pointer of this in upper class.

inline const OGRGeometryCollection *toUpperClass() const

Return pointer of this in upper class.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

Public Static Functions

static OGRMultiSurface *CastToMultiSurface(OGRMultiPolygon *poMP)

Cast to multisurface.

The passed in geometry is consumed and a new one returned .

パラメータ:

poMP -- the input geometry - ownership is passed to the method.

戻り値:

new geometry.

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

inline ChildType **begin()

Return begin of sub-geometry iterator.

Since

GDAL 2.3

inline ChildType **end()

Return end of sub-geometry iterator.

inline const ChildType *const *begin() const

Return begin of sub-geometry iterator.

Since

GDAL 2.3

inline const ChildType *const *end() const

Return end of sub-geometry iterator.

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual OGRGeometryCollection *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual void empty() override

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().

virtual OGRErr transform(OGRCoordinateTransformation *poCT) override

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 only does reprojection on a point-by-point basis. It does not include advanced logic to deal with discontinuities at poles or antimeridian. For that, use the OGRGeometryFactory::transformWithOptions() method.

This method is the same as the C function OGR_G_Transform().

パラメータ:

poCT -- the transformation to apply.

戻り値:

OGRERR_NONE on success or an error code.

virtual void flattenTo2D() override

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 OGRBoolean IsEmpty() const override

Returns TRUE (non-zero) 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.

戻り値:

TRUE if object is empty, otherwise FALSE.

virtual void segmentize(double dfMaxLength) override

Modify the geometry such it has no segment longer then the given distance.

This method modifies the geometry to add intermediate vertices if necessary so that the maximum length between 2 consecutive vertices is lower than dfMaxLength.

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()

パラメータ:

dfMaxLength -- the maximum distance between 2 points after segmentization

virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const override

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 non-linear 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 "loss-less" conversion.

This method is the same as the C function OGR_G_HasCurveGeometry().

Since

GDAL 2.0

パラメータ:

bLookForNonLinear -- set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

戻り値:

TRUE if this geometry is or has curve geometry.

virtual OGRGeometry *getCurveGeometry(const char *const *papszOptions = nullptr) const override

Return curve version of this geometry.

Returns a geometry that has possibly CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE or MULTISURFACE in it, by de-approximating 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().

Since

GDAL 2.0

パラメータ:

papszOptions -- options as a null-terminated list of strings. Unused for now. Must be set to NULL.

戻り値:

a new geometry.

virtual OGRGeometry *getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, const char *const *papszOptions = nullptr) const override

Return, possibly approximate, non-curve 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().

Since

GDAL 2.0

パラメータ:
  • dfMaxAngleStepSizeDegrees -- the largest step in degrees along the arc, zero to use the default setting.

  • papszOptions -- options as a null-terminated list of strings. See OGRGeometryFactory::curveToLineString() for valid options.

戻り値:

a new geometry.

virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const

Compute area of geometry collection, considered as a surface on the underlying ellipsoid of the SRS attached to the geometry.

The returned area will always be in square meters, and assumes that polygon edges describe geodesic lines on the ellipsoid.

If the geometry' SRS is not a geographic one, geometries are reprojected to the underlying geographic SRS of the geometry' SRS. OGRSpatialReference::GetDataAxisToSRSAxisMapping() is honored.

The area is computed as the sum of the areas of all members in this collection.

参考

get_Area() for an alternative method returning areas computed in 2D Cartesian space.

Since

GDAL 3.9

注釈

No warning will be issued if a member of the collection does not support the get_GeodesicArea method.

パラメータ:

poSRSOverride -- If not null, overrides OGRGeometry::getSpatialReference()

戻り値:

the area of the geometry in square meters, or a negative value in case of error.

virtual size_t WkbSize() const override

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().

戻り値:

size of binary representation in bytes.

virtual OGRErr importFromWkb(const unsigned char*, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override

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().

Since

GDAL 2.3

パラメータ:
  • 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

  • nBytesConsumedOut -- output parameter. Number of bytes consumed.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual OGRErr exportToWkb(unsigned char*, const OGRwkbExportOptions* = nullptr) const override

Convert a geometry into well known binary format.

This function relates to the SFCOM IWks::ExportToWKB() method.

This function is the same as the C function OGR_G_ExportToWkbEx().

Since

GDAL 3.9

パラメータ:
  • pabyDstBuffer -- a buffer into which the binary representation is written. This buffer must be at least OGR_G_WkbSize() byte in size.

  • psOptions -- WKB export options.

戻り値:

Currently OGRERR_NONE is always returned.

virtual OGRErr importFromWkt(const char**) override

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().

パラメータ:

ppszInput -- pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a geometry collection to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT representation of the geometry collection.

virtual 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.

注釈

No warning will be issued if a member of the collection does not support the get_Length method.

戻り値:

computed length.

virtual 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.

注釈

No warning will be issued if a member of the collection does not support the get_Area method.

戻り値:

computed area.

virtual int getDimension() const override

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().

戻り値:

0 for points, 1 for lines and 2 for surfaces.

virtual void getEnvelope(OGREnvelope *psEnvelope) const override

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().

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override

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

パラメータ:

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.

戻り値:

count of children geometries. May be zero.

OGRGeometry *getGeometryRef(int)

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.

パラメータ:

i -- the index of the geometry to fetch, between 0 and getNumGeometries() - 1.

戻り値:

pointer to requested geometry.

const OGRGeometry *getGeometryRef(int) 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.

パラメータ:

i -- the index of the geometry to fetch, between 0 and getNumGeometries() - 1.

戻り値:

pointer to requested geometry.

virtual OGRBoolean Equals(const OGRGeometry*) const override

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 sub-geometries 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().

戻り値:

TRUE if equivalent or FALSE otherwise.

virtual void setCoordinateDimension(int nDimension) override

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.

Deprecated:

use set3D() or setMeasured().

パラメータ:

nNewDimension -- New coordinate dimension value, either 2 or 3.

virtual void set3D(OGRBoolean bIs3D) override

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

パラメータ:

bIs3D -- Should the geometry have a Z dimension, either TRUE or FALSE.

virtual void setMeasured(OGRBoolean bIsMeasured) override

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

パラメータ:

bIsMeasured -- Should the geometry have a M dimension, either TRUE or FALSE.

virtual OGRErr addGeometry(const OGRGeometry*)

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().

パラメータ:

poNewGeom -- geometry to add to the container.

戻り値:

OGRERR_NONE if successful, or OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the type of geometry container.

virtual OGRErr addGeometryDirectly(OGRGeometry*)

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, but only if the method is successful. If the method fails, ownership still belongs to the caller.

This method is the same as the C function OGR_G_AddGeometryDirectly().

There is no SFCOM analog to this method.

パラメータ:

poNewGeom -- geometry to add to the container.

戻り値:

OGRERR_NONE if successful, or OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the type of geometry container.

OGRErr addGeometry(std::unique_ptr<OGRGeometry> geom)

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.

There is no SFCOM analog to this method.

パラメータ:

geom -- geometry to add to the container.

戻り値:

OGRERR_NONE if successful, or OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the type of geometry container.

virtual 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().

パラメータ:
  • 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.

戻り値:

OGRERR_NONE if successful, or OGRERR_FAILURE if the index is out of range.

virtual bool hasEmptyParts() const override

Returns whether a geometry has empty parts/rings.

Returns true if removeEmptyParts() will modify the geometry.

This is different from IsEmpty().

Since

GDAL 3.10

virtual void removeEmptyParts() override

Remove empty parts/rings from this geometry.

Since

GDAL 3.10

virtual void assignSpatialReference(const OGRSpatialReference *poSR) override

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 sub-geometries 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().

パラメータ:

poSR -- new spatial reference system to apply.

virtual void closeRings() override

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.

virtual void swapXY() override

Swap x and y coordinates.

Since

OGR 1.8.0

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

Public Static Functions

static 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).

Since

GDAL 2.2

パラメータ:

poSrc -- the input geometry - ownership is passed to the method.

戻り値:

new geometry.

OGRMultiCurve class

class OGRMultiCurve : public OGRGeometryCollection

A collection of OGRCurve.

Since

GDAL 2.0

Subclassed by OGRMultiLineString

Public Types

typedef OGRCurve ChildType

Type of child elements.

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

inline ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

inline ChildType **end()

Return end of iterator.

inline const ChildType *const *begin() const

Return begin of iterator.

Since

GDAL 2.3

inline const ChildType *const *end() const

Return end of iterator.

inline OGRCurve *getGeometryRef(int i)

See OGRGeometryCollection::getGeometryRef()

inline const OGRCurve *getGeometryRef(int i) const

See OGRGeometryCollection::getGeometryRef()

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual OGRMultiCurve *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual OGRErr importFromWkt(const char**) override

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().

パラメータ:

ppszInput -- pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a multicurve to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT representation of the multicurve.

virtual int getDimension() const override

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().

戻り値:

0 for points, 1 for lines and 2 for surfaces.

virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const override

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 non-linear 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 "loss-less" conversion.

This method is the same as the C function OGR_G_HasCurveGeometry().

Since

GDAL 2.0

パラメータ:

bLookForNonLinear -- set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

戻り値:

TRUE if this geometry is or has curve geometry.

inline OGRGeometryCollection *toUpperClass()

Return pointer of this in upper class.

inline const OGRGeometryCollection *toUpperClass() const

Return pointer of this in upper class.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

Public Static Functions

static 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).

パラメータ:

poMC -- the input geometry - ownership is passed to the method.

戻り値:

new geometry.

OGRMultiSurface class

class OGRMultiSurface : public OGRGeometryCollection

A collection of non-overlapping 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

inline ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

inline ChildType **end()

Return end of iterator.

inline const ChildType *const *begin() const

Return begin of iterator.

Since

GDAL 2.3

inline const ChildType *const *end() const

Return end of iterator.

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual OGRMultiSurface *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual OGRErr importFromWkt(const char**) override

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().

パラメータ:

ppszInput -- pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a geometry collection to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT representation of the geometry collection.

virtual OGRErr PointOnSurface(OGRPoint *poPoint) const

This method relates to the SFCOM IMultiSurface::get_PointOnSurface() method.

NOTE: Only implemented when GEOS included in build.

パラメータ:

poPoint -- point to be set with an internal point.

戻り値:

OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise.

virtual int getDimension() const override

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().

戻り値:

0 for points, 1 for lines and 2 for surfaces.

inline OGRSurface *getGeometryRef(int i)

See OGRGeometryCollection::getGeometryRef()

inline const OGRSurface *getGeometryRef(int i) const

See OGRGeometryCollection::getGeometryRef()

virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const override

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 non-linear 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 "loss-less" conversion.

This method is the same as the C function OGR_G_HasCurveGeometry().

Since

GDAL 2.0

パラメータ:

bLookForNonLinear -- set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

戻り値:

TRUE if this geometry is or has curve geometry.

inline OGRGeometryCollection *toUpperClass()

Return pointer of this in upper class.

inline const OGRGeometryCollection *toUpperClass() const

Return pointer of this in upper class.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

Public Static Functions

static 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).

パラメータ:

poMS -- the input geometry - ownership is passed to the method.

戻り値:

new geometry.

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() override

Destructor.

OGRPolyhedralSurface &operator=(const OGRPolyhedralSurface &other)

Assignment operator.

inline ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

inline ChildType **end()

Return end of iterator.

inline const ChildType *const *begin() const

Return begin of iterator.

Since

GDAL 2.3

inline const ChildType *const *end() const

Return end of iterator.

virtual size_t WkbSize() const override

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().

戻り値:

size of binary representation in bytes.

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRwkbGeometryType getGeometryType() const override

Returns the WKB Type of PolyhedralSurface.

virtual OGRErr importFromWkb(const unsigned char*, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override

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().

Since

GDAL 2.3

パラメータ:
  • 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

  • nBytesConsumedOut -- output parameter. Number of bytes consumed.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual OGRErr exportToWkb(unsigned char*, const OGRwkbExportOptions* = nullptr) const override

Convert a geometry into well known binary format.

This function relates to the SFCOM IWks::ExportToWKB() method.

This function is the same as the C function OGR_G_ExportToWkbEx().

Since

GDAL 3.9

パラメータ:
  • pabyDstBuffer -- a buffer into which the binary representation is written. This buffer must be at least OGR_G_WkbSize() byte in size.

  • psOptions -- WKB export options.

戻り値:

Currently OGRERR_NONE is always returned.

virtual OGRErr importFromWkt(const char**) override

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().

パラメータ:

ppszInput -- pointer to a pointer to the source text. The pointer is updated to pointer after the consumed text.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual std::string exportToWkt(const OGRWktOptions &opts = OGRWktOptions(), OGRErr *err = nullptr) const override

Export a polyhedral surface to WKT.

パラメータ:
  • opts -- Output options.

  • err -- Pointer to error code, if desired.

戻り値:

WKT representation of the polyhedral surface.

virtual int getDimension() const override

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().

戻り値:

0 for points, 1 for lines and 2 for surfaces.

virtual void empty() override

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().

virtual OGRPolyhedralSurface *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual void getEnvelope(OGREnvelope *psEnvelope) const override

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().

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual void getEnvelope(OGREnvelope3D *psEnvelope) const override

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

パラメータ:

psEnvelope -- the structure in which to place the results.

virtual void flattenTo2D() override

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 OGRErr transform(OGRCoordinateTransformation*) override

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 only does reprojection on a point-by-point basis. It does not include advanced logic to deal with discontinuities at poles or antimeridian. For that, use the OGRGeometryFactory::transformWithOptions() method.

This method is the same as the C function OGR_G_Transform().

パラメータ:

poCT -- the transformation to apply.

戻り値:

OGRERR_NONE on success or an error code.

virtual OGRBoolean Equals(const OGRGeometry*) const override

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 sub-geometries 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().

戻り値:

TRUE if equivalent or FALSE otherwise.

virtual double get_Area() const override

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

戻り値:

area enclosed by the PolyhedralSurface

virtual double get_GeodesicArea(const OGRSpatialReference *poSRSOverride = nullptr) const override

Get the area of the surface object, considered as a surface on the underlying ellipsoid of the SRS attached to the geometry.

The returned area will always be in square meters, and assumes that polygon edges describe geodesic lines on the ellipsoid.

If the geometry' SRS is not a geographic one, geometries are reprojected to the underlying geographic SRS of the geometry' SRS. OGRSpatialReference::GetDataAxisToSRSAxisMapping() is honored.

For polygons the area is computed as the area of the outer ring less the area of all internal rings.

Note that geometries with circular arcs will be linearized in their original coordinate space first, so the resulting geodesic area will be an approximation.

参考

get_Area() for an alternative method returning areas computed in 2D Cartesian space.

Since

GDAL 3.9

パラメータ:

poSRSOverride -- If not null, overrides OGRGeometry::getSpatialReference()

戻り値:

the area of the geometry in square meters, or a negative value in case of error.

virtual OGRErr PointOnSurface(OGRPoint*) const override

This method relates to the SFCOM ISurface::get_PointOnSurface() method.

NOTE: Only implemented when GEOS included in build.

パラメータ:

poPoint -- point to be set with an internal point.

戻り値:

OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise.

virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const override

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 non-linear 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 "loss-less" conversion.

This method is the same as the C function OGR_G_HasCurveGeometry().

Since

GDAL 2.0

パラメータ:

bLookForNonLinear -- set it to TRUE to check if the geometry is or contains a CIRCULARSTRING.

戻り値:

TRUE if this geometry is or has curve geometry.

virtual OGRErr addGeometry(const OGRGeometry*)

Add a new geometry to a collection.

Only a POLYGON can be added to a POLYHEDRALSURFACE.

戻り値:

OGRErr OGRERR_NONE if the polygon is successfully added

OGRErr addGeometryDirectly(OGRGeometry *poNewGeom)

Add a geometry directly to the container.

Ownership of the passed geometry is taken by the container rather than cloning as addCurve() does, but only if the method is successful. If the method fails, ownership still belongs to the caller.

This method is the same as the C function OGR_G_AddGeometryDirectly().

There is no SFCOM analog to this method.

パラメータ:

poNewGeom -- geometry to add to the container.

戻り値:

OGRERR_NONE if successful, or OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the type of geometry container.

OGRErr addGeometry(std::unique_ptr<OGRGeometry> poNewGeom)

Add a geometry directly to the container.

There is no SFCOM analog to this method.

パラメータ:

geom -- geometry to add to the container.

戻り値:

OGRERR_NONE if successful, or OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the type of geometry container.

int getNumGeometries() const

Fetch number of geometries in PolyhedralSurface.

戻り値:

count of children geometries. May be zero.

OGRPolygon *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.

パラメータ:

i -- the index of the geometry to fetch, between 0 and getNumGeometries() - 1.

戻り値:

pointer to requested geometry.

const OGRPolygon *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.

パラメータ:

i -- the index of the geometry to fetch, between 0 and getNumGeometries() - 1.

戻り値:

pointer to requested geometry.

virtual OGRBoolean IsEmpty() const override

Checks if the PolyhedralSurface is empty.

戻り値:

TRUE if the PolyhedralSurface is empty, FALSE otherwise

virtual void setCoordinateDimension(int nDimension) override

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.

パラメータ:

nNewDimension -- New coordinate dimension value, either 2 or 3.

virtual void set3D(OGRBoolean bIs3D) override

Set the type as 3D geometry.

virtual void setMeasured(OGRBoolean bIsMeasured) override

Set the type as Measured.

virtual void swapXY() override

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.

パラメータ:
  • 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.

戻り値:

OGRERR_NONE if successful, or OGRERR_FAILURE if the index is out of range.

virtual bool hasEmptyParts() const override

Returns whether a geometry has empty parts/rings.

Returns true if removeEmptyParts() will modify the geometry.

This is different from IsEmpty().

Since

GDAL 3.10

virtual void removeEmptyParts() override

Remove empty parts/rings from this geometry.

Since

GDAL 3.10

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

virtual void assignSpatialReference(const OGRSpatialReference *poSR) override

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 sub-geometries 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().

パラメータ:

poSR -- new spatial reference system to apply.

Public Static Functions

static 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)

パラメータ:

poPS -- the input geometry - ownership is passed to the method.

戻り値:

new geometry.

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.

パラメータ:
  • p -- Point 1

  • q -- Point 2

  • r -- 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.

パラメータ:
  • other -- the Polygon we wish to construct a triangle from

  • eErr -- encapsulates an error code; contains OGRERR_NONE if the triangle is constructed successfully

OGRTriangle &operator=(const OGRTriangle &other)

Assignment operator.

パラメータ:

other -- A triangle passed as a parameter

戻り値:

OGRTriangle A copy of other

~OGRTriangle() override

Destructor.

virtual const char *getGeometryName() const override

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().

戻り値:

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.

virtual OGRwkbGeometryType getGeometryType() const override

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().

戻り値:

the geometry type code.

virtual OGRTriangle *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

virtual OGRErr importFromWkb(const unsigned char*, size_t, OGRwkbVariant, size_t &nBytesConsumedOut) override

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().

Since

GDAL 2.3

パラメータ:
  • 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

  • nBytesConsumedOut -- output parameter. Number of bytes consumed.

戻り値:

OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

virtual OGRErr addRingDirectly(OGRCurve *poNewRing) override

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.

パラメータ:

poNewRing -- ring to be added to the polygon.

戻り値:

OGRERR_NONE in case of success

inline OGRPolygon *toUpperClass()

Return pointer of this in upper class.

inline const OGRPolygon *toUpperClass() const

Return pointer of this in upper class.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

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.

inline ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

inline ChildType **end()

Return end of iterator.

inline const ChildType *const *begin() const

Return begin of iterator.

Since

GDAL 2.3

inline const ChildType *const *end() const

Return end of iterator.

OGRTriangulatedSurface &operator=(const OGRTriangulatedSurface &other)

Assignment operator.

virtual const char *getGeometryName() const override

Returns the geometry name of the TriangulatedSurface.

戻り値:

"TIN"

virtual OGRwkbGeometryType getGeometryType() const override

Returns the WKB Type of TriangulatedSurface.

virtual OGRTriangulatedSurface *clone() const override

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().

戻り値:

a new object instance with the same geometry, and spatial reference system as the original.

inline OGRTriangle *getGeometryRef(int i)

See OGRPolyhedralSurface::getGeometryRef()

inline const OGRTriangle *getGeometryRef(int i) const

See OGRPolyhedralSurface::getGeometryRef()

virtual OGRErr addGeometry(const OGRGeometry*) override

Add a new geometry to a collection.

Only a POLYGON can be added to a POLYHEDRALSURFACE.

戻り値:

OGRErr OGRERR_NONE if the polygon is successfully added

inline OGRPolyhedralSurface *toUpperClass()

Return pointer of this in upper class.

inline const OGRPolyhedralSurface *toUpperClass() const

Return pointer of this in upper class.

inline virtual void accept(IOGRGeometryVisitor *visitor) override

Accept a visitor.

inline virtual void accept(IOGRConstGeometryVisitor *visitor) const override

Accept a visitor.

Public Static Functions

static 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)

パラメータ:

poTS -- the input geometry - ownership is passed to the method.

戻り値:

new geometry.