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/export.h>
29 #include <geos/inline.h>
37 class CoordinateSequenceFactory;
39 class CoordinateSequence;
42 class GeometryCollection;
45 class MultiLineString;
70 struct GeometryFactoryDeleter
80 using Ptr = std::unique_ptr<GeometryFactory, GeometryFactoryDeleter>;
87 static GeometryFactory::Ptr
create();
185 std::vector<Geometry *> *newGeoms)
const;
189 const std::vector<Geometry *> &newGeoms)
const;
196 std::vector<Geometry *> *newLines)
const;
200 const std::vector<Geometry *> &fromLines)
const;
210 const std::vector<Geometry *> &fromPolys)
const;
218 std::unique_ptr<Geometry> createLinearRing(
219 std::unique_ptr<CoordinateSequence> newCoords)
const;
233 const std::vector<Geometry *> &fromPoints)
const;
245 const std::vector<Coordinate> &fromCoords)
const;
252 std::vector<Geometry *> *holes)
const;
256 const std::vector<Geometry *> &holes)
const;
267 std::unique_ptr<Geometry> createLineString(
268 std::unique_ptr<CoordinateSequence> coordinates)
const;
318 bool isHeterogeneous =
false;
321 for (T i=from; i != toofar; ++i)
325 if ( geomClass < 0 ) {
326 geomClass = g->getClassSortIndex();
328 else if ( geomClass != g->getClassSortIndex() ) {
329 isHeterogeneous =
true;
335 return std::unique_ptr<Geometry>( createGeometryCollection() );
340 return std::unique_ptr<Geometry>( (*from)->clone() );
349 std::vector<Geometry*> fromGeoms;
350 for (T i=from; i != toofar; ++i) {
352 fromGeoms.push_back(
const_cast<Geometry*
>(g));
357 if ( isHeterogeneous ) {
358 return std::unique_ptr<Geometry>( createGeometryCollection(fromGeoms) );
362 if (
dynamic_cast<const Polygon*
>(*from) ) {
363 return std::unique_ptr<Geometry>( createMultiPolygon(fromGeoms) );
364 }
else if (
dynamic_cast<const LineString*
>(*from) ) {
365 return std::unique_ptr<Geometry>( createMultiLineString(fromGeoms) );
366 }
else if (
dynamic_cast<const Point*
>(*from) ) {
367 return std::unique_ptr<Geometry>( createMultiPoint(fromGeoms) );
371 return std::unique_ptr<Geometry>();
473 mutable int _refCount;
479 void dropRef()
const;
487 # include "geos/geom/GeometryFactory.inl"
490 #endif // ndef GEOS_GEOM_GEOMETRYFACTORY_H
GeometryFactory(const PrecisionModel *pm, int newSRID, CoordinateSequenceFactory *nCoordinateSequenceFactory)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel,...
MultiPolygon * createMultiPolygon() const
Construct an EMPTY MultiPolygon.
LinearRing * createLinearRing(CoordinateSequence *newCoords) const
Construct a LinearRing taking ownership of given arguments.
GeometryCollection * createGeometryCollection() const
Construct an EMPTY GeometryCollection.
Geometry * buildGeometry(std::vector< Geometry * > *geoms) const
Definition: MultiPoint.h:56
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.
Definition: LinearRing.h:57
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
std::unique_ptr< LineString > createLineString(const LineString &ls) const
Copy a LineString.
MultiPolygon * createMultiPolygon(std::vector< Geometry * > *newPolys) const
Construct a MultiPolygon taking ownership of given arguments.
MultiPoint * createMultiPoint(const CoordinateSequence &fromCoords) const
Construct a MultiPoint containing a Point geometry for each Coordinate in the given list.
MultiPoint * createMultiPoint() const
Constructs an EMPTY MultiPoint.
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.
Polygon * createPolygon() const
Construct an EMPTY Polygon.
Polygon * createPolygon(const LinearRing &shell, const std::vector< Geometry * > &holes) const
Construct a Polygon with a deep-copy of given arguments.
A factory to create concrete instances of CoordinateSequences.
Definition: CoordinateSequenceFactory.h:47
Models a collection of (}s.
Definition: MultiLineString.h:51
Point * createPoint(const CoordinateSequence &coordinates) const
Creates a Point with a deep-copy of the given CoordinateSequence.
LineString * createLineString() const
Construct an EMPTY LineString.
GeometryFactory(const PrecisionModel *pm)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and the defaul...
Represents a linear polygon, which may include holes.
Definition: Polygon.h:67
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:60
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:177
MultiLineString * createMultiLineString(std::vector< Geometry * > *newLines) const
Construct a MultiLineString taking ownership of given arguments.
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:56
LineString * createLineString(const CoordinateSequence &coordinates) const
Construct a LineString with a deep-copy of given argument.
MultiLineString * createMultiLineString(const std::vector< Geometry * > &fromLines) const
Construct a MultiLineString with a deep-copy of given arguments.
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59
GeometryCollection * createGeometryCollection(const std::vector< Geometry * > &newGeoms) const
Constructs a GeometryCollection with a deep-copy of args.
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.
LinearRing * createLinearRing() const
Construct an EMPTY LinearRing.
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.
MultiLineString * createMultiLineString() const
Construct an EMPTY MultiLineString.
GeometryFactory()
Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial...
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:59
Polygon * createPolygon(LinearRing *shell, std::vector< Geometry * > *holes) const
Construct a Polygon taking ownership of given arguments.
Point * createPoint() const
Creates an EMPTY Point.
std::unique_ptr< Geometry > buildGeometry(T from, T toofar) const
See buildGeometry(std::vector<Geometry *>&) for semantics.
Definition: GeometryFactory.h:316
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
GeometryFactory(const GeometryFactory &gf)
Copy constructor.
Geometry * buildGeometry(const std::vector< Geometry * > &geoms) const
This function does the same thing of the omonimouse function taking vector pointer instead of referen...
Models a collection of Polygons.
Definition: MultiPolygon.h:61
static const GeometryFactory * getDefaultInstance()
Return a pointer to the default GeometryFactory. This is a global shared object instantiated using de...
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.
Geometry * createEmptyGeometry() const
Construct the EMPTY Geometry.
Definition: LineString.h:70
Geometry * toGeometry(const Envelope *envelope) const
Converts an Envelope to a Geometry.
MultiPolygon * createMultiPolygon(const std::vector< 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...
MultiPoint * createMultiPoint(const std::vector< Geometry * > &fromPoints) const
Construct a MultiPoint with a deep-copy of given arguments.