17#include <geos/geom/Coordinate.h>
18#include <geos/geom/CoordinateSequence.h>
19#include <geos/geom/Dimension.h>
20#include <geos/operation/overlayng/OverlayEdge.h>
21#include <geos/operation/overlayng/OverlayLabel.h>
22#include <geos/operation/overlayng/EdgeSourceInfo.h>
23#include <geos/util/GEOSException.h>
24#include <geos/export.h>
60 int aDim = OverlayLabel::DIM_UNKNOWN;
63 int bDim = OverlayLabel::DIM_UNKNOWN;
66 std::unique_ptr<geom::CoordinateSequence> pts;
85 static void initLabel(
OverlayLabel& lbl, uint8_t geomIndex,
int dim,
int depthDelta,
bool p_isHole);
87 static int labelDim(
int dim,
int depthDelta)
90 return OverlayLabel::DIM_NOT_PART;
93 return OverlayLabel::DIM_LINE;
96 bool isCollapse = (depthDelta == 0);
98 return OverlayLabel::DIM_COLLAPSE;
100 return OverlayLabel::DIM_BOUNDARY;
103 bool isHole(
int index)
const
110 bool isBoundary(
int geomIndex)
const
113 return aDim == OverlayLabel::DIM_BOUNDARY;
114 return bDim == OverlayLabel::DIM_BOUNDARY;
121 bool isShell(
int geomIndex)
const
123 if (geomIndex == 0) {
124 return (aDim == OverlayLabel::DIM_BOUNDARY && ! aIsHole);
126 return (bDim == OverlayLabel::DIM_BOUNDARY && ! bIsHole);
129 static Location locationRight(
int depthDelta)
131 int sgn = delSign(depthDelta);
134 case 1:
return Location::INTERIOR;
135 case -1:
return Location::EXTERIOR;
140 static Location locationLeft(
int depthDelta)
143 int sgn = delSign(depthDelta);
146 case 1:
return Location::EXTERIOR;
147 case -1:
return Location::INTERIOR;
152 static int delSign(
int depthDel)
154 if (depthDel > 0)
return 1;
155 if (depthDel < 0)
return -1;
161 if (info->getIndex() == 0) {
162 aDim = info->getDimension();
163 aIsHole = info->isHole();
164 aDepthDelta = info->getDepthDelta();
167 bDim = info->getDimension();
168 bIsHole = info->isHole();
169 bDepthDelta = info->getDepthDelta();
173 static bool isHoleMerged(
int geomIndex,
const Edge* edge1,
const Edge* edge2)
176 bool isShell1 = edge1->isShell(geomIndex);
177 bool isShell2 = edge2->isShell(geomIndex);
178 bool isShellMerged = isShell1 || isShell2;
180 return !isShellMerged;
187 : aDim(OverlayLabel::DIM_UNKNOWN)
190 , bDim(OverlayLabel::DIM_UNKNOWN)
196 friend std::ostream& operator<<(std::ostream& os,
const Edge& e);
204 std::unique_ptr<geom::CoordinateSequence> getCoordinates()
225 return pts->getAt(index);
228 std::size_t size()
const
233 bool direction()
const
235 if (pts->size() < 2) {
246 if (cmp0 != 0) cmp = cmp0;
250 if (cmp1 != 0) cmp = cmp1;
254 throw util::GEOSException(
"Edge direction cannot be determined because endpoints are equal");
267 if (!getCoordinate(0).equals2D(edge2->getCoordinate(0))) {
270 if (!getCoordinate(1).equals2D(edge2->getCoordinate(1))) {
276 int dimension(
int geomIndex)
const
278 if (geomIndex == 0)
return aDim;
293 aIsHole = isHoleMerged(0,
this, edge);
294 bIsHole = isHoleMerged(1,
this, edge);
296 if (edge->aDim > aDim) aDim = edge->aDim;
297 if (edge->bDim > bDim) bDim = edge->bDim;
299 bool relDir = relativeDirection(edge);
300 int flipFactor = relDir ? 1 : -1;
301 aDepthDelta += flipFactor * edge->aDepthDelta;
302 bDepthDelta += flipFactor * edge->bDepthDelta;
307 initLabel(lbl, 0, aDim, aDepthDelta, aIsHole);
308 initLabel(lbl, 1, bDim, bDepthDelta, bIsHole);
311 bool compareTo(
const Edge& e)
const
322 const geom::Coordinate& cca = getCoordinate(1);
323 const geom::Coordinate& ccb = e.getCoordinate(1);
324 if(cca.compareTo(ccb) < 0) {
327 else if (cca.compareTo(ccb) > 0) {
338bool EdgeComparator(
const Edge* a,
const Edge* b);
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
int compareTo(const Coordinate &other) const
TODO: deprecate this, move logic to CoordinateLessThen instead.
Definition: Coordinate.h:161
@ L
Dimension value of a curve (1).
Definition: Dimension.h:43
@ False
Dimension value of the empty geometry (-1).
Definition: Dimension.h:37
Definition: EdgeSourceInfo.h:38
Definition: operation/overlayng/Edge.h:55
bool relativeDirection(const Edge *edge2) const
Definition: operation/overlayng/Edge.h:264
void merge(const Edge *edge)
Definition: operation/overlayng/Edge.h:286
Definition: OverlayLabel.h:87
Base class for all GEOS exceptions.
Definition: GEOSException.h:37
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