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();
102 static GeometryFactory::Ptr create(
const PrecisionModel* pm,
int newSRID,
132 static GeometryFactory::Ptr create(
const PrecisionModel* pm,
int newSRID);
148 getDefaultInstance();
159 std::unique_ptr<Geometry> toGeometry(
const Envelope* envelope)
const;
167 std::unique_ptr<Point> createPoint(std::size_t coordinateDimension = 2)
const;
179 std::unique_ptr<GeometryCollection> createGeometryCollection()
const;
182 std::unique_ptr<Geometry> createEmptyGeometry()
const;
186 std::vector<Geometry*>* newGeoms)
const;
189 std::unique_ptr<GeometryCollection> createGeometryCollection(
190 std::vector<std::unique_ptr<T>> && newGeoms)
const {
192 return std::unique_ptr<GeometryCollection>(
new GeometryCollection(Geometry::toGeometryArray(std::move(newGeoms)), *
this));
197 const std::vector<const Geometry*>& newGeoms)
const;
200 std::unique_ptr<MultiLineString> createMultiLineString()
const;
204 std::vector<Geometry*>* newLines)
const;
208 const std::vector<const Geometry*>& fromLines)
const;
210 std::unique_ptr<MultiLineString> createMultiLineString(
211 std::vector<std::unique_ptr<LineString>> && fromLines)
const;
213 std::unique_ptr<MultiLineString> createMultiLineString(
214 std::vector<std::unique_ptr<Geometry>> && fromLines)
const;
217 std::unique_ptr<MultiPolygon> createMultiPolygon()
const;
220 MultiPolygon* createMultiPolygon(std::vector<Geometry*>* newPolys)
const;
224 const std::vector<const Geometry*>& fromPolys)
const;
226 std::unique_ptr<MultiPolygon> createMultiPolygon(
227 std::vector<std::unique_ptr<Polygon>> && fromPolys)
const;
229 std::unique_ptr<MultiPolygon> createMultiPolygon(
230 std::vector<std::unique_ptr<Geometry>> && fromPolys)
const;
233 std::unique_ptr<LinearRing> createLinearRing()
const;
238 std::unique_ptr<LinearRing> createLinearRing(
239 std::unique_ptr<CoordinateSequence> && newCoords)
const;
246 std::unique_ptr<MultiPoint> createMultiPoint()
const;
249 MultiPoint* createMultiPoint(std::vector<Geometry*>* newPoints)
const;
251 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Point>> && newPoints)
const;
253 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Geometry>> && newPoints)
const;
257 const std::vector<const Geometry*>& fromPoints)
const;
269 const std::vector<Coordinate>& fromCoords)
const;
272 std::unique_ptr<Polygon> createPolygon(std::size_t coordinateDimension = 2)
const;
276 std::vector<LinearRing*>* holes)
const;
278 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell)
const;
280 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell,
281 std::vector<std::unique_ptr<LinearRing>> && holes)
const;
284 std::unique_ptr<Polygon> createPolygon(std::vector<Coordinate> && coords)
const;
288 const std::vector<LinearRing*>& holes)
const;
291 std::unique_ptr<LineString> createLineString(std::size_t coordinateDimension = 2)
const;
294 std::unique_ptr<LineString> createLineString(
const LineString& ls)
const;
299 std::unique_ptr<LineString> createLineString(
300 std::unique_ptr<CoordinateSequence> && coordinates)
const;
313 std::unique_ptr<Geometry> createEmpty(
int dimension)
const;
345 Geometry* buildGeometry(std::vector<Geometry*>* geoms)
const;
347 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Geometry>> && geoms)
const;
349 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Point>> && geoms)
const;
351 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<LineString>> && geoms)
const;
353 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Polygon>> && geoms)
const;
364 std::unique_ptr<Geometry>
367 bool isHeterogeneous =
false;
368 std::size_t count = 0;
370 for(T i = from; i != toofar; ++i) {
374 geomClass = g->getSortIndex();
376 else if(geomClass != g->getSortIndex()) {
377 isHeterogeneous =
true;
383 return std::unique_ptr<Geometry>(createGeometryCollection());
388 return (*from)->clone();
397 std::vector<std::unique_ptr<Geometry>> fromGeoms;
398 for(T i = from; i != toofar; ++i) {
399 fromGeoms.push_back((*i)->clone());
403 if(isHeterogeneous) {
404 return createGeometryCollection(std::move(fromGeoms));
408 switch((*from)->getDimension()) {
409 case Dimension::A:
return createMultiPolygon(std::move(fromGeoms));
410 case Dimension::L:
return createMultiLineString(std::move(fromGeoms));
411 case Dimension::P:
return createMultiPoint(std::move(fromGeoms));
424 Geometry* buildGeometry(
const std::vector<const Geometry*>& geoms)
const;
437 void destroyGeometry(
Geometry* g)
const;
516 mutable int _refCount;
522 void dropRef()
const;
530 # include "geos/geom/GeometryFactory.inl" 533 #endif // ndef GEOS_GEOM_GEOMETRYFACTORY_H An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Definition: MultiPolygon.h:59
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:188
Indicates one or more illegal arguments.
Definition: IllegalArgumentException.h:34
Definition: LineString.h:68
Represents a linear polygon, which may include holes.
Definition: Polygon.h:64
Dimension value of a curve (1).
Definition: Dimension.h:45
Dimension value of a surface (2).
Definition: Dimension.h:48
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:55
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26
Definition: MultiPoint.h:54
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple...
Definition: LinearRing.h:57
Dimension value of a point (0).
Definition: Dimension.h:42
A factory to create concrete instances of CoordinateSequences.
Definition: CoordinateSequenceFactory.h:48
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Models a collection of LineStrings.
Definition: MultiLineString.h:51
std::unique_ptr< Geometry > buildGeometry(T from, T toofar) const
See buildGeometry(std::vector<Geometry *>&) for semantics.
Definition: GeometryFactory.h:365