GEOS 3.13.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 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
87public:
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:70
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:88
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:92
Definition Angle.h:26
Basic namespace for all GEOS functionalities.
Definition geos.h:39