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;
75 unique_ptr(
const unique_ptr& o): _f(o.release()) {};
79 unique_ptr& operator=(
const unique_ptr& o) {
86 unique_ptr(): _f(0) {}
88 ~unique_ptr() { reset(0); }
96 static GeometryFactory::unique_ptr create();
110 static GeometryFactory::unique_ptr create(
const PrecisionModel *pm,
int newSRID,
129 static GeometryFactory::unique_ptr create(
const PrecisionModel *pm);
140 static GeometryFactory::unique_ptr create(
const PrecisionModel* pm,
int newSRID);
156 getDefaultInstance();
175 Point* createPoint()
const;
190 Geometry* createEmptyGeometry()
const;
194 std::vector<Geometry *> *newGeoms)
const;
198 const std::vector<Geometry *> &newGeoms)
const;
205 std::vector<Geometry *> *newLines)
const;
209 const std::vector<Geometry *> &fromLines)
const;
215 MultiPolygon* createMultiPolygon(std::vector<Geometry *> *newPolys)
const;
219 const std::vector<Geometry *> &fromPolys)
const;
227 std::auto_ptr<Geometry> createLinearRing(
228 std::auto_ptr<CoordinateSequence> newCoords)
const;
238 MultiPoint* createMultiPoint(std::vector<Geometry *> *newPoints)
const;
242 const std::vector<Geometry *> &fromPoints)
const;
254 const std::vector<Coordinate> &fromCoords)
const;
257 Polygon* createPolygon()
const;
261 std::vector<Geometry *> *holes)
const;
265 const std::vector<Geometry *> &holes)
const;
271 std::auto_ptr<LineString> createLineString(
const LineString& ls)
const;
276 std::auto_ptr<Geometry> createLineString(
277 std::auto_ptr<CoordinateSequence> coordinates)
const;
314 Geometry* buildGeometry(std::vector<Geometry *> *geoms)
const;
327 bool isHeterogeneous =
false;
330 for (T i=from; i != toofar; ++i)
334 if ( geomClass < 0 ) {
335 geomClass = g->getClassSortIndex();
337 else if ( geomClass != g->getClassSortIndex() ) {
338 isHeterogeneous =
true;
344 return std::auto_ptr<Geometry>( createGeometryCollection() );
349 return std::auto_ptr<Geometry>( (*from)->clone() );
358 std::vector<Geometry*> fromGeoms;
359 for (T i=from; i != toofar; ++i) {
361 fromGeoms.push_back(
const_cast<Geometry*
>(g));
366 if ( isHeterogeneous ) {
367 return std::auto_ptr<Geometry>( createGeometryCollection(fromGeoms) );
371 if (
dynamic_cast<const Polygon*
>(*from) ) {
372 return std::auto_ptr<Geometry>( createMultiPolygon(fromGeoms) );
373 }
else if (
dynamic_cast<const LineString*
>(*from) ) {
374 return std::auto_ptr<Geometry>( createMultiLineString(fromGeoms) );
375 }
else if (
dynamic_cast<const Point*
>(*from) ) {
376 return std::auto_ptr<Geometry>( createMultiPoint(fromGeoms) );
380 return std::auto_ptr<Geometry>();
390 Geometry* buildGeometry(
const std::vector<Geometry *> &geoms)
const;
403 void destroyGeometry(
Geometry *g)
const;
482 mutable int _refCount;
488 void dropRef()
const;
496 # include "geos/geom/GeometryFactory.inl"
499 #endif // ndef GEOS_GEOM_GEOMETRYFACTORY_H