20 #ifndef GEOS_GEOM_GEOMETRYFACTORY_H
21 #define GEOS_GEOM_GEOMETRYFACTORY_H
23 #include <geos/geom/Geometry.h>
24 #include <geos/geom/GeometryCollection.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/export.h>
30 #include <geos/inline.h>
31 #include <geos/util.h>
36 #include <geos/util/IllegalArgumentException.h>
40 class CoordinateSequenceFactory;
42 class CoordinateSequence;
45 class GeometryCollection;
48 class MultiLineString;
71 struct GeometryFactoryDeleter {
81 using Ptr = std::unique_ptr<GeometryFactory, GeometryFactoryDeleter>;
88 static GeometryFactory::Ptr
create();
186 std::vector<Geometry*>* newGeoms)
const;
188 std::unique_ptr<GeometryCollection> createGeometryCollection(
189 std::vector<std::unique_ptr<Geometry>> && newGeoms)
const;
193 const std::vector<const Geometry*>& newGeoms)
const;
200 std::vector<Geometry*>* newLines)
const;
204 const std::vector<const Geometry*>& fromLines)
const;
206 std::unique_ptr<MultiLineString> createMultiLineString(
207 std::vector<std::unique_ptr<LineString>> && fromLines)
const;
209 std::unique_ptr<MultiLineString> createMultiLineString(
210 std::vector<std::unique_ptr<Geometry>> && fromLines)
const;
220 const std::vector<const Geometry*>& fromPolys)
const;
222 std::unique_ptr<MultiPolygon> createMultiPolygon(
223 std::vector<std::unique_ptr<Polygon>> && fromPolys)
const;
225 std::unique_ptr<MultiPolygon> createMultiPolygon(
226 std::vector<std::unique_ptr<Geometry>> && fromPolys)
const;
234 std::unique_ptr<LinearRing> createLinearRing(
235 std::unique_ptr<CoordinateSequence> && newCoords)
const;
247 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Point>> && newPoints)
const;
249 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Geometry>> && newPoints)
const;
253 const std::vector<const Geometry*>& fromPoints)
const;
265 const std::vector<Coordinate>& fromCoords)
const;
272 std::vector<LinearRing*>* holes)
const;
274 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell)
const;
276 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell,
277 std::vector<std::unique_ptr<LinearRing>> && holes)
const;
281 const std::vector<LinearRing*>& holes)
const;
292 std::unique_ptr<LineString> createLineString(
293 std::unique_ptr<CoordinateSequence> && coordinates)
const;
331 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Geometry>> && geoms)
const;
342 std::unique_ptr<Geometry>
345 bool isHeterogeneous =
false;
348 for(T i = from; i != toofar; ++i) {
352 geomClass = g->getSortIndex();
354 else if(geomClass != g->getSortIndex()) {
355 isHeterogeneous =
true;
361 return std::unique_ptr<Geometry>(createGeometryCollection());
366 return (*from)->clone();
375 std::vector<std::unique_ptr<Geometry>> fromGeoms;
376 for(T i = from; i != toofar; ++i) {
377 fromGeoms.push_back((*i)->clone());
381 if(isHeterogeneous) {
382 return createGeometryCollection(std::move(fromGeoms));
386 switch((*from)->getDimension()) {
387 case Dimension::A:
return createMultiPolygon(std::move(fromGeoms));
388 case Dimension::L:
return createMultiLineString(std::move(fromGeoms));
389 case Dimension::P:
return createMultiPoint(std::move(fromGeoms));
494 mutable int _refCount;
500 void dropRef()
const;
508 # include "geos/geom/GeometryFactory.inl"
511 #endif // ndef GEOS_GEOM_GEOMETRYFACTORY_H
GeometryFactory(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.
Geometry * buildGeometry(std::vector< Geometry * > *geoms) const
Definition: MultiPoint.h:53
@ A
Dimension value of a surface (2).
Definition: Dimension.h:96
Polygon * createPolygon(LinearRing *shell, std::vector< LinearRing * > *holes) const
Construct a Polygon taking ownership of given arguments.
Geometry * createGeometry(const Geometry *g) const
Returns a clone of given Geometry.
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
GeometryCollection * createGeometryCollection(std::vector< Geometry * > *newGeoms) const
Construct a GeometryCollection 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...
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition: LinearRing.h:54
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
std::unique_ptr< LineString > createLineString(const LineString &ls) const
Copy a LineString.
std::unique_ptr< LinearRing > createLinearRing() const
Construct an EMPTY LinearRing.
std::unique_ptr< Geometry > toGeometry(const Envelope *envelope) const
Converts an Envelope to a Geometry.
std::unique_ptr< MultiPolygon > createMultiPolygon() const
Construct an EMPTY MultiPolygon.
MultiPolygon * createMultiPolygon(std::vector< Geometry * > *newPolys) const
Construct a MultiPolygon 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.
MultiPoint * createMultiPoint(const CoordinateSequence &fromCoords) const
Construct a MultiPoint containing a Point geometry for each Coordinate in the given list.
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,...
static GeometryFactory::Ptr create(const GeometryFactory &gf)
Copy constructor.
std::unique_ptr< Point > createPoint() const
Creates an EMPTY Point.
std::unique_ptr< Geometry > createEmptyGeometry() const
Construct the EMPTY Geometry.
A factory to create concrete instances of CoordinateSequences.
Definition: CoordinateSequenceFactory.h:48
Models a collection of LineStrings.
Definition: MultiLineString.h:51
Point * createPoint(const CoordinateSequence &coordinates) const
Creates a Point with a deep-copy of the given CoordinateSequence.
GeometryFactory(const PrecisionModel *pm)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and the defaul...
Indicates one or more illegal arguments.
Definition: IllegalArgumentException.h:60
Represents a linear polygon, which may include holes.
Definition: Polygon.h:64
MultiPoint * createMultiPoint(std::vector< Geometry * > *newPoints) const
Construct a MultiPoint taking ownership of given arguments.
MultiPoint * createMultiPoint(const std::vector< Coordinate > &fromCoords) const
Construct a MultiPoint containing a Point geometry for each Coordinate in the given vector.
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:84
virtual ~GeometryFactory()
Destructor.
GeometryFactory(const PrecisionModel *pm, int newSRID)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and spatial-re...
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
MultiLineString * createMultiLineString(std::vector< Geometry * > *newLines) const
Construct a MultiLineString taking ownership of given arguments.
@ L
Dimension value of a curve (1).
Definition: Dimension.h:93
std::unique_ptr< MultiPoint > createMultiPoint() const
Constructs an EMPTY MultiPoint.
std::unique_ptr< LineString > createLineString() const
Construct an EMPTY LineString.
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:55
LineString * createLineString(const CoordinateSequence &coordinates) const
Construct a LineString with a deep-copy of given argument.
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
static GeometryFactory::Ptr create(CoordinateSequenceFactory *nCoordinateSequenceFactory)
Constructs a GeometryFactory that generates Geometries having the given CoordinateSequence implementa...
Point * createPoint(CoordinateSequence *coordinates) const
Creates a Point taking ownership of the given CoordinateSequence.
void destroy()
Request that the instance is deleted.
LineString * createLineString(CoordinateSequence *coordinates) const
Construct a LineString taking ownership of given argument.
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...
Point * createPoint(const Coordinate &coordinate) const
Creates a Point using the given Coordinate.
LinearRing * createLinearRing(const CoordinateSequence &coordinates) const
Construct a LinearRing with a deep-copy of given arguments.
GeometryFactory()
Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial...
MultiPoint * createMultiPoint(const std::vector< const Geometry * > &fromPoints) const
Construct a MultiPoint with a deep-copy of given arguments.
@ P
Dimension value of a point (0).
Definition: Dimension.h:90
void destroyGeometry(Geometry *g) const
Destroy a Geometry, or release it.
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:90
std::unique_ptr< GeometryCollection > createGeometryCollection() const
Construct an EMPTY GeometryCollection.
std::unique_ptr< Geometry > buildGeometry(T from, T toofar) const
See buildGeometry(std::vector<Geometry *>&) for semantics.
Definition: GeometryFactory.h:343
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
GeometryFactory(const GeometryFactory &gf)
Copy constructor.
Models a collection of Polygons.
Definition: MultiPolygon.h:59
static const GeometryFactory * getDefaultInstance()
Return a pointer to the default GeometryFactory. This is a global shared object instantiated using de...
std::unique_ptr< Polygon > createPolygon() const
Construct an EMPTY Polygon.
MultiLineString * createMultiLineString(const std::vector< const Geometry * > &fromLines) const
Construct a MultiLineString with a deep-copy of given arguments.
const CoordinateSequenceFactory * getCoordinateSequenceFactory() const
Returns the CoordinateSequenceFactory associated with this GeometryFactory.
const PrecisionModel * getPrecisionModel() const
Returns the PrecisionModel that Geometries created by this factory will be associated with.
GeometryCollection * createGeometryCollection(const std::vector< const Geometry * > &newGeoms) const
Constructs a GeometryCollection with a deep-copy of args.
Definition: LineString.h:68
MultiPolygon * createMultiPolygon(const std::vector< const Geometry * > &fromPolys) const
Construct a MultiPolygon with a deep-copy of given arguments.
GeometryFactory(CoordinateSequenceFactory *nCoordinateSequenceFactory)
Constructs a GeometryFactory that generates Geometries having the given CoordinateSequence implementa...
static GeometryFactory::Ptr create()
Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial...
std::unique_ptr< MultiLineString > createMultiLineString() const
Construct an EMPTY MultiLineString.