19 #ifndef GEOS_OP_UNION_UNARYUNION_H
20 #define GEOS_OP_UNION_UNARYUNION_H
25 #include <geos/export.h>
26 #include <geos/geom/GeometryFactory.h>
27 #include <geos/geom/BinaryOp.h>
28 #include <geos/geom/Point.h>
29 #include <geos/geom/LineString.h>
30 #include <geos/geom/Polygon.h>
31 #include <geos/geom/util/GeometryExtracter.h>
32 #include <geos/operation/overlay/OverlayOp.h>
37 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
43 class GeometryFactory;
89 class GEOS_DLL UnaryUnionOp {
93 static std::unique_ptr<geom::Geometry>
96 UnaryUnionOp op(geoms);
101 static std::unique_ptr<geom::Geometry>
102 Union(
const T& geoms,
103 geom::GeometryFactory& geomFact)
105 UnaryUnionOp op(geoms, geomFact);
109 static std::unique_ptr<geom::Geometry>
110 Union(
const geom::Geometry& geom)
112 UnaryUnionOp op(geom);
117 UnaryUnionOp(
const T& geoms, geom::GeometryFactory& geomFactIn)
119 geomFact(&geomFactIn)
125 UnaryUnionOp(
const T& geoms)
132 UnaryUnionOp(
const geom::Geometry& geom)
134 geomFact(geom.getFactory())
149 std::unique_ptr<geom::Geometry> Union();
153 template <
typename T>
155 extractGeoms(
const T& geoms)
157 for(
typename T::const_iterator
162 const geom::Geometry* geom = *i;
168 extract(
const geom::Geometry& geom)
170 using namespace geom::util;
173 geomFact = geom.getFactory();
176 GeometryExtracter::extract<geom::Polygon>(geom, polygons);
177 GeometryExtracter::extract<geom::LineString>(geom, lines);
178 GeometryExtracter::extract<geom::Point>(geom, points);
193 std::unique_ptr<geom::Geometry>
194 unionNoOpt(
const geom::Geometry& g0)
200 empty = geomFact->createEmptyGeometry();
203 return BinaryOp(&g0, empty.get(), overlay::overlayOp(OverlayOp::opUNION));
215 std::unique_ptr<geom::Geometry> unionWithNull(std::unique_ptr<geom::Geometry> g0,
216 std::unique_ptr<geom::Geometry> g1);
218 std::vector<const geom::Polygon*> polygons;
219 std::vector<const geom::LineString*> lines;
220 std::vector<const geom::Point*> points;
222 const geom::GeometryFactory* geomFact;
224 std::unique_ptr<geom::Geometry> empty;