From 94ad1003e9b650aae43c54d66785bc9d4c404db0 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Fri, 24 Aug 2012 14:16:50 +0100 Subject: [PATCH] bugfix to store shortest distance to route within the the closest point no longer required --- WebContent/base/OSRM.Via.js | 4 ++-- WebContent/base/leaflet/L.Bugfixes.js | 34 +-------------------------- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/WebContent/base/OSRM.Via.js b/WebContent/base/OSRM.Via.js index a4faa9a19..9390d2782 100644 --- a/WebContent/base/OSRM.Via.js +++ b/WebContent/base/OSRM.Via.js @@ -78,7 +78,7 @@ drawDragMarker: function(event) { // get distance to route var minpoint = OSRM.G.route._current_route.route.closestLayerPoint( event.layerPoint ); - var min_dist = minpoint ? minpoint._sqDist : 1000; + var min_dist = minpoint ? minpoint.distance : 1000; // get distance to markers var mouse = event.latlng; @@ -109,7 +109,7 @@ drawDragMarker: function(event) { min_dist = 1000; } - if( min_dist < 400) { + if( min_dist < 20) { OSRM.G.markers.dragger.setPosition( OSRM.G.map.layerPointToLatLng(minpoint) ); OSRM.G.markers.dragger.show(); } else diff --git a/WebContent/base/leaflet/L.Bugfixes.js b/WebContent/base/leaflet/L.Bugfixes.js index 645593581..fc73c3786 100644 --- a/WebContent/base/leaflet/L.Bugfixes.js +++ b/WebContent/base/leaflet/L.Bugfixes.js @@ -19,36 +19,4 @@ or see http://www.gnu.org/licenses/agpl.txt. // [assorted bugfixes to Leaflet functions we use] -// return closest point on segment or distance to that point -L.LineUtil._sqClosestPointOnSegment = function (p, p1, p2, sqDist) { - var x = p1.x, - y = p1.y, - dx = p2.x - x, - dy = p2.y - y, - dot = dx * dx + dy * dy, - t; - - if (dot > 0) { - t = ((p.x - x) * dx + (p.y - y) * dy) / dot; - - if (t > 1) { - x = p2.x; - y = p2.y; - } else if (t > 0) { - x += dx * t; - y += dy * t; - } - } - - dx = p.x - x; - dy = p.y - y; - - // DS_CHANGE: modified return values - if(sqDist) - return dx*dx + dy*dy; - else { - var p = new L.Point(x,y); - p._sqDist = dx*dx + dy*dy; - return p; - } -}; +// none at the moment, thanks to Leaflet 0.4+ \ No newline at end of file