GEOS 3.14.0dev
RelateEdge.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (c) 2024 Martin Davis
7 * Copyright (C) 2024 Paul Ramsey <pramsey@cleverelephant.ca>
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************/
15
16#pragma once
17
18#include <geos/geom/Location.h>
19#include <geos/export.h>
20
21#include <memory>
22#include <vector>
23
24// Forward declarations
25namespace geos {
26namespace operation {
27namespace relateng {
28class RelateNode;
29}
30}
31namespace geom {
32 class CoordinateXY;
33 class Geometry;
34}
35}
36
37namespace geos { // geos.
38namespace operation { // geos.operation
39namespace relateng { // geos.operation.relateng
40
41
42class GEOS_DLL RelateEdge {
43 using CoordinateXY = geos::geom::CoordinateXY;
44 using Geometry = geos::geom::Geometry;
46
47private:
48
52 static constexpr Location LOC_UNKNOWN = Location::NONE;
53
54 // Members
55 const RelateNode* node;
56 const CoordinateXY* dirPt;
57
58 int aDim = DIM_UNKNOWN;
59 Location aLocLeft = LOC_UNKNOWN;
60 Location aLocRight = LOC_UNKNOWN;
61 Location aLocLine = LOC_UNKNOWN;
62
63 int bDim = DIM_UNKNOWN;
64 Location bLocLeft = LOC_UNKNOWN;
65 Location bLocRight = LOC_UNKNOWN;
66 Location bLocLine = LOC_UNKNOWN;
67
68
69public:
70
71 // Constants
72 static constexpr bool IS_FORWARD = true;
73 static constexpr bool IS_REVERSE = false;
74 static constexpr int DIM_UNKNOWN = -1;
75
76 // Constructors
77 RelateEdge(
78 const RelateNode* node, const CoordinateXY* pt,
79 bool isA, bool isForward);
80
81 RelateEdge(
82 const RelateNode* node, const CoordinateXY* pt,
83 bool isA);
84
85 RelateEdge(
86 const RelateNode* node, const CoordinateXY* pt,
87 bool isA, Location locLeft, Location locRight, Location locLine);
88
89 // Methods
90 static RelateEdge* create(
91 const RelateNode* node,
92 const CoordinateXY* dirPt,
93 bool isA, int dim, bool isForward);
94
95 static std::size_t findKnownEdgeIndex(
96 std::vector<std::unique_ptr<RelateEdge>>& edges,
97 bool isA);
98
99 static void setAreaInterior(
100 std::vector<std::unique_ptr<RelateEdge>>& edges,
101 bool isA);
102
103 bool isInterior(bool isA, int position) const;
104
105 Location location(bool isA, int position) const;
106
107 int compareToEdge(const CoordinateXY* edgeDirPt) const;
108
109 void setDimLocations(bool isA, int dim, Location loc);
110
111 void setAreaInterior(bool isA);
112
113 void setLocation(bool isA, int pos, Location loc);
114
115 void setAllLocations(bool isA, Location loc);
116
117 void setUnknownLocations(bool isA, Location loc);
118
119 void merge(bool isA, int dim, bool isForward);
120
121 std::string toString() const;
122
123 friend std::ostream& operator<<(std::ostream& os, const RelateEdge& re);
124
125
126private:
127
128 // Methods
129 void mergeSideLocation(bool isA, int pos, Location loc);
130
141 void mergeDimEdgeLoc(bool isA, Location locEdge);
142
143 void setDimension(bool isA, int dimension);
144
145 void setLeft(bool isA, Location loc);
146
147 void setRight(bool isA, Location loc);
148
149 void setOn(bool isA, Location loc);
150
151 int dimension(bool isA) const;
152
153 bool isKnown(bool isA) const;
154
155 bool isKnown(bool isA, int pos) const;
156
157 void setLocations(bool isA, Location locLeft, Location locRight, Location locLine);
158
159 void setLocationsLine(bool isA);
160
161 void setLocationsArea(bool isA, bool isForward);
162
163 std::string labelString() const;
164
165 std::string locationString(bool isA) const;
166
167
168};
169
170} // namespace geos.operation.relateng
171} // namespace geos.operation
172} // namespace geos
173
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:32
Basic namespace for all GEOS functionalities.
Definition geos.h:39