Ignore:
Timestamp:
2014-12-09T17:59:09+01:00 (8 years ago)
Author:
akks
Message:

fix #10821: ImproveWayAccuracy produced self-intersecting ways
remove Geometry.getSegmentAltituteIntersection method (use closestPointToSegment)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r7509 r7776  
    824824        double yC = inv12*b1 + inv22*b2;
    825825        return new EastNorth(xC, yC);
    826     }
    827 
    828     /**
    829      * Returns the coordinate of intersection of segment sp1-sp2 and an altitude
    830      * to it starting at point ap. If the line defined with sp1-sp2 intersects
    831      * its altitude out of sp1-sp2, null is returned.
    832      *
    833      * @param sp1
    834      * @param sp2
    835      * @param ap
    836      * @return Intersection coordinate or null
    837      */
    838     public static EastNorth getSegmentAltituteIntersection(EastNorth sp1, EastNorth sp2, EastNorth ap) {
    839 
    840         CheckParameterUtil.ensureValidCoordinates(sp1, "sp1");
    841         CheckParameterUtil.ensureValidCoordinates(sp2, "sp2");
    842         CheckParameterUtil.ensureValidCoordinates(ap, "ap");
    843 
    844         Double segmentLenght = sp1.distance(sp2);
    845         Double altitudeAngle = getSegmentAngle(sp1, sp2) + Math.PI / 2;
    846 
    847         // Taking a random point on the altitude line (angle is known).
    848         EastNorth ap2 = new EastNorth(ap.east() + 1000
    849                 * Math.cos(altitudeAngle), ap.north() + 1000
    850                 * Math.sin(altitudeAngle));
    851 
    852         // Finding the intersection of two lines
    853         EastNorth resultCandidate = Geometry.getLineLineIntersection(sp1, sp2,
    854                 ap, ap2);
    855 
    856         // Filtering result
    857         if (resultCandidate != null
    858                 && resultCandidate.distance(sp1) * .999 < segmentLenght
    859                 && resultCandidate.distance(sp2) * .999 < segmentLenght) {
    860             return resultCandidate;
    861         } else {
    862             return null;
    863         }
    864826    }
    865827
Note: See TracChangeset for help on using the changeset viewer.