22 #include <geos/geom/Geometry.h> 23 #include <geos/geom/GeometryCollection.h> 24 #include <geos/geom/GeometryFactory.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/util/IllegalArgumentException.h> 30 #include <geos/export.h> 38 class CoordinateSequenceFactory;
40 class CoordinateSequence;
43 class GeometryCollection;
46 class MultiLineString;
69 struct GeometryFactoryDeleter {
79 using Ptr = std::unique_ptr<GeometryFactory, GeometryFactoryDeleter>;
86 static GeometryFactory::Ptr create();
100 static GeometryFactory::Ptr create(
const PrecisionModel* pm,
int newSRID,
130 static GeometryFactory::Ptr create(
const PrecisionModel* pm,
int newSRID);
146 getDefaultInstance();
157 std::unique_ptr<Geometry> toGeometry(
const Envelope* envelope)
const;
164 return &precisionModel;
168 std::unique_ptr<Point> createPoint(std::size_t coordinateDimension = 2)
const;
180 std::unique_ptr<GeometryCollection> createGeometryCollection()
const;
183 std::unique_ptr<Geometry> createEmptyGeometry()
const;
187 std::vector<Geometry*>* newGeoms)
const;
190 std::unique_ptr<GeometryCollection> createGeometryCollection(
191 std::vector<std::unique_ptr<T>> && newGeoms)
const {
193 return std::unique_ptr<GeometryCollection>(
new GeometryCollection(Geometry::toGeometryArray(std::move(newGeoms)), *
this));
197 GeometryCollection* createGeometryCollection(
198 const std::vector<const Geometry*>& newGeoms)
const;
201 std::unique_ptr<MultiLineString> createMultiLineString()
const;
204 MultiLineString* createMultiLineString(
205 std::vector<Geometry*>* newLines)
const;
208 MultiLineString* createMultiLineString(
209 const std::vector<const Geometry*>& fromLines)
const;
211 std::unique_ptr<MultiLineString> createMultiLineString(
212 std::vector<std::unique_ptr<LineString>> && fromLines)
const;
214 std::unique_ptr<MultiLineString> createMultiLineString(
215 std::vector<std::unique_ptr<Geometry>> && fromLines)
const;
218 std::unique_ptr<MultiPolygon> createMultiPolygon()
const;
221 MultiPolygon* createMultiPolygon(std::vector<Geometry*>* newPolys)
const;
224 MultiPolygon* createMultiPolygon(
225 const std::vector<const Geometry*>& fromPolys)
const;
227 std::unique_ptr<MultiPolygon> createMultiPolygon(
228 std::vector<std::unique_ptr<Polygon>> && fromPolys)
const;
230 std::unique_ptr<MultiPolygon> createMultiPolygon(
231 std::vector<std::unique_ptr<Geometry>> && fromPolys)
const;
234 std::unique_ptr<LinearRing> createLinearRing()
const;
237 LinearRing* createLinearRing(CoordinateSequence* newCoords)
const;
239 std::unique_ptr<LinearRing> createLinearRing(
240 std::unique_ptr<CoordinateSequence> && newCoords)
const;
242 std::unique_ptr<LinearRing> createLinearRing(
243 std::vector<Coordinate> && coordinates)
const;
246 LinearRing* createLinearRing(
247 const CoordinateSequence& coordinates)
const;
250 std::unique_ptr<MultiPoint> createMultiPoint()
const;
253 MultiPoint* createMultiPoint(std::vector<Geometry*>* newPoints)
const;
255 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<Coordinate> && newPoints)
const;
257 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Point>> && newPoints)
const;
259 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Geometry>> && newPoints)
const;
262 MultiPoint* createMultiPoint(
263 const std::vector<const Geometry*>& fromPoints)
const;
268 MultiPoint* createMultiPoint(
269 const CoordinateSequence& fromCoords)
const;
274 MultiPoint* createMultiPoint(
275 const std::vector<Coordinate>& fromCoords)
const;
278 std::unique_ptr<Polygon> createPolygon(std::size_t coordinateDimension = 2)
const;
281 Polygon* createPolygon(LinearRing* shell,
282 std::vector<LinearRing*>* holes)
const;
284 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell)
const;
286 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell,
287 std::vector<std::unique_ptr<LinearRing>> && holes)
const;
290 std::unique_ptr<Polygon> createPolygon(std::vector<Coordinate> && coords)
const;
293 Polygon* createPolygon(
const LinearRing& shell,
294 const std::vector<LinearRing*>& holes)
const;
297 std::unique_ptr<LineString> createLineString(std::size_t coordinateDimension = 2)
const;
300 std::unique_ptr<LineString> createLineString(
const LineString& ls)
const;
303 LineString* createLineString(CoordinateSequence* coordinates)
const;
305 std::unique_ptr<LineString> createLineString(
306 std::unique_ptr<CoordinateSequence> && coordinates)
const;
308 std::unique_ptr<LineString> createLineString(
309 std::vector<Coordinate> && coordinates)
const;
312 LineString* createLineString(
313 const CoordinateSequence& coordinates)
const;
322 std::unique_ptr<Geometry> createEmpty(
int dimension)
const;
354 Geometry* buildGeometry(std::vector<Geometry*>* geoms)
const;
356 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Geometry>> && geoms)
const;
358 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Point>> && geoms)
const;
360 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<LineString>> && geoms)
const;
362 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Polygon>> && geoms)
const;
373 std::unique_ptr<Geometry>
376 bool isHeterogeneous =
false;
377 std::size_t count = 0;
379 for(T i = from; i != toofar; ++i) {
383 geomClass = g->getSortIndex();
385 else if(geomClass != g->getSortIndex()) {
386 isHeterogeneous =
true;
392 return std::unique_ptr<Geometry>(createGeometryCollection());
397 return (*from)->clone();
406 std::vector<std::unique_ptr<Geometry>> fromGeoms;
407 for(T i = from; i != toofar; ++i) {
408 fromGeoms.push_back((*i)->clone());
412 if(isHeterogeneous) {
413 return createGeometryCollection(std::move(fromGeoms));
417 switch((*from)->getDimension()) {
418 case Dimension::A:
return createMultiPolygon(std::move(fromGeoms));
419 case Dimension::L:
return createMultiLineString(std::move(fromGeoms));
420 case Dimension::P:
return createMultiPoint(std::move(fromGeoms));
433 Geometry* buildGeometry(
const std::vector<const Geometry*>& geoms)
const;
445 return coordinateListFactory;
452 void destroyGeometry(
Geometry* g)
const;
531 mutable int _refCount;
537 void dropRef()
const;
const PrecisionModel * getPrecisionModel() const
Returns the PrecisionModel that Geometries created by this factory will be associated with...
Definition: GeometryFactory.h:162
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:58
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:90
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Indicates one or more illegal arguments.
Definition: IllegalArgumentException.h:33
Dimension value of a curve (1).
Definition: Dimension.h:43
Dimension value of a surface (2).
Definition: Dimension.h:46
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:52
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25
const CoordinateSequenceFactory * getCoordinateSequenceFactory() const
Returns the CoordinateSequenceFactory associated with this GeometryFactory.
Definition: GeometryFactory.h:443
Dimension value of a point (0).
Definition: Dimension.h:40
A factory to create concrete instances of CoordinateSequences.
Definition: CoordinateSequenceFactory.h:44
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
std::unique_ptr< Geometry > buildGeometry(T from, T toofar) const
See buildGeometry(std::vector<Geometry *>&) for semantics.
Definition: GeometryFactory.h:374