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