Ignore:
Timestamp:
2014-12-09T17:59:09+01:00 (11 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/actions/mapmode/ImproveWayAccuracyHelper.java

    r6830 r7776  
    143143            ++i;
    144144
    145             // Finding intersection of the segment with its altitude from p (c)
    146             EastNorth altitudeIntersection = Geometry.getSegmentAltituteIntersection(wpp.a.getEastNorth(),
    147                     wpp.b.getEastNorth(), pEN);
    148 
    149             if (altitudeIntersection != null) {
    150                 // If the segment intersects with the altitude from p
    151                 currentDistance = pEN.distance(altitudeIntersection);
    152 
    153                 // Making an angle too big to let this candidate win any others
     145            EastNorth a = wpp.a.getEastNorth();
     146            EastNorth b = wpp.b.getEastNorth();
     147           
     148            // Finding intersection of the segment with its altitude from p
     149            EastNorth altitudeIntersection = Geometry.closestPointToSegment(a, b, pEN);
     150            currentDistance = pEN.distance(altitudeIntersection);
     151           
     152            if (!altitudeIntersection.equals(a) && !altitudeIntersection.equals(b)) {
     153                // If the segment intersects with the altitude from p,
     154                // make an angle too big to let this candidate win any others
    154155                // having the same distance.
    155156                currentAngle = Double.MAX_VALUE;
    156 
    157157            } else {
    158                 // Otherwise: Distance is equal to the shortest distance from p
    159                 // to a or b
    160                 currentDistance = Math.min(pEN.distance(wpp.a.getEastNorth()),
    161                         pEN.distance(wpp.b.getEastNorth()));
    162 
    163                 // Measuring the angle
    164                 currentAngle = Math.abs(Geometry.getCornerAngle(
    165                         wpp.a.getEastNorth(), pEN, wpp.b.getEastNorth()));
     158                // Otherwise measure the angle
     159                currentAngle = Math.abs(Geometry.getCornerAngle(a, pEN, b));
    166160            }
    167161
Note: See TracChangeset for help on using the changeset viewer.