Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Jun 30, 2023
1 parent 83845f0 commit d6a280c
Showing 1 changed file with 3 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down

0 comments on commit d6a280c

Please sign in to comment.