diff --git a/WebContent/OSRM.EventHandler.js b/WebContent/OSRM.EventHandler.js deleted file mode 100644 index a43033505..000000000 --- a/WebContent/OSRM.EventHandler.js +++ /dev/null @@ -1,61 +0,0 @@ -/* -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU AFFERO General Public License as published by -the Free Software Foundation; either version 3 of the License, or -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -or see http://www.gnu.org/licenses/agpl.txt. -*/ - -// OSRM EventHandler -// [adds simple event handling: other classes can derive from this class to acquire custom event handling] - - -OSRM.EventHandler = function() { - this._listeners = {}; -}; - -OSRM.extend( OSRM.EventHandler, { - - // add listener - addListener: function(type, listener) { - if( this._listeners[type] == undefined) - this._listeners[type] = []; - this._listeners[type].push(listener); - }, - - //remove event listener - removeListener: function(type, listener) { - if( this._listeners[type] != undefined) { - for(var i=0; i directly draw results - if(query.match(/^\s*[-+]?[0-9]*\.?[0-9]+\s*[,;]\s*[-+]?[0-9]*\.?[0-9]+\s*$/)){ - var coord = query.split(/[,;]/); - OSRM.Geocoder._onclickResult(marker_id, coord[0], coord[1]); - OSRM.Geocoder.updateAddress( marker_id ); - return; - } - - //build request for geocoder - var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json&json_callback=%jsonp" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&accept-language="+OSRM.Localization.current_language+"&q=" + query; - OSRM.JSONP.call( call, OSRM.Geocoder._showResults, OSRM.Geocoder._showResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_"+marker_id, {marker_id:marker_id,query:query} ); -}, - - -// helper function for clicks on geocoder search results -_onclickResult: function(marker_id, lat, lon) { - var index; - if( marker_id == OSRM.C.SOURCE_LABEL ) - index = OSRM.G.markers.setSource( new L.LatLng(lat, lon) ); - else if( marker_id == OSRM.C.TARGET_LABEL ) - index = OSRM.G.markers.setTarget( new L.LatLng(lat, lon) ); - else - return; - - OSRM.G.markers.route[index].show(); - OSRM.G.markers.route[index].centerView(); - if( OSRM.G.markers.route.length > 1 ) - OSRM.Routing.getRoute(); -}, - - -// process geocoder response -_showResults: function(response, parameters) { - if(!response){ - OSRM.Geocoder._showResults_Empty(parameters); - return; - } - - if(response.length == 0) { - OSRM.Geocoder._showResults_Empty(parameters); - return; - } - - // show first result - OSRM.Geocoder._onclickResult(parameters.marker_id, response[0].lat, response[0].lon); - if( OSRM.G.markers.route.length > 1 ) // if a route is displayed, we don't need to show other possible geocoding results - return; - - // show possible results for input - var html = ""; - html += ''; - for(var i=0; i < response.length; i++){ - var result = response[i]; - - //odd or even ? - var rowstyle='results-odd'; - if(i%2==0) { rowstyle='results-even'; } - - html += ''; - html += ''; - html += '"; - } - html += '
'+(i+1)+'.'; - - if(result.display_name){ - html += '
'+result.display_name+'
'; - } - html += "
'; - - document.getElementById('information-box-header').innerHTML = - "
"+OSRM.loc("SEARCH_RESULTS")+"
" + - "
("+OSRM.loc("FOUND_X_RESULTS").replace(/%i/,response.length)+")
"; - "
(found "+response.length+" results)"+"
"; - document.getElementById('information-box').innerHTML = html; -}, -_showResults_Empty: function(parameters) { - document.getElementById('information-box-header').innerHTML = - "
"+OSRM.loc("SEARCH_RESULTS")+"
" + - "
("+OSRM.loc("FOUND_X_RESULTS").replace(/%i/,0)+")
"; - if(parameters.marker_id == OSRM.C.SOURCE_LABEL) - document.getElementById('information-box').innerHTML = "
"+OSRM.loc("NO_RESULTS_FOUND_SOURCE")+": "+parameters.query +"
"; - else if(parameters.marker_id == OSRM.C.TARGET_LABEL) - document.getElementById('information-box').innerHTML = "
"+OSRM.loc("NO_RESULTS_FOUND_TARGET")+": "+parameters.query +"
"; - else - document.getElementById('information-box').innerHTML = "
"+OSRM.loc("NO_RESULTS_FOUND")+": "+parameters.query +"
"; -}, -_showResults_Timeout: function() { - document.getElementById('information-box-header').innerHTML = - "
"+OSRM.loc("SEARCH_RESULTS")+"
" + - "
("+OSRM.loc("FOUND_X_RESULTS").replace(/%i/,0)+")
"; - document.getElementById('information-box').innerHTML = "
"+OSRM.loc("TIMED_OUT")+"
"; -}, - - -// [reverse geocoding] - -//update geo coordinates in input boxes -updateLocation: function(marker_id) { - if (marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource()) { - document.getElementById("gui-input-source").value = OSRM.G.markers.route[0].getLat().toFixed(6) + ", " + OSRM.G.markers.route[0].getLng().toFixed(6); - } else if (marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget()) { - document.getElementById("gui-input-target").value = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getLat().toFixed(6) + ", " + OSRM.G.markers.route[OSRM.G.markers.route.length-1].getLng().toFixed(6); - } -}, - - -// update address in input boxes -updateAddress: function(marker_id, do_fallback_to_lat_lng) { - // build request for reverse geocoder - var lat = null; - var lng = null; - - if(marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource()) { - lat = OSRM.G.markers.route[0].getLat(); - lng = OSRM.G.markers.route[0].getLng(); - } else if(marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget() ) { - lat = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getLat(); - lng = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getLng(); - } else - return; - - var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json&json_callback=%jsonp" + "&accept-language="+OSRM.Localization.current_language + "&lat=" + lat + "&lon=" + lng; - OSRM.JSONP.call( call, OSRM.Geocoder._showReverseResults, OSRM.Geocoder._showReverseResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "reverse_geocoder_"+marker_id, {marker_id:marker_id, do_fallback: do_fallback_to_lat_lng} ); -}, - - -// processing JSONP response of reverse geocoder -_showReverseResults: function(response, parameters) { - if(!response) { - OSRM.Geocoder._showReverseResults_Timeout(response, parameters); - return; - } - - if(response.address == undefined) { - OSRM.Geocoder._showReverseResults_Timeout(response, parameters); - return; - } - - // build reverse geocoding address - var used_address_data = 0; - var address = ""; - if( response.address.road) { - address += response.address.road; - used_address_data++; - } - if( response.address.city ) { - if( used_address_data > 0 ) - address += ", "; - address += response.address.city; - used_address_data++; - } else if( response.address.village ) { - if( used_address_data > 0 ) - address += ", "; - address += response.address.village; - used_address_data++; - } - if( used_address_data < 2 && response.address.country ) { - if( used_address_data > 0 ) - address += ", "; - address += response.address.country; - used_address_data++; - } - if( used_address_data == 0 ) { - OSRM.Geocoder._showReverseResults_Timeout(response, parameters); - return; - } - - // add result to DOM - if(parameters.marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource() ) - document.getElementById("gui-input-source").value = address; - else if(parameters.marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget() ) - document.getElementById("gui-input-target").value = address; -}, -_showReverseResults_Timeout: function(response, parameters) { - if(!parameters.do_fallback) - return; - - OSRM.Geocoder.updateLocation(parameters.marker_id); -} - -}; diff --git a/WebContent/OSRM.JSONP.js b/WebContent/OSRM.JSONP.js deleted file mode 100644 index cd039987c..000000000 --- a/WebContent/OSRM.JSONP.js +++ /dev/null @@ -1,104 +0,0 @@ -/* -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU AFFERO General Public License as published by -the Free Software Foundation; either version 3 of the License, or -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -or see http://www.gnu.org/licenses/agpl.txt. -*/ - -// OSRM JSONP call wrapper -// [wrapper for JSONP calls with DOM cleaning, fencing, timout handling] - -OSRM.JSONP = { - - // storage to keep track of unfinished JSONP calls - fences: {}, - callbacks: {}, - timeouts: {}, - timers: {}, - - - // default callback routines - late: function() {}, - empty: function() {}, - - - // init JSONP call - call: function(source, callback_function, timeout_function, timeout, id, parameters) { - // only one active JSONP call per id - if (OSRM.JSONP.fences[id] == true) - return false; - OSRM.JSONP.fences[id] = true; - - // wrap timeout function - OSRM.JSONP.timeouts[id] = function(response) { - console.log("timeout",id); - try { - timeout_function(response, parameters); - } finally { - OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions - OSRM.JSONP.timeouts[id] = OSRM.JSONP.empty; - OSRM.JSONP.fences[id] = undefined; // clean fence - } - }; - - // wrap callback function - OSRM.JSONP.callbacks[id] = function(response) { - clearTimeout(OSRM.JSONP.timers[id]); // clear timeout timer - OSRM.JSONP.timers[id] = undefined; - - try { - callback_function(response, parameters); // actual wrapped callback - } finally { - OSRM.JSONP.callbacks[id] = OSRM.JSONP.empty; // clean functions - OSRM.JSONP.timeouts[id] = OSRM.JSONP.late; - OSRM.JSONP.fences[id] = undefined; // clean fence - } - }; - - // clean DOM - var jsonp = document.getElementById('jsonp_'+id); - if(jsonp) - jsonp.parentNode.removeChild(jsonp); - - // add script to DOM - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.id = 'jsonp_'+id; - script.src = source.replace(/%jsonp/,"OSRM.JSONP.callbacks."+id); - document.head.appendChild(script); - - // start timeout timer - OSRM.JSONP.timers[id] = setTimeout(OSRM.JSONP.timeouts[id], timeout); - return true; - }, - - clear: function(id) { - clearTimeout(OSRM.JSONP.timers[id]); // clear timeout timer - OSRM.JSONP.callbacks[id] = OSRM.JSONP.empty; // clean functions - OSRM.JSONP.timeouts[id] = OSRM.JSONP.empty; - OSRM.JSONP.fences[id] = undefined; // clean fence - - // clean DOM - var jsonp = document.getElementById('jsonp_'+id); - if(jsonp) - jsonp.parentNode.removeChild(jsonp); - }, - - // reset all data - reset: function() { - OSRM.JSONP.fences = {}; - OSRM.JSONP.callbacks = {}; - OSRM.JSONP.timeouts = {}; - OSRM.JSONP.timers = {}; - } -}; diff --git a/WebContent/OSRM.Map.js b/WebContent/OSRM.Map.js deleted file mode 100644 index a9d60c421..000000000 --- a/WebContent/OSRM.Map.js +++ /dev/null @@ -1,142 +0,0 @@ -/* -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU AFFERO General Public License as published by -the Free Software Foundation; either version 3 of the License, or -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -or see http://www.gnu.org/licenses/agpl.txt. -*/ - -// OSRM map handling -// [initialization, event handling, centering relative to UI] - -// will hold the map object -OSRM.GLOBALS.map = null; - - -// map view/model -// [extending Leaflet L.Map with setView/fitBounds methods that respect UI visibility] -OSRM.MapView = L.Map.extend({ - setViewUI: function(position, zoom, no_animation) { - if( OSRM.GUI.visible == true ) { - var point = this.project( position, zoom); - point.x-=OSRM.GUI.width/2; - position = this.unproject(point,zoom); - } - this.setView( position, zoom, no_animation); - }, - fitBoundsUI: function(bounds) { - var southwest = bounds.getSouthWest(); - var northeast = bounds.getNorthEast(); - var zoom = this.getBoundsZoom(bounds); - var sw_point = this.project( southwest, zoom); - if( OSRM.GUI.visible == true ) - sw_point.x-=OSRM.GUI.width+20; - else - sw_point.x-=20; - sw_point.y+=20; - var ne_point = this.project( northeast, zoom); - ne_point.y-=20; - sw_point.x+=20; - bounds.extend( this.unproject(sw_point,zoom) ); - bounds.extend( this.unproject(ne_point,zoom) ); - this.fitBounds( bounds ); - }, - getCenterUI: function(unbounded) { - var viewHalf = this.getSize(); - if( OSRM.GUI.visible == true ) - viewHalf.x += OSRM.GUI.width; - var centerPoint = this._getTopLeftPoint().add(viewHalf.divideBy(2)); - - return this.unproject(centerPoint, this._zoom, unbounded); - } -}); - - -// map controller -// [map initialization, event handling] -OSRM.Map = { - -// map initialization -init: function() { - // check if GUI is initialized! - if(OSRM.GUI.visible == null) - OSRM.GUI.init(); - - // setup tile servers - var tile_servers = OSRM.DEFAULTS.TILE_SERVERS; - var base_maps = {}; - for(var i=0, size=tile_servers.length; i routes are not hidden during zoom - fadeAnimation: false - }); - - // add layer control - var layersControl = new L.Control.Layers(base_maps, {}); - OSRM.G.map.addControl(layersControl); - - // move zoom markers - OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.left=(OSRM.GUI.width+10)+"px"; - OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px"; - - // map events - OSRM.G.map.on('zoomend', OSRM.Map.zoomed ); - OSRM.G.map.on('click', OSRM.Map.click ); - OSRM.G.map.on('contextmenu', OSRM.Map.contextmenu ); - OSRM.G.map.on('mousemove', OSRM.Map.mousemove ); -}, - -// init map position and zoom (respect UI visibility / use browser geolocation) -initPosition: function() { - var position = new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE); - OSRM.G.map.setViewUI( position, OSRM.DEFAULTS.ONLOAD_ZOOM_LEVEL, true); - if (navigator.geolocation && document.URL.indexOf("file://") == -1) // convenience: FF does not save access rights for local files - navigator.geolocation.getCurrentPosition(OSRM.Map.geolocationResponse); -}, - -// map event handlers -zoomed: function(e) { - if(OSRM.G.dragging) - OSRM.Routing.getDragRoute(); - else - OSRM.Routing.getZoomRoute(); -}, -contextmenu: function(e) {;}, -mousemove: function(e) { OSRM.Via.drawDragMarker(e); }, -click: function(e) { - if( !OSRM.G.markers.hasSource() ) { - var index = OSRM.G.markers.setSource( e.latlng ); - OSRM.Geocoder.updateAddress( OSRM.C.SOURCE_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG ); - OSRM.G.markers.route[index].show(); - OSRM.G.markers.route[index].centerView( OSRM.G.map.getZoom() ); - OSRM.Routing.getRoute(); - } else if( !OSRM.G.markers.hasTarget() ) { - var index = OSRM.G.markers.setTarget( e.latlng ); - OSRM.Geocoder.updateAddress( OSRM.C.TARGET_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG ); - OSRM.G.markers.route[index].show(); - OSRM.G.markers.route[index].centerView( OSRM.G.map.getZoom() ); - OSRM.Routing.getRoute(); - } -}, -geolocationResponse: function(response) { - var latlng = new L.LatLng(response.coords.latitude, response.coords.longitude); - OSRM.G.map.setViewUI(latlng, OSRM.DEFAULTS.ZOOM_LEVEL ); -} -}; diff --git a/WebContent/OSRM.Markers.js b/WebContent/OSRM.Markers.js deleted file mode 100644 index ccd2f975b..000000000 --- a/WebContent/OSRM.Markers.js +++ /dev/null @@ -1,281 +0,0 @@ -/* -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU AFFERO General Public License as published by -the Free Software Foundation; either version 3 of the License, or -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -or see http://www.gnu.org/licenses/agpl.txt. -*/ - -// OSRM markers -// [base marker class, derived highlight marker and route marker classes, marker management] - - -// base marker class (wraps Leaflet markers) -OSRM.Marker = function( label, style, position ) { - this.label = label ? label : "marker"; - this.position = position ? position : new L.LatLng(0,0); - - this.marker = new L.MouseMarker( this.position, style ); - this.marker.parent = this; - - this.shown = false; - this.hint = null; -}; -OSRM.extend( OSRM.Marker,{ -show: function() { - OSRM.G.map.addLayer(this.marker); - this.shown = true; -}, -hide: function() { - OSRM.G.map.removeLayer(this.marker); - this.shown = false; -}, -setPosition: function( position ) { - this.position = position; - this.marker.setLatLng( position ); - this.hint = null; -}, -getPosition: function() { - return this.position; -}, -getLat: function() { - return this.position.lat; -}, -getLng: function() { - return this.position.lng; -}, -isShown: function() { - return this.shown; -}, -centerView: function(zoom) { - if( zoom == undefined ) - zoom = OSRM.DEFAULTS.ZOOM_LEVEL; - OSRM.G.map.setViewUI( this.position, zoom ); -}, -toString: function() { - return "OSRM.Marker: \""+this.label+"\", "+this.position+")"; -} -}); - - -// route marker class (draggable, invokes route drawing routines) -OSRM.RouteMarker = function ( label, style, position ) { - style.baseicon = style.icon; - OSRM.RouteMarker.prototype.base.constructor.apply( this, arguments ); - this.label = label ? label : "route_marker"; - - this.marker.on( 'click', this.onClick ); - this.marker.on( 'drag', this.onDrag ); - this.marker.on( 'dragstart', this.onDragStart ); - this.marker.on( 'dragend', this.onDragEnd ); -}; -OSRM.inheritFrom( OSRM.RouteMarker, OSRM.Marker ); -OSRM.extend( OSRM.RouteMarker, { -onClick: function(e) { - for( var i=0; i1) - OSRM.Routing.getDragRoute(); - OSRM.Geocoder.updateLocation( this.parent.label ); -}, -onDragStart: function(e) { - OSRM.G.dragging = true; - this.switchIcon(this.options.dragicon); - - // store id of dragged marker - for( var i=0; i this.route.length-2 ) - return -1; - - this.route.splice(id+1,0, new OSRM.RouteMarker(OSRM.C.VIA_LABEL, {draggable:true,icon:OSRM.G.icons['marker-via'],dragicon:OSRM.G.icons['marker-via-drag']}, position)); - return id+1; -}, -removeMarker: function(id) { - if( id >= this.route.length ) - return; - - // also remove vias if source or target are removed - if( id==0 && this.route[0].label == OSRM.C.SOURCE_LABEL ) { - this.removeVias(); - document.getElementById('gui-input-source').value = ""; - document.getElementById('information-box').innerHTML = ""; - document.getElementById('information-box-header').innerHTML = ""; - document.getElementById('gui-delete-source').style.visibility = "hidden"; - } else if( id == this.route.length-1 && this.route[ this.route.length-1 ].label == OSRM.C.TARGET_LABEL ) { - this.removeVias(); - id = this.route.length-1; - document.getElementById('gui-input-target').value = ""; - document.getElementById('information-box').innerHTML = ""; - document.getElementById('information-box-header').innerHTML = ""; - document.getElementById('gui-delete-target').style.visibility = "hidden"; - } - - this.route[id].hide(); - this.route.splice(id, 1); -}, -reverseMarkers: function() { - var size = this.route.length; - - // invert route, if a route is shown - if( size > 1 ) { - // switch positions in nodes - var temp_position = this.route[0].getPosition(); - this.route[0].setPosition( this.route[size-1].getPosition() ); - OSRM.G.markers.route[size-1].setPosition( temp_position ); - // switch nodes in array - var temp_node = OSRM.G.markers.route[0]; - OSRM.G.markers.route[0] = OSRM.G.markers.route[size-1]; - OSRM.G.markers.route[size-1] = temp_node; - // reverse route - OSRM.G.markers.route.reverse(); - // clear information (both delete markers stay visible) - document.getElementById('information-box').innerHTML = ""; - document.getElementById('information-box-header').innerHTML = ""; - - // invert marker, if only one marker is shown (implicit clear of information / delete markers) - } else if( size > 0 ) { - var position = this.route[0].getPosition(); - var label = this.route[0].label; - this.removeMarker(0); - if( label == OSRM.C.TARGET_LABEL ) - this.setSource( position ); - else if( label == OSRM.C.SOURCE_LABEL ) - this.setTarget( position ); - this.route[0].show(); - } - -}, -hasSource: function() { - if( OSRM.G.markers.route[0] && OSRM.G.markers.route[0].label == OSRM.C.SOURCE_LABEL ) - return true; - return false; -}, -hasTarget: function() { - if( OSRM.G.markers.route[OSRM.G.markers.route.length-1] && OSRM.G.markers.route[OSRM.G.markers.route.length-1].label == OSRM.C.TARGET_LABEL ) - return true; - return false; -} -}); diff --git a/WebContent/OSRM.Route.js b/WebContent/OSRM.Route.js deleted file mode 100644 index 54a1097e8..000000000 --- a/WebContent/OSRM.Route.js +++ /dev/null @@ -1,193 +0,0 @@ -/* -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU AFFERO General Public License as published by -the Free Software Foundation; either version 3 of the License, or -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -or see http://www.gnu.org/licenses/agpl.txt. -*/ - -// OSRM routes -// [drawing of all types of route geometry] - - -// simple route class (wraps Leaflet Polyline) -OSRM.SimpleRoute = function (label, style) { - this.label = (label ? label : "route"); - this.route = new L.DashedPolyline(); - this.route.setLatLngs( [] ); - if(style) this.route.setStyle( style ); - - this.shown = false; -}; -OSRM.extend( OSRM.SimpleRoute,{ -show: function() { - OSRM.G.map.addLayer(this.route); - this.shown = true; -}, -hide: function() { - OSRM.G.map.removeLayer(this.route); - this.shown = false; -}, -isShown: function() { - return this.shown; -}, -getPoints: function() { - return this.route._originalPoints; -}, -getPositions: function() { - return this.route.getLatLngs(); -}, -setPositions: function(positions) { - this.route.setLatLngs( positions ); -}, -setStyle: function(style) { - this.route.setStyle(style); -}, -centerView: function() { - var bounds = new L.LatLngBounds( this.getPositions() ); - OSRM.g.map.fitBoundsUI( bounds ); -}, -toString: function() { - return "OSRM.Route("+ this.label + ", " + this.route.getLatLngs().length + " points)"; -} -}); - - -// multiroute class (wraps Leaflet LayerGroup to hold several disjoint routes) -OSRM.MultiRoute = function (label) { - this.label = (label ? label : "multiroute"); - this.route = new L.LayerGroup(); - - this.shown = false; -}; -OSRM.extend( OSRM.MultiRoute,{ -show: function() { - OSRM.G.map.addLayer(this.route); - this.shown = true; -}, -hide: function() { - OSRM.G.map.removeLayer(this.route); - this.shown = false; -}, -isShown: function() { - return this.shown; -}, -addRoute: function(positions) { - var line = new L.DashedPolyline( positions ); - line.on('click', function(e) { OSRM.G.route.fire('click',e); }); - this.route.addLayer( line ); -}, -clearRoutes: function() { - this.route.clearLayers(); -}, -setStyle: function(style) { - this.route.invoke('setStyle', style); -}, -toString: function() { - return "OSRM.MultiRoute("+ this.label + ")"; -} -}); - - -// route management (handles drawing of route geometry - current route, old route, unnamed route, highlight unnamed streets) -// [this holds the route geometry] -OSRM.Route = function() { - this._current_route = new OSRM.SimpleRoute("current" , {dashed:false} ); - this._old_route = new OSRM.SimpleRoute("old", {dashed:false,color:"#123"} ); - this._unnamed_route = new OSRM.MultiRoute("unnamed"); - - this._current_route_style = {dashed:false,color:'#0033FF', weight:5}; - this._current_noroute_style = {dashed:true, color:'#222222', weight:2}; - this._old_route_style = {dashed:false,color:'#112233', weight:5}; - this._old_noroute_style = {dashed:true, color:'#000000', weight:2}; - this._unnamed_route_style = {dashed:false, color:'#FF00FF', weight:10}; - this._old_unnamed_route_style = {dashed:false, color:'#990099', weight:10}; - - this._noroute = OSRM.Route.ROUTE; -}; -OSRM.Route.NOROUTE = true; -OSRM.Route.ROUTE = false; -OSRM.extend( OSRM.Route,{ - - showRoute: function(positions, noroute) { - this._noroute = noroute; - this._current_route.setPositions( positions ); - if ( this._noroute == OSRM.Route.NOROUTE ) - this._current_route.setStyle( this._current_noroute_style ); - else - this._current_route.setStyle( this._current_route_style ); - this._current_route.show(); - //this._raiseUnnamedRoute(); - }, - hideRoute: function() { - this._current_route.hide(); - this._unnamed_route.hide(); - }, - hideAll: function() { - this._current_route.hide(); - this._unnamed_route.hide(); - this._old_route.hide(); - this._noroute = OSRM.Route.ROUTE; - }, - - showUnnamedRoute: function(positions) { - this._unnamed_route.clearRoutes(); - for(var i=0; i easier way in will be available Leaflet 0.4 - _raiseUnnamedRoute: function() { - if(this._unnamed_route.isShown()) { - this._unnamed_route.hide(); - this._unnamed_route.show(); - } - }, - showOldRoute: function() { - this._old_route.setPositions( this._current_route.getPositions() ); - if ( this._noroute == OSRM.Route.NOROUTE) - this._old_route.setStyle( this._old_noroute_style ); - else - this._old_route.setStyle( this._old_route_style ); - this._old_route.show(); - this._raiseUnnamedRoute(); - // change color of unnamed route highlighting - no separate object as dragged route does not have unnamed route highlighting - this._unnamed_route.setStyle( this._old_unnamed_route_style ); - }, - hideOldRoute: function() { - this._old_route.hide(); - }, - - isShown: function() { - return this._current_route.isShown(); - }, - isRoute: function() { - return !(this._noroute); - }, - getPositions: function() { - return this._current_route.getPositions(); - }, - getPoints: function() { - return this._current_route.getPoints(); - }, - fire: function(type,event) { - this._current_route.route.fire(type,event); - }, - centerView: function() { - this._current_route.centerView(); - } -}); diff --git a/WebContent/OSRM.Utils.js b/WebContent/OSRM.Utils.js deleted file mode 100644 index 9c4decdc7..000000000 --- a/WebContent/OSRM.Utils.js +++ /dev/null @@ -1,67 +0,0 @@ -/* -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU AFFERO General Public License as published by -the Free Software Foundation; either version 3 of the License, or -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -or see http://www.gnu.org/licenses/agpl.txt. -*/ - -// OSRM utility functions -// [mixed functions] - - -OSRM.Utils = { - -// [human readabilty functions] - -// human readable time -secondsToTime: function(seconds){ - seconds = parseInt(seconds); - minutes = parseInt(seconds/60); - seconds = seconds%60; - hours = parseInt(minutes/60); - minutes = minutes%60; - if(hours==0){ - return minutes + ' ' + 'min'; - } - else{ - return hours + ' ' + 'h' + ' ' + minutes + ' ' + 'min'; - } -}, -//human readable distance -metersToDistance: function(distance){ - distance = parseInt(distance); - - if(distance >= 100000){ return (parseInt(distance/1000))+' ' + 'km'; } - else if(distance >= 10000){ return (parseInt(distance/1000).toFixed(1))+' ' + 'km'; } - else if(distance >= 1000){ return (parseFloat(distance/1000).toFixed(2))+' ' + 'km'; } - else{ return distance+' ' + 'm'; } -}, - - -// [verification routines] - -// verify angles -isLatitude: function(value) { - if( value >=-90 && value <=90) - return true; - else - return false; -}, -isLongitude: function(value) { - if( value >=-180 && value <=180) - return true; - else - return false; -} - -}; \ No newline at end of file diff --git a/WebContent/OSRM.Via.js b/WebContent/OSRM.Via.js deleted file mode 100644 index 9775d3b3d..000000000 --- a/WebContent/OSRM.Via.js +++ /dev/null @@ -1,121 +0,0 @@ -/* -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU AFFERO General Public License as published by -the Free Software Foundation; either version 3 of the License, or -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -or see http://www.gnu.org/licenses/agpl.txt. -*/ - -// OSRM via marker routines -// [find correct position for a via marker] - -// store location of via points returned by server -OSRM.GLOBALS.via_points = []; - - -OSRM.Via = { - -// find route segment of current route geometry that is closest to the new via node (marked by index of its endpoint) -_findNearestRouteSegment: function( new_via ) { - var min_dist = Number.MAX_VALUE; - var min_index = undefined; - - var p = OSRM.G.map.latLngToLayerPoint( new_via ); - var positions = OSRM.G.route.getPoints(); - for(var i=1; i nearest_index) { - new_via_index = i; - break; - } - } - - // add via node - return new_via_index; -}, - - -//function that draws a drag marker -dragTimer: new Date(), - -drawDragMarker: function(event) { - if( OSRM.G.route.isShown() == false) - return; - if( OSRM.G.dragging == true ) - return; - - // throttle computation - if( (new Date() - OSRM.Via.dragTimer) < 25 ) - return; - OSRM.Via.dragTimer = new Date(); - - // get distance to route - var minpoint = OSRM.G.route._current_route.route.closestLayerPoint( event.layerPoint ); - var min_dist = minpoint ? minpoint._sqDist : 1000; - - // get distance to markers - var mouse = event.latlng; - for(var i=0, size=OSRM.G.markers.route.length; i"; - OSRM.debug.content.scrollTop = OSRM.debug.content.scrollHeight; -}; -OSRM.debug.clear = function() { - OSRM.debug.content.innerHTML = ""; -}; - - -// add elements to DOM -OSRM.debug.init = function() { - //create DOM objects for debug output - var wrapper = document.createElement('div'); - wrapper.id = "OSRM.debug-wrapper"; - wrapper.className = "gui-wrapper"; - wrapper.style.cssText = "width:410px;height:95%;top:5px;right:50px;"; - - var box = document.createElement('div'); - box.id = "OSRM.debug-box"; - box.className = "gui-box"; - box.style.cssText = "width:390px;top:0px;bottom:0px;"; - - var clear = document.createElement('a'); - clear.id = "OSRM.debug-clear"; - clear.className = "button not-selectable"; - clear.innerHTML = "clear"; - clear.onclick = OSRM.debug.clear; - - OSRM.debug.content= document.createElement('div'); - OSRM.debug.content.id = "OSRM.debug-content"; - OSRM.debug.content.style.cssText = "position:absolute;bottom:0px;top:20px;width:380px;font-size:11px;overflow:auto;margin:5px;"; - - // add elements - document.body.appendChild(wrapper); - wrapper.appendChild(box); - box.appendChild(clear); - box.appendChild(OSRM.debug.content); -}; - - -// onload event -OSRM.Browser.onLoadHandler( OSRM.debug.init ); \ No newline at end of file diff --git a/WebContent/base/OSRM.Map.js b/WebContent/base/OSRM.Map.js index 31685234a..01e8ec9a1 100644 --- a/WebContent/base/OSRM.Map.js +++ b/WebContent/base/OSRM.Map.js @@ -41,7 +41,7 @@ init: function() { } // setup map - OSRM.G.map = new L.MapView('map', { + OSRM.G.map = new OSRM.MapView('map', { center: new L.LatLng(OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE), zoom: OSRM.DEFAULTS.ONLOAD_ZOOM_LEVEL, layers: [base_maps[tile_servers[0].display_name]], diff --git a/WebContent/base/OSRM.Markers.js b/WebContent/base/OSRM.Markers.js index ccd2f975b..09179abbb 100644 --- a/WebContent/base/OSRM.Markers.js +++ b/WebContent/base/OSRM.Markers.js @@ -15,159 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see http://www.gnu.org/licenses/agpl.txt. */ -// OSRM markers -// [base marker class, derived highlight marker and route marker classes, marker management] - - -// base marker class (wraps Leaflet markers) -OSRM.Marker = function( label, style, position ) { - this.label = label ? label : "marker"; - this.position = position ? position : new L.LatLng(0,0); - - this.marker = new L.MouseMarker( this.position, style ); - this.marker.parent = this; - - this.shown = false; - this.hint = null; -}; -OSRM.extend( OSRM.Marker,{ -show: function() { - OSRM.G.map.addLayer(this.marker); - this.shown = true; -}, -hide: function() { - OSRM.G.map.removeLayer(this.marker); - this.shown = false; -}, -setPosition: function( position ) { - this.position = position; - this.marker.setLatLng( position ); - this.hint = null; -}, -getPosition: function() { - return this.position; -}, -getLat: function() { - return this.position.lat; -}, -getLng: function() { - return this.position.lng; -}, -isShown: function() { - return this.shown; -}, -centerView: function(zoom) { - if( zoom == undefined ) - zoom = OSRM.DEFAULTS.ZOOM_LEVEL; - OSRM.G.map.setViewUI( this.position, zoom ); -}, -toString: function() { - return "OSRM.Marker: \""+this.label+"\", "+this.position+")"; -} -}); - - -// route marker class (draggable, invokes route drawing routines) -OSRM.RouteMarker = function ( label, style, position ) { - style.baseicon = style.icon; - OSRM.RouteMarker.prototype.base.constructor.apply( this, arguments ); - this.label = label ? label : "route_marker"; - - this.marker.on( 'click', this.onClick ); - this.marker.on( 'drag', this.onDrag ); - this.marker.on( 'dragstart', this.onDragStart ); - this.marker.on( 'dragend', this.onDragEnd ); -}; -OSRM.inheritFrom( OSRM.RouteMarker, OSRM.Marker ); -OSRM.extend( OSRM.RouteMarker, { -onClick: function(e) { - for( var i=0; i1) - OSRM.Routing.getDragRoute(); - OSRM.Geocoder.updateLocation( this.parent.label ); -}, -onDragStart: function(e) { - OSRM.G.dragging = true; - this.switchIcon(this.options.dragicon); - - // store id of dragged marker - for( var i=0; i1) + OSRM.Routing.getDragRoute(); + OSRM.Geocoder.updateLocation( this.parent.label ); +}, +onDragStart: function(e) { + OSRM.G.dragging = true; + this.switchIcon(this.options.dragicon); + + // store id of dragged marker + for( var i=0; i - - - - - + + + + @@ -50,10 +49,13 @@ or see http://www.gnu.org/licenses/agpl.txt. - - + + + + + diff --git a/WebContent/printing/printing.html b/WebContent/printing/printing.html index e38518d57..64a0d6809 100644 --- a/WebContent/printing/printing.html +++ b/WebContent/printing/printing.html @@ -29,9 +29,6 @@ or see http://www.gnu.org/licenses/agpl.txt. - - - @@ -39,8 +36,9 @@ or see http://www.gnu.org/licenses/agpl.txt. + + - diff --git a/WebContent/printing/printing.js b/WebContent/printing/printing.js index 37a3d845c..8303bba42 100644 --- a/WebContent/printing/printing.js +++ b/WebContent/printing/printing.js @@ -27,7 +27,7 @@ OSRM.G = OSRM.GLOBALS; function initialize(tile_server) { // setup map var tile_layer = new L.TileLayer(tile_server.url, tile_server.options); - OSRM.G.map = new L.MapView("overview-map", { + OSRM.G.map = new OSRM.MapView("overview-map", { center: new L.LatLng(51.505, -0.09), zoom: 13, zoomAnimation: false,