60 int aDim = OverlayLabel::DIM_UNKNOWN;
63 int bDim = OverlayLabel::DIM_UNKNOWN;
66 std::shared_ptr<const geom::CoordinateSequence> pts;
86 static void initLabel(
OverlayLabel& lbl, uint8_t geomIndex,
int dim,
int depthDelta,
bool p_isHole);
88 static int labelDim(
int dim,
int depthDelta)
90 if (dim == geom::Dimension::False)
91 return OverlayLabel::DIM_NOT_PART;
93 if (dim == geom::Dimension::L)
94 return OverlayLabel::DIM_LINE;
97 bool isCollapse = (depthDelta == 0);
99 return OverlayLabel::DIM_COLLAPSE;
101 return OverlayLabel::DIM_BOUNDARY;
104 bool isHole(
int index)
const
111 bool isBoundary(
int geomIndex)
const
114 return aDim == OverlayLabel::DIM_BOUNDARY;
115 return bDim == OverlayLabel::DIM_BOUNDARY;
122 bool isShell(
int geomIndex)
const
124 if (geomIndex == 0) {
125 return (aDim == OverlayLabel::DIM_BOUNDARY && ! aIsHole);
127 return (bDim == OverlayLabel::DIM_BOUNDARY && ! bIsHole);
130 static Location locationRight(
int depthDelta)
132 int sgn = delSign(depthDelta);
134 case 0:
return Location::NONE;
135 case 1:
return Location::INTERIOR;
136 case -1:
return Location::EXTERIOR;
138 return Location::NONE;
141 static Location locationLeft(
int depthDelta)
144 int sgn = delSign(depthDelta);
146 case 0:
return Location::NONE;
147 case 1:
return Location::EXTERIOR;
148 case -1:
return Location::INTERIOR;
150 return Location::NONE;
153 static int delSign(
int depthDel)
155 if (depthDel > 0)
return 1;
156 if (depthDel < 0)
return -1;
162 if (info->getIndex() == 0) {
163 aDim = info->getDimension();
164 aIsHole = info->isHole();
165 aDepthDelta = info->getDepthDelta();
168 bDim = info->getDimension();
169 bIsHole = info->isHole();
170 bDepthDelta = info->getDepthDelta();
174 static bool isHoleMerged(
int geomIndex,
const Edge* edge1,
const Edge* edge2)
177 bool isShell1 = edge1->isShell(geomIndex);
178 bool isShell2 = edge2->isShell(geomIndex);
179 bool isShellMerged = isShell1 || isShell2;
181 return !isShellMerged;
187 Edge(
const std::shared_ptr<const geom::CoordinateSequence>& p_pts,
const EdgeSourceInfo* info,
bool isCurved);
189 friend std::ostream& operator<<(std::ostream& os,
const Edge& e);
193 bool isCurved()
const {
198 std::unique_ptr<geom::CoordinateSequence> getCoordinates()
const
210 std::shared_ptr<const geom::CoordinateSequence> releaseCoordinates()
217 const geom::CoordinateXY& getCoordinate(std::size_t index)
const
219 return pts->
getAt(index);
222 std::size_t size()
const
227 bool direction()
const
229 if (pts->size() < 2) {
233 const geom::CoordinateXY& p0 = getCoordinate(0);
234 const geom::CoordinateXY& pn0 = getCoordinate(pts->size() - 1);
236 const int cmp0 = p0.compareTo(pn0);
241 const geom::CoordinateXY& p1 = getCoordinate(1);
242 const geom::CoordinateXY& pn1 = getCoordinate(pts->size() - 2);
243 const int cmp1 = p1.compareTo(pn1);
248 throw util::GEOSException(
"Edge direction cannot be determined because endpoints are equal");
258 if (!getCoordinate(0).equals2D(edge2->getCoordinate(0))) {
261 if (!getCoordinate(1).equals2D(edge2->getCoordinate(1))) {
267 int dimension(
int geomIndex)
const
269 if (geomIndex == 0)
return aDim;
284 aIsHole = isHoleMerged(0,
this, edge);
285 bIsHole = isHoleMerged(1,
this, edge);
287 if (edge->aDim > aDim) aDim = edge->aDim;
288 if (edge->bDim > bDim) bDim = edge->bDim;
290 bool relDir = relativeDirection(edge);
291 int flipFactor = relDir ? 1 : -1;
292 aDepthDelta += flipFactor * edge->aDepthDelta;
293 bDepthDelta += flipFactor * edge->bDepthDelta;
298 initLabel(lbl, 0, aDim, aDepthDelta, aIsHole);
299 initLabel(lbl, 1, bDim, bDepthDelta, bIsHole);
302 bool compareTo(
const Edge& e)
const
304 const geom::CoordinateXY& ca = getCoordinate(0);
305 const geom::CoordinateXY& cb = e.getCoordinate(0);
306 if(ca.compareTo(cb) < 0) {
309 else if (ca.compareTo(cb) > 0) {
313 const geom::CoordinateXY& cca = getCoordinate(1);
314 const geom::CoordinateXY& ccb = e.getCoordinate(1);
315 if(cca.compareTo(ccb) < 0) {
318 else if (cca.compareTo(ccb) > 0) {