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> 39 class CoordinateSequence;
42 class GeometryCollection;
45 class MultiLineString;
68 struct GeometryFactoryDeleter {
78 using Ptr = std::unique_ptr<GeometryFactory, GeometryFactoryDeleter>;
85 static GeometryFactory::Ptr create();
106 static GeometryFactory::Ptr create(
const PrecisionModel* pm,
int newSRID);
122 getDefaultInstance();
126 static std::unique_ptr<Point> createPointFromInternalCoord(
const Coordinate* coord,
133 std::unique_ptr<Geometry> toGeometry(
const Envelope* envelope)
const;
140 return &precisionModel;
144 std::unique_ptr<Point> createPoint(std::size_t coordinateDimension = 2)
const;
147 std::unique_ptr<Point> createPoint(
const Coordinate& coordinate)
const;
148 std::unique_ptr<Point> createPoint(
const CoordinateXY& coordinate)
const;
149 std::unique_ptr<Point> createPoint(
const CoordinateXYM& coordinate)
const;
150 std::unique_ptr<Point> createPoint(
const CoordinateXYZM& coordinate)
const;
153 std::unique_ptr<Point> createPoint(std::unique_ptr<CoordinateSequence>&& coordinates)
const;
159 std::unique_ptr<GeometryCollection> createGeometryCollection()
const;
162 std::unique_ptr<Geometry> createEmptyGeometry()
const;
167 std::vector<std::unique_ptr<T>> && newGeoms)
const {
169 return std::unique_ptr<GeometryCollection>(
new GeometryCollection(Geometry::toGeometryArray(std::move(newGeoms)), *
this));
173 std::unique_ptr<GeometryCollection> createGeometryCollection(
174 const std::vector<const Geometry*>& newGeoms)
const;
177 std::unique_ptr<MultiLineString> createMultiLineString()
const;
180 std::unique_ptr<MultiLineString> createMultiLineString(
181 const std::vector<const Geometry*>& fromLines)
const;
184 std::unique_ptr<MultiLineString> createMultiLineString(
185 std::vector<std::unique_ptr<LineString>> && fromLines)
const;
187 std::unique_ptr<MultiLineString> createMultiLineString(
188 std::vector<std::unique_ptr<Geometry>> && fromLines)
const;
191 std::unique_ptr<MultiPolygon> createMultiPolygon()
const;
194 std::unique_ptr<MultiPolygon> createMultiPolygon(
195 const std::vector<const Geometry*>& fromPolys)
const;
198 std::unique_ptr<MultiPolygon> createMultiPolygon(
199 std::vector<std::unique_ptr<Polygon>> && fromPolys)
const;
201 std::unique_ptr<MultiPolygon> createMultiPolygon(
202 std::vector<std::unique_ptr<Geometry>> && fromPolys)
const;
205 std::unique_ptr<LinearRing> createLinearRing(std::size_t coordinateDimension = 2)
const;
208 std::unique_ptr<LinearRing> createLinearRing(
209 std::unique_ptr<CoordinateSequence> && newCoords)
const;
212 std::unique_ptr<LinearRing> createLinearRing(
216 std::unique_ptr<MultiPoint> createMultiPoint()
const;
219 std::unique_ptr<MultiPoint> createMultiPoint(
const T& fromCoords)
const 221 std::vector<std::unique_ptr<Geometry>> pts;
222 pts.reserve(fromCoords.size());
223 for (
const auto& c : fromCoords) {
224 pts.emplace_back(createPoint(c));
227 return createMultiPoint(std::move(pts));
231 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Point>> && newPoints)
const;
233 std::unique_ptr<MultiPoint> createMultiPoint(std::vector<std::unique_ptr<Geometry>> && newPoints)
const;
236 std::unique_ptr<MultiPoint> createMultiPoint(
237 const std::vector<const Geometry*>& fromPoints)
const;
242 std::unique_ptr<MultiPoint> createMultiPoint(
243 const CoordinateSequence& fromCoords)
const;
246 std::unique_ptr<Polygon> createPolygon(std::size_t coordinateDimension = 2)
const;
249 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell)
const;
251 std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell,
252 std::vector<std::unique_ptr<LinearRing>> && holes)
const;
255 std::unique_ptr<Polygon> createPolygon(CoordinateSequence && coords)
const;
258 Polygon* createPolygon(
const LinearRing& shell,
259 const std::vector<LinearRing*>& holes)
const;
262 std::unique_ptr<LineString> createLineString(std::size_t coordinateDimension = 2)
const;
265 std::unique_ptr<LineString> createLineString(
const LineString& ls)
const;
268 std::unique_ptr<LineString> createLineString(
269 std::unique_ptr<CoordinateSequence> && coordinates)
const;
272 std::unique_ptr<LineString> createLineString(
273 const CoordinateSequence& coordinates)
const;
282 std::unique_ptr<Geometry> createEmpty(
int dimension)
const;
289 std::unique_ptr<Geometry> createEmpty(
GeometryTypeId typeId)
const;
291 std::unique_ptr<Geometry> createMulti(std::unique_ptr<Geometry> && geom)
const;
323 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Geometry>> && geoms)
const;
325 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Point>> && geoms)
const;
327 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<LineString>> && geoms)
const;
329 std::unique_ptr<Geometry> buildGeometry(std::vector<std::unique_ptr<Polygon>> && geoms)
const;
340 std::unique_ptr<Geometry>
343 bool isHeterogeneous =
false;
344 std::size_t count = 0;
346 for(T i = from; i != toofar; ++i) {
350 geomClass = g->getSortIndex();
352 else if(geomClass != g->getSortIndex()) {
353 isHeterogeneous =
true;
359 return std::unique_ptr<Geometry>(createGeometryCollection());
364 return (*from)->clone();
373 std::vector<std::unique_ptr<Geometry>> fromGeoms;
374 for(T i = from; i != toofar; ++i) {
375 fromGeoms.push_back((*i)->clone());
379 if(isHeterogeneous) {
380 return createGeometryCollection(std::move(fromGeoms));
384 switch((*from)->getDimension()) {
385 case Dimension::A:
return createMultiPolygon(std::move(fromGeoms));
386 case Dimension::L:
return createMultiLineString(std::move(fromGeoms));
387 case Dimension::P:
return createMultiPoint(std::move(fromGeoms));
400 std::unique_ptr<Geometry> buildGeometry(
const std::vector<const Geometry*>& geoms)
const;
408 std::unique_ptr<Geometry> createGeometry(
const Geometry* g)
const;
411 void destroyGeometry(Geometry* g)
const;
438 GeometryFactory(
const PrecisionModel* pm);
449 GeometryFactory(
const PrecisionModel* pm,
int newSRID);
456 GeometryFactory(
const GeometryFactory& gf);
459 virtual ~GeometryFactory();
463 PrecisionModel precisionModel;
466 mutable int _refCount;
469 friend class Geometry;
472 void dropRef()
const;
const PrecisionModel * getPrecisionModel() const
Returns the PrecisionModel that Geometries created by this factory will be associated with...
Definition: GeometryFactory.h:138
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:216
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:90
GeometryTypeId
Geometry types.
Definition: Geometry.h:73
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:65
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:166
std::unique_ptr< Geometry > buildGeometry(T from, T toofar) const
See buildGeometry(std::vector<Geometry *>&) for semantics.
Definition: GeometryFactory.h:341