几何图形C++ API

包含文件:ogr_geometry.h

ogergometryFactory类

classOGRGeometryFactory

Create geometry objects from well known text/binary.

公共静态函数

OGRErrcreateFromWkb(const void*, OGRSpatialReference*, OGRGeometry**, int = -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.

Return

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

Parameters

  • pabyData: pointer to the input BLOB data.

  • poSR: pointer to the spatial reference to be assigned to the created geometry object. This may be NULL.

  • ppoReturn: the newly created geometry object will be assigned to the indicated pointer on return. This will be NULL in case of failure. If not NULL, *ppoReturn should be freed with OGRGeometryFactory::destroyGeometry() after use.

  • nBytes: the number of bytes available in pabyData, or -1 if it isn't known.

  • eWkbVariant: WKB variant.

OGRErrcreateFromWkb(const void *pabyDataOGRSpatialReference*, OGRGeometry**, int nSizeOGRwkbVarianteVariant, int &nBytesConsumedOut)

Create a geometry object of the appropriate type from its well known binary representation.

Note that if nBytes is passed as zero, no checking can be done on whether the pabyData is sufficient. This can result in a crash if the input data is corrupt. This function returns no indication of the number of bytes from the data source actually used to represent the returned geometry object. Use OGRGeometry::WkbSize() on the returned geometry to establish the number of bytes it required in WKB format.

Also note that this is a static method, and that there is no need to instantiate an OGRGeometryFactory object.

The C function OGR_G_CreateFromWkb() is the same as this method.

Return

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

Since

GDAL 2.3

Parameters

  • pabyData: pointer to the input BLOB data.

  • poSR: pointer to the spatial reference to be assigned to the created geometry object. This may be NULL.

  • ppoReturn: the newly created geometry object will be assigned to the indicated pointer on return. This will be NULL in case of failure. If not NULL, *ppoReturn should be freed with OGRGeometryFactory::destroyGeometry() after use.

  • nBytes: the number of bytes available in pabyData, or -1 if it isn't known.

  • eWkbVariant: WKB variant.

  • nBytesConsumedOut: output parameter. Number of bytes consumed.

OGRErrcreateFromWkt(const char*, 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.

Return

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

Since

GDAL 2.3

Parameters

  • pszData: input zero terminated string containing well known text representation of the geometry to be created.

  • poSR: pointer to the spatial reference to be assigned to the created geometry object. This may be NULL.

  • ppoReturn: the newly created geometry object will be assigned to the indicated pointer on return. This will be NULL if the method fails. If not NULL, *ppoReturn should be freed with OGRGeometryFactory::destroyGeometry() after use.

OGRErrcreateFromWkt(const char**, 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:

Parameters

  • ppszData: input zero terminated string containing well known text representation of the geometry to be created. The pointer is updated to point just beyond that last character consumed.

  • poSR: pointer to the spatial reference to be assigned to the created geometry object. This may be NULL.

  • ppoReturn: the newly created geometry object will be assigned to the indicated pointer on return. This will be NULL if the method fails. If not NULL, *ppoReturn should be freed with OGRGeometryFactory::destroyGeometry() after use.

const char* wkt= "POINT(0 0)";

// cast because OGR_G_CreateFromWkt will move the pointer
char* pszWkt = (char*) wkt;
OGRSpatialReferenceH ref = OSRNewSpatialReference(NULL);
OGRGeometryH new_geom;
OSRSetAxisMappingStrategy(poSR, OAMS_TRADITIONAL_GIS_ORDER);
OGRErr err = OGR_G_CreateFromWkt(&pszWkt, ref, &new_geom);

Return

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

OGRErrcreateFromWkt(char **ppszInputOGRSpatialReference *poSRSOGRGeometry **ppoGeom)

Deprecated.

Deprecated:

in GDAL 2.3

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

Return

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

Parameters

  • pabyData: pointer to the input BLOB data.

  • poSR: pointer to the spatial reference to be assigned to the created geometry object. This may be NULL.

  • ppoReturn: the newly created geometry object will be assigned to the indicated pointer on return. This will be NULL in case of failure, but NULL might be a valid return for a NULL shape.

  • nBytes: the number of bytes available in pabyData.

  • pnBytesConsumed: if not NULL, it will be set to the number of bytes consumed (at most nBytes).

OGRGeometry *createFromGML(const char*)

Create geometry from GML.

This method translates a fragment of GML containing only the geometry portion into a corresponding OGRGeometry. There are many limitations on the forms of GML geometries supported by this parser, but they are too numerous to list here.

The following GML2 elements are parsed : Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, MultiGeometry.

(OGR >= 1.8.0) The following GML3 elements are parsed : Surface, MultiSurface, PolygonPatch, Triangle, Rectangle, Curve, MultiCurve, LineStringSegment, Arc, Circle, CompositeSurface, OrientableSurface, Solid, Tin, TriangulatedSurface.

Arc and Circle elements are stroked to linestring, by using a 4 degrees step, unless the user has overridden the value with the OGR_ARC_STEPSIZE configuration variable.

The C function OGR_G_CreateFromGML() is the same as this method.

Return

a geometry on success, or NULL on error.

Parameters

  • pszData: The GML fragment for the geometry.

OGRGeometry *createFromGEOS(GEOSContextHandle_t hGEOSCtxt, GEOSGeom)

Builds a OGRGeometry* from a GEOSGeom.

Return

a OGRGeometry*

Parameters

  • hGEOSCtxt: GEOS context

  • geosGeom: GEOS geometry

OGRGeometry *createFromGeoJson(const char*)

Create geometry from GeoJson fragment.

Return

a geometry on success, or NULL on error.

Since

GDAL 2.3

Parameters

  • pszJsonString: The GeoJSON fragment for the geometry.

OGRGeometry *createFromGeoJson(const CPLJSONObject &oJSONObject)

Create geometry from GeoJson fragment.

Return

a geometry on success, or NULL on error.

Since

GDAL 2.3

Parameters

  • oJsonObject: The JSONObject class describes the GeoJSON geometry.

void destroyGeometry(OGRGeometry*)

Destroy geometry object.

Equivalent to invoking delete on a geometry, but it guaranteed to take place within the context of the GDAL/OGR heap.

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

Parameters

  • poGeom: the geometry to deallocate.

OGRGeometry *createGeometry(OGRwkbGeometryType)

Create an empty geometry of desired type.

This is equivalent to allocating the desired geometry with new, but the allocation is guaranteed to take place in the context of the GDAL/OGR heap.

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

Return

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

Parameters

  • eGeometryType: the type code of the geometry class to be instantiated.

OGRGeometry *forceToPolygon(OGRGeometry*)

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.

Return

new geometry.

Parameters

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

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

Return

new geometry.

Parameters

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

  • bOnlyInOrder: flag that, if set to FALSE, indicate that the order of points in a linestring might be reversed if it enables to match the extremity of another linestring. If set to TRUE, the start of a linestring must match the end of another linestring.

OGRGeometry *forceToMultiPolygon(OGRGeometry*)

Convert to multipolygon.

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

Return

new geometry.

OGRGeometry *forceToMultiPoint(OGRGeometry*)

Convert to multipoint.

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

Return

new geometry.

OGRGeometry *forceToMultiLineString(OGRGeometry*)

Convert to multilinestring.

Tries to force the provided geometry to be a multilinestring.

  • linestrings are placed in a multilinestring.

  • circularstrings and compoundcurves will be approximated and placed in a multilinestring.

  • geometry collections will be converted to multilinestring if they only contain linestrings.

  • polygons will be changed to a collection of linestrings (one per ring).

  • curvepolygons will be approximated and changed to a collection of ( linestrings (one per ring).

The passed in geometry is consumed and a new one returned (or potentially the same one).

Return

new geometry.

OGRGeometry *forceTo(OGRGeometry *poGeomOGRwkbGeometryTypeeTargetTypeconst 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).

Return

new geometry.

Since

GDAL 2.0

Parameters

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

  • eTargetType: target output geometry type.

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

OGRGeometry *removeLowerDimensionSubGeoms(constOGRGeometry *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.

Return

a new geometry.

Since

GDAL 3.1.0

Parameters

  • poGeom: input geometry

OGRGeometry *organizePolygons(OGRGeometry **papoPolygons, int nPolygonCount, int *pbResultValidGeometryconst 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)

Return

a single resulting geometry (either OGRPolygonOGRCurvePolygonOGRMultiPolygonOGRMultiSurface or OGRGeometryCollection). Returns a POLYGON EMPTY in the case of nPolygonCount being 0.

Parameters

  • papoPolygons: array of geometry pointers - should all be OGRPolygons. Ownership of the geometries is passed, but not of the array itself.

  • nPolygonCount: number of items in papoPolygons

  • pbIsValidGeometry: value will be set TRUE if result is valid or FALSE otherwise.

  • papszOptions: a list of strings for passing options

bool haveGEOS()

Test if GEOS enabled.

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

Return

TRUE if available, otherwise FALSE.

OGRGeometry *transformWithOptions(constOGRGeometry *poSrcGeomOGRCoordinateTransformation *poCT, char **papszOptionsconstTransformWithOptionsCache &cache = TransformWithOptionsCache())

Transform a geometry.

Return

(new) transformed geometry.

Parameters

  • 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

OGRGeometry *approximateArcAngles(double dfX, double dfY, double dfZ, double dfPrimaryRadius, double dfSecondaryAxis, double dfRotation, double dfStartAngle, double dfEndAngle, double dfMaxAngleStepSizeDegreesconst 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.

See

CPLSetConfigOption()

Return

OGRLineString geometry representing an approximation of the arc.

Since

OGR 1.8.0

Parameters

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

int GetCurveParmeters(double x0, double y0, double x1, double y1, double x2, double y2, double &R, double &cx, double &cy, double &alpha0, double &alpha1, double &alpha2)

Returns the parameter of an arc circle.

Angles are return in radians, with trigonometic convention (counter clock wise)

Return

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

Since

GDAL 2.0

Parameters

  • x0: x of first 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)

OGRLineString *curveToLineString(double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, int bHasZ, double dfMaxAngleStepSizeDegreesconst char *const *papszOptions = nullptr)

Converts an arc circle into an approximate line string.

The arc circle is defined by a first point, an intermediate point and a final point.

The provided dfMaxAngleStepSizeDegrees is a hint. The discretization algorithm may pick a slightly different value.

So as to avoid gaps when rendering curve polygons that share common arcs, this method is guaranteed to return a line with reversed vertex if called with inverted first and final point, and identical intermediate point.

Return

the converted geometry (ownership to caller).

Since

GDAL 2.0

Parameters

  • x0: x of first 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.

OGRCurve *curveFromLineString(constOGRLineString *poLSconst char *const *papszOptions = nullptr)

Try to convert a linestring approximating curves into a curve.

This method can return a COMPOUNDCURVE, a CIRCULARSTRING or a LINESTRING.

This method is the reverse of curveFromLineString().

Return

the converted geometry (ownership to caller).

Since

GDAL 2.0

Parameters

  • poLS: handle to the geometry to convert.

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

classTransformWithOptionsCache

Opaque class used as argument to transformWithOptions()

structPrivate

骨量测定课

classOGRGeometry

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

Simple Feature Access - Part 1: Common Architecture | OGC">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 OGRCurveOGRGeometryCollectionOGRPointOGRSurface

公共职能

OGRGeometry(constOGRGeometry &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=(constOGRGeometry &other)

Assignment operator.

Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.

Since

GDAL 2.1

bool operator==(constOGRGeometry &other)const

Returns if two geometries are equal.

bool operator!=(constOGRGeometry &other)const

Returns if two geometries are different.

int getDimension()const = 0

Get the dimension of this object.

This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).

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

Return

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

int getCoordinateDimension()const

Get the dimension of the coordinates in this object.

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

Deprecated:

use CoordinateDimension().

Return

this will return 2 or 3.

int CoordinateDimension()const

Get the dimension of the coordinates in this object.

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

Return

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

Since

GDAL 2.1

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

Return

TRUE if object is empty, otherwise FALSE.

OGRBooleanIsValid()const

Test if the geometry is valid.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always return FALSE.

Return

TRUE if the geometry has no points, otherwise FALSE.

OGRGeometry *MakeValid()const

Attempts to make an invalid geometry valid without losing vertices.

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

Return

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

Since

GDAL 3.0

OGRBooleanIsSimple()const

Test if the geometry is simple.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always return FALSE.

Return

TRUE if the geometry has no points, otherwise FALSE.

OGRBooleanIs3D()const

Returns whether the geometry has a Z component.

OGRBooleanIsMeasured()const

Returns whether the geometry has a M component.

OGRBooleanIsRing()const

Test if the geometry is a ring.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always return FALSE.

Return

TRUE if the geometry has no points, otherwise FALSE.

void empty() = 0

Clear geometry information. This restores the geometry to its initial state after construction, and before assignment of actual geometry.

This method relates to the SFCOM IGeometry::Empty() method.

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

OGRGeometry *clone()const = 0

Make a copy of this object.

This method relates to the SFCOM IGeometry::clone() method.

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

Return

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

void getEnvelope(OGREnvelope *psEnvelope)const = 0

Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.

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

Parameters

  • psEnvelope: the structure in which to place the results.

void getEnvelope(OGREnvelope3D *psEnvelope)const = 0

Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.

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

Since

OGR 1.9.0

Parameters

  • psEnvelope: the structure in which to place the results.

int WkbSize()const = 0

Returns size of related binary representation.

This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.

This method relates to the SFCOM IWks::WkbSize() method.

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

Return

size of binary representation in bytes.

OGRErrimportFromWkb(constGByte*, int = -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().

Return

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

Parameters

  • pabyData: the binary input data.

  • nSize: the size of pabyData in bytes, or -1 if not known.

  • eWkbVariant: if wkbVariantPostGIS1, special interpretation is done for curve geometries code

OGRErrimportFromWkb(const unsigned char*, int, OGRwkbVariant, int &nBytesConsumedOut) = 0

Assign geometry from well known binary data.

The object must have already been instantiated as the correct derived type of geometry object to match the binaries type. This method is used by the OGRGeometryFactory class, but not normally called by application code.

This method relates to the SFCOM IWks::ImportFromWKB() method.

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

Return

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

Since

GDAL 2.3

Parameters

  • pabyData: the binary input data.

  • nSize: the size of pabyData in bytes, or -1 if not known.

  • eWkbVariant: if wkbVariantPostGIS1, special interpretation is done for curve geometries code

  • nBytesConsumedOut: output parameter. Number of bytes consumed.

OGRErrexportToWkb(OGRwkbByteOrder, unsigned char*, OGRwkbVariant = wkbVariantOldOgc)const = 0

Convert a geometry into well known binary format.

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

This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.

Return

Currently OGRERR_NONE is always returned.

Parameters

  • eByteOrder: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.

  • pabyData: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.

  • eWkbVariant: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

OGRErrimportFromWkt(const char **ppszInput) = 0

Assign geometry from well known text data.

The object must have already been instantiated as the correct derived type of geometry object to match the text type. This method is used by the OGRGeometryFactory class, but not normally called by application code.

This method relates to the SFCOM IWks::ImportFromWKT() method.

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

Return

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

Parameters

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

OGRErrexportToWkt(char **ppszDstTextOGRwkbVariant = wkbVariantOldOgc)const

Convert a geometry into well known text format.

This method relates to the SFCOM IWks::ExportToWKT() method.

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

Return

Currently OGRERR_NONE is always returned.

Parameters

  • ppszDstText: a text buffer is allocated by the program, and assigned to the passed pointer. After use, *ppszDstText should be freed with CPLFree().

  • variant: the specification that must be conformed too :

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

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

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

Export a WKT geometry.

Return

WKT string representing this geometry.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

OGRwkbGeometryTypegetGeometryType()const = 0

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

OGRwkbGeometryTypegetIsoGeometryType()const

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

Return

the geometry type that conforms with ISO SQL/MM Part3

const char *getGeometryName()const = 0

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

void dumpReadable(FILE*, const char* = nullptr, char **papszOptions = nullptr)const

Dump geometry in well known text format to indicated output file.

A few options can be defined to change the default dump :

  • DISPLAY_GEOMETRY=NO : to hide the dump of the geometry

  • DISPLAY_GEOMETRY=WKT or YES (default) : dump the geometry as a WKT

  • DISPLAY_GEOMETRY=SUMMARY : to get only a summary of the geometry

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

Parameters

  • fp: the text file to write the geometry to.

  • pszPrefix: the prefix to put on each line of output.

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

void flattenTo2D() = 0

Convert geometry to strictly 2D. In a sense this converts all Z coordinates to 0.0.

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

char *exportToGML(const char *const *papszOptions = nullptr)const

Convert a geometry into GML format.

The GML geometry is expressed directly in terms of GML basic data types assuming the this is available in the gml namespace. The returned string should be freed with CPLFree() when no longer required.

The supported options in OGR 1.8.0 are :

  • FORMAT=GML3. Otherwise it will default to GML 2.1.2 output.

  • GML3_LINESTRING_ELEMENT=curve. (Only valid for FORMAT=GML3) To use gml:Curve element for linestrings. Otherwise gml:LineString will be used .

  • GML3_LONGSRS=YES/NO. (Only valid for FORMAT=GML3) Default to YES. If YES, SRS with EPSG authority will be written with the "urn:ogc:def:crs:EPSG::" prefix. In the case, if the SRS is a geographic SRS without explicit AXIS order, but that the same SRS authority code imported with ImportFromEPSGA() should be treated as lat/long, then the function will take care of coordinate order swapping. If set to NO, SRS with EPSG authority will be written with the "EPSG:" prefix, even if they are in lat/long order.

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

Return

A GML fragment or NULL in case of error.

Parameters

  • papszOptions: NULL-terminated list of options.

char *exportToKML()const

Convert a geometry into KML format.

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

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

Return

A KML fragment or NULL in case of error.

char *exportToJson()const

Convert a geometry into GeoJSON format.

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

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

Return

A GeoJSON fragment or NULL in case of error.

void accept(IOGRGeometryVisitor *visitor) = 0

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)const = 0

Accept a visitor.

GEOSGeom exportToGEOS(GEOSContextHandle_t hGEOSCtxt)const

Returns a GEOSGeom object corresponding to the geometry.

Return

a GEOSGeom object corresponding to the geometry.

Parameters

  • hGEOSCtxt: GEOS context

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

Return

TRUE if this geometry is or has curve geometry.

Since

GDAL 2.0

Parameters

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

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

Return curve version of this geometry.

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

Return

a new geometry.

Since

GDAL 2.0

Parameters

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

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

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

Return

a new geometry.

Since

GDAL 2.0

Parameters

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

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

void closeRings()

Force rings to be closed.

If this geometry, or any contained geometries has polygon rings that are not closed, they will be closed by adding the starting point at the end.

void setCoordinateDimension(int nDimension)

Set the coordinate dimension.

This method sets the explicit coordinate dimension. Setting the coordinate dimension of a geometry to 2 should zero out any existing Z values. Setting the dimension of a geometry collection, a compound curve, a polygon, etc. will affect the children geometries. This will also remove the M dimension if present before this call.

Deprecated:

use set3D() or setMeasured().

Parameters

  • nNewDimension: New coordinate dimension value, either 2 or 3.

void set3D(OGRBooleanbIs3D)

Add or remove the Z coordinate dimension.

This method adds or removes the explicit Z coordinate dimension. Removing the Z coordinate dimension of a geometry will remove any existing Z values. Adding the Z dimension to a geometry collection, a compound curve, a polygon, etc. will affect the children geometries.

Since

GDAL 2.1

Parameters

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

void setMeasured(OGRBooleanbIsMeasured)

Add or remove the M coordinate dimension.

This method adds or removes the explicit M coordinate dimension. Removing the M coordinate dimension of a geometry will remove any existing M values. Adding the M dimension to a geometry collection, a compound curve, a polygon, etc. will affect the children geometries.

Since

GDAL 2.1

Parameters

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

void assignSpatialReference(OGRSpatialReference *poSR)

Assign spatial reference to this object.

Any existing spatial reference is replaced, but under no circumstances does this result in the object being reprojected. It is just changing the interpretation of the existing geometry. Note that assigning a spatial reference increments the reference count on the OGRSpatialReference, but does not copy it.

Starting with GDAL 2.3, this will also assign the spatial reference to potential 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().

Parameters

  • poSR: new spatial reference system to apply.

OGRSpatialReference *getSpatialReference(void)const

Returns spatial reference system for object.

This method relates to the SFCOM IGeometry::get_SpatialReference() method.

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

Return

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

OGRErrtransform(OGRCoordinateTransformation *poCT) = 0

Apply arbitrary coordinate transformation to geometry.

This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.

Note that this method does not require that the geometry already have a spatial reference system. It will be assumed that they can be treated as having the source spatial reference system of the OGRCoordinateTransformation object, and the actual SRS of the geometry will be ignored. On successful completion the output OGRSpatialReference of the OGRCoordinateTransformation will be assigned to the geometry.

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

Return

OGRERR_NONE on success or an error code.

Parameters

  • poCT: the transformation to apply.

OGRErrtransformTo(OGRSpatialReference *poSR)

Transform geometry to new spatial reference system.

This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.

This method will only work if the geometry already has an assigned spatial reference system, and if it is transformable to the target coordinate system.

Because this method requires internal creation and initialization of an OGRCoordinateTransformation object it is significantly more expensive to use this method to transform many geometries than it is to create the OGRCoordinateTransformation in advance, and call transform() with that transformation. This method exists primarily for convenience when only transforming a single geometry.

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

Return

OGRERR_NONE on success, or an error code.

Parameters

  • poSR: spatial reference system to transform to.

void segmentize(double dfMaxLength)

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

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

Parameters

  • dfMaxLength: the maximum distance between 2 points after segmentization

OGRBooleanIntersects(constOGRGeometry*)const

Do these features intersect?

Determines whether two geometries intersect. If GEOS is enabled, then this is done in rigorous fashion otherwise TRUE is returned if the envelopes (bounding boxes) of the two geometries overlap.

The poOtherGeom argument may be safely NULL, but in this case the method will always return TRUE. That is, a NULL geometry is treated as being everywhere.

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

Return

TRUE if the geometries intersect, otherwise FALSE.

Parameters

  • poOtherGeom: the other geometry to test against.

OGRBooleanEquals(constOGRGeometry*)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().

Return

TRUE if equivalent or FALSE otherwise.

OGRBooleanDisjoint(constOGRGeometry*)const

Test for disjointness.

Tests if this geometry and the other passed into the method are disjoint.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

TRUE if they are disjoint, otherwise FALSE.

Parameters

  • poOtherGeom: the geometry to compare to this geometry.

OGRBooleanTouches(constOGRGeometry*)const

Test for touching.

Tests if this geometry and the other passed into the method are touching.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

TRUE if they are touching, otherwise FALSE.

Parameters

  • poOtherGeom: the geometry to compare to this geometry.

OGRBooleanCrosses(constOGRGeometry*)const

Test for crossing.

Tests if this geometry and the other passed into the method are crossing.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

TRUE if they are crossing, otherwise FALSE.

Parameters

  • poOtherGeom: the geometry to compare to this geometry.

OGRBooleanWithin(constOGRGeometry*)const

Test for containment.

Tests if actual geometry object is within the passed geometry.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

TRUE if poOtherGeom is within this geometry, otherwise FALSE.

Parameters

  • poOtherGeom: the geometry to compare to this geometry.

OGRBooleanContains(constOGRGeometry*)const

Test for containment.

Tests if actual geometry object contains the passed geometry.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

TRUE if poOtherGeom contains this geometry, otherwise FALSE.

Parameters

  • poOtherGeom: the geometry to compare to this geometry.

OGRBooleanOverlaps(constOGRGeometry*)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.

Return

TRUE if they are overlapping, otherwise FALSE.

Parameters

  • poOtherGeom: the geometry to compare to this geometry.

OGRGeometry *Boundary()const

Compute boundary.

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

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

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

Since

OGR 1.8.0

double Distance(constOGRGeometry*)const

Compute distance between two geometries.

Returns the shortest distance between the two geometries. The distance is expressed into the same unit as the coordinates of the geometries.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

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

Parameters

  • poOtherGeom: the other geometry to compare against.

OGRGeometry *ConvexHull()const

Compute convex hull.

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

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

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

OGRGeometry *Buffer(double dfDist, int nQuadSegs = 30)const

Compute buffer of geometry.

Builds a new geometry containing the buffer region around the geometry on which it is invoked. The buffer is a polygon containing the region within the buffer distance of the original geometry.

Some buffer sections are properly described as curves, but are converted to approximate polygons. The nQuadSegs parameter can be used to control how many segments should be used to define a 90 degree curve - a quadrant of a circle. A value of 30 is a reasonable default. Large values result in large numbers of vertices in the resulting buffer geometry while small numbers reduce the accuracy of the result.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

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

Parameters

  • dfDist: the buffer distance to be applied. Should be expressed into the same unit as the coordinates of the geometry.

  • nQuadSegs: the number of segments used to approximate a 90 degree (quadrant) of curvature.

OGRGeometry *Intersection(constOGRGeometry*)const

Compute intersection.

Generates a new geometry which is the region of intersection of the two geometries operated on. The Intersects() method can be used to test if two geometries intersect.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

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

Parameters

  • poOtherGeom: the other geometry intersected with "this" geometry.

OGRGeometry *Union(constOGRGeometry*)const

Compute union.

Generates a new geometry which is the region of union of the two geometries operated on.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

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

Parameters

  • poOtherGeom: the other geometry unioned with "this" geometry.

OGRGeometry *UnionCascaded()const

Compute union using cascading.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

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

Since

OGR 1.8.0

OGRGeometry *Difference(constOGRGeometry*)const

Compute difference.

Generates a new geometry which is the region of this geometry with the region of the second geometry removed.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

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

Parameters

  • poOtherGeom: the other geometry removed from "this" geometry.

OGRGeometry *SymDifference(constOGRGeometry*)const

Compute symmetric difference.

Generates a new geometry which is the symmetric difference of this geometry and the second geometry passed into the method.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

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

Since

OGR 1.8.0

Parameters

  • poOtherGeom: the other geometry.

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

Return

OGRERR_NONE on success or OGRERR_FAILURE on error.

Since

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

OGRGeometry *Simplify(double dTolerance)const

Simplify the geometry.

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

This function is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this function will always fail, issuing a CPLE_NotSupported error.

Return

the simplified geometry or NULL if an error occurs.

Since

OGR 1.8.0

Parameters

  • dTolerance: the distance tolerance for the simplification.

OGRGeometry *SimplifyPreserveTopology(double dTolerance)const

Simplify the geometry while preserving topology.

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

This function is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this function will always fail, issuing a CPLE_NotSupported error.

Return

the simplified geometry or NULL if an error occurs.

Since

OGR 1.9.0

Parameters

  • dTolerance: the distance tolerance for the simplification.

OGRGeometry *DelaunayTriangulation(double dfTolerance, int bOnlyEdges)const

Return a Delaunay triangulation of the vertices of the geometry.

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

This function is built on the GEOS library, v3.4 or above. If OGR is built without the GEOS library, this function will always fail, issuing a CPLE_NotSupported error.

Return

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

Since

OGR 2.1

Parameters

  • dfTolerance: optional snapping tolerance to use for improved robustness

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

OGRGeometry *Polygonize()const

Polygonizes a set of sparse edges.

A new geometry object is created and returned containing a collection of reassembled Polygons: NULL will be returned if the input collection doesn't corresponds to a MultiLinestring, or when reassembling Edges into Polygons is impossible due to topological inconsistencies.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

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

Since

OGR 1.9.0

double Distance3D(constOGRGeometry *poOtherGeom)const

Returns the 3D distance between two geometries.

The distance is expressed into the same unit as the coordinates of the geometries.

This method is built on the SFCGAL library, check it for the definition of the geometry operation. If OGR is built without the SFCGAL library, this method will always return -1.0

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

Return

distance between the two geometries

Since

GDAL 2.2

void swapXY()

Swap x and y coordinates.

Since

OGR 1.8.0

OGRPoint *toPoint()

Down-cast to OGRPoint*.

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

Since

GDAL 2.3

constOGRPoint *toPoint()const

Down-cast to OGRPoint*.

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

Since

GDAL 2.3

OGRCurve *toCurve()

Down-cast to OGRCurve*.

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

Since

GDAL 2.3

constOGRCurve *toCurve()const

Down-cast to OGRCurve*.

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

Since

GDAL 2.3

OGRSimpleCurve *toSimpleCurve()

Down-cast to OGRSimpleCurve*.

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

Since

GDAL 2.3

const OGRSimpleCurve *toSimpleCurve()const

Down-cast to OGRSimpleCurve*.

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

Since

GDAL 2.3

OGRLineString *toLineString()

Down-cast to OGRLineString*.

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

Since

GDAL 2.3

constOGRLineString *toLineString()const

Down-cast to OGRLineString*.

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

Since

GDAL 2.3

OGRLinearRing *toLinearRing()

Down-cast to OGRLinearRing*.

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

Since

GDAL 2.3

constOGRLinearRing *toLinearRing()const

Down-cast to OGRLinearRing*.

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

Since

GDAL 2.3

OGRCircularString *toCircularString()

Down-cast to OGRCircularString*.

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

Since

GDAL 2.3

constOGRCircularString *toCircularString()const

Down-cast to OGRCircularString*.

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

Since

GDAL 2.3

OGRCompoundCurve *toCompoundCurve()

Down-cast to OGRCompoundCurve*.

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

Since

GDAL 2.3

const OGRCompoundCurve *toCompoundCurve()const

Down-cast to OGRCompoundCurve*.

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

Since

GDAL 2.3

OGRSurface *toSurface()

Down-cast to OGRSurface*.

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

Since

GDAL 2.3

constOGRSurface *toSurface()const

Down-cast to OGRSurface*.

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

Since

GDAL 2.3

OGRPolygon *toPolygon()

Down-cast to OGRPolygon*.

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

Since

GDAL 2.3

constOGRPolygon *toPolygon()const

Down-cast to OGRPolygon*.

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

Since

GDAL 2.3

OGRTriangle *toTriangle()

Down-cast to OGRTriangle*.

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

Since

GDAL 2.3

constOGRTriangle *toTriangle()const

Down-cast to OGRTriangle*.

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

Since

GDAL 2.3

OGRCurvePolygon *toCurvePolygon()

Down-cast to OGRCurvePolygon*.

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

Since

GDAL 2.3

constOGRCurvePolygon *toCurvePolygon()const

Down-cast to OGRCurvePolygon*.

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

Since

GDAL 2.3

OGRGeometryCollection *toGeometryCollection()

Down-cast to OGRGeometryCollection*.

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

Since

GDAL 2.3

constOGRGeometryCollection *toGeometryCollection()const

Down-cast to OGRGeometryCollection*.

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

Since

GDAL 2.3

OGRMultiPoint *toMultiPoint()

Down-cast to OGRMultiPoint*.

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

Since

GDAL 2.3

constOGRMultiPoint *toMultiPoint()const

Down-cast to OGRMultiPoint*.

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

Since

GDAL 2.3

OGRMultiLineString *toMultiLineString()

Down-cast to OGRMultiLineString*.

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

Since

GDAL 2.3

constOGRMultiLineString *toMultiLineString()const

Down-cast to OGRMultiLineString*.

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

Since

GDAL 2.3

OGRMultiPolygon *toMultiPolygon()

Down-cast to OGRMultiPolygon*.

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

Since

GDAL 2.3

constOGRMultiPolygon *toMultiPolygon()const

Down-cast to OGRMultiPolygon*.

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

Since

GDAL 2.3

OGRMultiCurve *toMultiCurve()

Down-cast to OGRMultiCurve*.

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

Since

GDAL 2.3

constOGRMultiCurve *toMultiCurve()const

Down-cast to OGRMultiCurve*.

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

Since

GDAL 2.3

OGRMultiSurface *toMultiSurface()

Down-cast to OGRMultiSurface*.

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

Since

GDAL 2.3

constOGRMultiSurface *toMultiSurface()const

Down-cast to OGRMultiSurface*.

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

Since

GDAL 2.3

OGRPolyhedralSurface *toPolyhedralSurface()

Down-cast to OGRPolyhedralSurface*.

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

Since

GDAL 2.3

constOGRPolyhedralSurface *toPolyhedralSurface()const

Down-cast to OGRPolyhedralSurface*.

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

Since

GDAL 2.3

OGRTriangulatedSurface *toTriangulatedSurface()

Down-cast to OGRTriangulatedSurface*.

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

Since

GDAL 2.3

constOGRTriangulatedSurface *toTriangulatedSurface()const

Down-cast to OGRTriangulatedSurface*.

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

Since

GDAL 2.3

公共静态函数

GEOSContextHandle_t createGEOSContext()

Create a new GEOS context.

Return

a new GEOS context.

void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt)

Destroy a GEOS context.

Parameters

  • hGEOSCtxt: GEOS context

OGRGeometryHToHandle(OGRGeometry *poGeom)

Convert a OGRGeometry* to a OGRGeometryH.

Since

GDAL 2.3

OGRGeometry *FromHandle(OGRGeometryHhGeom)

Convert a OGRGeometryH to a OGRGeometry*.

Since

GDAL 2.3

OGRPoint类

classOGRPoint : publicOGRGeometry

Point class.

Implements SFCOM IPoint methods.

公共职能

OGRPoint()

Create an empty point.

OGRPoint(double x, double y)

Create a point.

Parameters

  • xIn: x

  • yIn: y

OGRPoint(double x, double y, double z)

Create a point.

Parameters

  • xIn: x

  • yIn: y

  • zIn: z

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

Create a point.

Parameters

  • xIn: x

  • yIn: y

  • zIn: z

  • mIn: m

OGRPoint(constOGRPoint &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=(constOGRPoint &other)

Assignment operator.

Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.

Since

GDAL 2.1

int WkbSize()constoverride

Returns size of related binary representation.

This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.

This method relates to the SFCOM IWks::WkbSize() method.

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

Return

size of binary representation in bytes.

OGRErrimportFromWkb(const unsigned char*, int, OGRwkbVariant, int &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().

Return

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

Since

GDAL 2.3

Parameters

  • pabyData: the binary input data.

  • nSize: the size of pabyData in bytes, or -1 if not known.

  • eWkbVariant: if wkbVariantPostGIS1, special interpretation is done for curve geometries code

  • nBytesConsumedOut: output parameter. Number of bytes consumed.

OGRErrexportToWkb(OGRwkbByteOrder, unsigned char*, OGRwkbVariant = wkbVariantOldOgc)constoverride

Convert a geometry into well known binary format.

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

This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.

Return

Currently OGRERR_NONE is always returned.

Parameters

  • eByteOrder: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.

  • pabyData: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.

  • eWkbVariant: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

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

Return

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

Parameters

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

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

Export a point to WKT.

Return

WKT string representing this point.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

int getDimension()constoverride

Get the dimension of this object.

This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).

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

Return

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

OGRGeometry *clone()constoverride

Make a copy of this object.

This method relates to the SFCOM IGeometry::clone() method.

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

Return

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

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

void getEnvelope(OGREnvelope *psEnvelope)constoverride

Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.

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

Parameters

  • psEnvelope: the structure in which to place the results.

void getEnvelope(OGREnvelope3D *psEnvelope)constoverride

Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.

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

Since

OGR 1.9.0

Parameters

  • psEnvelope: the structure in which to place the results.

OGRBooleanIsEmpty()constoverride

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.

Return

TRUE if object is empty, otherwise FALSE.

double getX()const

Return x.

Fetch X coordinate.

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

Return

the X coordinate of this point.

double getY()const

Return y.

Fetch Y coordinate.

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

Return

the Y coordinate of this point.

double getZ()const

Return z.

Fetch Z coordinate.

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

Return

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

double getM()const

Return m.

void setCoordinateDimension(int nDimension)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().

Parameters

  • nNewDimension: New coordinate dimension value, either 2 or 3.

void setX(double xIn)

Set x.

Assign point X coordinate.

There is no corresponding SFCOM method.

Parameters

  • xIn: x

void setY(double yIn)

Set y.

Assign point Y coordinate.

There is no corresponding SFCOM method.

Parameters

  • yIn: y

void setZ(double zIn)

Set z.

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

There is no corresponding SFCOM method.

Parameters

  • zIn: z

void setM(double mIn)

Set m.

Parameters

  • mIn: m

OGRBooleanEquals(constOGRGeometry*)constoverride

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

Return

TRUE if equivalent or FALSE otherwise.

OGRBooleanIntersects(constOGRGeometry*)constoverride

Do these features intersect?

Determines whether two geometries intersect. If GEOS is enabled, then this is done in rigorous fashion otherwise TRUE is returned if the envelopes (bounding boxes) of the two geometries overlap.

The poOtherGeom argument may be safely NULL, but in this case the method will always return TRUE. That is, a NULL geometry is treated as being everywhere.

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

Return

TRUE if the geometries intersect, otherwise FALSE.

Parameters

  • poOtherGeom: the other geometry to test against.

OGRBooleanWithin(constOGRGeometry*)constoverride

Test for containment.

Tests if actual geometry object is within the passed geometry.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

TRUE if poOtherGeom is within this geometry, otherwise FALSE.

Parameters

  • poOtherGeom: the geometry to compare to this geometry.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

OGRErrtransform(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 is the same as the C function OGR_G_Transform().

Return

OGRERR_NONE on success or an error code.

Parameters

  • poCT: the transformation to apply.

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

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

void swapXY()override

Swap x and y coordinates.

Since

OGR 1.8.0

公共静态函数

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

Create a XYM point.

Since

GDAL 3.1

Parameters

  • x: x

  • y: y

  • m: m

OGRLineString类

classOGRLineString : 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

公共职能

OGRLineString()

Create an empty line string.

OGRLineString(constOGRLineString &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=(constOGRLineString &other)

Assignment operator.

Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.

Since

GDAL 2.1

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

Return a linestring from a curve geometry.

The returned geometry is a new instance whose ownership belongs to the caller.

If the dfMaxAngleStepSizeDegrees is zero, then a default value will be used. This is currently 4 degrees unless the user has overridden the value with the OGR_ARC_STEPSIZE configuration variable.

This method relates to the ISO SQL/MM Part 3 ICurve::CurveToLine() method.

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

Return

a line string approximating the curve

Since

GDAL 2.0

Parameters

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

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

OGRGeometry *getCurveGeometry(const char *const *papszOptions = nullptr)constoverride

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

Return

a new geometry.

Since

GDAL 2.0

Parameters

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

double get_Area()constoverride

Get the area of the (closed) curve.

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

Return

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

Since

GDAL 2.0

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRSimpleCurve *toUpperClass()

Return pointer of this in upper class.

const OGRSimpleCurve *toUpperClass()const

Return pointer of this in upper class.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

欧格林类

classOGRLinearRing : publicOGRLineString

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.

公共职能

OGRLinearRing()

Constructor.

OGRLinearRing(constOGRLinearRing &other)

Copy constructor.

Note: before GDAL 2.1, only the default implementation of the constructor existed, which could be unsafe to use.

Since

GDAL 2.1

OGRLinearRing(OGRLinearRing*)

Constructor.

Parameters

  • poSrcRing: source ring.

OGRLinearRing &operator=(constOGRLinearRing &other)

Assignment operator.

Note: before GDAL 2.1, only the default implementation of the operator existed, which could be unsafe to use.

Since

GDAL 2.1

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRGeometry *clone()constoverride

Make a copy of this object.

This method relates to the SFCOM IGeometry::clone() method.

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

Return

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

int isClockwise()const

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

Return

TRUE if clockwise otherwise FALSE.

void reverseWindingOrder()

Reverse order of points.

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

OGRBooleanisPointInRing(constOGRPoint *pt, int bTestEnvelope = TRUE)const

Returns whether the point is inside the ring.

Return

TRUE or FALSE.

Parameters

  • poPoint: point

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

OGRBooleanisPointOnRingBoundary(constOGRPoint *pt, int bTestEnvelope = TRUE)const

Returns whether the point is on the ring boundary.

Return

TRUE or FALSE.

Parameters

  • poPoint: point

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

OGRErrtransform(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 is the same as the C function OGR_G_Transform().

Return

OGRERR_NONE on success or an error code.

Parameters

  • poCT: the transformation to apply.

OGRLineString *toUpperClass()

Return pointer of this in upper class.

constOGRLineString *toUpperClass()const

Return pointer of this in upper class.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

int WkbSize()constoverride

Returns size of related binary representation.

This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.

This method relates to the SFCOM IWks::WkbSize() method.

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

Return

size of binary representation in bytes.

OGRErrimportFromWkb(const unsigned char*, int, OGRwkbVariant, int &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().

Return

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

Since

GDAL 2.3

Parameters

  • pabyData: the binary input data.

  • nSize: the size of pabyData in bytes, or -1 if not known.

  • eWkbVariant: if wkbVariantPostGIS1, special interpretation is done for curve geometries code

  • nBytesConsumedOut: output parameter. Number of bytes consumed.

OGRErrexportToWkb(OGRwkbByteOrder, unsigned char*, OGRwkbVariant = wkbVariantOldOgc)constoverride

Convert a geometry into well known binary format.

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

This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.

Return

Currently OGRERR_NONE is always returned.

Parameters

  • eByteOrder: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.

  • pabyData: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.

  • eWkbVariant: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

OGRCircularString类

classOGRCircularString : 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

公共职能

OGRCircularString()

Create an empty circular string.

OGRCircularString(constOGRCircularString &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=(constOGRCircularString &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

OGRErrimportFromWkb(const unsigned char*, int, OGRwkbVariant, int &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().

Return

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

Since

GDAL 2.3

Parameters

  • pabyData: the binary input data.

  • nSize: the size of pabyData in bytes, or -1 if not known.

  • eWkbVariant: if wkbVariantPostGIS1, special interpretation is done for curve geometries code

  • nBytesConsumedOut: output parameter. Number of bytes consumed.

OGRErrexportToWkb(OGRwkbByteOrder, unsigned char*, OGRwkbVariant = wkbVariantOldOgc)constoverride

Convert a geometry into well known binary format.

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

This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.

Return

Currently OGRERR_NONE is always returned.

Parameters

  • eByteOrder: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.

  • pabyData: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.

  • eWkbVariant: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

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

Return

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

Parameters

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

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

Export a circular string to WKT.

Return

WKT string representing this circular string.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

OGRBooleanIsValid()constoverride

Test if the geometry is valid.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always return FALSE.

Return

TRUE if the geometry has no points, otherwise FALSE.

void getEnvelope(OGREnvelope *psEnvelope)constoverride

Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.

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

Parameters

  • psEnvelope: the structure in which to place the results.

void getEnvelope(OGREnvelope3D *psEnvelope)constoverride

Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.

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

Since

OGR 1.9.0

Parameters

  • psEnvelope: the structure in which to place the results.

double get_Length()constoverride

Returns the length of the curve.

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

Return

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

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

Return a linestring from a curve geometry.

The returned geometry is a new instance whose ownership belongs to the caller.

If the dfMaxAngleStepSizeDegrees is zero, then a default value will be used. This is currently 4 degrees unless the user has overridden the value with the OGR_ARC_STEPSIZE configuration variable.

This method relates to the ISO SQL/MM Part 3 ICurve::CurveToLine() method.

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

Return

a line string approximating the curve

Since

GDAL 2.0

Parameters

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

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

void Value(double, OGRPoint*)constoverride

Fetch point at given distance along curve.

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

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

Parameters

  • dfDistance: distance along the curve at which to sample position. This distance should be between zero and get_Length() for this curve.

  • poPoint: the point to be assigned the curve position.

double get_Area()constoverride

Get the area of the (closed) curve.

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

Return

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

Since

GDAL 2.0

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

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

Parameters

  • dfMaxLength: the maximum distance between 2 points after segmentization

OGRBooleanhasCurveGeometry(int bLookForNonLinear = FALSE)constoverride

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

Return

TRUE if this geometry is or has curve geometry.

Since

GDAL 2.0

Parameters

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

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

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

Return

a new geometry.

Since

GDAL 2.0

Parameters

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

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

OGRSimpleCurve *toUpperClass()

Return pointer of this in upper class.

const OGRSimpleCurve *toUpperClass()const

Return pointer of this in upper class.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

OGRCurve类

classOGRCurve : publicOGRGeometry

Abstract curve base class for OGRLineStringOGRCircularString and OGRCompoundCurve.

Subclassed by OGRCompoundCurve, OGRSimpleCurve

公共类型

typedefOGRPointChildType

Type of child elements.

公共职能

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.

double get_Length()const = 0

Returns the length of the curve.

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

Return

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

void StartPoint(OGRPoint*)const = 0

Return the curve start point.

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

Parameters

  • poPoint: the point to be assigned the start location.

void EndPoint(OGRPoint*)const = 0

Return the curve end point.

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

Parameters

  • poPoint: the point to be assigned the end location.

int get_IsClosed()const

Return TRUE if curve is closed.

Tests if a curve is closed. A curve is closed if its start point is equal to its end point.

For equality tests, the M dimension is ignored.

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

Return

TRUE if closed, else FALSE.

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

Parameters

  • dfDistance: distance along the curve at which to sample position. This distance should be between zero and get_Length() for this curve.

  • poPoint: the point to be assigned the curve position.

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

Return a linestring from a curve geometry.

The returned geometry is a new instance whose ownership belongs to the caller.

If the dfMaxAngleStepSizeDegrees is zero, then a default value will be used. This is currently 4 degrees unless the user has overridden the value with the OGR_ARC_STEPSIZE configuration variable.

This method relates to the ISO SQL/MM Part 3 ICurve::CurveToLine() method.

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

Return

a line string approximating the curve

Since

GDAL 2.0

Parameters

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

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

int getDimension()constoverride

Get the dimension of this object.

This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).

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

Return

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

int getNumPoints()const = 0

Return the number of points of a curve geometry.

This method, as a method of OGRCurve, does not relate to a standard. For circular strings or linestrings, it returns the number of points, conforming to SF COM NumPoints(). For compound curves, it returns the sum of the number of points of each of its components (non including intermediate starting/ending points of the different parts).

Return

the number of points of the curve.

Since

GDAL 2.0

OGRPointIterator *getPointIterator()const = 0

Returns a point iterator over the curve.

The curve must not be modified while an iterator exists on it.

The iterator must be destroyed with OGRPointIterator::destroy().

Return

a point iterator over the curve.

Since

GDAL 2.0

OGRBooleanIsConvex()const

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

Return

TRUE if the curve forms a convex shape.

Since

GDAL 2.0

double get_Area()const = 0

Get the area of the (closed) curve.

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

Return

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

Since

GDAL 2.0

OGRSimpleCurve *toSimpleCurve()

Down-cast to OGRSimpleCurve*.

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

const OGRSimpleCurve *toSimpleCurve()const

Down-cast to OGRSimpleCurve*.

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

公共静态函数

OGRCompoundCurve *CastToCompoundCurve(OGRCurve *puCurve)

Cast to compound curve.

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

Return

new geometry

Since

GDAL 2.0

Parameters

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

OGRLineString *CastToLineString(OGRCurve *poCurve)

Cast to linestring.

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

Return

new geometry.

Since

GDAL 2.0

Parameters

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

OGRLinearRing *CastToLinearRing(OGRCurve *poCurve)

Cast to linear ring.

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

Return

new geometry.

Since

GDAL 2.0

Parameters

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

OGRSurface类

classOGRSurface : publicOGRGeometry

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

Subclassed by OGRCurvePolygonOGRPolyhedralSurface

公共职能

double get_Area()const = 0

Get the area of the surface object.

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

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

Return

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

OGRErrPointOnSurface(OGRPoint *poPoint)const

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

NOTE: Only implemented when GEOS included in build.

Return

OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise.

Parameters

  • poPoint: point to be set with an internal point.

OGRPolygon类

classOGRPolygon : publicOGRCurvePolygon

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

公共类型

typedefOGRLinearRingChildType

Type of child elements.

公共职能

OGRPolygon()

Create an empty polygon.

OGRPolygon(constOGRPolygon &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=(constOGRPolygon &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

ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

ChildType **end()

Return end of iterator.

constChildType *const *begin()const

Return begin of iterator.

Since

GDAL 2.3

constChildType *const *end()const

Return end of iterator.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

OGRBooleanhasCurveGeometry(int bLookForNonLinear = FALSE)constoverride

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

Return

TRUE if this geometry is or has curve geometry.

Since

GDAL 2.0

Parameters

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

OGRGeometry *getCurveGeometry(const char *const *papszOptions = nullptr)constoverride

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

Return

a new geometry.

Since

GDAL 2.0

Parameters

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

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

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

Return

a new geometry.

Since

GDAL 2.0

Parameters

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

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

int WkbSize()constoverride

Returns size of related binary representation.

This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.

This method relates to the SFCOM IWks::WkbSize() method.

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

Return

size of binary representation in bytes.

OGRErrimportFromWkb(const unsigned char*, int, OGRwkbVariant, int &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().

Return

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

Since

GDAL 2.3

Parameters

  • pabyData: the binary input data.

  • nSize: the size of pabyData in bytes, or -1 if not known.

  • eWkbVariant: if wkbVariantPostGIS1, special interpretation is done for curve geometries code

  • nBytesConsumedOut: output parameter. Number of bytes consumed.

OGRErrexportToWkb(OGRwkbByteOrder, unsigned char*, OGRwkbVariant = wkbVariantOldOgc)constoverride

Convert a geometry into well known binary format.

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

This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.

Return

Currently OGRERR_NONE is always returned.

Parameters

  • eByteOrder: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.

  • pabyData: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.

  • eWkbVariant: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

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

Return

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

Parameters

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

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

Export a polygon to WKT.

Return

WKT representation of the polygon.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

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

Return a polygon from a curve polygon.

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

The returned geometry is a new instance whose ownership belongs to the caller.

Return

a linestring

Since

OGR 2.0

Parameters

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

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

OGRLinearRing *getExteriorRing()

Fetch reference to external polygon ring.

Note that the returned ring pointer is to an internal data object of the OGRPolygon. It should not be modified or deleted by the application, and the pointer is only valid till the polygon is next modified. Use the OGRGeometry::clone() method to make a separate copy within the application.

Relates to the SFCOM IPolygon::get_ExteriorRing() method.

Return

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

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.

Return

pointer to interior ring. May be NULL.

Parameters

constOGRLinearRing *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.

Return

pointer to interior ring. May be NULL.

Parameters

OGRLinearRing *stealExteriorRing()

"Steal" reference to external polygon ring.

After the call to that function, only call to stealInteriorRing() or destruction of the OGRPolygon is valid. Other operations may crash.

Return

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

OGRLinearRing *stealInteriorRing(int)

"Steal" reference to indicated interior ring.

After the call to that function, only call to stealInteriorRing() or destruction of the OGRPolygon is valid. Other operations may crash.

Return

pointer to interior ring. May be NULL.

Parameters

OGRBooleanIsPointOnSurface(constOGRPoint*)const

Return whether the point is on the surface.

Return

TRUE or FALSE

OGRCurvePolygon *toUpperClass()

Return pointer of this in upper class.

constOGRCurvePolygon *toUpperClass()const

Return pointer of this in upper class.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

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类

classOGRCurvePolygon : publicOGRSurface

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

公共类型

typedefOGRCurveChildType

Type of child elements.

公共职能

OGRCurvePolygon()

Create an empty curve polygon.

OGRCurvePolygon(constOGRCurvePolygon&)

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=(constOGRCurvePolygon &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

ChildType **begin()

Return begin of curve iterator.

Since

GDAL 2.3

ChildType **end()

Return end of curve iterator.

constChildType *const *begin()const

Return begin of curve iterator.

Since

GDAL 2.3

constChildType *const *end()const

Return end of curve iterator.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

OGRGeometry *clone()constoverride

Make a copy of this object.

This method relates to the SFCOM IGeometry::clone() method.

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

Return

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

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

OGRErrtransform(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 is the same as the C function OGR_G_Transform().

Return

OGRERR_NONE on success or an error code.

Parameters

  • poCT: the transformation to apply.

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

OGRBooleanIsEmpty()constoverride

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.

Return

TRUE if object is empty, otherwise FALSE.

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

Parameters

  • dfMaxLength: the maximum distance between 2 points after segmentization

OGRBooleanhasCurveGeometry(int bLookForNonLinear = FALSE)constoverride

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

Return

TRUE if this geometry is or has curve geometry.

Since

GDAL 2.0

Parameters

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

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

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

Return

a new geometry.

Since

GDAL 2.0

Parameters

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

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

double get_Area()constoverride

Get the area of the surface object.

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

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

Return

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

int WkbSize()constoverride

Returns size of related binary representation.

This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.

This method relates to the SFCOM IWks::WkbSize() method.

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

Return

size of binary representation in bytes.

OGRErrimportFromWkb(const unsigned char*, int, OGRwkbVariant, int &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().

Return

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

Since

GDAL 2.3

Parameters

  • pabyData: the binary input data.

  • nSize: the size of pabyData in bytes, or -1 if not known.

  • eWkbVariant: if wkbVariantPostGIS1, special interpretation is done for curve geometries code

  • nBytesConsumedOut: output parameter. Number of bytes consumed.

OGRErrexportToWkb(OGRwkbByteOrder, unsigned char*, OGRwkbVariant = wkbVariantOldOgc)constoverride

Convert a geometry into well known binary format.

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

This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.

Return

Currently OGRERR_NONE is always returned.

Parameters

  • eByteOrder: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.

  • pabyData: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.

  • eWkbVariant: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

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

Return

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

Parameters

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

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

Export a curve polygon to WKT.

Return

WKT representation of the curve polygon.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

int getDimension()constoverride

Get the dimension of this object.

This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).

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

Return

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

void getEnvelope(OGREnvelope *psEnvelope)constoverride

Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.

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

Parameters

  • psEnvelope: the structure in which to place the results.

void getEnvelope(OGREnvelope3D *psEnvelope)constoverride

Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.

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

Since

OGR 1.9.0

Parameters

  • psEnvelope: the structure in which to place the results.

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

Return a polygon from a curve polygon.

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

The returned geometry is a new instance whose ownership belongs to the caller.

Return

a linestring

Since

OGR 2.0

Parameters

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

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

OGRBooleanEquals(constOGRGeometry*)constoverride

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

Return

TRUE if equivalent or FALSE otherwise.

OGRBooleanIntersects(constOGRGeometry*)constoverride

Do these features intersect?

Determines whether two geometries intersect. If GEOS is enabled, then this is done in rigorous fashion otherwise TRUE is returned if the envelopes (bounding boxes) of the two geometries overlap.

The poOtherGeom argument may be safely NULL, but in this case the method will always return TRUE. That is, a NULL geometry is treated as being everywhere.

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

Return

TRUE if the geometries intersect, otherwise FALSE.

Parameters

  • poOtherGeom: the other geometry to test against.

OGRBooleanContains(constOGRGeometry*)constoverride

Test for containment.

Tests if actual geometry object contains the passed geometry.

Geometry validity is not checked. In case you are unsure of the validity of the input geometries, call IsValid() before, otherwise the result might be wrong.

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

This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.

Return

TRUE if poOtherGeom contains this geometry, otherwise FALSE.

Parameters

  • poOtherGeom: the geometry to compare to this geometry.

void setCoordinateDimension(int nDimension)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().

Parameters

  • nNewDimension: New coordinate dimension value, either 2 or 3.

void set3D(OGRBooleanbIs3D)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

Parameters

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

void setMeasured(OGRBooleanbIsMeasured)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

Parameters

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

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

Parameters

  • poSR: new spatial reference system to apply.

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

Return

OGRERR_NONE in case of success

Parameters

  • poNewRing: ring to be added to the polygon.

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

Return

OGRERR_NONE in case of success

Parameters

  • poNewRing: ring to be added to the polygon.

OGRCurve *getExteriorRingCurve()

Fetch reference to external polygon ring.

Note that the returned ring pointer is to an internal data object of the OGRCurvePolygon. It should not be modified or deleted by the application, and the pointer is only valid till the polygon is next modified. Use the OGRGeometry::clone() method to make a separate copy within the application.

Relates to the Simple Features for COM (SFCOM) IPolygon::get_ExteriorRing() method. TODO(rouault): What does that mean?

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.

Return

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

Relates to the SFCOM IPolygon::get_ExteriorRing() method.

Return

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

int getNumInteriorRings()const

Fetch the number of internal rings.

Relates to the SFCOM IPolygon::get_NumInteriorRings() method.

Return

count of internal rings, zero or more.

OGRCurve *getInteriorRingCurve(int)

Fetch reference to indicated internal ring.

Note that the returned ring pointer is to an internal data object of the OGRCurvePolygon. It should not be modified or deleted by the application, and the pointer is only valid till the polygon is next modified. Use the OGRGeometry::clone() method to make a separate copy within the application.

Relates to the SFCOM IPolygon::get_InternalRing() method.

Return

pointer to interior ring. May be NULL.

Parameters

constOGRCurve *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.

Return

pointer to interior ring. May be NULL.

Parameters

OGRCurve *stealExteriorRingCurve()

"Steal" reference to external ring.

After the call to that function, only call to stealInteriorRing() or destruction of the OGRCurvePolygon is valid. Other operations may crash.

Return

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

OGRErrremoveRing(int iIndex, bool bDelete = true)

Remove a geometry from the container.

Removing a geometry will cause the geometry count to drop by one, and all "higher" geometries will shuffle down one in index.

There is no SFCOM analog to this method.

Return

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

Parameters

  • iIndex: the index of the geometry to delete. A value of -1 is a special flag meaning that all geometries should be removed.

  • bDelete: if true the geometry will be deallocated, otherwise it will not. The default is true as the container is considered to own the geometries in it.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

void swapXY()override

Swap x and y coordinates.

Since

OGR 1.8.0

OGRMultiPoint类

classOGRMultiPoint : publicOGRGeometryCollection

A collection of OGRPoint.

公共类型

typedefOGRPointChildType

Type of child elements.

公共职能

OGRMultiPoint()

Create an empty multi point collection.

OGRMultiPoint(constOGRMultiPoint &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=(constOGRMultiPoint &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

ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

ChildType **end()

Return end of iterator.

constChildType *const *begin()const

Return begin of iterator.

Since

GDAL 2.3

constChildType *const *end()const

Return end of iterator.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

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

Return

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

Parameters

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

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

Export a multipoint to WKT.

Return

WKT representation of the multipoint.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

int getDimension()constoverride

Get the dimension of this object.

This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).

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

Return

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

OGRGeometryCollection *toUpperClass()

Return pointer of this in upper class.

constOGRGeometryCollection *toUpperClass()const

Return pointer of this in upper class.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

OGRBooleanhasCurveGeometry(int bLookForNonLinear = FALSE)constoverride

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

Return

TRUE if this geometry is or has curve geometry.

Since

GDAL 2.0

Parameters

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

OGRMultiLineString类

classOGRMultiLineString : publicOGRMultiCurve

A collection of OGRLineString.

公共类型

typedefOGRLineStringChildType

Type of child elements.

公共职能

OGRMultiLineString()

Create an empty multi line string collection.

OGRMultiLineString(constOGRMultiLineString &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=(constOGRMultiLineString &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

ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

ChildType **end()

Return end of iterator.

constChildType *const *begin()const

Return begin of iterator.

Since

GDAL 2.3

constChildType *const *end()const

Return end of iterator.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

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

Export a multilinestring to WKT.

Return

WKT representation of the multilinestring.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

OGRBooleanhasCurveGeometry(int bLookForNonLinear = FALSE)constoverride

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

Return

TRUE if this geometry is or has curve geometry.

Since

GDAL 2.0

Parameters

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

OGRGeometryCollection *toUpperClass()

Return pointer of this in upper class.

constOGRGeometryCollection *toUpperClass()const

Return pointer of this in upper class.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

公共静态函数

OGRMultiCurve *CastToMultiCurve(OGRMultiLineString *poMLS)

Cast to multicurve.

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

Return

new geometry.

Parameters

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

OGRMultiPolygon类

classOGRMultiPolygon : publicOGRMultiSurface

A collection of non-overlapping OGRPolygon.

公共类型

typedefOGRPolygonChildType

Type of child elements.

公共职能

OGRMultiPolygon()

Create an empty multi polygon collection.

OGRMultiPolygon(constOGRMultiPolygon &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=(constOGRMultiPolygon &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

ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

ChildType **end()

Return end of iterator.

constChildType *const *begin()const

Return begin of iterator.

Since

GDAL 2.3

constChildType *const *end()const

Return end of iterator.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

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

Export a multipolygon to WKT.

Return

WKT representation of the multipolygon.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

OGRBooleanhasCurveGeometry(int bLookForNonLinear = FALSE)constoverride

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

Return

TRUE if this geometry is or has curve geometry.

Since

GDAL 2.0

Parameters

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

OGRGeometryCollection *toUpperClass()

Return pointer of this in upper class.

constOGRGeometryCollection *toUpperClass()const

Return pointer of this in upper class.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

公共静态函数

OGRMultiSurface *CastToMultiSurface(OGRMultiPolygon *poMP)

Cast to multisurface.

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

Return

new geometry.

Parameters

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

ogergometrycollection类

classOGRGeometryCollection : publicOGRGeometry

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 OGRMultiCurveOGRMultiPointOGRMultiSurface

公共类型

typedefOGRGeometryChildType

Type of child elements.

公共职能

OGRGeometryCollection()

Create an empty geometry collection.

OGRGeometryCollection(constOGRGeometryCollection &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=(constOGRGeometryCollection &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

ChildType **begin()

Return begin of sub-geometry iterator.

Since

GDAL 2.3

ChildType **end()

Return end of sub-geometry iterator.

constChildType *const *begin()const

Return begin of sub-geometry iterator.

Since

GDAL 2.3

constChildType *const *end()const

Return end of sub-geometry iterator.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

OGRGeometry *clone()constoverride

Make a copy of this object.

This method relates to the SFCOM IGeometry::clone() method.

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

Return

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

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

OGRErrtransform(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 is the same as the C function OGR_G_Transform().

Return

OGRERR_NONE on success or an error code.

Parameters

  • poCT: the transformation to apply.

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

OGRBooleanIsEmpty()constoverride

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.

Return

TRUE if object is empty, otherwise FALSE.

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

Parameters

  • dfMaxLength: the maximum distance between 2 points after segmentization

OGRBooleanhasCurveGeometry(int bLookForNonLinear = FALSE)constoverride

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

Return

TRUE if this geometry is or has curve geometry.

Since

GDAL 2.0

Parameters

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

OGRGeometry *getCurveGeometry(const char *const *papszOptions = nullptr)constoverride

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

Return

a new geometry.

Since

GDAL 2.0

Parameters

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

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

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

Return

a new geometry.

Since

GDAL 2.0

Parameters

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

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

int WkbSize()constoverride

Returns size of related binary representation.

This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.

This method relates to the SFCOM IWks::WkbSize() method.

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

Return

size of binary representation in bytes.

OGRErrimportFromWkb(const unsigned char*, int, OGRwkbVariant, int &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().

Return

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

Since

GDAL 2.3

Parameters

  • pabyData: the binary input data.

  • nSize: the size of pabyData in bytes, or -1 if not known.

  • eWkbVariant: if wkbVariantPostGIS1, special interpretation is done for curve geometries code

  • nBytesConsumedOut: output parameter. Number of bytes consumed.

OGRErrexportToWkb(OGRwkbByteOrder, unsigned char*, OGRwkbVariant = wkbVariantOldOgc)constoverride

Convert a geometry into well known binary format.

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

This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.

Return

Currently OGRERR_NONE is always returned.

Parameters

  • eByteOrder: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.

  • pabyData: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.

  • eWkbVariant: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

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

Return

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

Parameters

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

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

Export a geometry collection to WKT.

Return

WKT representation of the geometry collection.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

double get_Length()const

Compute the length of a multicurve.

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

Note

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

Return

computed length.

double get_Area()const

Compute area of geometry collection.

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

Note

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

Return

computed area.

int getDimension()constoverride

Get the dimension of this object.

This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).

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

Return

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

void getEnvelope(OGREnvelope *psEnvelope)constoverride

Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.

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

Parameters

  • psEnvelope: the structure in which to place the results.

void getEnvelope(OGREnvelope3D *psEnvelope)constoverride

Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.

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

Since

OGR 1.9.0

Parameters

  • psEnvelope: the structure in which to place the results.

int getNumGeometries()const

Fetch number of geometries in container.

This method relates to the SFCOM IGeometryCollect::get_NumGeometries() method.

Return

count of children geometries. May be zero.

OGRGeometry *getGeometryRef(int)

Fetch geometry from container.

This method returns a pointer to a geometry within the container. The returned geometry remains owned by the container, and should not be modified. The pointer is only valid until the next change to the geometry container. Use IGeometry::clone() to make a copy.

This method relates to the SFCOM IGeometryCollection::get_Geometry() method.

Return

pointer to requested geometry.

Parameters

constOGRGeometry *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.

Return

pointer to requested geometry.

Parameters

OGRBooleanEquals(constOGRGeometry*)constoverride

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

Return

TRUE if equivalent or FALSE otherwise.

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

Parameters

  • nNewDimension: New coordinate dimension value, either 2 or 3.

void set3D(OGRBooleanbIs3D)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

Parameters

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

void setMeasured(OGRBooleanbIsMeasured)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

Parameters

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

OGRErraddGeometry(constOGRGeometry*)

Add a geometry to the container.

Some subclasses of OGRGeometryCollection restrict the types of geometry that can be added, and may return an error. The passed geometry is cloned to make an internal copy.

There is no SFCOM analog to this method.

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

Return

OGRERR_NONE if successful, or OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the type of geometry container.

Parameters

  • poNewGeom: geometry to add to the container.

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

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

There is no SFCOM analog to this method.

Return

OGRERR_NONE if successful, or OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the type of geometry container.

Parameters

  • poNewGeom: geometry to add to the container.

OGRErrremoveGeometry(int iIndex, int bDelete = TRUE)

Remove a geometry from the container.

Removing a geometry will cause the geometry count to drop by one, and all "higher" geometries will shuffle down one in index.

There is no SFCOM analog to this method.

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

Return

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

Parameters

  • iGeom: the index of the geometry to delete. A value of -1 is a special flag meaning that all geometries should be removed.

  • bDelete: if TRUE the geometry will be deallocated, otherwise it will not. The default is TRUE as the container is considered to own the geometries in it.

void assignSpatialReference(OGRSpatialReference *poSR)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().

Parameters

  • poSR: new spatial reference system to apply.

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.

void swapXY()override

Swap x and y coordinates.

Since

OGR 1.8.0

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

公共静态函数

OGRGeometryCollection *CastToGeometryCollection(OGRGeometryCollection *poSrc)

Cast to geometry collection.

This methods cast a derived class of geometry collection to a plain geometry collection.

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

Return

new geometry.

Since

GDAL 2.2

Parameters

  • poSrc: the input geometry - ownership is passed to the method.

OGRMultiCurve类

classOGRMultiCurve : publicOGRGeometryCollection

A collection of OGRCurve.

Since

GDAL 2.0

Subclassed by OGRMultiLineString

公共类型

typedefOGRCurveChildType

Type of child elements.

公共职能

OGRMultiCurve()

Create an empty multi curve collection.

OGRMultiCurve(constOGRMultiCurve &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=(constOGRMultiCurve &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

ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

ChildType **end()

Return end of iterator.

constChildType *const *begin()const

Return begin of iterator.

Since

GDAL 2.3

constChildType *const *end()const

Return end of iterator.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

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

Return

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

Parameters

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

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

Export a multicurve to WKT.

Return

WKT representation of the multicurve.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

int getDimension()constoverride

Get the dimension of this object.

This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).

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

Return

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

OGRBooleanhasCurveGeometry(int bLookForNonLinear = FALSE)constoverride

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

Return

TRUE if this geometry is or has curve geometry.

Since

GDAL 2.0

Parameters

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

OGRGeometryCollection *toUpperClass()

Return pointer of this in upper class.

constOGRGeometryCollection *toUpperClass()const

Return pointer of this in upper class.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

公共静态函数

OGRMultiLineString *CastToMultiLineString(OGRMultiCurve *poMC)

Cast to multi line string.

This method should only be called if the multicurve actually only contains instances of OGRLineString. This can be verified if hasCurveGeometry(TRUE) returns FALSE. It is not intended to approximate circular curves. For that use getLinearGeometry().

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

Return

new geometry.

Parameters

  • poMC: the input geometry - ownership is passed to the method.

OGRMultiSurface类

classOGRMultiSurface : publicOGRGeometryCollection

A collection of non-overlapping OGRSurface.

Since

GDAL 2.0

Subclassed by OGRMultiPolygon

公共类型

typedefOGRSurfaceChildType

Type of child elements.

公共职能

OGRMultiSurface()

Create an empty multi surface collection.

OGRMultiSurface(constOGRMultiSurface &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=(constOGRMultiSurface &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

ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

ChildType **end()

Return end of iterator.

constChildType *const *begin()const

Return begin of iterator.

Since

GDAL 2.3

constChildType *const *end()const

Return end of iterator.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

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

Return

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

Parameters

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

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

Export a geometry collection to WKT.

Return

WKT representation of the geometry collection.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

OGRErrPointOnSurface(OGRPoint *poPoint)const

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

NOTE: Only implemented when GEOS included in build.

Return

OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise.

Parameters

  • poPoint: point to be set with an internal point.

int getDimension()constoverride

Get the dimension of this object.

This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).

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

Return

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

OGRBooleanhasCurveGeometry(int bLookForNonLinear = FALSE)constoverride

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

Return

TRUE if this geometry is or has curve geometry.

Since

GDAL 2.0

Parameters

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

OGRGeometryCollection *toUpperClass()

Return pointer of this in upper class.

constOGRGeometryCollection *toUpperClass()const

Return pointer of this in upper class.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

公共静态函数

OGRMultiPolygon *CastToMultiPolygon(OGRMultiSurface *poMS)

Cast to multipolygon.

This method should only be called if the multisurface actually only contains instances of OGRPolygon. This can be verified if hasCurveGeometry(TRUE) returns FALSE. It is not intended to approximate curve polygons. For that use getLinearGeometry().

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

Return

new geometry.

Parameters

  • poMS: the input geometry - ownership is passed to the method.

八面体曲面类

classOGRPolyhedralSurface : publicOGRSurface

PolyhedralSurface class.

Since

GDAL 2.2

Subclassed by OGRTriangulatedSurface

公共类型

typedefOGRPolygonChildType

Type of child elements.

公共职能

OGRPolyhedralSurface()

Create an empty PolyhedralSurface.

OGRPolyhedralSurface(constOGRPolyhedralSurface &poGeom)

Copy constructor.

~OGRPolyhedralSurface()override

Destructor.

OGRPolyhedralSurface &operator=(constOGRPolyhedralSurface &other)

Assignment operator.

ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

ChildType **end()

Return end of iterator.

constChildType *const *begin()const

Return begin of iterator.

Since

GDAL 2.3

constChildType *const *end()const

Return end of iterator.

int WkbSize()constoverride

Returns size of related binary representation.

This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries.

This method relates to the SFCOM IWks::WkbSize() method.

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

Return

size of binary representation in bytes.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryTypegetGeometryType()constoverride

Returns the WKB Type of PolyhedralSurface.

OGRErrimportFromWkb(const unsigned char*, int, OGRwkbVariant, int &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().

Return

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

Since

GDAL 2.3

Parameters

  • pabyData: the binary input data.

  • nSize: the size of pabyData in bytes, or -1 if not known.

  • eWkbVariant: if wkbVariantPostGIS1, special interpretation is done for curve geometries code

  • nBytesConsumedOut: output parameter. Number of bytes consumed.

OGRErrexportToWkb(OGRwkbByteOrder, unsigned char*, OGRwkbVariant = wkbVariantOldOgc)constoverride

Convert a geometry into well known binary format.

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

This method is the same as the C function OGR_G_ExportToWkb() or OGR_G_ExportToIsoWkb(), depending on the value of eWkbVariant.

Return

Currently OGRERR_NONE is always returned.

Parameters

  • eByteOrder: One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.

  • pabyData: a buffer into which the binary representation is written. This buffer must be at least OGRGeometry::WkbSize() byte in size.

  • eWkbVariant: What standard to use when exporting geometries with three dimensions (or more). The default wkbVariantOldOgc is the historical OGR variant. wkbVariantIso is the variant defined in ISO SQL/MM and adopted by OGC for SFSQL 1.2.

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

Return

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

Parameters

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

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

Export a polyhedral surface to WKT.

Return

WKT representation of the polyhedral surface.

Parameters

  • opts: Output options.

  • err: Pointer to error code, if desired.

int getDimension()constoverride

Get the dimension of this object.

This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by OGRGeometry::getCoordinateDimension()).

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

Return

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

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

OGRGeometry *clone()constoverride

Make a copy of this object.

This method relates to the SFCOM IGeometry::clone() method.

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

Return

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

void getEnvelope(OGREnvelope *psEnvelope)constoverride

Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.

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

Parameters

  • psEnvelope: the structure in which to place the results.

void getEnvelope(OGREnvelope3D *psEnvelope)constoverride

Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.

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

Since

OGR 1.9.0

Parameters

  • psEnvelope: the structure in which to place the results.

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

OGRErrtransform(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 is the same as the C function OGR_G_Transform().

Return

OGRERR_NONE on success or an error code.

Parameters

  • poCT: the transformation to apply.

OGRBooleanEquals(constOGRGeometry*)constoverride

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

Return

TRUE if equivalent or FALSE otherwise.

double get_Area()constoverride

Returns the area enclosed.

This method is built on the SFCGAL library, check it for the definition of the geometry operation. If OGR is built without the SFCGAL library, this method will always return -1.0

Return

area enclosed by the PolyhedralSurface

OGRErrPointOnSurface(OGRPoint*)constoverride

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

NOTE: Only implemented when GEOS included in build.

Return

OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise.

Parameters

  • poPoint: point to be set with an internal point.

OGRBooleanhasCurveGeometry(int bLookForNonLinear = FALSE)constoverride

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

Return

TRUE if this geometry is or has curve geometry.

Since

GDAL 2.0

Parameters

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

OGRErraddGeometry(constOGRGeometry*)

Add a new geometry to a collection.

Only a POLYGON can be added to a POLYHEDRALSURFACE.

Return

OGRErr OGRERR_NONE if the polygon is successfully added

OGRErraddGeometryDirectly(OGRGeometry *poNewGeom)

Add a geometry directly to the container.

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

There is no SFCOM analog to this method.

Return

OGRERR_NONE if successful, or OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the type of geometry container.

Parameters

  • poNewGeom: geometry to add to the container.

int getNumGeometries()const

Fetch number of geometries in PolyhedralSurface.

Return

count of children geometries. May be zero.

OGRGeometry *getGeometryRef(int i)

Fetch geometry from container.

This method returns a pointer to an geometry within the container. The returned geometry remains owned by the container, and should not be modified. The pointer is only valid until the next change to the geometry container. Use IGeometry::clone() to make a copy.

Return

pointer to requested geometry.

Parameters

constOGRGeometry *getGeometryRef(int i)const

Fetch geometry from container.

This method returns a pointer to an geometry within the container. The returned geometry remains owned by the container, and should not be modified. The pointer is only valid until the next change to the geometry container. Use IGeometry::clone() to make a copy.

Return

pointer to requested geometry.

Parameters

OGRBooleanIsEmpty()constoverride

Checks if the PolyhedralSurface is empty.

Return

TRUE if the PolyhedralSurface is empty, FALSE otherwise

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.

Parameters

  • nNewDimension: New coordinate dimension value, either 2 or 3.

void set3D(OGRBooleanbIs3D)override

Set the type as 3D geometry.

void setMeasured(OGRBooleanbIsMeasured)override

Set the type as Measured.

void swapXY()override

Swap x and y coordinates.

OGRErrremoveGeometry(int iIndex, int bDelete = TRUE)

Remove a geometry from the container.

Removing a geometry will cause the geometry count to drop by one, and all "higher" geometries will shuffle down one in index.

Return

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

Parameters

  • iGeom: the index of the geometry to delete. A value of -1 is a special flag meaning that all geometries should be removed.

  • bDelete: if TRUE the geometry will be deallocated, otherwise it will not. The default is TRUE as the container is considered to own the geometries in it.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

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

Parameters

  • poSR: new spatial reference system to apply.

公共静态函数

OGRMultiPolygon *CastToMultiPolygon(OGRPolyhedralSurface *poPS)

Casts the OGRPolyhedralSurface to an OGRMultiPolygon.

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

Return

new geometry.

Parameters

  • poPS: the input geometry - ownership is passed to the method.

OGRTriangle类

classOGRTriangle : publicOGRPolygon

Triangle class.

Since

GDAL 2.2

公共职能

OGRTriangle()

Constructor.

OGRTriangle(constOGRPoint &pconstOGRPoint &qconstOGRPoint &r)

Construct a triangle from points.

Parameters

  • p: Point 1

  • q: Point 2

  • r: Point 3

OGRTriangle(constOGRTriangle &other)

Copy constructor.

OGRTriangle(constOGRPolygon &otherOGRErr &eErr)

Constructs an OGRTriangle from a valid OGRPolygon.

In case of error, NULL is returned.

Parameters

  • other: the Polygon we wish to construct a triangle from

  • eErr: encapsulates an error code; contains OGRERR_NONE if the triangle is constructed successfully

OGRTriangle &operator=(constOGRTriangle &other)

Assignment operator.

Return

OGRTriangle A copy of other

Parameters

  • other: A triangle passed as a parameter

~OGRTriangle()override

Destructor.

const char *getGeometryName()constoverride

Fetch WKT name for geometry type.

There is no SFCOM analog to this method.

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

Return

name used for this geometry type in well known text format. The returned pointer is to a static internal string and should not be modified or freed.

OGRwkbGeometryTypegetGeometryType()constoverride

Fetch geometry type.

Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.

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

Return

the geometry type code.

OGRErrimportFromWkb(const unsigned char*, int, OGRwkbVariant, int &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().

Return

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

Since

GDAL 2.3

Parameters

  • pabyData: the binary input data.

  • nSize: the size of pabyData in bytes, or -1 if not known.

  • eWkbVariant: if wkbVariantPostGIS1, special interpretation is done for curve geometries code

  • nBytesConsumedOut: output parameter. Number of bytes consumed.

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

Return

OGRERR_NONE in case of success

Parameters

  • poNewRing: ring to be added to the polygon.

OGRPolygon *toUpperClass()

Return pointer of this in upper class.

constOGRPolygon *toUpperClass()const

Return pointer of this in upper class.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

OGRTriangulatedSurface类

classOGRTriangulatedSurface : publicOGRPolyhedralSurface

TriangulatedSurface class.

Since

GDAL 2.2

公共类型

typedefOGRTriangleChildType

Type of child elements.

公共职能

OGRTriangulatedSurface()

Constructor.

OGRTriangulatedSurface(constOGRTriangulatedSurface &other)

Copy constructor.

~OGRTriangulatedSurface()

Destructor.

ChildType **begin()

Return begin of iterator.

Since

GDAL 2.3

ChildType **end()

Return end of iterator.

constChildType *const *begin()const

Return begin of iterator.

Since

GDAL 2.3

constChildType *const *end()const

Return end of iterator.

OGRTriangulatedSurface &operator=(constOGRTriangulatedSurface &other)

Assignment operator.

const char *getGeometryName()constoverride

Returns the geometry name of the TriangulatedSurface.

Return

"TIN"

OGRwkbGeometryTypegetGeometryType()constoverride

Returns the WKB Type of TriangulatedSurface.

OGRErraddGeometry(constOGRGeometry*)override

Add a new geometry to a collection.

Only a POLYGON can be added to a POLYHEDRALSURFACE.

Return

OGRErr OGRERR_NONE if the polygon is successfully added

OGRPolyhedralSurface *toUpperClass()

Return pointer of this in upper class.

constOGRPolyhedralSurface *toUpperClass()const

Return pointer of this in upper class.

void accept(IOGRGeometryVisitor *visitor)override

Accept a visitor.

void accept(IOGRConstGeometryVisitor *visitor)constoverride

Accept a visitor.

公共静态函数

OGRPolyhedralSurface *CastToPolyhedralSurface(OGRTriangulatedSurface *poTS)

Casts the OGRTriangulatedSurface to an OGRPolyhedralSurface.

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

Return

new geometry.

Parameters

  • poTS: the input geometry - ownership is passed to the method.

Next  Previous

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: OpenGL是一种图形渲染API,被广泛用于开发二维和三维游戏。通过OpenGL,开发者可以使用计算机的图形硬件加速游戏的绘制和渲染。 开发基于OpenGL的游戏需要一些基本的编程知识,如C或C++。首先,我们需要了解OpenGL的基本概念和编程接口,包括顶点缓冲对象、着色器、纹理等。我们还需要理解OpenGL的渲染管线,它定义了图形数据如何被处理和最终呈现给屏幕。 在OpenGL中,我们可以创建和加载各种对象:例如,通过顶点缓冲对象,我们可以创建和管理模型的顶点数据;通过纹理对象,我们可以加载和渲染纹理图像。通过着色器,我们可以编写顶点和片段着色器程序,控制模型的渲染和颜色。 为了实现一个完整的游戏,我们需要实现多个场景,并处理用户输入、物理碰撞和游戏逻辑。我们可以使用OpenGL的函数和库,如GLFW和GLUT,来处理窗口管理、输入事件和基本渲染循环。 除了OpenGL本身,我们还需要一些图形学和数学知识,如线性代数和三维几何。这些知识可以帮助我们实现物体的移动、旋转和缩放,以及光照和阴影效果等。 最后,我们需要进行游戏性能的优化,以确保游戏在各种计算机硬件上都能流畅运行。这可能涉及到优化渲染、减少资源使用和进行合理的内存管理。 总的来说,通过使用OpenGL开发游戏,我们可以利用图形硬件的强大能力,实现高质量、高性能的游戏体验。 ### 回答2: OpenGL 是一个跨平台的图形程序接口,它可以用来开发 2D 和 3D 游戏。使用 OpenGL 开发游戏可以让游戏在多个平台上运行,无论是在 Windows、Mac 还是 Linux 等系统中,因为 OpenGL 提供了一套统一的图形库。 在开发 OpenGL 游戏时,我们需要理解 OpenGL 的基本概念和运作原理。OpenGL 是一种基于状态机机制的图形 API,它通过将状态设置为不同的值来控制画面的渲染效果。通过设置不同的状态,开发者可以实现各种不同的效果,如光照、阴影、纹理等。 开发 OpenGL 游戏需要使用 OpenGL 的函数库,如 GLAD 或者 GLEW,这些函数库可以帮助我们加载 OpenGL 的函数,以便我们可以直接调用这些函数来进行图形渲染。此外,通过使用 OpenGL 的着色器语言 GLSL,我们可以编写图形渲染的具体代码,并将其传递给 OpenGL 运行。 在游戏开发中,我们还需要了解游戏循环的概念。通过使用 OpenGL,我们可以在每一帧中绘制不同的场景,并对游戏进行更新。游戏循环通常由三个主要步骤组成:输入处理、逻辑更新和渲染输出。输入处理负责接收玩家的输入,逻辑更新负责更新游戏中的物体状态,渲染输出负责将最新的游戏画面呈现给玩家。 总而言之,OpenGL 是一个功能强大的图形程序接口,可以用来开发跨平台的游戏。通过充分理解 OpenGL 的基本概念和运作原理,使用相关的函数库和着色器语言,我们可以开发出各种精美的 2D 和 3D 游戏。 ### 回答3: OpenGL是一种跨平台的图形库,广泛用于开发2D和3D游戏。通过使用OpenGL,开发者可以利用硬件加速的图形渲染功能,创建出高性能和具有吸引力的游戏。 在使用OpenGL开发游戏时,我们可以通过OpenGL的API(应用程序编程接口)来操作图形硬件来绘制2D和3D图形。OpenGL可以用于绘制各种各样的物体,如角色、场景、特效等,实现游戏中的视觉效果。 为了开发一个基于OpenGL的游戏,我们需要首先安装OpenGL开发环境。这通常包括OpenGL的库文件以及相应的开发工具,比如编译器和调试器。然后,我们可以使用编程语言(如C或C++)来编写游戏的代码,并通过OpenGL的函数来调用图形硬件。这些函数可以用来设置图形渲染的参数、绘制各种图形元素以及实现特效和动画等。 开发基于OpenGL的游戏需要考虑性能优化和资源管理。我们需要合理地使用OpenGL的功能和技巧,以提高游戏的帧率和响应速度。此外,我们也需要注意资源的管理,包括内存的分配和释放,以及纹理、模型和声音等资源的加载和释放。 总而言之,基于OpenGL的游戏开发是一项挑战性的任务,需要掌握图形编程、性能优化和资源管理等方面的知识。然而,通过充分利用OpenGL的功能和优势,我们可以开发出高质量、富有创意和令人陶醉的游戏作品。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值