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/geom/Polygon.h> 30 #include <geos/util/IllegalArgumentException.h> 31 #include <geos/export.h> 42 class CoordinateSequence;
45 class GeometryCollection;
48 class MultiLineString;
73 struct GeometryFactoryDeleter {
83 using Ptr = std::unique_ptr<GeometryFactory, GeometryFactoryDeleter>;
90 static GeometryFactory::Ptr create();
111 static GeometryFactory::Ptr create(
const PrecisionModel* pm,
int newSRID);
127 getDefaultInstance();
131 static std::unique_ptr<Point> createPointFromInternalCoord(
const Coordinate* coord,
138 std::unique_ptr<Geometry> toGeometry(
const Envelope* envelope)
const;
145 return &precisionModel;
149 std::unique_ptr<Point> createPoint(std::size_t coordinateDimension = 2)
const;
150 std::unique_ptr<Point> createPoint(
bool hasZ,
bool hasM)
const;
153 std::unique_ptr<Point> createPoint(
const Coordinate& coordinate)
const;
154 std::unique_ptr<Point> createPoint(
const CoordinateXY& coordinate)
const;
155 std::unique_ptr<Point> createPoint(
const CoordinateXYM& coordinate)
const;
156 std::unique_ptr<Point> createPoint(
const CoordinateXYZM& coordinate)
const;
159 std::unique_ptr<Point> createPoint(std::unique_ptr<CoordinateSequence>&& coordinates)
const;
165 std::unique_ptr<GeometryCollection> createGeometryCollection()
const;
173 std::vector<std::unique_ptr<T>> && newGeoms)
const {
175 return std::unique_ptr<GeometryCollection>(
new GeometryCollection(Geometry::toGeometryArray(std::move(newGeoms)), *
this));
179 std::unique_ptr<GeometryCollection> createGeometryCollection(
180 const std::vector<const Geometry*>& newGeoms)
const;
183 std::unique_ptr<MultiLineString> createMultiLineString()
const;
186 std::unique_ptr<MultiLineString> createMultiLineString(
187 const std::vector<const Geometry*>& fromLines)
const;
190 std::unique_ptr<MultiLineString> createMultiLineString(
191 std::vector<std::unique_ptr<LineString>> && fromLines)
const;
193 std::unique_ptr<MultiLineString> createMultiLineString(
194 std::vector<std::unique_ptr<Geometry>> && fromLines)
const;
197 std::unique_ptr<MultiCurve> createMultiCurve()
const;
200 std::unique_ptr<MultiCurve> createMultiCurve(
201 std::vector<std::unique_ptr<Geometry>> && fromCurves)
const;
203 std::unique_ptr<MultiCurve> createMultiCurve(
204 std::vector<std::unique_ptr<Curve>> && fromCurves)
const;
207 std::unique_ptr<MultiPolygon> createMultiPolygon()
const;
210 std::unique_ptr<MultiPolygon> createMultiPolygon(
211 const std::vector<const Geometry*>& fromPolys)
const;
214 std::unique_ptr<MultiPolygon> createMultiPolygon(
215 std::vector<std::unique_ptr<Polygon>> && fromPolys)
const;
217 std::unique_ptr<MultiPolygon> createMultiPolygon(
218 std::vector<std::unique_ptr<Geometry>> && fromPolys)
const;
221 std::unique_ptr<MultiSurface> createMultiSurface()
const;
224 std::unique_ptr<MultiSurface> createMultiSurface(
225 std::vector<std::unique_ptr<Geometry>> && from)
const;
227 std::unique_ptr<MultiSurface> createMultiSurface(
228 std::vector<std::unique_ptr<Surface>> && from)
const;
231 std::unique_ptr<LinearRing> createLinearRing(std::size_t coordinateDimension = 2)
const;
232 std::unique_ptr<LinearRing> createLinearRing(
bool hasZ,
bool hasM)
const;
235 std::unique_ptr<LinearRing> createLinearRing(
236 std::unique_ptr<CoordinateSequence> && newCoords)
const;
239 std::unique_ptr<LinearRing> createLinearRing(
243 std::unique_ptr<MultiPoint> createMultiPoint()
const;
246 std::unique_ptr<MultiPoint> createMultiPoint(
const T& fromCoords)
const 248 std::vector<std::unique_ptr<Geometry>> pts;
249 pts.reserve(fromCoords.size());
250 for (
const auto& c : fromCoords) {
251 pts.emplace_back(createPoint(c));
254 return createMultiPoint(std::move(pts));
258 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Point>> && newPoints)
const;
260 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Geometry>> && newPoints)
const;
263 std::unique_ptr<MultiPoint> createMultiPoint(
264 const std::vector<const Geometry*>& fromPoints)
const;
269 std::unique_ptr<MultiPoint> createMultiPoint(
270 const CoordinateSequence& fromCoords)
const;
273 std::unique_ptr<Polygon> createPolygon(std::size_t coordinateDimension = 2)
const;
274 std::unique_ptr<Polygon> createPolygon(
bool hasZ,
bool hasM)
const;
277 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell)
const;
279 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell,
280 std::vector<std::unique_ptr<LinearRing>> && holes)
const;
283 std::unique_ptr<Polygon> createPolygon(CoordinateSequence && coords)
const;
286 Polygon* createPolygon(
const LinearRing& shell,
287 const std::vector<LinearRing*>& holes)
const;
291 std::unique_ptr<CurvePolygon> createCurvePolygon(
bool hasZ,
bool hasM)
const;
294 std::unique_ptr<CurvePolygon> createCurvePolygon(std::unique_ptr<Curve>&& shell)
const;
296 std::unique_ptr<CurvePolygon> createCurvePolygon(std::unique_ptr<Curve>&& shell,
297 std::vector<std::unique_ptr<Curve>> && holes)
const;
300 std::unique_ptr<LineString> createLineString(std::size_t coordinateDimension = 2)
const;
301 std::unique_ptr<LineString> createLineString(
bool hasZ,
bool hasM)
const;
304 std::unique_ptr<LineString> createLineString(
const LineString& ls)
const;
307 std::unique_ptr<LineString> createLineString(
308 std::unique_ptr<CoordinateSequence> && coordinates)
const;
311 std::unique_ptr<LineString> createLineString(
312 const CoordinateSequence& coordinates)
const;
315 std::unique_ptr<CircularString> createCircularString(
bool hasZ,
bool hasM)
const;
318 std::unique_ptr<CircularString> createCircularString(
const CircularString& ls)
const;
321 std::unique_ptr<CircularString> createCircularString(
322 std::unique_ptr<CoordinateSequence> && coordinates)
const;
325 std::unique_ptr<CircularString> createCircularString(
326 const CoordinateSequence& coordinates)
const;
329 std::unique_ptr<CompoundCurve> createCompoundCurve()
const;
332 std::unique_ptr<CompoundCurve> createCompoundCurve(std::vector<std::unique_ptr<SimpleCurve>>&&)
const;
341 std::unique_ptr<Geometry> createEmpty(
int dimension)
const;
348 std::unique_ptr<Geometry> createEmpty(
GeometryTypeId typeId)
const;
350 std::unique_ptr<Geometry> createMulti(std::unique_ptr<Geometry> && geom)
const;
382 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Geometry>> && geoms)
const;
384 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Point>> && geoms)
const;
386 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<LineString>> && geoms)
const;
388 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Polygon>> && geoms)
const;
399 std::unique_ptr<Geometry>
402 bool isHeterogeneous =
false;
403 std::size_t count = 0;
405 for(T i = from; i != toofar; ++i) {
409 geomClass = g->getSortIndex();
411 else if(geomClass != g->getSortIndex()) {
412 isHeterogeneous =
true;
418 return std::unique_ptr<Geometry>(createGeometryCollection());
423 return (*from)->clone();
432 std::vector<std::unique_ptr<Geometry>> fromGeoms;
433 for(T i = from; i != toofar; ++i) {
434 fromGeoms.push_back((*i)->clone());
438 if(isHeterogeneous) {
439 return createGeometryCollection(std::move(fromGeoms));
443 switch((*from)->getDimension()) {
444 case Dimension::A:
return createMultiPolygon(std::move(fromGeoms));
445 case Dimension::L:
return createMultiLineString(std::move(fromGeoms));
446 case Dimension::P:
return createMultiPoint(std::move(fromGeoms));
459 std::unique_ptr<Geometry> buildGeometry(
const std::vector<const Geometry*>& geoms)
const;
467 std::unique_ptr<Geometry> createGeometry(
const Geometry* g)
const;
470 void destroyGeometry(Geometry* g)
const;
497 GeometryFactory(
const PrecisionModel* pm);
508 GeometryFactory(
const PrecisionModel* pm,
int newSRID);
515 GeometryFactory(
const GeometryFactory& gf);
518 virtual ~GeometryFactory();
522 PrecisionModel precisionModel;
525 mutable int _refCount;
528 friend class Geometry;
531 void dropRef()
const;
const PrecisionModel * getPrecisionModel() const
Returns the PrecisionModel that Geometries created by this factory will be associated with...
Definition: GeometryFactory.h:143
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:217
GeometryTypeId
Geometry types.
Definition: Geometry.h:74
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:88
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:197
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:70
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:51
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25
Dimension value of a point (0).
Definition: Dimension.h:40
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56
std::unique_ptr< GeometryCollection > createGeometryCollection(std::vector< std::unique_ptr< T >> &&newGeoms) const
Construct a GeometryCollection taking ownership of given arguments.
Definition: GeometryFactory.h:172
a collection of heterogeneus geometries
Definition: Geometry.h:90
std::unique_ptr< Geometry > buildGeometry(T from, T toofar) const
See buildGeometry(std::vector<Geometry *>&) for semantics.
Definition: GeometryFactory.h:400