GEOS 3.11.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
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>

Public Types

using Ptr = std::unique_ptr< GeometryFactory, GeometryFactoryDeleter >
 

Public Member Functions

PointcreatePointFromInternalCoord (const Coordinate *coord, const Geometry *exemplar) const
 
std::unique_ptr< GeometrytoGeometry (const Envelope *envelope) const
 
const PrecisionModelgetPrecisionModel () const
 Returns the PrecisionModel that Geometries created by this factory will be associated with.
 
std::unique_ptr< PointcreatePoint (std::size_t coordinateDimension=2) const
 Creates an EMPTY Point.
 
PointcreatePoint (const Coordinate &coordinate) const
 Creates a Point using the given Coordinate.
 
PointcreatePoint (CoordinateSequence *coordinates) const
 Creates a Point taking ownership of the given CoordinateSequence.
 
PointcreatePoint (const CoordinateSequence &coordinates) const
 Creates a Point with a deep-copy of the given CoordinateSequence.
 
std::unique_ptr< GeometryCollectioncreateGeometryCollection () const
 Construct an EMPTY GeometryCollection.
 
std::unique_ptr< GeometrycreateEmptyGeometry () const
 Construct the EMPTY Geometry.
 
GeometryCollectioncreateGeometryCollection (std::vector< Geometry * > *newGeoms) const
 Construct a GeometryCollection taking ownership of given arguments.
 
template<typename T >
std::unique_ptr< GeometryCollectioncreateGeometryCollection (std::vector< std::unique_ptr< T > > &&newGeoms) const
 
GeometryCollectioncreateGeometryCollection (const std::vector< const Geometry * > &newGeoms) const
 Constructs a GeometryCollection with a deep-copy of args.
 
std::unique_ptr< MultiLineStringcreateMultiLineString () const
 Construct an EMPTY MultiLineString.
 
MultiLineStringcreateMultiLineString (std::vector< Geometry * > *newLines) const
 Construct a MultiLineString taking ownership of given arguments.
 
MultiLineStringcreateMultiLineString (const std::vector< const Geometry * > &fromLines) const
 Construct a MultiLineString with a deep-copy of given arguments.
 
std::unique_ptr< MultiLineStringcreateMultiLineString (std::vector< std::unique_ptr< LineString > > &&fromLines) const
 
std::unique_ptr< MultiLineStringcreateMultiLineString (std::vector< std::unique_ptr< Geometry > > &&fromLines) const
 
std::unique_ptr< MultiPolygoncreateMultiPolygon () const
 Construct an EMPTY MultiPolygon.
 
MultiPolygoncreateMultiPolygon (std::vector< Geometry * > *newPolys) const
 Construct a MultiPolygon taking ownership of given arguments.
 
MultiPolygoncreateMultiPolygon (const std::vector< const Geometry * > &fromPolys) const
 Construct a MultiPolygon with a deep-copy of given arguments.
 
std::unique_ptr< MultiPolygoncreateMultiPolygon (std::vector< std::unique_ptr< Polygon > > &&fromPolys) const
 
std::unique_ptr< MultiPolygoncreateMultiPolygon (std::vector< std::unique_ptr< Geometry > > &&fromPolys) const
 
std::unique_ptr< LinearRingcreateLinearRing () const
 Construct an EMPTY LinearRing.
 
LinearRingcreateLinearRing (CoordinateSequence *newCoords) const
 Construct a LinearRing taking ownership of given arguments.
 
std::unique_ptr< LinearRingcreateLinearRing (std::unique_ptr< CoordinateSequence > &&newCoords) const
 
std::unique_ptr< LinearRingcreateLinearRing (std::vector< Coordinate > &&coordinates) const
 
LinearRingcreateLinearRing (const CoordinateSequence &coordinates) const
 Construct a LinearRing with a deep-copy of given arguments.
 
std::unique_ptr< MultiPointcreateMultiPoint () const
 Constructs an EMPTY MultiPoint.
 
MultiPointcreateMultiPoint (std::vector< Geometry * > *newPoints) const
 Construct a MultiPoint taking ownership of given arguments.
 
std::unique_ptr< MultiPointcreateMultiPoint (std::vector< Coordinate > &&newPoints) const
 
std::unique_ptr< MultiPointcreateMultiPoint (std::vector< std::unique_ptr< Point > > &&newPoints) const
 
std::unique_ptr< MultiPointcreateMultiPoint (std::vector< std::unique_ptr< Geometry > > &&newPoints) const
 
MultiPointcreateMultiPoint (const std::vector< const Geometry * > &fromPoints) const
 Construct a MultiPoint with a deep-copy of given arguments.
 
MultiPointcreateMultiPoint (const CoordinateSequence &fromCoords) const
 Construct a MultiPoint containing a Point geometry for each Coordinate in the given list.
 
MultiPointcreateMultiPoint (const std::vector< Coordinate > &fromCoords) const
 Construct a MultiPoint containing a Point geometry for each Coordinate in the given vector.
 
std::unique_ptr< PolygoncreatePolygon (std::size_t coordinateDimension=2) const
 Construct an EMPTY Polygon.
 
PolygoncreatePolygon (LinearRing *shell, std::vector< LinearRing * > *holes) const
 Construct a Polygon taking ownership of given arguments.
 
std::unique_ptr< PolygoncreatePolygon (std::unique_ptr< LinearRing > &&shell) const
 
std::unique_ptr< PolygoncreatePolygon (std::unique_ptr< LinearRing > &&shell, std::vector< std::unique_ptr< LinearRing > > &&holes) const
 
std::unique_ptr< PolygoncreatePolygon (std::vector< Coordinate > &&coords) const
 Construct a Polygon from a Coordinate vector, taking ownership of the vector.
 
PolygoncreatePolygon (const LinearRing &shell, const std::vector< LinearRing * > &holes) const
 Construct a Polygon with a deep-copy of given arguments.
 
std::unique_ptr< LineStringcreateLineString (std::size_t coordinateDimension=2) const
 Construct an EMPTY LineString.
 
std::unique_ptr< LineStringcreateLineString (const LineString &ls) const
 Copy a LineString.
 
LineStringcreateLineString (CoordinateSequence *coordinates) const
 Construct a LineString taking ownership of given argument.
 
std::unique_ptr< LineStringcreateLineString (std::unique_ptr< CoordinateSequence > &&coordinates) const
 
std::unique_ptr< LineStringcreateLineString (std::vector< Coordinate > &&coordinates) const
 
LineStringcreateLineString (const CoordinateSequence &coordinates) const
 Construct a LineString with a deep-copy of given argument.
 
std::unique_ptr< GeometrycreateEmpty (int dimension) const
 
GeometrybuildGeometry (std::vector< Geometry * > *geoms) const
 
std::unique_ptr< GeometrybuildGeometry (std::vector< std::unique_ptr< Geometry > > &&geoms) const
 
std::unique_ptr< GeometrybuildGeometry (std::vector< std::unique_ptr< Point > > &&geoms) const
 
std::unique_ptr< GeometrybuildGeometry (std::vector< std::unique_ptr< LineString > > &&geoms) const
 
std::unique_ptr< GeometrybuildGeometry (std::vector< std::unique_ptr< Polygon > > &&geoms) const
 
template<class T >
std::unique_ptr< GeometrybuildGeometry (T from, T toofar) const
 See buildGeometry(std::vector<Geometry *>&) for semantics. More...
 
GeometrybuildGeometry (const std::vector< const Geometry * > &geoms) const
 This function does the same thing of the omonimouse function taking vector pointer instead of reference. More...
 
int getSRID () const
 
const CoordinateSequenceFactorygetCoordinateSequenceFactory () const
 Returns the CoordinateSequenceFactory associated with this GeometryFactory.
 
GeometrycreateGeometry (const Geometry *g) const
 Returns a clone of given Geometry.
 
void destroyGeometry (Geometry *g) const
 Destroy a Geometry, or release it.
 
void destroy ()
 

Static Public Member Functions

static GeometryFactory::Ptr create ()
 Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial-reference ID of 0.
 
static GeometryFactory::Ptr create (const PrecisionModel *pm, int newSRID, CoordinateSequenceFactory *nCoordinateSequenceFactory)
 Constructs a GeometryFactory that generates Geometries having the given PrecisionModel, spatial-reference ID, and CoordinateSequence implementation. More...
 
static GeometryFactory::Ptr create (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.
 
static GeometryFactory::Ptr create (const PrecisionModel *pm)
 Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and the default CoordinateSequence implementation. More...
 
static GeometryFactory::Ptr create (const PrecisionModel *pm, int newSRID)
 Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and spatial-reference ID, and the default CoordinateSequence implementation. More...
 
static GeometryFactory::Ptr create (const GeometryFactory &gf)
 Copy constructor. More...
 
static const GeometryFactorygetDefaultInstance ()
 Return a pointer to the default GeometryFactory. This is a global shared object instantiated using default constructor.
 

Protected 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. More...
 
 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. More...
 
 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. More...
 
 GeometryFactory (const GeometryFactory &gf)
 Copy constructor. More...
 
virtual ~GeometryFactory ()
 Destructor.
 

Friends

class Geometry
 

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

◆ GeometryFactory() [1/4]

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

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

◆ GeometryFactory() [2/4]

geos::geom::GeometryFactory::GeometryFactory ( const PrecisionModel pm)
protected

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

Parameters
pmthe PrecisionModel to use

◆ GeometryFactory() [3/4]

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

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

Parameters
pmthe PrecisionModel to use, will be copied internally
newSRIDthe SRID to use

◆ GeometryFactory() [4/4]

geos::geom::GeometryFactory::GeometryFactory ( const GeometryFactory gf)
protected

Copy constructor.

Parameters
gfthe GeometryFactory to clone from

Member Function Documentation

◆ buildGeometry() [1/3]

Geometry * geos::geom::GeometryFactory::buildGeometry ( const std::vector< const 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.

◆ buildGeometry() [2/3]

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

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

For example:

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
geomsthe Geometrys 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

◆ buildGeometry() [3/3]

template<class T >
std::unique_ptr< Geometry > geos::geom::GeometryFactory::buildGeometry ( from,
toofar 
) const
inline

See buildGeometry(std::vector<Geometry *>&) for semantics.

Will clone the geometries accessible trough the iterator.

Template Parameters
Tan iterator yielding something which casts to const Geometry*
Parameters
fromstart iterator
toofarend iterator

References geos::geom::Dimension::A, geos::geom::Dimension::L, and geos::geom::Dimension::P.

◆ create() [1/4]

static GeometryFactory::Ptr geos::geom::GeometryFactory::create ( const GeometryFactory gf)
static

Copy constructor.

Parameters
gfthe GeometryFactory to clone from

◆ create() [2/4]

static GeometryFactory::Ptr geos::geom::GeometryFactory::create ( const PrecisionModel pm)
static

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

Parameters
pmthe PrecisionModel to use

◆ create() [3/4]

static GeometryFactory::Ptr geos::geom::GeometryFactory::create ( const PrecisionModel pm,
int  newSRID 
)
static

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

Parameters
pmthe PrecisionModel to use, will be copied internally
newSRIDthe SRID to use

◆ create() [4/4]

static GeometryFactory::Ptr geos::geom::GeometryFactory::create ( const PrecisionModel pm,
int  newSRID,
CoordinateSequenceFactory nCoordinateSequenceFactory 
)
static

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

◆ createEmpty()

std::unique_ptr< Geometry > geos::geom::GeometryFactory::createEmpty ( int  dimension) const

Creates an empty atomic geometry of the given dimension. If passed a dimension of -1 will create an empty GeometryCollection.

Parameters
dimensionthe required dimension (-1, 0, 1 or 2)
Returns
an empty atomic geometry of given dimension

◆ destroy()

void geos::geom::GeometryFactory::destroy ( )

Request that the instance is deleted.

It will really be deleted only after last child Geometry is deleted. Do not use the instance anymore after calling this function (unless you're a live child!).

◆ toGeometry()

std::unique_ptr< 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: