diff --git a/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java b/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
index 9ba8be6..964df7c 100644
|
a
|
b
|
public class ParallelWayAction extends MapMode implements AWTEventListener, MapV
|
| 404 | 404 | EastNorth nearestPointOnRefLine = Geometry.closestPointToLine(referenceSegment.getFirstNode().getEastNorth(), |
| 405 | 405 | referenceSegment.getSecondNode().getEastNorth(), enp); |
| 406 | 406 | |
| | 407 | // Note: d is the distance in _projected units_ |
| 407 | 408 | double d = enp.distance(nearestPointOnRefLine); |
| | 409 | double realD = mv.getProjection().eastNorth2latlon(enp).greatCircleDistance(mv.getProjection().eastNorth2latlon(nearestPointOnRefLine)); |
| | 410 | double snappedRealD = realD; |
| | 411 | |
| 408 | 412 | // TODO: abuse of isToTheRightSideOfLine function. |
| 409 | 413 | boolean toTheRight = Geometry.isToTheRightSideOfLine(referenceSegment.getFirstNode(), |
| 410 | 414 | referenceSegment.getFirstNode(), referenceSegment.getSecondNode(), new Node(enp)); |
| … |
… |
public class ParallelWayAction extends MapMode implements AWTEventListener, MapV
|
| 412 | 416 | if (snap) { |
| 413 | 417 | // TODO: Very simple snapping |
| 414 | 418 | // - 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; |
| 418 | 422 | } else { |
| 419 | | d = closestWholeUnit + Math.signum(closestWholeUnit - d) * -0.5; |
| | 423 | snappedRealD = closestWholeUnit + Math.signum(closestWholeUnit - realD) * -0.5; |
| 420 | 424 | } |
| 421 | 425 | } |
| | 426 | d = snappedRealD * (d/realD); // convert back to projected distance. (probably ok on small scales) |
| 422 | 427 | helperLineStart = nearestPointOnRefLine; |
| 423 | 428 | helperLineEnd = enp; |
| 424 | 429 | if (toTheRight) { |
| 425 | 430 | d = -d; |
| 426 | 431 | } |
| 427 | 432 | pWays.changeOffset(d); |
| 428 | | |
| 429 | | Main.map.statusLine.setDist(Math.abs(d)); |
| | 433 | |
| | 434 | Main.map.statusLine.setDist(Math.abs(snappedRealD)); |
| 430 | 435 | Main.map.statusLine.repaint(); |
| 431 | 436 | mv.repaint(); |
| 432 | 437 | } |