GEOS 3.14.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
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
53class GEOS_DLL OverlayPoints {
55 using CoordinateXY = geos::geom::CoordinateXY;
61
62private:
63
64 // Members
65 int opCode;
66 const Geometry* geom0;
67 const Geometry* geom1;
68 const PrecisionModel* pm;
69 const GeometryFactory* geometryFactory;
70 std::vector<std::unique_ptr<Point>> resultList;
71
72 using PointMap = std::map<CoordinateXY, std::unique_ptr<Point>>;
73
74 // Methods
75 void
76 computeIntersection(PointMap& map0,
77 PointMap& map1,
78 std::vector<std::unique_ptr<Point>>& resultList);
79
80 void
81 computeDifference(PointMap& map0,
82 PointMap& map1,
83 std::vector<std::unique_ptr<Point>>& resultList);
84
85 void
86 computeUnion(PointMap& map0,
87 PointMap& map1,
88 std::vector<std::unique_ptr<Point>>& resultList);
89
90 PointMap buildPointMap(const Geometry* geom);
91
92public:
93
97 OverlayPoints(int p_opCode, const Geometry* p_geom0, const Geometry* p_geom1, const PrecisionModel* p_pm)
98 : opCode(p_opCode)
99 , geom0(p_geom0)
100 , geom1(p_geom1)
101 , pm(p_pm)
102 , geometryFactory(p_geom0->getFactory()) {}
103
104 OverlayPoints(const OverlayPoints&) = delete;
105 OverlayPoints& operator=(const OverlayPoints&) = delete;
106
110 static std::unique_ptr<Geometry> overlay(int opCode, const Geometry* geom0, const Geometry* geom1, const PrecisionModel* pm);
111
117 std::unique_ptr<Geometry> getResult();
118
119
120};
121
122
123} // namespace geos.operation.overlayng
124} // namespace geos.operation
125} // namespace geos
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
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
Definition Point.h:61
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:88
Definition OverlayPoints.h:53
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:97
Basic namespace for all GEOS functionalities.
Definition geos.h:39