Skip to content

Commit

Permalink
Use isOnSegment in codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Apr 11, 2024
1 parent bce6bdb commit c462583
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c462583

Please sign in to comment.