# geos::geom::GeometryFactory Class Reference

Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geometry objects. More...

`#include <GeometryFactory.h>`

List of all members.

## Public Member Functions

| GeometryFactory ()
| Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial-reference ID of 0.
| GeometryFactory (const PrecisionModel *pm, int newSRID, CoordinateSequenceFactory *nCoordinateSequenceFactory)
| Constructs a GeometryFactory that generates Geometries having the given PrecisionModel, spatial-reference ID, and CoordinateSequence implementation.
| GeometryFactory (CoordinateSequenceFactory *nCoordinateSequenceFactory)
| Constructs a GeometryFactory that generates Geometries having the given CoordinateSequence implementation, a double-precision floating PrecisionModel and a spatial-reference ID of 0.
| GeometryFactory (const PrecisionModel *pm)
| Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and the default CoordinateSequence implementation.
| GeometryFactory (const PrecisionModel *pm, int newSRID)
| Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and spatial-reference ID, and the default CoordinateSequence implementation.
| GeometryFactory (const GeometryFactory &gf)
| Copy constructor.
virtual | ~GeometryFactory ()
| Destructor.
Point * | createPointFromInternalCoord (const Coordinate *coord, const Geometry *exemplar) const
Geometry * | toGeometry (const Envelope *envelope) const
| Converts an Envelope to a Geometry.
const PrecisionModel * | getPrecisionModel () const
| Returns the PrecisionModel that Geometries created by this factory will be associated with.
Point * | createPoint () const
| Creates an EMPTY Point.
Point * | createPoint (const Coordinate &coordinate) const
| Creates a Point using the given Coordinate.
Point * | createPoint (CoordinateSequence *coordinates) const
| Creates a Point taking ownership of the given CoordinateSequence.
Point * | createPoint (const CoordinateSequence &coordinates) const
| Creates a Point with a deep-copy of the given CoordinateSequence.
GeometryCollection * | createGeometryCollection () const
| Construct an EMPTY GeometryCollection.
Geometry * | createEmptyGeometry () const
| Construct the EMPTY Geometry.
GeometryCollection * | createGeometryCollection (std::vector< Geometry * > *newGeoms) const
| Construct a GeometryCollection taking ownership of given arguments.
GeometryCollection * | createGeometryCollection (const std::vector< Geometry * > &newGeoms) const
| Constructs a GeometryCollection with a deep-copy of args.
MultiLineString * | createMultiLineString () const
| Construct an EMPTY MultiLineString.
MultiLineString * | createMultiLineString (std::vector< Geometry * > *newLines) const
| Construct a MultiLineString taking ownership of given arguments.
MultiLineString * | createMultiLineString (const std::vector< Geometry * > &fromLines) const
| Construct a MultiLineString with a deep-copy of given arguments.
MultiPolygon * | createMultiPolygon () const
| Construct an EMPTY MultiPolygon.
MultiPolygon * | createMultiPolygon (std::vector< Geometry * > *newPolys) const
| Construct a MultiPolygon taking ownership of given arguments.
MultiPolygon * | createMultiPolygon (const std::vector< Geometry * > &fromPolys) const
| Construct a MultiPolygon with a deep-copy of given arguments.
LinearRing * | createLinearRing () const
| Construct an EMPTY LinearRing.
LinearRing * | createLinearRing (CoordinateSequence *newCoords) const
| Construct a LinearRing taking ownership of given arguments.
std::auto_ptr< Geometry > | createLinearRing (std::auto_ptr< CoordinateSequence > newCoords) const
LinearRing * | createLinearRing (const CoordinateSequence &coordinates) const
| Construct a LinearRing with a deep-copy of given arguments.
MultiPoint * | createMultiPoint () const
| Constructs an EMPTY `MultiPoint`.
MultiPoint * | createMultiPoint (std::vector< Geometry * > *newPoints) const
| Construct a MultiPoint taking ownership of given arguments.
MultiPoint * | createMultiPoint (const std::vector< Geometry * > &fromPoints) const
| Construct a MultiPoint with a deep-copy of given arguments.
MultiPoint * | createMultiPoint (const CoordinateSequence &fromCoords) const
| Construct a MultiPoint containing a Point geometry for each Coordinate in the given list.
Polygon * | createPolygon () const
| Construct an EMPTY Polygon.
Polygon * | createPolygon (LinearRing *shell, std::vector< Geometry * > *holes) const
| Construct a Polygon taking ownership of given arguments.
Polygon * | createPolygon (const LinearRing &shell, const std::vector< Geometry * > &holes) const
| Construct a Polygon with a deep-copy of given arguments.
LineString * | createLineString () const
| Construct an EMPTY LineString.
std::auto_ptr< LineString > | createLineString (const LineString &ls) const
| Copy a LineString.
LineString * | createLineString (CoordinateSequence *coordinates) const
| Construct a LineString taking ownership of given argument.
std::auto_ptr< Geometry > | createLineString (std::auto_ptr< CoordinateSequence > coordinates) const
LineString * | createLineString (const CoordinateSequence &coordinates) const
| Construct a LineString with a deep-copy of given argument.
Geometry * | buildGeometry (std::vector< Geometry * > *geoms) const
Geometry * | buildGeometry (const std::vector< Geometry * > &geoms) const
| This function does the same thing of the omonimouse function taking vector pointer instead of reference.
int | getSRID () const
const CoordinateSequenceFactory * | getCoordinateSequenceFactory () const
| Returns the CoordinateSequenceFactory associated with this GeometryFactory.
Geometry * | createGeometry (const Geometry *g) const
| Returns a clone of given Geometry.
void | destroyGeometry (Geometry *g) const
| Destroy a Geometry, or release it.

## Static Public Member Functions

static const GeometryFactory * | getDefaultInstance ()
| Return a pointer to the default GeometryFactory. This is a global shared object instantiated using default constructor.

## Detailed Description

Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geometry objects.

Note that the factory constructor methods do not change the input coordinates in any way. In particular, they are not rounded to the supplied `PrecisionModel`. It is assumed that input Coordinates meet the given precision.

## Constructor & Destructor Documentation

geos::geom::GeometryFactory::GeometryFactory | ( | const PrecisionModel * | pm,
|  | int | newSRID,
|  | CoordinateSequenceFactory * | nCoordinateSequenceFactory
| ) |  |

Constructs a GeometryFactory that generates Geometries having the given PrecisionModel, spatial-reference ID, and CoordinateSequence implementation.

NOTES: (1) the given PrecisionModel is COPIED (2) the CoordinateSequenceFactory is NOT COPIED and must be available for the whole lifetime of the GeometryFactory

geos::geom::GeometryFactory::GeometryFactory | ( | const PrecisionModel * | pm ) |

Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and the default CoordinateSequence implementation.

Parameters:

  pm | the PrecisionModel to use

geos::geom::GeometryFactory::GeometryFactory | ( | const PrecisionModel * | pm,
|  | int | newSRID
| ) |  |

Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and spatial-reference ID, and the default CoordinateSequence implementation.

Parameters:

  pm | the PrecisionModel to use
  newSRID | the SRID to use

geos::geom::GeometryFactory::GeometryFactory | ( | const GeometryFactory & | gf ) |

Copy constructor.

Parameters:

  gf | the GeometryFactory to clone from

## Member Function Documentation

Geometry* geos::geom::GeometryFactory::buildGeometry | ( | std::vector< Geometry * > * | geoms ) | const

Build an appropriate `Geometry`, `MultiGeometry`, or `GeometryCollection` to contain the `Geometry`s in it.

For example:

- If `geomList` contains a single `Polygon`, the `Polygon` is returned.
- If `geomList` contains several `Polygon`s, a `MultiPolygon` is returned.
- If `geomList` contains some `Polygon`s and some `LineString`s, a `GeometryCollection` is returned.
- If `geomList` is empty, an empty `GeometryCollection` is returned

Note that this method does not "flatten" Geometries in the input, and hence if any MultiGeometries are contained in the input a GeometryCollection containing them will be returned.

Parameters:

  newGeoms | the `Geometry`s to combine

Returns:
  A `Geometry` of the "smallest", "most type-specific" class that can contain the elements of `geomList`.

NOTE: the returned Geometry will take ownership of the given vector AND its elements

Geometry* geos::geom::GeometryFactory::buildGeometry | ( | const std::vector< Geometry * > & | geoms ) | const

This function does the same thing of the omonimouse function taking vector pointer instead of reference.

The difference is that this version will copy needed data leaving ownership to the caller.

Geometry* geos::geom::GeometryFactory::toGeometry | ( | const Envelope * | envelope ) | const

Converts an Envelope to a Geometry.

Returned Geometry can be a Point, a Polygon or an EMPTY geom.

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

- GeometryFactory.h