Changeset 4251 in josm
- Timestamp:
- 2011-07-16T12:36:05+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r4149 r4251 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(), … … 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; … … 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();
Note:
See TracChangeset
for help on using the changeset viewer.