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/geom/Polygon.h>
30#include <geos/util/IllegalArgumentException.h>
31#include <geos/export.h>
42class CoordinateSequence;
45class GeometryCollection;
73 struct GeometryFactoryDeleter {
83 using Ptr = std::unique_ptr<GeometryFactory, GeometryFactoryDeleter>;
90 static GeometryFactory::Ptr
create();
131 static std::unique_ptr<Point> createPointFromInternalCoord(
const Coordinate* coord,
145 return &precisionModel;
149 std::unique_ptr<Point>
createPoint(std::size_t coordinateDimension = 2)
const;
150 std::unique_ptr<Point> createPoint(
bool hasZ,
bool hasM)
const;
154 std::unique_ptr<Point> createPoint(
const CoordinateXY& coordinate)
const;
155 std::unique_ptr<Point> createPoint(
const CoordinateXYM& coordinate)
const;
156 std::unique_ptr<Point> createPoint(
const CoordinateXYZM& coordinate)
const;
159 std::unique_ptr<Point>
createPoint(std::unique_ptr<CoordinateSequence>&& coordinates)
const;
173 std::vector<std::unique_ptr<T>> && newGeoms)
const {
175 return std::unique_ptr<GeometryCollection>(
new GeometryCollection(Geometry::toGeometryArray(std::move(newGeoms)), *
this));
180 const std::vector<const Geometry*>& newGeoms)
const;
187 const std::vector<const Geometry*>& fromLines)
const;
191 std::vector<std::unique_ptr<LineString>> && fromLines)
const;
193 std::unique_ptr<MultiLineString> createMultiLineString(
194 std::vector<std::unique_ptr<Geometry>> && fromLines)
const;
201 std::vector<std::unique_ptr<Geometry>> && fromCurves)
const;
203 std::unique_ptr<MultiCurve> createMultiCurve(
204 std::vector<std::unique_ptr<Curve>> && fromCurves)
const;
211 const std::vector<const Geometry*>& fromPolys)
const;
215 std::vector<std::unique_ptr<Polygon>> && fromPolys)
const;
217 std::unique_ptr<MultiPolygon> createMultiPolygon(
218 std::vector<std::unique_ptr<Geometry>> && fromPolys)
const;
225 std::vector<std::unique_ptr<Geometry>> && from)
const;
227 std::unique_ptr<MultiSurface> createMultiSurface(
228 std::vector<std::unique_ptr<Surface>> && from)
const;
232 std::unique_ptr<LinearRing> createLinearRing(
bool hasZ,
bool hasM)
const;
236 std::unique_ptr<CoordinateSequence> && newCoords)
const;
246 std::unique_ptr<MultiPoint> createMultiPoint(
const T& fromCoords)
const
248 std::vector<std::unique_ptr<Geometry>> pts;
249 pts.reserve(fromCoords.size());
250 for (
const auto& c : fromCoords) {
251 pts.emplace_back(createPoint(c));
254 return createMultiPoint(std::move(pts));
258 std::unique_ptr<MultiPoint>
createMultiPoint(std::vector<std::unique_ptr<Point>> && newPoints)
const;
260 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Geometry>> && newPoints)
const;
264 const std::vector<const Geometry*>& fromPoints)
const;
273 std::unique_ptr<Polygon>
createPolygon(std::size_t coordinateDimension = 2)
const;
274 std::unique_ptr<Polygon> createPolygon(
bool hasZ,
bool hasM)
const;
277 std::unique_ptr<Polygon>
createPolygon(std::unique_ptr<LinearRing> && shell)
const;
279 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell,
280 std::vector<std::unique_ptr<LinearRing>> && holes)
const;
287 const std::vector<LinearRing*>& holes)
const;
296 std::unique_ptr<CurvePolygon> createCurvePolygon(std::unique_ptr<Curve>&& shell,
297 std::vector<std::unique_ptr<Curve>> && holes)
const;
301 std::unique_ptr<LineString> createLineString(
bool hasZ,
bool hasM)
const;
308 std::unique_ptr<CoordinateSequence> && coordinates)
const;
322 std::unique_ptr<CoordinateSequence> && coordinates)
const;
350 std::unique_ptr<Geometry> createMulti(std::unique_ptr<Geometry> && geom)
const;
382 std::unique_ptr<Geometry>
buildGeometry(std::vector<std::unique_ptr<Geometry>> && geoms)
const;
384 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Point>> && geoms)
const;
386 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<LineString>> && geoms)
const;
388 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Polygon>> && geoms)
const;
399 std::unique_ptr<Geometry>
402 bool isHeterogeneous =
false;
403 std::size_t count = 0;
405 for(T i = from; i != toofar; ++i) {
409 geomClass = g->getSortIndex();
411 else if(geomClass != g->getSortIndex()) {
412 isHeterogeneous =
true;
418 return std::unique_ptr<Geometry>(createGeometryCollection());
423 return (*from)->clone();
432 std::vector<std::unique_ptr<Geometry>> fromGeoms;
433 for(T i = from; i != toofar; ++i) {
434 fromGeoms.push_back((*i)->clone());
438 if(isHeterogeneous) {
439 return createGeometryCollection(std::move(fromGeoms));
443 switch((*from)->getDimension()) {
444 case Dimension::A:
return createMultiPolygon(std::move(fromGeoms));
445 case Dimension::L:
return createMultiLineString(std::move(fromGeoms));
446 case Dimension::P:
return createMultiPoint(std::move(fromGeoms));
459 std::unique_ptr<Geometry>
buildGeometry(
const std::vector<const Geometry*>& geoms)
const;
525 mutable int _refCount;
531 void dropRef()
const;
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
Represents a collection of heterogeneous Geometry objects.
Definition GeometryCollection.h:51
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
std::unique_ptr< MultiPolygon > createMultiPolygon(std::vector< std::unique_ptr< Polygon > > &&fromPolys) const
Construct a MultiPolygon taking ownership of given arguments.
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 > createGeometry(const Geometry *g) const
Returns a clone of given Geometry.
std::unique_ptr< Point > createPoint(const CoordinateSequence &coordinates) const
Creates a Point with a deep-copy of the given CoordinateSequence.
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...
std::unique_ptr< MultiPoint > createMultiPoint() const
Constructs an EMPTY MultiPoint.
std::unique_ptr< Point > createPoint(std::size_t coordinateDimension=2) const
Creates an EMPTY Point.
std::unique_ptr< MultiSurface > createMultiSurface(std::vector< std::unique_ptr< Geometry > > &&from) const
Construct a MultiSurface taking ownership of given arguments.
std::unique_ptr< CircularString > createCircularString(std::unique_ptr< CoordinateSequence > &&coordinates) const
Construct a CircularString taking ownership of given argument.
std::unique_ptr< MultiPolygon > createMultiPolygon() const
Construct an EMPTY MultiPolygon.
std::unique_ptr< LineString > createLineString(const CoordinateSequence &coordinates) const
Construct a LineString with a deep-copy of given argument.
std::unique_ptr< MultiSurface > createMultiSurface() const
Construct an EMPTY MultiSurface.
const PrecisionModel * getPrecisionModel() const
Returns the PrecisionModel that Geometries created by this factory will be associated with.
Definition GeometryFactory.h:143
std::unique_ptr< GeometryCollection > createGeometryCollection() const
Construct an EMPTY GeometryCollection.
std::unique_ptr< GeometryCollection > createGeometryCollection(const std::vector< const Geometry * > &newGeoms) const
Constructs a GeometryCollection with a deep-copy of args.
std::unique_ptr< LineString > createLineString(const LineString &ls) const
Copy a LineString.
std::unique_ptr< CircularString > createCircularString(const CoordinateSequence &coordinates) const
Construct a CircularString with a deep-copy of given argument.
std::unique_ptr< LineString > createLineString(std::size_t coordinateDimension=2) const
Construct an EMPTY LineString.
std::unique_ptr< LineString > createLineString(std::unique_ptr< CoordinateSequence > &&coordinates) const
Construct a LineString taking ownership of given argument.
std::unique_ptr< Geometry > createEmptyGeometry(GeometryTypeId type=GEOS_GEOMETRYCOLLECTION, bool hasZ=false, bool hasM=false) const
Construct the EMPTY Geometry.
std::unique_ptr< MultiLineString > createMultiLineString(const std::vector< const Geometry * > &fromLines) const
Construct a MultiLineString with a deep-copy of given arguments.
void destroyGeometry(Geometry *g) const
Destroy a Geometry, or release it.
std::unique_ptr< MultiPoint > createMultiPoint(const CoordinateSequence &fromCoords) const
Construct a MultiPoint containing a Point geometry for each Coordinate in the given list.
std::unique_ptr< CompoundCurve > createCompoundCurve(std::vector< std::unique_ptr< SimpleCurve > > &&) const
Construct a CompoundCurve taking ownership of given argument.
std::unique_ptr< MultiLineString > createMultiLineString(std::vector< std::unique_ptr< LineString > > &&fromLines) const
Construct a MultiLineString taking ownership of given arguments.
std::unique_ptr< MultiCurve > createMultiCurve() const
Construct an EMPTY MultiCurve.
std::unique_ptr< GeometryCollection > createGeometryCollection(std::vector< std::unique_ptr< T > > &&newGeoms) const
Construct a GeometryCollection taking ownership of given arguments.
Definition GeometryFactory.h:172
std::unique_ptr< MultiCurve > createMultiCurve(std::vector< std::unique_ptr< Geometry > > &&fromCurves) const
Construct a MultiCurve taking ownership of given arguments.
std::unique_ptr< LinearRing > createLinearRing(std::size_t coordinateDimension=2) const
Construct an EMPTY LinearRing.
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
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< CurvePolygon > createCurvePolygon(std::unique_ptr< Curve > &&shell) const
Construct a CurvePolygon taking ownership of given arguments.
std::unique_ptr< Point > createPoint(std::unique_ptr< CoordinateSequence > &&coordinates) const
Creates a Point taking ownership of the given CoordinateSequence.
std::unique_ptr< MultiPoint > createMultiPoint(const std::vector< const Geometry * > &fromPoints) const
Construct a MultiPoint with a deep-copy of given arguments.
std::unique_ptr< Point > createPoint(const Coordinate &coordinate) const
Creates a Point using the given Coordinate.
std::unique_ptr< Polygon > createPolygon(std::unique_ptr< LinearRing > &&shell) const
Construct a Polygon taking ownership of given arguments.
std::unique_ptr< Geometry > buildGeometry(std::vector< std::unique_ptr< Geometry > > &&geoms) const
static GeometryFactory::Ptr create(const GeometryFactory &gf)
Copy constructor.
std::unique_ptr< Polygon > createPolygon(CoordinateSequence &&coords) const
Construct a Polygon from a Coordinate vector, taking ownership of the vector.
std::unique_ptr< CompoundCurve > createCompoundCurve() const
Construct an EMPTY CompoundCurve.
std::unique_ptr< CircularString > createCircularString(const CircularString &ls) const
Copy a CircularString.
std::unique_ptr< 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...
std::unique_ptr< CurvePolygon > createCurvePolygon(bool hasZ, bool hasM) const
Construct an EMPTY CurvePolygon.
std::unique_ptr< Polygon > createPolygon(std::size_t coordinateDimension=2) const
Construct an EMPTY Polygon.
std::unique_ptr< CircularString > createCircularString(bool hasZ, bool hasM) const
Construct an EMPTY CircularString.
std::unique_ptr< LinearRing > createLinearRing(std::unique_ptr< CoordinateSequence > &&newCoords) const
Construct a LinearRing taking ownership of given arguments.
GeometryFactory(const GeometryFactory &gf)
Copy constructor.
GeometryFactory()
Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial...
static GeometryFactory::Ptr create(const PrecisionModel *pm, int newSRID)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and spatial-re...
std::unique_ptr< Geometry > createEmpty(GeometryTypeId typeId) const
std::unique_ptr< MultiPoint > createMultiPoint(std::vector< std::unique_ptr< Point > > &&newPoints) const
Construct a MultiPoint taking ownership of given arguments.
std::unique_ptr< LinearRing > createLinearRing(const CoordinateSequence &coordinates) const
Construct a LinearRing with a deep-copy of given arguments.
std::unique_ptr< MultiPolygon > createMultiPolygon(const std::vector< const Geometry * > &fromPolys) const
Construct a MultiPolygon 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:400
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Definition LineString.h:66
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
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:88
Indicates one or more illegal arguments.
Definition IllegalArgumentException.h:33
@ GEOS_GEOMETRYCOLLECTION
Definition geos_c.h:214
GeometryTypeId
Geometry types.
Definition Geometry.h:74
Basic namespace for all GEOS functionalities.
Definition geos.h:39