GEOS  3.13.0dev
OverlayPoints.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************/
14 
15 #pragma once
16 
17 #include <geos/export.h>
18 
19 #include <geos/geom/Geometry.h>
20 #include <geos/geom/Point.h>
21 
22 #include <map>
23 #include <vector>
24 
25 // Forward declarations
26 namespace geos {
27 namespace geom {
28 class Coordinate;
29 class CoordinateSequence;
30 class GeometryFactory;
31 class Geometry;
32 class PrecisionModel;
33 }
34 }
35 
36 namespace geos { // geos.
37 namespace operation { // geos.operation
38 namespace overlayng { // geos.operation.overlayng
39 
40 using namespace geos::geom;
41 
55 class GEOS_DLL OverlayPoints {
56 
57 private:
58 
59  // Members
60  int opCode;
61  const Geometry* geom0;
62  const Geometry* geom1;
63  const PrecisionModel* pm;
64  const GeometryFactory* geometryFactory;
65  std::vector<std::unique_ptr<Point>> resultList;
66 
67  using PointMap = std::map<CoordinateXY, std::unique_ptr<Point>>;
68 
69  // Methods
70  void
71  computeIntersection(PointMap& map0,
72  PointMap& map1,
73  std::vector<std::unique_ptr<Point>>& resultList);
74 
75  void
76  computeDifference(PointMap& map0,
77  PointMap& map1,
78  std::vector<std::unique_ptr<Point>>& resultList);
79 
80  void
81  computeUnion(PointMap& map0,
82  PointMap& map1,
83  std::vector<std::unique_ptr<Point>>& resultList);
84 
85  PointMap buildPointMap(const Geometry* geom);
86 
87 public:
88 
92  OverlayPoints(int p_opCode, const Geometry* p_geom0, const Geometry* p_geom1, const PrecisionModel* p_pm)
93  : opCode(p_opCode)
94  , geom0(p_geom0)
95  , geom1(p_geom1)
96  , pm(p_pm)
97  , geometryFactory(p_geom0->getFactory()) {}
98 
99  OverlayPoints(const OverlayPoints&) = delete;
100  OverlayPoints& operator=(const OverlayPoints&) = delete;
101 
105  static std::unique_ptr<Geometry> overlay(int opCode, const Geometry* geom0, const Geometry* geom1, const PrecisionModel* pm);
106 
112  std::unique_ptr<Geometry> getResult();
113 
114 
115 };
116 
117 
118 } // namespace geos.operation.overlayng
119 } // namespace geos.operation
120 } // namespace geos
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:65
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:88
Definition: OverlayPoints.h:55
static std::unique_ptr< Geometry > overlay(int opCode, const Geometry *geom0, const Geometry *geom1, const PrecisionModel *pm)
std::unique_ptr< Geometry > getResult()
OverlayPoints(int p_opCode, const Geometry *p_geom0, const Geometry *p_geom1, const PrecisionModel *p_pm)
Definition: OverlayPoints.h:92
Definition: Angle.h:26
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25