GEOS 3.14.0dev
HeuristicOverlay.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2013-2020 Sandro Santilli <strk@kbt.io>
7 * Copyright (C) 2006 Refractions Research Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: ORIGINAL WORK
17 *
18 **********************************************************************/
19
20#pragma once
21
22#include <geos/export.h>
23#include <geos/geom/Geometry.h>
24#include <geos/geom/Dimension.h>
25
26
27#include <memory> // for unique_ptr
28#include <vector>
29
30
31namespace geos {
32namespace geom {
33class Geometry;
34class GeometryFactory;
35}
36}
37
38
39namespace geos {
40namespace geom { // geos::geom
41
42std::unique_ptr<Geometry> GEOS_DLL
43HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode);
44
45class StructuredCollection {
46
47public:
48
49 StructuredCollection(const Geometry* g)
50 : factory(g->getFactory())
51 , pt_union(nullptr)
52 , line_union(nullptr)
53 , poly_union(nullptr)
54 {
55 readCollection(g);
56 unionByDimension();
57 };
58
59 StructuredCollection()
60 : factory(nullptr)
61 , pt_union(nullptr)
62 , line_union(nullptr)
63 , poly_union(nullptr)
64 {};
65
66 void readCollection(const Geometry* g);
67 const Geometry* getPolyUnion() const { return poly_union.get(); }
68 const Geometry* getLineUnion() const { return line_union.get(); }
69 const Geometry* getPointUnion() const { return pt_union.get(); }
70
71 std::unique_ptr<Geometry> doUnion(const StructuredCollection& a) const;
72 std::unique_ptr<Geometry> doIntersection(const StructuredCollection& a) const;
73 std::unique_ptr<Geometry> doSymDifference(const StructuredCollection& a) const;
74 std::unique_ptr<Geometry> doDifference(const StructuredCollection& a) const;
75 std::unique_ptr<Geometry> doUnaryUnion() const;
76
77 static void toVector(const Geometry* g, std::vector<const Geometry*>& v);
78 void unionByDimension(void);
79
80
81private:
82
83 const GeometryFactory* factory;
84 std::vector<const Geometry*> pts;
85 std::vector<const Geometry*> lines;
86 std::vector<const Geometry*> polys;
87 std::unique_ptr<Geometry> pt_union;
88 std::unique_ptr<Geometry> line_union;
89 std::unique_ptr<Geometry> poly_union;
90
91};
92
93
94
95
96
97} // namespace geos::geom
98} // namespace geos
99
Basic namespace for all GEOS functionalities.
Definition geos.h:39