From c0e86c47c2ca90e54c27ed133e06738baa3f8f60 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Fri, 11 May 2012 12:30:00 +0100 Subject: [PATCH] changed many names for jsonp routing functions --- WebContent/base/OSRM.Map.js | 5 +- WebContent/base/OSRM.Routes.js | 92 +++++++++++++++++++---------- WebContent/base/osrm/OSRM.Marker.js | 2 +- WebContent/gui/OSRM.RoutingGUI.js | 4 +- WebContent/routing/OSRM.Routing.js | 70 +++++++++++++++------- 5 files changed, 117 insertions(+), 56 deletions(-) diff --git a/WebContent/base/OSRM.Map.js b/WebContent/base/OSRM.Map.js index 78c77ac28..8cdb504d9 100644 --- a/WebContent/base/OSRM.Map.js +++ b/WebContent/base/OSRM.Map.js @@ -75,9 +75,10 @@ initPosition: function() { // map event handlers zoomed: function(e) { if(OSRM.G.dragging) - OSRM.Routing.getDragRoute(); + OSRM.Routing.getRoute_Dragging(); else - OSRM.Routing.getZoomRoute(); + OSRM.Routing.getRoute_Redraw(); +// OSRM.Routing.getRoute_History(); }, contextmenu: function(e) {;}, mousemove: function(e) { OSRM.Via.drawDragMarker(e); }, diff --git a/WebContent/base/OSRM.Routes.js b/WebContent/base/OSRM.Routes.js index b3919d518..6139263ca 100644 --- a/WebContent/base/OSRM.Routes.js +++ b/WebContent/base/OSRM.Routes.js @@ -18,6 +18,17 @@ or see http://www.gnu.org/licenses/agpl.txt. // OSRM route management (handles drawing of route geometry - current route, old route, unnamed route, highlight unnamed streets) // [this holds the route geometry] +//OSRM.SimplePosition = function(lat, lng, hint) { +// this.lat = lat; +// this.lng = lng; +// this.hint = hint; +//}; +//OSRM.extend( OSRM.SimplePosition,{ +//getLat: function() { return this.lat; }, +//getLng: function() { return this.lng; } +//}); + + OSRM.Route = function() { this._current_route = new OSRM.SimpleRoute("current" , {dashed:false} ); this._old_route = new OSRM.SimpleRoute("old", {dashed:false,color:"#123"} ); @@ -32,20 +43,24 @@ OSRM.Route = function() { this._noroute = OSRM.Route.ROUTE; - this._route_history_styles = [{dashed:false, color:'#FF0000', weight:5}, - {dashed:false, color:'#00FF00', weight:5}, - {dashed:false, color:'#0000FF', weight:5}, - {dashed:false, color:'#FF00FF', weight:5}, - {dashed:false, color:'#00FFFF', weight:5}, - {dashed:false, color:'#770000', weight:5}, - {dashed:false, color:'#007700', weight:5}, - {dashed:false, color:'#000077', weight:5}, - {dashed:false, color:'#770077', weight:5}, - {dashed:false, color:'#007777', weight:5} - ]; - this._route_history = []; - for(var i=0, size=this._route_history_styles.length; i0; i--) - this._route_history[i].setPositions( this._route_history[i-1].getPositions() ); - this._route_history[0].setPositions( this._current_route.getPositions() ); - } +// if( document.getElementById('option-show-previous-routes').checked == false) +// return; +// if(this.isShown() && this.isRoute()) { +// // move route and positions +// for(var i=this._history_routes-1; i>0; i--) { +// this._history_route[i].setPositions( this._history_route[i-1].getPositions() ); +// this._history_data[i] = this._history_data[i-1]; +// } +// // store new route and positions +// this._history_route[0].setPositions( this._current_route.getPositions() ); +// this._history_data[0] = []; +// var markers = OSRM.G.markers.route; +// for(var i=0,size=markers.length; i1) - OSRM.Routing.getDragRoute(); + OSRM.Routing.getRoute_Dragging(); OSRM.Geocoder.updateLocation( this.parent.label ); }, onDragStart: function(e) { diff --git a/WebContent/gui/OSRM.RoutingGUI.js b/WebContent/gui/OSRM.RoutingGUI.js index e17cf9a7e..e1fa88216 100644 --- a/WebContent/gui/OSRM.RoutingGUI.js +++ b/WebContent/gui/OSRM.RoutingGUI.js @@ -39,7 +39,7 @@ init: function() { document.getElementById("gui-reverse").onclick = OSRM.GUI.reverseRouting; document.getElementById("open-josm").onclick = OSRM.GUI.openJOSM; document.getElementById("open-osmbugs").onclick = OSRM.GUI.openOSMBugs; - document.getElementById("option-highlight-nonames").onclick = OSRM.Routing.getZoomRoute; + document.getElementById("option-highlight-nonames").onclick = OSRM.Routing.getRoute_Redraw; document.getElementById("option-show-previous-routes").onclick = OSRM.GUI.showPreviousRoutes; }, @@ -67,7 +67,7 @@ reverseRouting: function() { // recompute route if needed if( OSRM.G.route.isShown() ) { OSRM.G.markers.route.reverse(); - OSRM.Routing.getRoute(); // temporary route reversal for query, actual reversal done after receiving response + OSRM.Routing.getRoute_Reversed(); // temporary route reversal for query, actual reversal done after receiving response OSRM.G.markers.route.reverse(); OSRM.G.markers.highlight.hide(); OSRM.RoutingDescription.showSimple( OSRM.G.response ); diff --git a/WebContent/routing/OSRM.Routing.js b/WebContent/routing/OSRM.Routing.js index 375b936d2..82550aff3 100644 --- a/WebContent/routing/OSRM.Routing.js +++ b/WebContent/routing/OSRM.Routing.js @@ -92,7 +92,7 @@ showRoute: function(response) { } OSRM.Routing._updateHints(response); }, -showRouteZooming: function(response) { +showRouteRedraw: function(response) { if(!response) return; @@ -102,6 +102,15 @@ showRouteZooming: function(response) { } OSRM.Routing._updateHints(response); }, +showRouteHistory: function(response, history_id) { + if(!response) + return; + + if(response.status != 207) { + var positions = OSRM.RoutingGeometry._decode(response.route_geometry, 5); + OSRM.G.route._history_route[history_id].setPositions(positions); + } +}, @@ -116,33 +125,40 @@ getRoute: function() { return; } OSRM.JSONP.clear('dragging'); - OSRM.JSONP.clear('zooming'); + OSRM.JSONP.clear('redraw'); OSRM.JSONP.clear('route'); OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=true', OSRM.Routing.showRoute, OSRM.Routing.timeoutRoute, OSRM.DEFAULTS.JSONP_TIMEOUT, 'route'); }, -getZoomRoute: function() { +getRoute_Reversed: function() { if( OSRM.G.markers.route.length < 2 ) return; OSRM.JSONP.clear('dragging'); - OSRM.JSONP.clear('zooming'); - OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=true', OSRM.Routing.showRouteZooming, OSRM.Routing.timeoutRoute, OSRM.DEFAULTS.JSONP_TIMEOUT, 'zooming'); -}, -getDragRoute: function() { - OSRM.G.pending = !OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=false', OSRM.Routing.showRouteSimple, OSRM.Routing.timeoutRouteSimple, OSRM.DEFAULTS.JSONP_TIMEOUT, 'dragging');; -}, -getReverseRoute: function() { - if( OSRM.G.markers.route.length < 2 ) - return; - - OSRM.JSONP.clear('dragging'); - OSRM.JSONP.clear('zooming'); + OSRM.JSONP.clear('redraw'); OSRM.JSONP.clear('route'); OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=true', OSRM.Routing.showRoute, OSRM.Routing.timeoutRouteReverse, OSRM.DEFAULTS.JSONP_TIMEOUT, 'route'); }, +getRoute_Redraw: function() { + if( OSRM.G.markers.route.length < 2 ) + return; + + OSRM.JSONP.clear('dragging'); + OSRM.JSONP.clear('redraw'); + OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=true', OSRM.Routing.showRouteRedraw, OSRM.Routing.timeoutRoute, OSRM.DEFAULTS.JSONP_TIMEOUT, 'redraw'); +}, +getRoute_History: function() { + for(var i=0; i<10; i++) + if( OSRM.G.route._history_data[i].length > 0 ) { + OSRM.JSONP.clear('history'+i); + OSRM.JSONP.call(OSRM.Routing._buildHistoryCall(i)+'&instructions=false', OSRM.Routing.showRouteHistory, OSRM.JSONP.empty, OSRM.DEFAULTS.JSONP_TIMEOUT, 'history'+i, i); + } +}, +getRoute_Dragging: function() { + OSRM.G.pending = !OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=false', OSRM.Routing.showRouteSimple, OSRM.Routing.timeoutRouteSimple, OSRM.DEFAULTS.JSONP_TIMEOUT, 'dragging');; +}, draggingTimeout: function() { OSRM.G.markers.route[OSRM.G.dragid].hint = null; - OSRM.Routing.getDragRoute(); + OSRM.Routing.getRoute_Dragging(); }, _buildCall: function() { @@ -150,10 +166,24 @@ _buildCall: function() { source += '?z=' + OSRM.G.map.getZoom() + '&output=json&jsonp=%jsonp&geomformat=cmp'; if(OSRM.G.markers.checksum) source += '&checksum=' + OSRM.G.markers.checksum; - for(var i=0,size=OSRM.G.markers.route.length; i