GEOS  3.13.1
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 
31 namespace geos {
32 namespace geom {
33 class Geometry;
34 class GeometryFactory;
35 }
36 }
37 
38 
39 namespace geos {
40 namespace geom { // geos::geom
41 
42 std::unique_ptr<Geometry> GEOS_DLL
43 HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode);
44 
45 class StructuredCollection {
46 
47 public:
48 
49  static std::unique_ptr<Geometry> overlay(const Geometry* g0, const Geometry* g1, int opCode);
50 
51 private:
52 
53  const GeometryFactory* factory;
54  std::vector<const Geometry*> pts;
55  std::vector<const Geometry*> lines;
56  std::vector<const Geometry*> polys;
57  std::unique_ptr<Geometry> pt_union;
58  std::unique_ptr<Geometry> line_union;
59  std::unique_ptr<Geometry> poly_union;
60  Dimension::DimensionType dimension;
61 
62  StructuredCollection(const Geometry* g)
63  : factory(g->getFactory())
64  , pt_union(nullptr)
65  , line_union(nullptr)
66  , poly_union(nullptr)
67  , dimension(Dimension::DONTCARE)
68  {
69  readCollection(g);
70  unionByDimension();
71  };
72 
73  StructuredCollection()
74  : factory(nullptr)
75  , pt_union(nullptr)
76  , line_union(nullptr)
77  , poly_union(nullptr)
78  , dimension(Dimension::DONTCARE)
79  {};
80 
81  Dimension::DimensionType getDimension() const
82  {
83  return dimension;
84  };
85 
86  void addDimension(Dimension::DimensionType dim);
87  std::unique_ptr<Geometry> doUnaryUnion(int resultDim) const;
88  std::unique_ptr<Geometry> computeResult(StructuredCollection& coll, int opCode,
90 
91  void readCollection(const Geometry* g);
92  const Geometry* getPolyUnion() const { return poly_union.get(); }
93  const Geometry* getLineUnion() const { return line_union.get(); }
94  const Geometry* getPointUnion() const { return pt_union.get(); }
95 
96  std::unique_ptr<Geometry> doUnion(const StructuredCollection& a) const;
97  std::unique_ptr<Geometry> doIntersection(const StructuredCollection& a) const;
98  std::unique_ptr<Geometry> doSymDifference(const StructuredCollection& a) const;
99  std::unique_ptr<Geometry> doDifference(const StructuredCollection& a) const;
100 
101  static void toVector(const Geometry* g, std::vector<const Geometry*>& v);
102  void unionByDimension(void);
103 };
104 
105 
106 
107 
108 
109 } // namespace geos::geom
110 } // namespace geos
111 
DimensionType
Definition: Dimension.h:29
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25