GEOS  3.13.1
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
25 namespace geos {
26 namespace operation {
27 namespace relateng {
28 class RelateNode;
29 }
30 }
31 namespace geom {
32  class CoordinateXY;
33  class Geometry;
34 }
35 }
36 
37 
38 using geos::geom::CoordinateXY;
41 
42 
43 namespace geos { // geos.
44 namespace operation { // geos.operation
45 namespace relateng { // geos.operation.relateng
46 
47 
48 class GEOS_DLL RelateEdge {
49 
50 private:
51 
55  static constexpr Location LOC_UNKNOWN = Location::NONE;
56 
57  // Members
58  const RelateNode* node;
59  const CoordinateXY* dirPt;
60 
61  int aDim = DIM_UNKNOWN;
62  Location aLocLeft = LOC_UNKNOWN;
63  Location aLocRight = LOC_UNKNOWN;
64  Location aLocLine = LOC_UNKNOWN;
65 
66  int bDim = DIM_UNKNOWN;
67  Location bLocLeft = LOC_UNKNOWN;
68  Location bLocRight = LOC_UNKNOWN;
69  Location bLocLine = LOC_UNKNOWN;
70 
71 
72 public:
73 
74  // Constants
75  static constexpr bool IS_FORWARD = true;
76  static constexpr bool IS_REVERSE = false;
77  static constexpr int DIM_UNKNOWN = -1;
78 
79  // Constructors
80  RelateEdge(
81  const RelateNode* node, const CoordinateXY* pt,
82  bool isA, bool isForward);
83 
84  RelateEdge(
85  const RelateNode* node, const CoordinateXY* pt,
86  bool isA);
87 
88  RelateEdge(
89  const RelateNode* node, const CoordinateXY* pt,
90  bool isA, Location locLeft, Location locRight, Location locLine);
91 
92  // Methods
93  static RelateEdge* create(
94  const RelateNode* node,
95  const CoordinateXY* dirPt,
96  bool isA, int dim, bool isForward);
97 
98  static std::size_t findKnownEdgeIndex(
99  std::vector<std::unique_ptr<RelateEdge>>& edges,
100  bool isA);
101 
102  static void setAreaInterior(
103  std::vector<std::unique_ptr<RelateEdge>>& edges,
104  bool isA);
105 
106  bool isInterior(bool isA, int position) const;
107 
108  Location location(bool isA, int position) const;
109 
110  int compareToEdge(const CoordinateXY* edgeDirPt) const;
111 
112  void setDimLocations(bool isA, int dim, Location loc);
113 
114  void setAreaInterior(bool isA);
115 
116  void setLocation(bool isA, int pos, Location loc);
117 
118  void setAllLocations(bool isA, Location loc);
119 
120  void setUnknownLocations(bool isA, Location loc);
121 
122  void merge(bool isA, int dim, bool isForward);
123 
124  std::string toString() const;
125 
126  friend std::ostream& operator<<(std::ostream& os, const RelateEdge& re);
127 
128 
129 private:
130 
131  // Methods
132  void mergeSideLocation(bool isA, int pos, Location loc);
133 
144  void mergeDimEdgeLoc(bool isA, Location locEdge);
145 
146  void setDimension(bool isA, int dimension);
147 
148  void setLeft(bool isA, Location loc);
149 
150  void setRight(bool isA, Location loc);
151 
152  void setOn(bool isA, Location loc);
153 
154  int dimension(bool isA) const;
155 
156  bool isKnown(bool isA) const;
157 
158  bool isKnown(bool isA, int pos) const;
159 
160  void setLocations(bool isA, Location locLeft, Location locRight, Location locLine);
161 
162  void setLocationsLine(bool isA);
163 
164  void setLocationsArea(bool isA, bool isForward);
165 
166  std::string labelString() const;
167 
168  std::string locationString(bool isA) const;
169 
170 
171 };
172 
173 } // namespace geos.operation.relateng
174 } // namespace geos.operation
175 } // namespace geos
176 
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: Angle.h:25