OGRGeometryFactory Class Reference

#include <ogr_geometry.h>

List of all members.

Static Public Member Functions

static OGRErr createFromWkb (unsigned char *, OGRSpatialReference *, OGRGeometry **, int=-1)
 Create a geometry object of the appropriate type from it's well known binary representation.
static OGRErr createFromWkt (char **, OGRSpatialReference *, OGRGeometry **)
 Create a geometry object of the appropriate type from it's well known text representation.
static OGRErr createFromFgf (unsigned char *, OGRSpatialReference *, OGRGeometry **, int=-1, int *=NULL)
 Create a geometry object of the appropriate type from it's FGF (FDO Geometry Format) binary representation.
static OGRGeometrycreateFromGML (const char *)
 Create geometry from GML.
static void destroyGeometry (OGRGeometry *)
 Destroy geometry object.
static OGRGeometrycreateGeometry (OGRwkbGeometryType)
 Create an empty geometry of desired type.
static OGRGeometryforceToPolygon (OGRGeometry *)
 Convert to polygon.
static OGRGeometryforceToMultiPolygon (OGRGeometry *)
 Convert to multipolygon.
static OGRGeometryforceToMultiPoint (OGRGeometry *)
 Convert to multipoint.
static OGRGeometryforceToMultiLineString (OGRGeometry *)
 Convert to multilinestring.
static OGRGeometryorganizePolygons (OGRGeometry **papoPolygons, int nPolygonCount, int *pbResultValidGeometry, const char **papszOptions=NULL)
 Organize polygons based on geometries.
static int haveGEOS ()
 Test if GEOS enabled.
static OGRGeometryapproximateArcAngles (double dfX, double dfY, double dfZ, double dfPrimaryRadius, double dfSecondaryAxis, double dfRotation, double dfStartAngle, double dfEndAngle, double dfMaxAngleStepSizeDegrees)


Detailed Description

Create geometry objects from well known text/binary.

Member Function Documentation

OGRGeometry * OGRGeometryFactory::approximateArcAngles ( double  dfCenterX,
double  dfCenterY,
double  dfZ,
double  dfPrimaryRadius,
double  dfSecondaryRadius,
double  dfRotation,
double  dfStartAngle,
double  dfEndAngle,
double  dfMaxAngleStepSizeDegrees 
) [static]

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.

See also:
CPLSetConfigOption()
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.
Returns:
OGRLineString geometry representing an approximation of the arc.

References OGRLineString::setPoint().

OGRErr OGRGeometryFactory::createFromFgf ( unsigned char *  pabyData,
OGRSpatialReference poSR,
OGRGeometry **  ppoReturn,
int  nBytes = -1,
int *  pnBytesConsumed = NULL 
) [static]

Create a geometry object of the appropriate type from it's 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.

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.
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).
Returns:
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

References OGRGeometryCollection::addGeometryDirectly(), OGRPolygon::addRingDirectly(), OGRGeometry::assignSpatialReference(), OGRLineString::setNumPoints(), and OGRLineString::setPoint().

OGRGeometry * OGRGeometryFactory::createFromGML ( const char *  pszData  )  [static]

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 C function OGR_G_CreateFromGML() is the same as this method.

Parameters:
pszData The GML fragment for the geometry.
Returns:
a geometry on succes, or NULL on error.

OGRErr OGRGeometryFactory::createFromWkb ( unsigned char *  pabyData,
OGRSpatialReference poSR,
OGRGeometry **  ppoReturn,
int  nBytes = -1 
) [static]

Create a geometry object of the appropriate type from it's 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.

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.
nBytes the number of bytes available in pabyData, or -1 if it isn't known.
Returns:
OGRERR_NONE if all goes well, otherwise any of OGRERR_NOT_ENOUGH_DATA, OGRERR_UNSUPPORTED_GEOMETRY_TYPE, or OGRERR_CORRUPT_DATA may be returned.

References OGRGeometry::assignSpatialReference(), createGeometry(), and OGRGeometry::importFromWkb().

Referenced by OGRGeometryCollection::importFromWkb(), and OGR_G_CreateFromWkb().

OGRErr OGRGeometryFactory::createFromWkt ( char **  ppszData,
OGRSpatialReference poSR,
OGRGeometry **  ppoReturn 
) [static]

Create a geometry object of the appropriate type from it's well known text representation.

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

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.
Example:

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

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

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

References OGRGeometry::assignSpatialReference(), and OGRGeometry::importFromWkt().

Referenced by OGRGeometryCollection::importFromWkt(), and OGR_G_CreateFromWkt().

OGRGeometry * OGRGeometryFactory::createGeometry ( OGRwkbGeometryType  eGeometryType  )  [static]

Create an empty geometry of desired type.

This is equivelent 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().

Parameters:
eGeometryType the type code of the geometry class to be instantiated.
Returns:
the newly create geometry or NULL on failure.

References wkbGeometryCollection, wkbLinearRing, wkbLineString, wkbMultiLineString, wkbMultiPoint, wkbMultiPolygon, wkbPoint, and wkbPolygon.

Referenced by createFromWkb(), and OGR_G_CreateGeometry().

void OGRGeometryFactory::destroyGeometry ( OGRGeometry poGeom  )  [static]

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.

Referenced by OGR_G_DestroyGeometry().

OGRGeometry * OGRGeometryFactory::forceToMultiLineString ( OGRGeometry poGeom  )  [static]

Convert to multilinestring.

Tries to force the provided geometry to be a multilinestring.

  • linestrings are 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).

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

Returns:
new geometry.

References OGRMultiLineString::addGeometryDirectly(), OGRLineString::addSubLineString(), OGRPolygon::getExteriorRing(), OGRGeometryCollection::getGeometryRef(), OGRGeometry::getGeometryType(), OGRPolygon::getInteriorRing(), OGRGeometryCollection::getNumGeometries(), OGRPolygon::getNumInteriorRings(), OGRGeometryCollection::removeGeometry(), wkbGeometryCollection, wkbLineString, wkbMultiPolygon, and wkbPolygon.

OGRGeometry * OGRGeometryFactory::forceToMultiPoint ( OGRGeometry poGeom  )  [static]

Convert to multipoint.

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

Returns:
new geometry.

References OGRMultiPoint::addGeometryDirectly(), OGRGeometryCollection::getGeometryRef(), OGRGeometry::getGeometryType(), OGRGeometryCollection::getNumGeometries(), OGRGeometryCollection::removeGeometry(), wkbGeometryCollection, and wkbPoint.

OGRGeometry * OGRGeometryFactory::forceToMultiPolygon ( OGRGeometry poGeom  )  [static]

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

Returns:
new geometry.

References OGRMultiPolygon::addGeometryDirectly(), OGRGeometryCollection::getGeometryRef(), OGRGeometry::getGeometryType(), OGRGeometryCollection::getNumGeometries(), OGRGeometryCollection::removeGeometry(), wkbGeometryCollection, and wkbPolygon.

OGRGeometry * OGRGeometryFactory::forceToPolygon ( OGRGeometry poGeom  )  [static]

Convert to polygon.

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

Returns:
new geometry.

References OGRPolygon::addRing(), OGRPolygon::getExteriorRing(), OGRGeometryCollection::getGeometryRef(), OGRGeometry::getGeometryType(), OGRPolygon::getInteriorRing(), OGRGeometryCollection::getNumGeometries(), OGRPolygon::getNumInteriorRings(), wkbGeometryCollection, wkbMultiPolygon, and wkbPolygon.

int OGRGeometryFactory::haveGEOS (  )  [static]

Test if GEOS enabled.

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

Returns:
TRUE if available, otherwise FALSE.

Referenced by organizePolygons().

OGRGeometry * OGRGeometryFactory::organizePolygons ( OGRGeometry **  papoPolygons,
int  nPolygonCount,
int *  pbIsValidGeometry,
const char **  papszOptions = NULL 
) [static]

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.

All the input geometries must be OGRPolygons 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 shapefiles e.g.)

If the OGR_ORGANIZE_POLYGONS configuration option is defined, its value will override the value of the METHOD option of papszOptions (usefull to modify the behaviour of the shapefile driver)

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
Returns:
a single resulting geometry (either OGRPolygon or OGRMultiPolygon).

References OGRGeometry::getEnvelope(), haveGEOS(), and wkbPolygon.


The documentation for this class was generated from the following files:

Generated for GDAL by doxygen 1.5.7.1.