GEOS  3.9.1
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  // Methods
68  void
69  computeIntersection(std::map<Coordinate, std::unique_ptr<Point>>& map0,
70  std::map<Coordinate, std::unique_ptr<Point>>& map1,
71  std::vector<std::unique_ptr<Point>>& resultList);
72 
73  void
74  computeDifference(std::map<Coordinate, std::unique_ptr<Point>>& map0,
75  std::map<Coordinate, std::unique_ptr<Point>>& map1,
76  std::vector<std::unique_ptr<Point>>& resultList);
77 
78  void
79  computeUnion(std::map<Coordinate, std::unique_ptr<Point>>& map0,
80  std::map<Coordinate, std::unique_ptr<Point>>& map1,
81  std::vector<std::unique_ptr<Point>>& resultList);
82 
83  std::map<Coordinate, std::unique_ptr<Point>> buildPointMap(const Geometry* geom);
84 
85  Coordinate roundCoord(const Point* pt, const PrecisionModel* pm) const;
86 
87 
88 
89 public:
90 
94  OverlayPoints(int p_opCode, const Geometry* p_geom0, const Geometry* p_geom1, const PrecisionModel* p_pm)
95  : opCode(p_opCode)
96  , geom0(p_geom0)
97  , geom1(p_geom1)
98  , pm(p_pm)
99  , geometryFactory(p_geom0->getFactory()) {}
100 
101  OverlayPoints(const OverlayPoints&) = delete;
102  OverlayPoints& operator=(const OverlayPoints&) = delete;
103 
107  static std::unique_ptr<Geometry> overlay(int opCode, const Geometry* geom0, const Geometry* geom1, const PrecisionModel* pm);
108 
114  std::unique_ptr<Geometry> getResult();
115 
116 
117 };
118 
119 
120 } // namespace geos.operation.overlayng
121 } // namespace geos.operation
122 } // namespace geos
123 
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Definition: Point.h:66
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
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:94
Definition: IndexedNestedRingTester.h:27
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26