GDAL

Classes | Static Public Member Functions | List of all members
OGRGeometryFactory Class Reference

Create geometry objects from well known text/binary. More...

`#include <ogr_geometry.h>`

## Classes
class | TransformWithOptionsCache
| Opaque class used as argument to transformWithOptions() More...

## Static Public Member Functions
static OGRErr | createFromWkb (const void *, OGRSpatialReference *, OGRGeometry **, size_t=static_cast< size_t >(-1), OGRwkbVariant=wkbVariantOldOgc)
| Create a geometry object of the appropriate type from its well known binary representation. More...
static OGRErr | createFromWkb (const void *pabyData, OGRSpatialReference *, OGRGeometry **, size_t nSize, OGRwkbVariant eVariant, size_t &nBytesConsumedOut)
| Create a geometry object of the appropriate type from its well known binary representation. More...
static OGRErr | createFromWkt (const char *, OGRSpatialReference *, OGRGeometry **)
| Create a geometry object of the appropriate type from its well known text representation. More...
static OGRErr | createFromWkt (const char **, OGRSpatialReference *, OGRGeometry **)
| Create a geometry object of the appropriate type from its well known text representation. More...
static OGRErr | createFromWkt (char **ppszInput, OGRSpatialReference *poSRS, OGRGeometry **ppoGeom)
| Deprecated. More...
static OGRErr | createFromFgf (const void *, OGRSpatialReference *, OGRGeometry **, int=-1, int *=nullptr)
| Create a geometry object of the appropriate type from its FGF (FDO Geometry Format) binary representation. More...
static OGRGeometry * | createFromGML (const char *)
| Create geometry from GML. More...
static OGRGeometry * | createFromGEOS (GEOSContextHandle_t hGEOSCtxt, GEOSGeom)
| Builds a OGRGeometry* from a GEOSGeom. More...
static OGRGeometry * | createFromGeoJson (const char *, int=-1)
| Create geometry from GeoJson fragment. More...
static OGRGeometry * | createFromGeoJson (const CPLJSONObject &oJSONObject)
| Create geometry from GeoJson fragment. More...
static void | destroyGeometry (OGRGeometry *)
| Destroy geometry object. More...
static OGRGeometry * | createGeometry (OGRwkbGeometryType)
| Create an empty geometry of desired type. More...
static OGRGeometry * | forceToPolygon (OGRGeometry *)
| Convert to polygon. More...
static OGRGeometry * | forceToLineString (OGRGeometry *, bool bOnlyInOrder=true)
| Convert to line string. More...
static OGRGeometry * | forceToMultiPolygon (OGRGeometry *)
| Convert to multipolygon. More...
static OGRGeometry * | forceToMultiPoint (OGRGeometry *)
| Convert to multipoint. More...
static OGRGeometry * | forceToMultiLineString (OGRGeometry *)
| Convert to multilinestring. More...
static OGRGeometry * | forceTo (OGRGeometry *poGeom, OGRwkbGeometryType eTargetType, const char *const *papszOptions=nullptr)
| Convert to another geometry type. More...
static OGRGeometry * | removeLowerDimensionSubGeoms (const OGRGeometry *poGeom)
| Remove sub-geometries from a geometry collection that do not have the maximum topological dimensionality of the collection. More...
static OGRGeometry * | organizePolygons (OGRGeometry **papoPolygons, int nPolygonCount, int *pbResultValidGeometry, const char **papszOptions=nullptr)
| Organize polygons based on geometries. More...
static bool | haveGEOS ()
| Test if GEOS enabled. More...
static OGRGeometry * | transformWithOptions (const OGRGeometry *poSrcGeom, OGRCoordinateTransformation *poCT, char **papszOptions, const TransformWithOptionsCache &cache=TransformWithOptionsCache())
| Transform a geometry. More...
static OGRGeometry * | approximateArcAngles (double dfX, double dfY, double dfZ, double dfPrimaryRadius, double dfSecondaryAxis, double dfRotation, double dfStartAngle, double dfEndAngle, double dfMaxAngleStepSizeDegrees, const bool bUseMaxGap=false)
| Stroke arc to linestring. More...
static int | GetCurveParameters (double x0, double y0, double x1, double y1, double x2, double y2, double &R, double &cx, double &cy, double &alpha0, double &alpha1, double &alpha2)
| Returns the parameter of an arc circle. More...
static OGRLineString * | curveToLineString (double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, int bHasZ, double dfMaxAngleStepSizeDegrees, const char *const *papszOptions=nullptr)
| Converts an arc circle into an approximate line string. More...
static OGRCurve * | curveFromLineString (const OGRLineString *poLS, const char *const *papszOptions=nullptr)
| Try to convert a linestring approximating curves into a curve. More...

## Detailed Description

Create geometry objects from well known text/binary.

## Member Function Documentation

## ◆ approximateArcAngles()

OGRGeometry * OGRGeometryFactory::approximateArcAngles | ( | double | dfCenterX,
|  | double | dfCenterY,
|  | double | dfZ,
|  | double | dfPrimaryRadius,
|  | double | dfSecondaryRadius,
|  | double | dfRotation,
|  | double | dfStartAngle,
|  | double | dfEndAngle,
|  | double | dfMaxAngleStepSizeDegrees,
|  | const bool | bUseMaxGap = `false`
| ) |  |
| 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.

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 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.
  bUseMaxGap | Optional: whether to honor OGR_ARC_MAX_GAP.

Returns
  OGRLineString geometry representing an approximation of the arc.

Since
  OGR 1.8.0

## ◆ createFromFgf()

OGRErr OGRGeometryFactory::createFromFgf | ( | const void * | pabyData,
|  | OGRSpatialReference * | poSR,
|  | OGRGeometry ** | ppoReturn,
|  | int | nBytes = `-1`,
|  | int * | pnBytesConsumed = `nullptr`
| ) |  |
| static

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.

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

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.

## ◆ createFromGeoJson() [1/2]

OGRGeometry * OGRGeometryFactory::createFromGeoJson | ( | const char * | pszJsonString,
|  | int | nSize = `-1`
| ) |  |
| static

Create geometry from GeoJson fragment.

Parameters

  pszJsonString | The GeoJSON fragment for the geometry.
  nSize | (new in GDAL 3.4) Optional length of the string if it is not null-terminated

Returns
  a geometry on success, or NULL on error.

Since
  GDAL 2.3

## ◆ createFromGeoJson() [2/2]

OGRGeometry * OGRGeometryFactory::createFromGeoJson | ( | const CPLJSONObject & | oJsonObject | ) |
| static

Create geometry from GeoJson fragment.

Parameters

  oJsonObject | The JSONObject class describes the GeoJSON geometry.

Returns
  a geometry on success, or NULL on error.

Since
  GDAL 2.3

## ◆ createFromGEOS()

OGRGeometry * OGRGeometryFactory::createFromGEOS | ( | GEOSContextHandle_t | hGEOSCtxt,
|  | GEOSGeom | geosGeom
| ) |  |
| static

Builds a OGRGeometry* from a GEOSGeom.

Parameters

  hGEOSCtxt | GEOS context
  geosGeom | GEOS geometry

Returns
  a OGRGeometry*

## ◆ createFromGML()

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

Parameters

  pszData | The GML fragment for the geometry.

Returns
  a geometry on success, or NULL on error.

## ◆ createFromWkb() [1/2]

OGRErr OGRGeometryFactory::createFromWkb | ( | const void * | pabyData,
|  | OGRSpatialReference * | poSR,
|  | OGRGeometry ** | ppoReturn,
|  | size_t | nBytes = `static_cast<size_t>(-1)`,
|  | OGRwkbVariant | eWkbVariant = `wkbVariantOldOgc`
| ) |  |
| static

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.

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.

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.

## ◆ createFromWkb() [2/2]

OGRErr OGRGeometryFactory::createFromWkb | ( | const void * | pabyData,
|  | OGRSpatialReference * | poSR,
|  | OGRGeometry ** | ppoReturn,
|  | size_t | nBytes,
|  | OGRwkbVariant | eWkbVariant,
|  | size_t & | nBytesConsumedOut
| ) |  |
| static

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.

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.

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.

Since
  GDAL 2.3

## ◆ createFromWkt() [1/3]

static OGRErr OGRGeometryFactory::createFromWkt | ( | char ** | ppszInput,
|  | OGRSpatialReference * | poSRS,
|  | OGRGeometry ** | ppoGeom
| ) |  |
| inline static

Deprecated.

Deprecated:
  in GDAL 2.3

## ◆ createFromWkt() [2/3]

OGRErr OGRGeometryFactory::createFromWkt | ( | const char ** | ppszData,
|  | OGRSpatialReference * | poSR,
|  | OGRGeometry ** | ppoReturn
| ) |  |
| static

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.

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.

Example:

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

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.

## ◆ createFromWkt() [3/3]

OGRErr OGRGeometryFactory::createFromWkt | ( | const char * | pszData,
|  | OGRSpatialReference * | poSR,
|  | OGRGeometry ** | ppoReturn
| ) |  |
| static

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.

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.

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.

Since
  GDAL 2.3

## ◆ createGeometry()

OGRGeometry * OGRGeometryFactory::createGeometry | ( | OGRwkbGeometryType | eGeometryType | ) |
| static

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

Parameters

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

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

## ◆ curveFromLineString()

OGRCurve * OGRGeometryFactory::curveFromLineString | ( | const OGRLineString * | poLS,
|  | const char *const * | papszOptions = `nullptr`
| ) |  |
| static

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

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.

Returns
  the converted geometry (ownership to caller).

Since
  GDAL 2.0

## ◆ curveToLineString()

OGRLineString * OGRGeometryFactory::curveToLineString | ( | double | x0,
|  | double | y0,
|  | double | z0,
|  | double | x1,
|  | double | y1,
|  | double | z1,
|  | double | x2,
|  | double | y2,
|  | double | z2,
|  | int | bHasZ,
|  | double | dfMaxAngleStepSizeDegrees,
|  | const char *const * | papszOptions = `nullptr`
| ) |  |
| static

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.

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.

Returns
  the converted geometry (ownership to caller).

Since
  GDAL 2.0

## ◆ destroyGeometry()

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.

## ◆ forceTo()

OGRGeometry * OGRGeometryFactory::forceTo | ( | OGRGeometry * | poGeom,
|  | OGRwkbGeometryType | eTargetType,
|  | const char *const * | papszOptions = `nullptr`
| ) |  |
| static

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

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.

Returns
  new geometry.

Since
  GDAL 2.0

## ◆ forceToLineString()

OGRGeometry * OGRGeometryFactory::forceToLineString | ( | OGRGeometry * | poGeom,
|  | bool | bOnlyInOrder = `true`
| ) |  |
| static

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

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.

Returns
  new geometry.

## ◆ forceToMultiLineString()

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

Returns
  new geometry.

## ◆ forceToMultiPoint()

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 or collection of points. The passed in geometry is consumed and a new one returned (or potentially the same one).

Returns
  new geometry.

## ◆ forceToMultiPolygon()

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.

## ◆ forceToPolygon()

OGRGeometry * OGRGeometryFactory::forceToPolygon | ( | OGRGeometry * | poGeom | ) |
| static

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.

Parameters

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

Returns
  new geometry.

## ◆ GetCurveParameters()

int OGRGeometryFactory::GetCurveParameters | ( | double | x0,
|  | double | y0,
|  | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2,
|  | double & | R,
|  | double & | cx,
|  | double & | cy,
|  | double & | alpha0,
|  | double & | alpha1,
|  | double & | alpha2
| ) |  |
| static

Returns the parameter of an arc circle.

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

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)

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

Since
  GDAL 2.0

## ◆ haveGEOS()

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

## ◆ organizePolygons()

OGRGeometry * OGRGeometryFactory::organizePolygons | ( | OGRGeometry ** | papoPolygons,
|  | int | nPolygonCount,
|  | int * | pbIsValidGeometry,
|  | const char ** | papszOptions = `nullptr`
| ) |  |
| 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) 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)

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, OGRCurvePolygon, OGRMultiPolygon, OGRMultiSurface or OGRGeometryCollection). Returns a POLYGON EMPTY in the case of nPolygonCount being 0.

## ◆ removeLowerDimensionSubGeoms()

OGRGeometry * OGRGeometryFactory::removeLowerDimensionSubGeoms | ( | const OGRGeometry * | poGeom | ) |
| static

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.

Parameters

  poGeom | input geometry

Returns
  a new geometry.

Since
  GDAL 3.1.0

## ◆ transformWithOptions()

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

Transform a 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

Returns
  (new) transformed geometry.

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

- ogr_geometry.h
- ogrgeometryfactory.cpp

OSRSetAxisMappingStrategy
void OSRSetAxisMappingStrategy(OGRSpatialReferenceH hSRS, OSRAxisMappingStrategy strategy)
Set the data axis to CRS axis mapping strategy.
Definition: ogrspatialreference.cpp:11599
OGRSpatialReferenceH
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition: ogr_api.h:80
OAMS_TRADITIONAL_GIS_ORDER
@ OAMS_TRADITIONAL_GIS_ORDER
Traditional GIS order.
Definition: ogr_srs_api.h:669
OSRNewSpatialReference
OGRSpatialReferenceH OSRNewSpatialReference(const char *)
Constructor.
Definition: ogrspatialreference.cpp:733
OGRGeometryH
void * OGRGeometryH
Opaque type for a geometry.
Definition: ogr_api.h:65
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:318
OGR_G_CreateFromWkt
OGRErr OGR_G_CreateFromWkt(char **, OGRSpatialReferenceH, OGRGeometryH *)
Create a geometry object of the appropriate type from its well known text representation.
Definition: ogrgeometryfactory.cpp:544