22#include <geos/geom/Geometry.h>
23#include <geos/geom/GeometryCollection.h>
24#include <geos/geom/GeometryFactory.h>
25#include <geos/geom/MultiPoint.h>
26#include <geos/geom/MultiLineString.h>
27#include <geos/geom/MultiPolygon.h>
28#include <geos/geom/PrecisionModel.h>
29#include <geos/util/IllegalArgumentException.h>
30#include <geos/export.h>
38class CoordinateSequenceFactory;
40class CoordinateSequence;
43class GeometryCollection;
69 struct GeometryFactoryDeleter {
79 using Ptr = std::unique_ptr<GeometryFactory, GeometryFactoryDeleter>;
86 static GeometryFactory::Ptr
create();
164 return &precisionModel;
168 std::unique_ptr<Point>
createPoint(std::size_t coordinateDimension = 2)
const;
187 std::vector<Geometry*>* newGeoms)
const;
190 std::unique_ptr<GeometryCollection> createGeometryCollection(
191 std::vector<std::unique_ptr<T>> && newGeoms)
const {
193 return std::unique_ptr<GeometryCollection>(
new GeometryCollection(Geometry::toGeometryArray(std::move(newGeoms)), *
this));
198 const std::vector<const Geometry*>& newGeoms)
const;
205 std::vector<Geometry*>* newLines)
const;
209 const std::vector<const Geometry*>& fromLines)
const;
211 std::unique_ptr<MultiLineString> createMultiLineString(
212 std::vector<std::unique_ptr<LineString>> && fromLines)
const;
214 std::unique_ptr<MultiLineString> createMultiLineString(
215 std::vector<std::unique_ptr<Geometry>> && fromLines)
const;
225 const std::vector<const Geometry*>& fromPolys)
const;
227 std::unique_ptr<MultiPolygon> createMultiPolygon(
228 std::vector<std::unique_ptr<Polygon>> && fromPolys)
const;
230 std::unique_ptr<MultiPolygon> createMultiPolygon(
231 std::vector<std::unique_ptr<Geometry>> && fromPolys)
const;
239 std::unique_ptr<LinearRing> createLinearRing(
240 std::unique_ptr<CoordinateSequence> && newCoords)
const;
242 std::unique_ptr<LinearRing> createLinearRing(
243 std::vector<Coordinate> && coordinates)
const;
255 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<Coordinate> && newPoints)
const;
257 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Point>> && newPoints)
const;
259 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Geometry>> && newPoints)
const;
263 const std::vector<const Geometry*>& fromPoints)
const;
275 const std::vector<Coordinate>& fromCoords)
const;
278 std::unique_ptr<Polygon>
createPolygon(std::size_t coordinateDimension = 2)
const;
282 std::vector<LinearRing*>* holes)
const;
284 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell)
const;
286 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell,
287 std::vector<std::unique_ptr<LinearRing>> && holes)
const;
290 std::unique_ptr<Polygon>
createPolygon(std::vector<Coordinate> && coords)
const;
294 const std::vector<LinearRing*>& holes)
const;
305 std::unique_ptr<LineString> createLineString(
306 std::unique_ptr<CoordinateSequence> && coordinates)
const;
308 std::unique_ptr<LineString> createLineString(
309 std::vector<Coordinate> && coordinates)
const;
356 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Geometry>> && geoms)
const;
358 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Point>> && geoms)
const;
360 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<LineString>> && geoms)
const;
362 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Polygon>> && geoms)
const;
373 std::unique_ptr<Geometry>
376 bool isHeterogeneous =
false;
377 std::size_t count = 0;
379 for(T i = from; i != toofar; ++i) {
383 geomClass = g->getSortIndex();
385 else if(geomClass != g->getSortIndex()) {
386 isHeterogeneous =
true;
392 return std::unique_ptr<Geometry>(createGeometryCollection());
397 return (*from)->clone();
406 std::vector<std::unique_ptr<Geometry>> fromGeoms;
407 for(T i = from; i != toofar; ++i) {
408 fromGeoms.push_back((*i)->clone());
412 if(isHeterogeneous) {
413 return createGeometryCollection(std::move(fromGeoms));
417 switch((*from)->getDimension()) {
418 case Dimension::A:
return createMultiPolygon(std::move(fromGeoms));
419 case Dimension::L:
return createMultiLineString(std::move(fromGeoms));
420 case Dimension::P:
return createMultiPoint(std::move(fromGeoms));
445 return coordinateListFactory;
531 mutable int _refCount;
537 void dropRef()
const;
A factory to create concrete instances of CoordinateSequences.
Definition: CoordinateSequenceFactory.h:44
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
@ A
Dimension value of a surface (2).
Definition: Dimension.h:46
@ L
Dimension value of a curve (1).
Definition: Dimension.h:43
@ P
Dimension value of a point (0).
Definition: Dimension.h:40
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:52
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
static GeometryFactory::Ptr create(const PrecisionModel *pm)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and the defaul...
static const GeometryFactory * getDefaultInstance()
Return a pointer to the default GeometryFactory. This is a global shared object instantiated using de...
std::unique_ptr< Geometry > createEmptyGeometry() const
Construct the EMPTY Geometry.
static GeometryFactory::Ptr create()
Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial...
GeometryFactory(const PrecisionModel *pm)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and the defaul...
Geometry * buildGeometry(std::vector< Geometry * > *geoms) const
std::unique_ptr< MultiPoint > createMultiPoint() const
Constructs an EMPTY MultiPoint.
Polygon * createPolygon(LinearRing *shell, std::vector< LinearRing * > *holes) const
Construct a Polygon taking ownership of given arguments.
GeometryCollection * createGeometryCollection(const std::vector< const Geometry * > &newGeoms) const
Constructs a GeometryCollection with a deep-copy of args.
std::unique_ptr< Point > createPoint(std::size_t coordinateDimension=2) const
Creates an EMPTY Point.
MultiPoint * createMultiPoint(std::vector< Geometry * > *newPoints) const
Construct a MultiPoint taking ownership of given arguments.
LineString * createLineString(const CoordinateSequence &coordinates) const
Construct a LineString with a deep-copy of given argument.
std::unique_ptr< MultiPolygon > createMultiPolygon() const
Construct an EMPTY MultiPolygon.
LineString * createLineString(CoordinateSequence *coordinates) const
Construct a LineString taking ownership of given argument.
Point * createPoint(const CoordinateSequence &coordinates) const
Creates a Point with a deep-copy of the given CoordinateSequence.
const PrecisionModel * getPrecisionModel() const
Returns the PrecisionModel that Geometries created by this factory will be associated with.
Definition: GeometryFactory.h:162
LinearRing * createLinearRing(const CoordinateSequence &coordinates) const
Construct a LinearRing with a deep-copy of given arguments.
std::unique_ptr< GeometryCollection > createGeometryCollection() const
Construct an EMPTY GeometryCollection.
MultiPoint * createMultiPoint(const std::vector< Coordinate > &fromCoords) const
Construct a MultiPoint containing a Point geometry for each Coordinate in the given vector.
std::unique_ptr< LinearRing > createLinearRing() const
Construct an EMPTY LinearRing.
std::unique_ptr< LineString > createLineString(const LineString &ls) const
Copy a LineString.
std::unique_ptr< LineString > createLineString(std::size_t coordinateDimension=2) const
Construct an EMPTY LineString.
GeometryFactory(CoordinateSequenceFactory *nCoordinateSequenceFactory)
Constructs a GeometryFactory that generates Geometries having the given CoordinateSequence implementa...
MultiPolygon * createMultiPolygon(const std::vector< const Geometry * > &fromPolys) const
Construct a MultiPolygon with a deep-copy of given arguments.
Point * createPoint(const Coordinate &coordinate) const
Creates a Point using the given Coordinate.
void destroyGeometry(Geometry *g) const
Destroy a Geometry, or release it.
static GeometryFactory::Ptr create(CoordinateSequenceFactory *nCoordinateSequenceFactory)
Constructs a GeometryFactory that generates Geometries having the given CoordinateSequence implementa...
Geometry * buildGeometry(const std::vector< const Geometry * > &geoms) const
This function does the same thing of the omonimouse function taking vector pointer instead of referen...
MultiPolygon * createMultiPolygon(std::vector< Geometry * > *newPolys) const
Construct a MultiPolygon taking ownership of given arguments.
GeometryFactory(const PrecisionModel *pm, int newSRID, CoordinateSequenceFactory *nCoordinateSequenceFactory)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel,...
Point * createPoint(CoordinateSequence *coordinates) const
Creates a Point taking ownership of the given CoordinateSequence.
GeometryCollection * createGeometryCollection(std::vector< Geometry * > *newGeoms) const
Construct a GeometryCollection taking ownership of given arguments.
Polygon * createPolygon(const LinearRing &shell, const std::vector< LinearRing * > &holes) const
Construct a Polygon with a deep-copy of given arguments.
std::unique_ptr< Geometry > createEmpty(int dimension) const
MultiPoint * createMultiPoint(const CoordinateSequence &fromCoords) const
Construct a MultiPoint containing a Point geometry for each Coordinate in the given list.
std::unique_ptr< MultiLineString > createMultiLineString() const
Construct an EMPTY MultiLineString.
GeometryFactory(const PrecisionModel *pm, int newSRID)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and spatial-re...
virtual ~GeometryFactory()
Destructor.
std::unique_ptr< Polygon > createPolygon(std::vector< Coordinate > &&coords) const
Construct a Polygon from a Coordinate vector, taking ownership of the vector.
static GeometryFactory::Ptr create(const GeometryFactory &gf)
Copy constructor.
Geometry * createGeometry(const Geometry *g) const
Returns a clone of given Geometry.
MultiLineString * createMultiLineString(std::vector< Geometry * > *newLines) const
Construct a MultiLineString taking ownership of given arguments.
std::unique_ptr< Polygon > createPolygon(std::size_t coordinateDimension=2) const
Construct an EMPTY Polygon.
const CoordinateSequenceFactory * getCoordinateSequenceFactory() const
Returns the CoordinateSequenceFactory associated with this GeometryFactory.
Definition: GeometryFactory.h:443
GeometryFactory(const GeometryFactory &gf)
Copy constructor.
GeometryFactory()
Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial...
MultiLineString * createMultiLineString(const std::vector< const Geometry * > &fromLines) const
Construct a MultiLineString with a deep-copy of given arguments.
static GeometryFactory::Ptr create(const PrecisionModel *pm, int newSRID)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and spatial-re...
static GeometryFactory::Ptr create(const PrecisionModel *pm, int newSRID, CoordinateSequenceFactory *nCoordinateSequenceFactory)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel,...
LinearRing * createLinearRing(CoordinateSequence *newCoords) const
Construct a LinearRing taking ownership of given arguments.
MultiPoint * createMultiPoint(const std::vector< const Geometry * > &fromPoints) const
Construct a MultiPoint with a deep-copy of given arguments.
std::unique_ptr< Geometry > toGeometry(const Envelope *envelope) const
std::unique_ptr< Geometry > buildGeometry(T from, T toofar) const
See buildGeometry(std::vector<Geometry *>&) for semantics.
Definition: GeometryFactory.h:374
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Definition: LineString.h:66
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition: LinearRing.h:55
Models a collection of LineStrings.
Definition: MultiLineString.h:50
Definition: MultiPoint.h:51
Definition: MultiPolygon.h:59
Represents a linear polygon, which may include holes.
Definition: Polygon.h:61
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:90
Indicates one or more illegal arguments.
Definition: IllegalArgumentException.h:33
Basic namespace for all GEOS functionalities.
Definition: geos.h:39