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();
101 static GeometryFactory::Ptr create(
const PrecisionModel *pm,
int newSRID,
131 static GeometryFactory::Ptr create(
const PrecisionModel* pm,
int newSRID);
147 getDefaultInstance();
166 Point* createPoint()
const;
181 Geometry* createEmptyGeometry()
const;
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;
206 MultiPolygon* createMultiPolygon(std::vector<Geometry *> *newPolys)
const;
210 const std::vector<Geometry *> &fromPolys)
const;
218 std::unique_ptr<Geometry> createLinearRing(
219 std::unique_ptr<CoordinateSequence> newCoords)
const;
229 MultiPoint* createMultiPoint(std::vector<Geometry *> *newPoints)
const;
233 const std::vector<Geometry *> &fromPoints)
const;
245 const std::vector<Coordinate> &fromCoords)
const;
248 Polygon* createPolygon()
const;
252 std::vector<Geometry *> *holes)
const;
256 const std::vector<Geometry *> &holes)
const;
262 std::unique_ptr<LineString> createLineString(
const LineString& ls)
const;
267 std::unique_ptr<Geometry> createLineString(
268 std::unique_ptr<CoordinateSequence> coordinates)
const;
305 Geometry* buildGeometry(std::vector<Geometry *> *geoms)
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>();
381 Geometry* buildGeometry(
const std::vector<Geometry *> &geoms)
const;
394 void destroyGeometry(
Geometry *g)
const;
473 mutable int _refCount;
479 void dropRef()
const;
487 # include "geos/geom/GeometryFactory.inl"
490 #endif // ndef GEOS_GEOM_GEOMETRYFACTORY_H
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:59
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Models a collection of Polygons.
Definition: MultiPolygon.h:60
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:177
Definition: LineString.h:70
Represents a linear polygon, which may include holes.
Definition: Polygon.h:66
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:56
void destroy()
Request that the instance is deleted.
Definition: MultiPoint.h:55
Models an OGC SFS LinearRing.
Definition: LinearRing.h:57
std::unique_ptr< Geometry > buildGeometry(T from, T toofar) const
See buildGeometry(std::vector<Geometry *>&) for semantics.
Definition: GeometryFactory.h:316
A factory to create concrete instances of CoordinateSequences.
Definition: CoordinateSequenceFactory.h:47
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59
Models a collection of (}s.
Definition: MultiLineString.h:51