From d6a280c4fc73df694441baf325122e466a08d82c Mon Sep 17 00:00:00 2001 From: Martin Davis Date: Fri, 30 Jun 2023 15:05:12 -0700 Subject: [PATCH] Code cleanup --- .../jts/algorithm/RobustLineIntersector.java | 33 ++----------------- 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/modules/core/src/main/java/org/locationtech/jts/algorithm/RobustLineIntersector.java b/modules/core/src/main/java/org/locationtech/jts/algorithm/RobustLineIntersector.java index e6cd2ac3ce..21a5891773 100644 --- a/modules/core/src/main/java/org/locationtech/jts/algorithm/RobustLineIntersector.java +++ b/modules/core/src/main/java/org/locationtech/jts/algorithm/RobustLineIntersector.java @@ -223,46 +223,19 @@ private static Coordinate copy(Coordinate p) { /** * This method computes the actual value of the intersection point. - * To obtain the maximum precision from the intersection calculation, - * the coordinates are normalized by subtracting the minimum - * ordinate values (in absolute value). This has the effect of - * removing common significant digits from the calculation to - * maintain more bits of precision. + * It is rounded to the precision model if being used. */ private Coordinate intersection( Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2) { Coordinate intPt = intersectionSafe(p1, p2, q1, q2); - - /* - // TESTING ONLY - Coordinate intPtDD = CGAlgorithmsDD.intersection(p1, p2, q1, q2); - double dist = intPt.distance(intPtDD); - System.out.println(intPt + " - " + intPtDD + " dist = " + dist); - //intPt = intPtDD; - */ - - /** - * Due to rounding it can happen that the computed intersection is - * outside the envelopes of the input segments. Clearly this - * is inconsistent. - * This code checks this condition and forces a more reasonable answer - * - * MD - May 4 2005 - This is still a problem. Here is a failure case: - * - * LINESTRING (2089426.5233462777 1180182.3877339689, 2085646.6891757075 1195618.7333999649) - * LINESTRING (1889281.8148903656 1997547.0560044837, 2259977.3672235999 483675.17050843034) - * int point = (2097408.2633752143,1144595.8008114607) - * - * MD - Dec 14 2006 - This does not seem to be a failure case any longer - */ + if (! isInSegmentEnvelopes(intPt)) { // System.out.println("Intersection outside segment envelopes: " + intPt); // compute a safer result // copy the coordinate, since it may be rounded later intPt = copy(nearestEndpoint(p1, p2, q1, q2)); -// intPt = CentralEndpointIntersector.getIntersection(p1, p2, q1, q2); // System.out.println("Segments: " + this); // System.out.println("Snapped to " + intPt); @@ -288,7 +261,7 @@ private void checkDD(Coordinate p1, Coordinate p2, Coordinate q1, */ /** - * Computes a segment intersection using homogeneous coordinates. + * Computes a segment intersection. * Round-off error can cause the raw computation to fail, * (usually due to the segments being approximately parallel). * If this happens, a reasonable approximation is computed instead.