Changeset 4251 in josm


Ignore:
Timestamp:
2011-07-16T12:36:05+02:00 (10 years ago)
Author:
bastiK
Message:

applied #6598 - Parallelway mode reports wrong offset distance in statusline (patch by olejorgenb)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java

    r4149 r4251  
    405405                referenceSegment.getSecondNode().getEastNorth(), enp);
    406406
     407        // Note: d is the distance in _projected units_
    407408        double d = enp.distance(nearestPointOnRefLine);
     409        double realD = mv.getProjection().eastNorth2latlon(enp).greatCircleDistance(mv.getProjection().eastNorth2latlon(nearestPointOnRefLine));
     410        double snappedRealD = realD;
     411       
    408412        // TODO: abuse of isToTheRightSideOfLine function.
    409413        boolean toTheRight = Geometry.isToTheRightSideOfLine(referenceSegment.getFirstNode(),
     
    413417            // TODO: Very simple snapping
    414418            // - Snap steps and/or threshold relative to the distance?
    415             long closestWholeUnit = Math.round(d);
    416             if (Math.abs(closestWholeUnit - d) < snapThreshold) {
    417                 d = closestWholeUnit;
     419            long closestWholeUnit = Math.round(realD);
     420            if (Math.abs(closestWholeUnit - realD) < snapThreshold) {
     421                snappedRealD = closestWholeUnit;
    418422            } else {
    419                 d = closestWholeUnit + Math.signum(closestWholeUnit - d) * -0.5;
     423                snappedRealD = closestWholeUnit + Math.signum(closestWholeUnit - realD) * -0.5;
    420424            }
    421425        }
     426        d = snappedRealD * (d/realD); // convert back to projected distance. (probably ok on small scales)
    422427        helperLineStart = nearestPointOnRefLine;
    423428        helperLineEnd = enp;
     
    426431        }
    427432        pWays.changeOffset(d);
    428 
    429         Main.map.statusLine.setDist(Math.abs(d));
     433       
     434        Main.map.statusLine.setDist(Math.abs(snappedRealD));
    430435        Main.map.statusLine.repaint();
    431436        mv.repaint();
Note: See TracChangeset for help on using the changeset viewer.