61 int aDim = OverlayLabel::DIM_UNKNOWN;
64 int bDim = OverlayLabel::DIM_UNKNOWN;
67 std::unique_ptr<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;
188 : aDim(OverlayLabel::DIM_UNKNOWN)
191 , bDim(OverlayLabel::DIM_UNKNOWN)
197 friend std::ostream& operator<<(std::ostream& os,
const Edge& e);
205 std::unique_ptr<geom::CoordinateSequence> getCoordinates()
226 return pts->getAt(index);
229 std::size_t size()
const
234 bool direction()
const
236 if (pts->size() < 2) {
246 int cmp0 = p0.compareTo(pn0);
247 if (cmp0 != 0) cmp = cmp0;
250 int cmp1 = p1.compareTo(pn1);
251 if (cmp1 != 0) cmp = cmp1;
255 throw util::GEOSException(
"Edge direction cannot be determined because endpoints are equal");
268 if (!getCoordinate(0).equals2D(edge2->getCoordinate(0))) {
271 if (!getCoordinate(1).equals2D(edge2->getCoordinate(1))) {
277 int dimension(
int geomIndex)
const
279 if (geomIndex == 0)
return aDim;
294 aIsHole = isHoleMerged(0,
this, edge);
295 bIsHole = isHoleMerged(1,
this, edge);
297 if (edge->aDim > aDim) aDim = edge->aDim;
298 if (edge->bDim > bDim) bDim = edge->bDim;
300 bool relDir = relativeDirection(edge);
301 int flipFactor = relDir ? 1 : -1;
302 aDepthDelta += flipFactor * edge->aDepthDelta;
303 bDepthDelta += flipFactor * edge->bDepthDelta;
308 initLabel(lbl, 0, aDim, aDepthDelta, aIsHole);
309 initLabel(lbl, 1, bDim, bDepthDelta, bIsHole);
312 bool compareTo(
const Edge& e)
const
316 if(ca.compareTo(cb) < 0) {
319 else if (ca.compareTo(cb) > 0) {
323 const geom::Coordinate& cca = getCoordinate(1);
324 const geom::Coordinate& ccb = e.getCoordinate(1);
325 if(cca.compareTo(ccb) < 0) {
328 else if (cca.compareTo(ccb) > 0) {