Skip to content

Commit

Permalink
Improve code for RelateNG self-noding check
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Aug 20, 2024
1 parent 28aa77d commit 7c26270
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,9 @@ public int locateWithDim(Coordinate pt) {
* Indicates whether the geometry requires self-noding
* for correct evaluation of specific spatial predicates.
* Self-noding is required for geometries which may self-cross
* - i.e. lines, and overlapping polygons in GeometryCollections.
* - i.e. lines, and overlapping elements in GeometryCollections.
* Self-noding is not required for polygonal geometries,
* since they can only touch at vertices.
* This ensures that the coordinates of nodes created by
* crossing segments are computed explicitly.
* This ensures that node locations match in situations
* where a self-crossing and mutual crossing occur at the same logical location.
* E.g. a self-crossing line tested against a single segment
* identical to one of the crossed segments.
*
* @return true if self-noding is required for this geometry
*/
Expand All @@ -267,7 +261,7 @@ public boolean isSelfNodingRequired() {
|| geom instanceof Polygon
|| geom instanceof MultiPolygon)
return false;
//-- GC with a single polygon does not need noding
//-- a GC with a single polygon does not need noding
if (hasAreas && geom.getNumGeometries() == 1)
return false;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,24 @@ public boolean isAreaArea() {
/**
* Indicates whether the input geometries require self-noding
* for correct evaluation of specific spatial predicates.
* Self-noding is required for geometries which may self-cross
* - i.e. lines, and overlapping polygons in GeometryCollections.
* Self-noding is not required for polygonal geometries,
* since they can only touch at vertices.
* This ensures that the coordinates of nodes created by
* crossing segments are computed explicitly.
* Self-noding is required for geometries which may
* have self-crossing linework.
* This causes the coordinates of nodes created by
* crossing segments to be computed explicitly.
* This ensures that node locations match in situations
* where a self-crossing and mutual crossing occur at the same logical location.
* E.g. a self-crossing line tested against a single segment
* The canonical example is a self-crossing line tested against a single segment
* identical to one of the crossed segments.
*
* @return true if self-noding is required
*/
public boolean isSelfNodingRequired() {
if (geomA.isSelfNodingRequired()) return true;
if (geomB.isSelfNodingRequired()) return true;
return predicate.requireSelfNoding();
if (predicate.requireSelfNoding()) {
if (geomA.isSelfNodingRequired()
|| geomB.isSelfNodingRequired())
return true;
}
return false;
}

public boolean isExteriorCheckRequired(boolean isA) {
Expand Down

0 comments on commit 7c26270

Please sign in to comment.