GEOS 3.11.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
26namespace geos {
27namespace geom {
28class Coordinate;
29class CoordinateSequence;
30class GeometryFactory;
31class Geometry;
32class PrecisionModel;
33}
34}
35
36namespace geos { // geos.
37namespace operation { // geos.operation
38namespace overlayng { // geos.operation.overlayng
39
40using namespace geos::geom;
41
55class GEOS_DLL OverlayPoints {
56
57private:
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
85public:
86
90 OverlayPoints(int p_opCode, const Geometry* p_geom0, const Geometry* p_geom1, const PrecisionModel* p_pm)
91 : opCode(p_opCode)
92 , geom0(p_geom0)
93 , geom1(p_geom1)
94 , pm(p_pm)
95 , geometryFactory(p_geom0->getFactory()) {}
96
97 OverlayPoints(const OverlayPoints&) = delete;
98 OverlayPoints& operator=(const OverlayPoints&) = delete;
99
103 static std::unique_ptr<Geometry> overlay(int opCode, const Geometry* geom0, const Geometry* geom1, const PrecisionModel* pm);
104
110 std::unique_ptr<Geometry> getResult();
111
112
113};
114
115
116} // namespace geos.operation.overlayng
117} // namespace geos.operation
118} // namespace geos
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
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:90
Definition: OverlayPoints.h:55
std::unique_ptr< Geometry > getResult()
static std::unique_ptr< Geometry > overlay(int opCode, const Geometry *geom0, const Geometry *geom1, const PrecisionModel *pm)
OverlayPoints(int p_opCode, const Geometry *p_geom0, const Geometry *p_geom1, const PrecisionModel *p_pm)
Definition: OverlayPoints.h:90
Definition: Angle.h:26
Basic namespace for all GEOS functionalities.
Definition: geos.h:39