From c4625837599bca3fdddc9550b00f6faa80d24091 Mon Sep 17 00:00:00 2001 From: Martin Davis Date: Wed, 10 Apr 2024 18:27:46 -0700 Subject: [PATCH] Use isOnSegment in codebase --- .../java/org/locationtech/jts/algorithm/CGAlgorithms.java | 4 +--- .../jts/operation/valid/PolygonTopologyAnalyzer.java | 7 ++----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/modules/core/src/main/java/org/locationtech/jts/algorithm/CGAlgorithms.java b/modules/core/src/main/java/org/locationtech/jts/algorithm/CGAlgorithms.java index 5697bd2c5a..dad9032d41 100644 --- a/modules/core/src/main/java/org/locationtech/jts/algorithm/CGAlgorithms.java +++ b/modules/core/src/main/java/org/locationtech/jts/algorithm/CGAlgorithms.java @@ -179,12 +179,10 @@ public static int locatePointInRing(Coordinate p, Coordinate[] ring) */ public static boolean isOnLine(Coordinate p, Coordinate[] pt) { - LineIntersector lineIntersector = new RobustLineIntersector(); for (int i = 1; i < pt.length; i++) { Coordinate p0 = pt[i - 1]; Coordinate p1 = pt[i]; - lineIntersector.computeIntersection(p, p0, p1); - if (lineIntersector.hasIntersection()) { + if (PointLocation.isOnSegment(p, p0, p1)) { return true; } } diff --git a/modules/core/src/main/java/org/locationtech/jts/operation/valid/PolygonTopologyAnalyzer.java b/modules/core/src/main/java/org/locationtech/jts/operation/valid/PolygonTopologyAnalyzer.java index 4e2f8d21a8..2dac531ce5 100644 --- a/modules/core/src/main/java/org/locationtech/jts/operation/valid/PolygonTopologyAnalyzer.java +++ b/modules/core/src/main/java/org/locationtech/jts/operation/valid/PolygonTopologyAnalyzer.java @@ -14,16 +14,15 @@ import java.util.ArrayList; import java.util.List; -import org.locationtech.jts.algorithm.LineIntersector; import org.locationtech.jts.algorithm.Orientation; import org.locationtech.jts.algorithm.PointLocation; import org.locationtech.jts.algorithm.PolygonNodeTopology; -import org.locationtech.jts.algorithm.RobustLineIntersector; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.CoordinateArrays; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.LinearRing; import org.locationtech.jts.geom.Location; +import org.locationtech.jts.geom.MultiPolygon; import org.locationtech.jts.geom.Polygon; import org.locationtech.jts.noding.BasicSegmentString; import org.locationtech.jts.noding.MCIndexNoder; @@ -185,10 +184,8 @@ private static int ringIndexNext(Coordinate[] ringPts, int index) { * @return the intersection segment index, or -1 if no intersection is found */ private static int intersectingSegIndex(Coordinate[] ringPts, Coordinate pt) { - LineIntersector li = new RobustLineIntersector(); for (int i = 0; i < ringPts.length - 1; i++) { - li.computeIntersection(pt, ringPts[i], ringPts[i + 1]); - if (li.hasIntersection()) { + if (PointLocation.isOnSegment(pt, ringPts[i], ringPts[i + 1])) { //-- check if pt is the start point of the next segment if (pt.equals2D(ringPts[i + 1])) { return i + 1;