8000 Fine-tune IsValidOp Ring Self-Intersection reporting by dr-jts · Pull Request #757 · locationtech/jts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fine-tune IsValidOp Ring Self-Intersection reporting #757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,9 @@ private int findInvalidIntersection(SegmentString ss0, int segIndex0,
/**
* Check for an intersection in the interior of both segments.
* Collinear intersections by definition contain an interior intersection.
* They occur in either a zero-width spike or gore,
* or adjacent rings.
*/
if (li.isProper() || li.getIntersectionNum() >= 2) {
return selfIntersectionCode(isSameSegString);
return TopologyValidationError.SELF_INTERSECTION;
}

/**
Expand All @@ -138,6 +136,8 @@ private int findInvalidIntersection(SegmentString ss0, int segIndex0,
/**
* Under OGC semantics, rings cannot self-intersect.
* So the intersection is invalid.
*
* The return of RING_SELF_INTERSECTION is to match the previous IsValid semantics.
*/
if (isSameSegString && ! isInvertedRingValid) {
return TopologyValidationError.RING_SELF_INTERSECTION;
Expand Down Expand Up @@ -170,7 +170,7 @@ private int findInvalidIntersection(SegmentString ss0, int segIndex0,
}
boolean hasCrossing = PolygonNode.isCrossing(intPt, e00, e01, e10, e11);
if (hasCrossing) {
return selfIntersectionCode(isSameSegString);
return TopologyValidationError.SELF_INTERSECTION;
}

/**
Expand Down Expand Up @@ -198,11 +198,6 @@ private int findInvalidIntersection(SegmentString ss0, int segIndex0,
return NO_INVALID_INTERSECTION;
}

private static int selfIntersectionCode(boolean isSameRing) {
return isSameRing ? TopologyValidationError.RING_SELF_INTERSECTION
: TopologyValidationError.SELF_INTERSECTION;
}

private boolean addDoubleTouch(SegmentString ss0, SegmentString ss1, Coordinate intPt) {
return PolygonRing.addTouch((PolygonRing) ss0.getData(), (PolygonRing) ss1.getData(), intPt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testValidSimplePolygon() {
}

public void testInvalidSimplePolygonRingSelfIntersection() {
checkInvalid( TopologyValidationError.RING_SELF_INTERSECTION,
checkInvalid( TopologyValidationError.SELF_INTERSECTION,
"POLYGON ((10 90, 90 10, 90 90, 10 10, 10 90))");
}

Expand All @@ -68,6 +68,11 @@ public void testInvalidPolygonInverted() {
"POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))");
}

public void testInvalidPolygonSelfCrossing() {
checkInvalid( TopologyValidationError.SELF_INTERSECTION,
"POLYGON ((70 250, 70 500, 80 400, 40 400, 70 250))");
}

public void testSimplePolygonHole() {
checkValid(
"POLYGON ((10 90, 90 90, 90 10, 10 10, 10 90), (60 20, 20 70, 90 90, 60 20))");
Expand Down
0