Compare commits

...

143 Commits

Author SHA1 Message Date
DennisSchiefer 96e5c4b518 version bump 2012-04-27 16:10:03 +01:00
DennisSchiefer a3cfd49f97 shortener reply parameter name flexible,
check if reply is correct,
beautified continue marker
2012-04-27 12:13:27 +01:00
DennisSchiefer fbe722465d individual ids/classes for geocoder search results 2012-04-27 08:55:11 +01:00
DennisSchiefer 448e6cfdc7 gui handling now uses a main class in which all other gui classes plug
in
2012-04-27 08:40:18 +01:00
DennisSchiefer 8e79b29925 changed result-link to route-link 2012-04-27 07:02:37 +01:00
DennisSchiefer bd61494cf4 added authors 2012-04-27 07:01:33 +01:00
DennisSchiefer d33a75812d changed result-link to route-link 2012-04-27 07:01:19 +01:00
DennisSchiefer 9f5f6019bf changed language in html to English 2012-04-26 15:32:48 +01:00
DennisSchiefer aef70b832c josm request will also use only 6 digits precision 2012-04-26 13:45:54 +01:00
DennisSchiefer 611d265a27 corrected display of geocoder results 2012-04-26 13:45:23 +01:00
DennisSchiefer 635b13b61c all route/geocoder requests will only send 6 digits after the decimal
point.
2012-04-26 13:15:41 +01:00
DennisSchiefer a8a4f56292 printing support finalized (yeah!) 2012-04-26 12:49:30 +01:00
DennisSchiefer a0ceee732e added relative root url for Leaflet 2012-04-26 12:48:01 +01:00
DennisSchiefer 560ce74d06 printing window will now be loaded in IE and Chrome 2012-04-26 07:34:51 +01:00
DennisSchiefer d7ffb0d492 trying to get printing to act correctly with Chrome/IE 2012-04-25 16:36:53 +01:00
DennisSchiefer 369edbe9a7 opening josm will only load the current view if you are close enough,
opening josm will no longer trigger a constant loading symbol in
browsers
2012-04-25 15:01:20 +01:00
DennisSchiefer 94ca30c690 printing icon can now deactivates when there is no route 2012-04-25 12:17:36 +01:00
DennisSchiefer ab1e5255eb Merge branch 'trial/folders' into develop 2012-04-25 07:12:02 +01:00
shiin 0068d4062d changed header area for normal routes 2012-04-24 23:23:27 +02:00
shiin 04298b73f3 added image for "head on",
removed unneeded images
2012-04-24 23:06:19 +02:00
DennisSchiefer 7657f0de22 finished printing support (?) 2012-04-24 22:12:24 +02:00
DennisSchiefer 7cdeeb0723 continued work on printing header 2012-04-24 15:28:09 +01:00
DennisSchiefer c0b71cb62a restored large images 2012-04-24 15:24:42 +01:00
DennisSchiefer 253df58fdb beginning to restructure routing header area 2012-04-24 09:38:20 +01:00
DennisSchiefer cd3005f9fe corrected wrong name when querying layers 2012-04-24 09:35:13 +01:00
DennisSchiefer 94cf796ed2 refinement to French translation 2012-04-24 08:50:27 +01:00
DennisSchiefer 18995379ab added explanation for contributing 2012-04-24 07:42:03 +01:00
DennisSchiefer a5246cc8b8 added french to config 2012-04-24 07:41:44 +01:00
DennisSchiefer 3a7f527c68 french translation added, thanks to Nicolas belett VIGNERON,
Moyg, Jean-Frédéric
2012-04-24 07:25:22 +01:00
DennisSchiefer f404337383 Merge remote-tracking branch 'temp/master' into develop 2012-04-24 07:16:38 +01:00
shiin 7421117278 extended mapview to give information about the current visible tile
layer,
continued work on printing
2012-04-24 00:56:41 +02:00
JeanFred f6173b7a48 Add localisation in French 2012-04-23 22:14:27 +02:00
DennisSchiefer dffd67ef72 continued printing work 2012-04-23 17:30:09 +01:00
DennisSchiefer 3444499cf4 onload event can use a different window 2012-04-23 17:29:53 +01:00
DennisSchiefer 7241438502 corrected error ne instead of sw direction 2012-04-23 17:29:18 +01:00
DennisSchiefer 44c38146c9 enabled printing 2012-04-23 14:48:09 +01:00
DennisSchiefer 2060088c6b finished making jsonp parameter names interchangeable 2012-04-23 09:58:34 +01:00
shiin 38defe9629 some files weren't removed properly... 2012-04-23 00:09:22 +02:00
shiin 087bb12847 more file & folder restructuring 2012-04-23 00:08:02 +02:00
shiin c59a6f9444 reorganized folders 2012-04-22 23:48:43 +02:00
shiin 40c0222ffd better UI for route reversal (source/target are changed when response is
received/timeout)
2012-04-22 21:03:50 +02:00
shiin f763ec2664 work-around for invisible scrollbars in Chrome when usind webkit3d 2012-04-22 20:50:09 +02:00
DennisSchiefer 186f78f01e adapted printing to new geometry routines 2012-04-21 08:14:17 +01:00
DennisSchiefer 1da10942d5 changed jsonp call, so that position of the callback command has
to be given as "%jsonp" in the string
2012-04-21 08:13:42 +01:00
DennisSchiefer 7ad253732a link shortener parameters now changeable in config file 2012-04-21 08:11:57 +01:00
DennisSchiefer 4b1c4068f2 Merge branch 'trial/printing' into develop 2012-04-20 12:11:50 +01:00
DennisSchiefer 57ec4e5465 route geometry is requeried 2012-04-20 11:07:47 +01:00
DennisSchiefer f3290ab64b zooming/switching to show unnamed roads will not rebuild the complete
driving directions,
pending JSONP calls can be cleared
2012-04-20 07:37:26 +02:00
DennisSchiefer eb3c2f560e switched back to using normal images in route description (FF wasn't
actually faster, he just reported wrong numbers)
2012-04-19 21:32:07 +02:00
DennisSchiefer 869b13e9db init via_nodes with empty array 2012-04-19 12:59:31 +01:00
DennisSchiefer 57d9bc5bae route direction icons are now background images (which should be faster
in rendering)
2012-04-19 11:02:09 +01:00
DennisSchiefer 917ef160c5 delete route when reversing it 2012-04-19 11:01:18 +01:00
DennisSchiefer ae513dce5c corrected error with marking unnamed streets, introduced by speeding up
route geometry computation
2012-04-19 11:00:57 +01:00
DennisSchiefer 93b5ce2968 switched to small driving direction images 2012-04-19 09:59:36 +01:00
DennisSchiefer ba08d0b36c added road to first driving direction,
allow geographic direction in all driving directions
2012-04-19 09:57:15 +01:00
DennisSchiefer 2e60e92b31 added waiting message to route reversal,
moved reversal logic to OSRM.Markers
2012-04-19 09:48:32 +01:00
DennisSchiefer 5a9a55544b improved speed of decoding route geometry 2012-04-18 16:56:56 +01:00
DennisSchiefer ee7c79641a fixed bug in route reversal (source/target marker would switch colors
when dragged)
2012-04-18 16:55:56 +01:00
DennisSchiefer 6e57c31ec2 added localization to route link 2012-04-18 16:29:44 +01:00
DennisSchiefer 3d9d4f3764 geolocation will no longer interfer with initial position/route passed
to the website,
corrected centering offset of routes
2012-04-18 08:51:31 +01:00
DennisSchiefer 596e7fc60a added cross-browser support for onload event,
made IE8 work again
2012-04-18 07:46:04 +01:00
DennisSchiefer 8845c070a2 moved favicon handling to webserver 2012-04-18 06:56:17 +01:00
DennisSchiefer eaf5dd328f added finnish for overview map 2012-04-17 22:37:15 +02:00
DennisSchiefer 20a0a3b170 Merge remote-tracking branch 'origin/develop' into develop 2012-04-17 22:35:03 +02:00
DennisSchiefer 8d5d1a9400 Merge branch 'trial/printing' into develop 2012-04-17 22:34:18 +02:00
DennisSchiefer 572a306d6d Merge commit 'f2efcfc588f75c391946b1cf8d5600fcf849d3c9' into develop 2012-04-17 22:33:26 +02:00
DennisSchiefer 63a9e4c6c2 remove newline 2012-04-17 22:32:56 +02:00
DennisSchiefer c84d4b323e Merge commit '9bd4b772789b11ca085e7e7f052b410903cf2eb0' into develop 2012-04-17 22:30:28 +02:00
DennisSchiefer 46f717566d added finnish localization 2012-04-17 09:06:15 +01:00
DennisSchiefer 0199673d14 Merge remote-tracking branch 'temp/master' into develop 2012-04-17 09:03:16 +01:00
Teemu Koskinen 607d5408d3 Add Finnish translations 2012-04-16 21:01:40 +03:00
DennisSchiefer 33035fccc0 pushed version 2012-04-16 19:43:57 +02:00
DennisSchiefer c14e461370 added onload_zoomlevel 2012-04-16 19:39:47 +02:00
DennisSchiefer 6f4e9a1d11 added explanation to driving instruction localization 2012-04-16 18:57:21 +02:00
DennisSchiefer 3610e21854 bugfix for zoomlevel in route links 2012-04-16 18:51:22 +02:00
DennisSchiefer f6a3815e91 continued work on printing support 2012-04-16 16:04:36 +01:00
DennisSchiefer f2efcfc588 increased padding when centering on a route 2012-04-16 16:03:59 +01:00
DennisSchiefer 2bf573dbe1 bug in position of " in string 2012-04-16 12:28:51 +01:00
DennisSchiefer 9bd4b77278 use relative image locations 2012-04-16 12:28:16 +01:00
DennisSchiefer fb995ad0b0 small UI move 2012-04-16 10:26:10 +01:00
DennisSchiefer 3a85661e45 fixed bugs with IE 2012-04-16 10:23:31 +01:00
DennisSchiefer 0ba881c390 localization for printing 2012-04-15 23:12:17 +02:00
DennisSchiefer c7782b2776 more work on printing 2012-04-15 23:01:05 +02:00
DennisSchiefer 23ca80030e disabled printing for this release 2012-04-15 19:35:50 +02:00
DennisSchiefer f08c389faa moved version to 0.1.4 2012-04-15 19:35:26 +02:00
DennisSchiefer 47369a0036 continued work on printing support 2012-04-15 19:34:18 +02:00
DennisSchiefer 253b591a87 fixed error with translation of east to German 2012-04-15 19:33:23 +02:00
DennisSchiefer 5c4488d350 removed fixed with from input boxes 2012-04-15 19:32:41 +02:00
DennisSchiefer 25310ff1bd corrected error in via computation when no road was visible 2012-04-15 19:31:49 +02:00
DennisSchiefer c2d52080d3 use geocode even if no route is found 2012-04-14 18:49:28 +02:00
DennisSchiefer bf681855ed moved list of supported languages and tileservers to config file 2012-04-14 18:26:32 +02:00
DennisSchiefer 899d216b9b made it easier to remove localization and on-demand loading of new
language packs,
added parameter to say whether to use on-demand reloading,
added parameter for the directory that contains the localization files,
corrected a small bug when the string for the HEAD_ON instruction was
not available,
2012-04-14 18:03:33 +02:00
DennisSchiefer 73aeab3a57 reworked loading of images and icons (-> easier to add new ones),
adapted routing description to use new description ids,
fixed bug with localization dropdown and FF3,
added localization for "(found X results)"
2012-04-13 17:47:53 +01:00
DennisSchiefer 61073ebc9d added newline to readme 2012-04-12 22:52:18 +02:00
DennisSchiefer 393334cabd corrected error in route description,
made dropdown button more beautiful
2012-04-12 22:44:30 +02:00
DennisSchiefer 01e4afe2f0 changed legal string in html file 2012-04-11 23:07:00 +02:00
DennisSchiefer 9b599c90f8 Merge branch 'trial/printing' into develop
Conflicts:
	WebContent/OSRM.debug.js
2012-04-11 23:03:24 +02:00
DennisSchiefer 252c234221 made parsing of get parameters more robust 2012-04-11 22:59:41 +02:00
DennisSchiefer 888a5d04c8 removal of dragger marker more consistent,
changed printing initialization to be more easily removable from GUI,
localization bug fixes,
added option to give language as get parameter (hl=),
2012-04-11 22:00:19 +02:00
DennisSchiefer b1631eff77 more localization,
fixed bugs with FF3
2012-04-11 17:31:02 +01:00
DennisSchiefer ffd5e2de99 all images are now loaded in main.js 2012-04-10 23:50:04 +02:00
DennisSchiefer ea207cef6e improved language support: geocoding uses language settings, geocoding
results & locations are also translated if possible
2012-04-10 21:47:30 +02:00
DennisSchiefer 893c09f6fc Merge remote-tracking branch 'origin/trial/printing' into trial/printing
Conflicts:
	WebContent/OSRM.GUI.js
2012-04-09 22:35:47 +02:00
shiin 213bb71b35 changed behaviour of geocoder (return always triggers geocoder, moving a
single marker clears search results)
2012-04-09 11:59:32 +02:00
shiin 0fd8d4d8cf all visible lat/lng coordinates are truncated after 6 digits (this
includes inputboxes, osmbugs link, route link, gpx link),
moved all events from html to javascript
2012-04-08 19:50:30 +02:00
shiin 13f0a3fb6b redid html and css,
switched to sans-serif font
2012-04-08 12:02:36 +02:00
shiin 3141d3ba48 prepared localization / route description module to use description ids
instead of description strings
2012-04-06 12:27:23 +02:00
DennisSchiefer 4ff4fcf516 corrected bug in reverse geocoder timeout handler 2012-04-05 09:08:41 +02:00
DennisSchiefer f273f0cfc5 drag marker can no longer be removed by clicking on it 2012-04-05 09:04:48 +02:00
DennisSchiefer dc192d47a8 input boxes are no longer deleted on language change 2012-04-05 01:12:15 +02:00
DennisSchiefer 0f032f7635 bugfix, so that markers will use correct mousepointer again 2012-04-04 15:40:16 +02:00
DennisSchiefer 060c7e499a added bugtracker URL to readme 2012-04-04 15:11:38 +02:00
DennisSchiefer 28a241c371 more testing on printing 2012-04-04 13:08:25 +02:00
DennisSchiefer bab2887f8f Merge branch 'trial/dragging' into develop
Conflicts:
	WebContent/OSRM.JSONP.js
	WebContent/OSRM.debug.js
	WebContent/main.html
2012-04-03 21:30:35 +02:00
DennisSchiefer abba49a44e - added GUI support for language switching
- first tests for support of printing
2012-04-03 21:13:44 +02:00
DennisSchiefer 4638e7c24d corrected error and bumped version to 0.1.3 2012-04-02 20:57:39 +02:00
DennisSchiefer fe420e5bfc added buttons to delete source and target 2012-04-02 08:54:25 +02:00
DennisSchiefer 93ae928236 added icons that can change their image,
added image change while dragging markers,
increased (invisible) size of drag marker,
fixed issues with drag marker and highlight marker overlapping
2012-04-02 08:29:03 +02:00
DennisSchiefer 3b485f1426 finished dragging of routes,
moved corrected bugs in Leaflet to their own file
(drag after dragend, distance to path),
open osmbugs in new window
2012-04-01 19:13:54 +02:00
DennisSchiefer 5165e01a5c added draggable routes,
changed findViaPosition to only return the index and not set the node,
IMPORTANT: changed leaflet-src.js for a bugfix!,
2012-03-30 16:30:16 +01:00
DennisSchiefer 7b4e923ec4 added option (commented out) to use input box for route links to get
a marked url when clicking in it -> test what is better
2012-03-30 10:35:14 +01:00
DennisSchiefer 007dd19cec added buttons to switch to JOSM and OSM Bugs,
added getCenter function that respects UI visibility
2012-03-30 10:10:51 +01:00
DennisSchiefer fd3cf02af4 complete restructure of OSRM.Routing 2012-03-29 16:55:12 +01:00
DennisSchiefer 2bb51717b9 extracted OSRM.Map and OSRM.MapView classes,
moved centering that respects UI visibility to OSRM.MapView
2012-03-29 14:34:55 +01:00
DennisSchiefer 4fe6346146 reordered styles in main.html,
readded default values to GUI,
made TODO marker to check whether GUI is initilaized
2012-03-28 15:02:09 +01:00
DennisSchiefer c5bd2b0b1d renamed routing.js,
encapsulated local helper functions in OSRM.base
2012-03-28 14:30:26 +01:00
DennisSchiefer 71426cf760 changed OSRM debug to work with IE6,
deactivated JSONP timing routines
2012-03-28 14:06:18 +01:00
DennisSchiefer 0ab287e707 modified JSONP statistics,
rearranged OSRM debug so that it works in IE
2012-03-28 13:59:39 +01:00
DennisSchiefer 49cc0bfb09 added functions to test JSONP timings 2012-03-28 13:01:26 +01:00
DennisSchiefer e132ac5c53 moved routing functions to OSRM namespace,
added functions to measure JSONP timings
2012-03-28 12:57:42 +01:00
DennisSchiefer 1a9776cff9 moved utils into OSRM namespace 2012-03-28 12:17:22 +01:00
DennisSchiefer 342a0d22bd - removed bug in centering routes when UI was hidden
- moved all browser dependencies to OSRM.Browser
- refactored via code to use Leaflet functions
- added function to extract route layerPoints
2012-03-28 10:51:54 +01:00
DennisSchiefer 251a43980a switched to Markdown readme 2012-03-26 16:47:40 +01:00
DennisSchiefer 41ba8b5e3e next try 2012-03-26 14:28:38 +01:00
DennisSchiefer 30df2aae10 Do inline links now work with Github asciidoc renderer? 2012-03-26 14:27:18 +01:00
DennisSchiefer a6f00b1856 yet another version 2012-03-26 14:15:44 +01:00
DennisSchiefer af26c47052 GitHUB didn't like my asciidoc... 2012-03-26 14:01:53 +01:00
DennisSchiefer 0a774aeef2 Changed name of README 2012-03-26 13:58:32 +01:00
DennisSchiefer a89aa68686 added README 2012-03-26 13:53:39 +01:00
DennisSchiefer 4b93107415 made logo a bit smaller so that it is centered,
removing source or target now clears route description,
changed GUI handling to no longer be dependent on the actual width of
the sidebar
2012-03-23 18:13:07 +01:00
DennisSchiefer e0602934b2 Refactored Geocoder -> now resides in OSRM namespace 2012-03-23 09:55:55 +01:00
DennisSchiefer fdace26222 changed getPosition().lat / .lng to getLat(), getLng() 2012-03-22 18:31:35 +01:00
DennisSchiefer bef41ed667 geocoder error messages now state the input string,
website is XHTML1.0 strict compliant,
centering now respects if the sidebar is shown,
corrected spelling mistakes
2012-03-22 17:35:09 +01:00
67 changed files with 3969 additions and 1806 deletions
+9
View File
@@ -0,0 +1,9 @@
The following people contributed code to the Open Source Routing Machine:
Dennis Schieferdecker
Dennis Luxen
Pascal Neis
Teemu Koskinen
Nicolas Belett Vigneron
Moyg
Jean-Frédéric
+63
View File
@@ -0,0 +1,63 @@
Overview
--------
The repository provides a Leaflet [(1)] based web frontend to the Open Source Routing Machine (Project-OSRM [(2)]).
The frontend is implemented in Javascript.
Data is fetched from routing and geocoding servers using JSONP queries.
The website is XHTML 1.0 Strict compliant.
A deployed version of the the web frontend can be seen at [(3)].
Setup
-----
The frontend should work directly as provided.
Several settings - including the URL for the routing server and the geocoder server - can be specified in `OSRM.config.js`.
Different tile servers can be specified in `OSRM.Map.js`.
Note that the URL shortener used for generating route links only works with URLs pointing to the official Project-OSRM website.
Branches
--------
* The `master` branch will always point to the latest released version of the frontend.
* The `develop` branch should always point to a working version with new features and bugfixes (think of it as a nightly-build).
* Other branches contain various work in progress.
Bugtracking
-----------
Please use the OSRM-Project bug tracker [(4)] for submitting any bug reports or feature requests.
Contribute
----------
If you like to contribute, you can simply fork the project and start coding.
When you are going to provide a more substantial addition, please create a new branch first.
For pull requests use the develop branch as target, never the master branch.
Integration into Project-OSRM repository
----------------------------------------
The Project-OSRM repository already contains the frontend repository as a submodule.
It will always point to the latest deployed version.
To successfully work a repository that contains submodules, use the following git commands (available in git 1.7.1+):
* `git clone --recursive`
to clone a repository and the contained submodules
* `git pull && git submodule update`
to pull the latest version of the repository and update its submodules if required
Note that the frontend can also be checked out independently of the Project-OSRM repository.
References
----------
[(1)] Cloudmade Leaflet: http://leaflet.cloudmade.com/
[(2)] Project OSRM: http://project-osrm.org/
[(3)] Project OSRM Frontend: http://map.project-osrm.org/
[(4)] Project OSRM Bugtracker: https://github.com/DennisOSRM/Project-OSRM/issues/
[(1)]: http://leaflet.cloudmade.com/ "Cloudmade Leaflet"
[(2)]: http://project-osrm.org/ "Project OSRM"
[(3)]: http://map.project-osrm.org/ "Project-OSRM Frontend"
[(4)]: https://github.com/DennisOSRM/Project-OSRM/issues/ "Project-OSRM Bugtracker"
-80
View File
@@ -1,80 +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 GUI functionality
// [responsible for all non-routing related GUI behaviour]
OSRM.GUI = {
// show/hide main-gui
toggleMain: function() {
// show main-gui
if( document.getElementById('main-wrapper').style.left == "-410px" ) {
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="hidden";
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="420px";
getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
document.getElementById('blob-wrapper').style.visibility="hidden";
document.getElementById('main-wrapper').style.left="5px";
if( OSRM.Browser.FF3!=-1 || OSRM.Browser.IE6_9!=-1 ) {
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
}
// hide main-gui
} else {
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="hidden";
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="30px";
getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
document.getElementById('main-wrapper').style.left="-410px";
if( OSRM.Browser.FF3!=-1 || OSRM.Browser.IE6_9!=-1 ) {
document.getElementById('blob-wrapper').style.visibility="visible";
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
}
}
// execute after animation
if( OSRM.Browser.FF3==-1 && OSRM.Browser.IE6_9==-1 ) {
document.getElementById('main-wrapper').addEventListener("transitionend", OSRM.GUI.onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("webkitTransitionEnd", OSRM.GUI.onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("oTransitionEnd", OSRM.GUI.onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("MSTransitionEnd", OSRM.GUI.onMainTransitionEnd, false);
}
},
// do stuff after main-gui animation finished
onMainTransitionEnd: function() {
// after hiding main-gui
if( document.getElementById('main-wrapper').style.left == "-410px" ) {
document.getElementById('blob-wrapper').style.visibility="visible";
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
// after showing main-gui
} else {
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
}
},
// show/hide small options bubble
toggleOptions: function() {
if(document.getElementById('options-box').style.visibility=="visible") {
document.getElementById('options-box').style.visibility="hidden";
} else {
document.getElementById('options-box').style.visibility="visible";
}
}
};
-217
View File
@@ -1,217 +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.setView( new L.LatLng( this.position.lat, this.position.lng), zoom);
},
toString: function() {
return "OSRM.Marker: \""+this.label+"\", "+this.position+")";
}
});
// highlight marker class (cannot be dragged)
OSRM.HighlightMarker = function( label, style, position) {
OSRM.HighlightMarker.prototype.base.constructor.apply( this, arguments );
this.label = label ? label : "highlight_marker";
this.marker.on( 'click', this.onClick );
};
OSRM.inheritFrom( OSRM.HighlightMarker, OSRM.Marker );
OSRM.extend( OSRM.HighlightMarker, {
toString: function() {
return "OSRM.HighlightMarker: \""+this.label+"\", "+this.position+")";
},
onClick: function(e) {
this.parent.hide();
}
});
// route marker class (draggable, invokes route drawing routines)
OSRM.RouteMarker = function ( label, style, position ) {
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; i<OSRM.G.markers.route.length; i++) {
if( OSRM.G.markers.route[i].marker === this ) {
OSRM.G.markers.removeMarker( i );
break;
}
}
getRoute(OSRM.C.FULL_DESCRIPTION);
OSRM.G.markers.highlight.hide();
},
onDrag: function(e) {
this.parent.setPosition( e.target.getLatLng() );
getRoute(OSRM.C.NO_DESCRIPTION);
updateLocation( this.parent.label );
},
onDragStart: function(e) {
OSRM.G.dragging = true;
// store id of dragged marker
for( var i=0; i<OSRM.G.markers.route.length; i++)
if( OSRM.G.markers.route[i].marker === this ) {
OSRM.G.dragid = i;
break;
}
OSRM.G.markers.highlight.hide();
if (OSRM.G.route.isShown())
OSRM.G.route.showOldRoute();
},
onDragEnd: function(e) {
OSRM.G.dragging = false;
this.parent.setPosition( e.target.getLatLng() );
getRoute(OSRM.C.FULL_DESCRIPTION);
if (OSRM.G.route.isShown()) {
OSRM.G.route.hideOldRoute();
OSRM.G.route.hideUnnamedRoute();
}
if(OSRM.G.route.isShown()==false)
updateAddress(this.parent.label);
},
toString: function() {
return "OSRM.RouteMarker: \""+this.label+"\", "+this.position+")";
}
});
// marker management class (all route markers should only be set and deleted with these routines!)
// [this holds the vital information of the route]
OSRM.Markers = function() {
this.route = new Array();
this.highlight = new OSRM.HighlightMarker("highlight", {draggable:false,icon:OSRM.icons['marker-highlight']});;
};
OSRM.extend( OSRM.Markers,{
removeAll: function() {
for(var i=0; i<this.route.length;i++)
this.route[i].hide();
this.route.splice(0, this.route.length);
},
removeVias: function() {
// assert correct route array s - v - t
for(var i=1; i<this.route.length-1;i++)
this.route[i].hide();
this.route.splice(1, this.route.length-2);
},
setSource: function(position) {
// source node is always first node
if( this.route[0] && this.route[0].label == OSRM.C.SOURCE_LABEL )
this.route[0].setPosition(position);
else
this.route.splice(0,0, new OSRM.RouteMarker(OSRM.C.SOURCE_LABEL, {draggable:true,icon:OSRM.icons['marker-source']}, position));
return 0;
},
setTarget: function(position) {
// target node is always last node
if( this.route[this.route.length-1] && this.route[ this.route.length-1 ].label == OSRM.C.TARGET_LABEL )
this.route[this.route.length-1].setPosition(position);
else
this.route.splice( this.route.length,0, new OSRM.RouteMarker(OSRM.C.TARGET_LABEL, {draggable:true,icon:OSRM.icons['marker-target']}, position));
return this.route.length-1;
},
setVia: function(id, position) {
// via nodes only between source and target nodes
if( this.route.length<2 || id > this.route.length-2 )
return -1;
this.route.splice(id+1,0, new OSRM.RouteMarker(OSRM.C.VIA_LABEL, {draggable:true,icon:OSRM.icons['marker-via']}, 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('input-source-name').value = "";
} 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('input-target-name').value = "";
}
this.route[id].hide();
this.route.splice(id, 1);
},
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;
}
});
+2 -28
View File
@@ -19,36 +19,10 @@ or see http://www.gnu.org/licenses/agpl.txt.
// [has to be loaded before all other OSRM classes]
var OSRM = {};
OSRM.VERSION = '0.1.2';
OSRM.DATE = '120319';
OSRM.VERSION = '0.1.5';
OSRM.DATE = '120427';
OSRM.CONSTANTS = {};
OSRM.DEFAULTS = {};
OSRM.GLOBALS = {};
OSRM.G = OSRM.GLOBALS; // abbreviations
OSRM.C = OSRM.CONSTANTS;
// [convenience function] declare one class to be a subclass of another class
OSRM._inheritFromHelper = function() {};
OSRM.inheritFrom = function( sub_class, base_class ) {
OSRM._inheritFromHelper.prototype = base_class.prototype;
sub_class.prototype = new OSRM._inheritFromHelper();
sub_class.prototype.constructor = sub_class;
sub_class.prototype.base = base_class.prototype;
};
// [convenience function] extend prototypes of a class -> used to add member values and functions
OSRM.extend = function( target_class, properties ) {
for( property in properties ) {
target_class.prototype[property] = properties[property];
}
};
// [usage of convenience functions]
// SubClass = function() {
// SubClass.prototype.base.constructor.apply(this, arguments);
// }
// OSRM.inheritFrom( SubClass, BaseClass );
// OSRM.extend( SubClass, { property:value } );
+39 -2
View File
@@ -24,13 +24,50 @@ OSRM.DEFAULTS = {
HOST_GEOCODER_URL: 'http://nominatim.openstreetmap.org/search',
HOST_REVERSE_GEOCODER_URL: 'http://nominatim.openstreetmap.org/reverse',
WEBSITE_URL: document.URL.replace(/#*(\?.*|$)/i,""), // truncates URL before first ?, and removes tailing #
JSONP_TIMEOUT: 5000,
JSONP_TIMEOUT: 10000,
ZOOM_LEVEL: 14,
ONLOAD_ZOOM_LEVEL: 5,
ONLOAD_LATITUDE: 48.84,
ONLOAD_LONGITUDE: 10.10,
ONLOAD_SOURCE: "",
ONLOAD_TARGET: "",
HIGHLIGHT_ZOOM_LEVEL: 16,
GEOCODER_BOUNDS: '', // the world is not enough!
//GEOCODER_BOUNDS: '&bounded=1&viewbox=-27.0,72.0,46.0,36.0', // bounds for Europe
SHORTENER_PARAMETERS: '%url&jsonp=%jsonp',
SHORTENER_REPLY_PARAMETER: 'ShortURL',
LANGUAGE: "en",
GEOCODER_BOUNDS: '&bounded=1&viewbox=-27.0,72.0,46.0,36.0'
LANGUAGE_FILES_DIRECTORY: "localization/",
LANUGAGE_ONDEMAND_RELOADING: true,
LANGUAGE_SUPPORTED: [
{display_name:"en", encoding:"en"},
{display_name:"de", encoding:"de"},
{display_name:"fi", encoding:"fi"},
{display_name:"fr", encoding:"fr"}
],
TILE_SERVERS: [
{ display_name: 'osm.org',
url:'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution:'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 Mapnik',
options:{maxZoom: 18}
},
{ display_name: 'osm.de',
url:'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png',
attribution:'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 Mapnik',
options:{maxZoom: 18}
},
{ display_name: 'MapQuest',
url:'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png',
attribution:'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 MapQuest',
options:{maxZoom: 18, subdomains: '1234'}
},
{ display_name: 'CloudMade',
url:'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
attribution:'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade',
options:{maxZoom: 18}
}
]
};
+217
View File
@@ -0,0 +1,217 @@
/*
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 geocoding routines
// [geocoder query, management and display of geocoder results]
// some constants
OSRM.CONSTANTS.SOURCE_LABEL = "source";
OSRM.CONSTANTS.TARGET_LABEL = "target";
OSRM.CONSTANTS.VIA_LABEL = "via";
OSRM.CONSTANTS.DO_FALLBACK_TO_LAT_LNG = true;
OSRM.Geocoder = {
//[normal geocoding]
// process input request and call geocoder if needed
call: function(marker_id, query) {
if(query=="")
return;
//geo coordinates given -> 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 += '<table class="results medium-font">';
for(var i=0; i < response.length; i++){
var result = response[i];
//odd or even ?
var rowstyle='results-body-odd';
if(i%2==0) { rowstyle='results-body-even'; }
html += '<tr class="'+rowstyle+'">';
html += '<td class="results-body-counter"><span">'+(i+1)+'.</span></td>';
html += '<td class="results-body-items">';
if(result.display_name){
html += '<div class="results-body-item" onclick="OSRM.Geocoder._onclickResult(\''+parameters.marker_id+'\', '+result.lat+', '+result.lon+');">'+result.display_name+'</div>';
}
html += "</td></tr>";
}
html += '</table>';
document.getElementById('information-box-header').innerHTML =
"<div class='header-title'>"+OSRM.loc("SEARCH_RESULTS")+"</div>" +
"<div class='header-content'>("+OSRM.loc("FOUND_X_RESULTS").replace(/%i/,response.length)+")</div>";
"<div class='header-content'>(found "+response.length+" results)"+"</div>";
document.getElementById('information-box').innerHTML = html;
},
_showResults_Empty: function(parameters) {
document.getElementById('information-box-header').innerHTML =
"<div class='header-title'>"+OSRM.loc("SEARCH_RESULTS")+"</div>" +
"<div class='header-content'>("+OSRM.loc("FOUND_X_RESULTS").replace(/%i/,0)+")</div>";
if(parameters.marker_id == OSRM.C.SOURCE_LABEL)
document.getElementById('information-box').innerHTML = "<div class='no-results big-font'>"+OSRM.loc("NO_RESULTS_FOUND_SOURCE")+": "+parameters.query +"</div>";
else if(parameters.marker_id == OSRM.C.TARGET_LABEL)
document.getElementById('information-box').innerHTML = "<div class='no-results big-font'>"+OSRM.loc("NO_RESULTS_FOUND_TARGET")+": "+parameters.query +"</div>";
else
document.getElementById('information-box').innerHTML = "<div class='no-results big-font'>"+OSRM.loc("NO_RESULTS_FOUND")+": "+parameters.query +"</div>";
},
_showResults_Timeout: function() {
document.getElementById('information-box-header').innerHTML =
"<div class='header-title'>"+OSRM.loc("SEARCH_RESULTS")+"</div>" +
"<div class='header-content'>("+OSRM.loc("FOUND_X_RESULTS").replace(/%i/,0)+")</div>";
document.getElementById('information-box').innerHTML = "<div class='no-results big-font'>"+OSRM.loc("TIMED_OUT")+"</div>";
},
// [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.toFixed(6) + "&lon=" + lng.toFixed(6);
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);
}
};
+103
View File
@@ -0,0 +1,103 @@
/*
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 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<size; i++) {
tile_servers[i].options.attribution = tile_servers[i].attribution;
base_maps[ tile_servers[i].display_name ] = new L.TileLayer( tile_servers[i].url, tile_servers[i].options );
}
// setup 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]],
zoomAnimation: false, // remove animations -> routes are not hidden during zoom
fadeAnimation: false
});
// add layer control
var layerControl = new L.Control.QueryableLayers(base_maps, {});
OSRM.G.map.addLayerControl(layerControl);
// 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 );
}
};
+131
View File
@@ -0,0 +1,131 @@
/*
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 marker management (all route markers should only be set and deleted with these routines!)
// [this holds the vital information of the route]
OSRM.Markers = function() {
this.route = new Array();
this.highlight = new OSRM.DragMarker("highlight", {draggable:true,icon:OSRM.G.icons['marker-highlight'],dragicon:OSRM.G.icons['marker-highlight-drag']});;
this.dragger = new OSRM.DragMarker("drag", {draggable:true,icon:OSRM.G.icons['marker-drag'],dragicon:OSRM.G.icons['marker-drag']});;
};
OSRM.extend( OSRM.Markers,{
removeAll: function() {
for(var i=0; i<this.route.length;i++)
this.route[i].hide();
this.route.splice(0, this.route.length);
document.getElementById('gui-delete-source').style.visibility = "hidden";
document.getElementById('gui-delete-target').style.visibility = "hidden";
},
removeVias: function() {
// assert correct route array s - v - t
for(var i=1; i<this.route.length-1;i++)
this.route[i].hide();
this.route.splice(1, this.route.length-2);
},
setSource: function(position) {
// source node is always first node
if( this.route[0] && this.route[0].label == OSRM.C.SOURCE_LABEL )
this.route[0].setPosition(position);
else
this.route.splice(0,0, new OSRM.RouteMarker(OSRM.C.SOURCE_LABEL, {draggable:true,icon:OSRM.G.icons['marker-source'],dragicon:OSRM.G.icons['marker-source-drag']}, position));
document.getElementById('gui-delete-source').style.visibility = "visible";
return 0;
},
setTarget: function(position) {
// target node is always last node
if( this.route[this.route.length-1] && this.route[ this.route.length-1 ].label == OSRM.C.TARGET_LABEL )
this.route[this.route.length-1].setPosition(position);
else
this.route.splice( this.route.length,0, new OSRM.RouteMarker(OSRM.C.TARGET_LABEL, {draggable:true,icon:OSRM.G.icons['marker-target'],dragicon:OSRM.G.icons['marker-target-drag']}, position));
document.getElementById('gui-delete-target').style.visibility = "visible";
return this.route.length-1;
},
setVia: function(id, position) {
// via nodes only between source and target nodes
if( this.route.length<2 || id > 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;
}
});
@@ -15,94 +15,9 @@ 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;
this.route.on('click', this.onClick);
};
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;
},
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.fitBounds( bounds );
},
onClick: function(e) {
if(OSRM.G.route.isRoute())
findViaPosition( e.latlng );
},
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)
// OSRM 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"} );
@@ -134,12 +49,16 @@ OSRM.extend( OSRM.Route,{
hideRoute: function() {
this._current_route.hide();
this._unnamed_route.hide();
// activate printing
OSRM.Printing.deactivate();
},
hideAll: function() {
this._current_route.hide();
this._unnamed_route.hide();
this._old_route.hide();
this._noroute = OSRM.Route.ROUTE;
// activate printing
OSRM.Printing.deactivate();
},
showUnnamedRoute: function(positions) {
@@ -184,6 +103,9 @@ OSRM.extend( OSRM.Route,{
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);
},
+121
View File
@@ -0,0 +1,121 @@
/*
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<positions.length; i++) {
var _sqDist = L.LineUtil._sqClosestPointOnSegment(p, positions[i-1], positions[i], true);
if( _sqDist < min_dist) {
min_dist = _sqDist;
min_index = i;
}
}
return min_index;
},
// find the correct index among all via nodes to insert the new via node, and insert it
findViaIndex: function( new_via_position ) {
// find route segment that is closest to click position (marked by last index)
var nearest_index = OSRM.Via._findNearestRouteSegment( new_via_position );
// find correct index to insert new via node
var new_via_index = OSRM.G.via_points.length;
var via_index = Array();
for(var i=0; i<OSRM.G.via_points.length; i++) {
via_index[i] = OSRM.Via._findNearestRouteSegment( new L.LatLng(OSRM.G.via_points[i][0], OSRM.G.via_points[i][1]) );
if(via_index[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<size; i++) {
if(OSRM.G.markers.route[i].label=='drag')
continue;
var position = OSRM.G.markers.route[i].getPosition();
var dist = OSRM.G.map.project(mouse).distanceTo(OSRM.G.map.project(position));
if( dist < 20 )
min_dist = 1000;
}
// check whether mouse is over another marker
var pos = OSRM.G.map.layerPointToContainerPoint(event.layerPoint);
var obj = document.elementFromPoint(pos.x,pos.y);
for(var i=0, size=OSRM.G.markers.route.length; i<size; i++) {
if(OSRM.G.markers.route[i].label=='drag')
continue;
if( obj == OSRM.G.markers.route[i].marker._icon)
min_dist = 1000;
}
// special care for highlight marker
if( OSRM.G.markers.highlight.isShown() ) {
if( OSRM.G.map.project(mouse).distanceTo(OSRM.G.map.project( OSRM.G.markers.highlight.getPosition() ) ) < 20 )
min_dist = 1000;
else if( obj == OSRM.G.markers.highlight.marker._icon)
min_dist = 1000;
}
if( min_dist < 400) {
OSRM.G.markers.dragger.setPosition( OSRM.G.map.layerPointToLatLng(minpoint) );
OSRM.G.markers.dragger.show();
} else
OSRM.G.markers.dragger.hide();
}
};
+86
View File
@@ -0,0 +1,86 @@
/*
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.
*/
// Leaflet bugfixes
// [assorted bugfixes to Leaflet functions we use]
// find relative leaflet URL
var i = 0;
while( L.ROOT_URL[i] == document.URL[i] ) { i++; }
L.RELATIVE_ROOT_URL = L.ROOT_URL.slice(i);
// 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;
}
};
// makes requestAnimFrame respect the immediate paramter -> prevents drag events after dragend events
// (alternatively: add if(!this.dragging ) return to L.Draggable._updatePosition, but must be done in leaflet.js!)
// [TODO: In Leaflet 0.4 use L.Util.cancelAnimFrame(this._animRequest) in L.Draggable._onUp() instead, also has to be done in leaflet.js!]
L.Util.requestAnimFrame = (function () {
function timeoutDefer(callback) {
window.setTimeout(callback, 1000 / 60);
}
var requestFn = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
timeoutDefer;
return function (callback, context, immediate, contextEl) {
callback = context ? L.Util.bind(callback, context) : callback;
if (immediate ) { // DS_CHANGE: removed additional condition requestFn === timeoutDefer
callback();
} else {
requestFn(callback, contextEl);
}
};
}());
@@ -15,17 +15,20 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM browser detection
// [simple detection routines to respect some browser peculiarities]
// queryable Layers control
// [simply Control.Layers extended by query functions]
L.Control.QueryableLayers = L.Control.Layers.extend({
getActiveLayerName: function () {
var i, input, obj,
inputs = this._form.getElementsByTagName('input'),
inputsLen = inputs.length;
(function() {
var useragent = navigator.userAgent;
OSRM.Browser = {
FF3: useragent.search(/Firefox\/3/),
IE6_9: useragent.search(/MSIE (6|7|8|9)/)
};
}());
// (runs anonymous function to prevent local variables cluttering global namespace)
for (i = 0; i < inputsLen; i++) {
input = inputs[i];
obj = this._layers[input.layerId];
if (input.checked && !obj.overlay) {
return obj.name;
}
}
}
});
@@ -16,8 +16,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
*/
// Leaflet extension: MouseMarker
// [marker class that propagates modifier and button presses]
// [currently deactivated: propagation mousemove events]
// [marker class that propagates modifier and button presses in mouse click events and allows for changing icons]
// extended marker class
@@ -25,21 +24,34 @@ L.MouseMarker = L.Marker.extend({
initialize: function (latlng, options) {
L.Marker.prototype.initialize.apply(this, arguments);
},
// _initInteraction: function (){
// L.Marker.prototype._initInteraction.apply(this, arguments);
// if (this.options.clickable)
// L.DomEvent.addListener(this._icon, 'mousemove', this._fireMouseEvent, this);
// },
// _fireMouseEvent: function (e) {
// this.fire(e.type, {
// latlng: this._map.mouseEventToLatLng(e),
// layerPoint: this._map.mouseEventToLayerPoint(e)
// });
// L.DomEvent.stopPropagation(e);
// },
switchIcon: function( icon ) {
this.options.icon = icon;
if (this._map) {
this._changeIcon();
this._reset();
}
},
_changeIcon: function () {
var options = this.options;
if (this._icon) {
this._icon = options.icon.switchIcon( this._icon );
if (this.options.clickable) // TODO: only needed until Leaflet 0.4
this._icon.className += ' leaflet-clickable';
}
var panes = this._map._panes;
if (this._shadow)
panes.shadowPane.removeChild(this._shadow);
this._shadow = options.icon.createShadow();
if (this._shadow)
panes.shadowPane.appendChild(this._shadow);
},
_onMouseClick: function (e) {
L.DomEvent.stopPropagation(e);
if (this.dragging && this.dragging.moved()) { return; }
+115
View File
@@ -0,0 +1,115 @@
/*
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.
*/
// Leaflet extension: SwitchableIcon
// [will be an extension of L.Icon in Leaflet 0.4, for now it is a copy with added functionality]
// icon class with functions to simply switch the icon images
L.SwitchableIcon = L.Class.extend({
options: {
/*
iconUrl: (String) (required)
iconSize: (Point) (can be set through CSS)
iconAnchor: (Point) (centered by default if size is specified, can be set in CSS with negative margins)
popupAnchor: (Point) (if not specified, popup opens in the anchor point)
shadowUrl: (Point) (no shadow by default)
shadowSize: (Point)
*/
className: ''
},
initialize: function (options) {
L.Util.setOptions(this, options);
},
createIcon: function () {
return this._createIcon('icon');
},
createShadow: function () {
return this.options.shadowUrl ? this._createIcon('shadow') : null;
},
_createIcon: function (name) {
var img = this._createImg(this.options[name + 'Url']);
this._setIconStyles(img, name);
return img;
},
_setIconStyles: function (img, name) {
var options = this.options,
size = options[name + 'Size'],
anchor = options.iconAnchor;
if (!anchor && size) {
anchor = size.divideBy(2, true);
}
if (name === 'shadow' && anchor && options.shadowOffset) {
anchor._add(options.shadowOffset);
}
img.className = 'leaflet-marker-' + name + ' ' + options.className;
if (anchor) {
img.style.marginLeft = (-anchor.x) + 'px';
img.style.marginTop = (-anchor.y) + 'px';
}
if (size) {
img.style.width = size.x + 'px';
img.style.height = size.y + 'px';
}
},
_createImg: function (src) {
var el;
if (!L.Browser.ie6) {
el = document.createElement('img');
el.src = src;
} else {
el = document.createElement('div');
el.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '")';
}
return el;
},
// new functions start here
switchIcon: function (el) {
return this._switchIcon('icon', el);
},
switchShadow: function (el) {
return this.options.shadowUrl ? this._switchIcon('shadow', el) : null;
},
_switchIcon: function (name, el) {
var img = this._switchImg(this.options[name + 'Url'], el);
this._setIconStyles(img, name);
return img;
},
_switchImg: function (src, el) {
if (!L.Browser.ie6) {
el.src = src;
} else {
el.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '")';
}
return el;
}
});
+82
View File
@@ -0,0 +1,82 @@
/*
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.
*/
// map view/model
// [extending Leaflet L.Map with setView/fitBounds methods that respect UI visibility, better layerControl]
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;
ne_point.x+=20;
bounds.extend( this.unproject(sw_point,zoom) );
bounds.extend( this.unproject(ne_point,zoom) );
this.fitBounds( bounds );
},
getBoundsUI: function(unbounded) {
var bounds = this.getPixelBounds();
if( OSRM.GUI.visible == true )
bounds.min.x+=OSRM.GUI.width;
var sw = this.unproject(new L.Point(bounds.min.x, bounds.max.y), this._zoom, true),
ne = this.unproject(new L.Point(bounds.max.x, bounds.min.y), this._zoom, true);
return new L.LatLngBounds(sw, ne);
},
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);
},
addLayerControl: function( layerControl ) {
if( this.layerControl )
return;
this.layerControl = layerControl;
this.addControl(this.layerControl);
},
getActiveLayerId: function() {
var tile_server_id = 0;
var tile_servers = OSRM.DEFAULTS.TILE_SERVERS;
var tile_server_name = this.layerControl.getActiveLayerName();
for(var i=0, size=tile_servers.length; i<size; i++)
if( tile_servers[tile_server_id].display_name == tile_server_name ) {
tile_server_id = i;
break;
}
return tile_server_id;
}
});
+166
View File
@@ -0,0 +1,166 @@
/*
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]
// 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; i<OSRM.G.markers.route.length; i++) {
if( OSRM.G.markers.route[i].marker === this ) {
OSRM.G.markers.removeMarker( i );
break;
}
}
OSRM.Routing.getRoute();
OSRM.G.markers.highlight.hide();
OSRM.G.markers.dragger.hide();
},
onDrag: function(e) {
this.parent.setPosition( e.target.getLatLng() );
if(OSRM.G.markers.route.length>1)
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<OSRM.G.markers.route.length; i++)
if( OSRM.G.markers.route[i].marker === this ) {
OSRM.G.dragid = i;
break;
}
if( this.parent != OSRM.G.markers.highlight)
OSRM.G.markers.highlight.hide();
if( this.parent != OSRM.G.markers.dragger)
OSRM.G.markers.dragger.hide();
if (OSRM.G.route.isShown())
OSRM.G.route.showOldRoute();
},
onDragEnd: function(e) {
OSRM.G.dragging = false;
this.switchIcon(this.options.baseicon);
this.parent.setPosition( e.target.getLatLng() );
if (OSRM.G.route.isShown()) {
OSRM.Routing.getRoute();
OSRM.G.route.hideOldRoute();
OSRM.G.route.hideUnnamedRoute();
} else {
OSRM.Geocoder.updateAddress(this.parent.label);
OSRM.GUI.clearResults();
}
},
toString: function() {
return "OSRM.RouteMarker: \""+this.label+"\", "+this.position+")";
}
});
//drag marker class (draggable, invokes route drawing routines)
OSRM.DragMarker = function ( label, style, position ) {
OSRM.DragMarker.prototype.base.constructor.apply( this, arguments );
this.label = label ? label : "drag_marker";
};
OSRM.inheritFrom( OSRM.DragMarker, OSRM.RouteMarker );
OSRM.extend( OSRM.DragMarker, {
onClick: function(e) {
if( this.parent != OSRM.G.markers.dragger)
this.parent.hide();
},
onDragStart: function(e) {
var new_via_index = OSRM.Via.findViaIndex( e.target.getLatLng() );
OSRM.G.markers.route.splice(new_via_index+1,0, this.parent );
OSRM.RouteMarker.prototype.onDragStart.call(this,e);
},
onDragEnd: function(e) {
OSRM.G.markers.route[OSRM.G.dragid] = new OSRM.RouteMarker(OSRM.C.VIA_LABEL, {draggable:true,icon:OSRM.G.icons['marker-via'],dragicon:OSRM.G.icons['marker-via-drag']}, e.target.getLatLng() );
OSRM.G.markers.route[OSRM.G.dragid].show();
OSRM.RouteMarker.prototype.onDragEnd.call(this,e);
this.parent.hide();
},
toString: function() {
return "OSRM.DragMarker: \""+this.label+"\", "+this.position+")";
}
});
+98
View File
@@ -0,0 +1,98 @@
/*
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 + ")";
}
});

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

-203
View File
@@ -1,203 +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 geocoding routines
// [geocoder query, management and display of geocoder results]
// [TODO: better separation of GUI and geocoding routines, reverse geocoding]
// some constants
OSRM.CONSTANTS.SOURCE_LABEL = "source";
OSRM.CONSTANTS.TARGET_LABEL = "target";
OSRM.CONSTANTS.VIA_LABEL = "via";
OSRM.C.DO_FALLBACK_TO_LAT_LNG = true;
//[normal geocoding]
// process input request and call geocoder if needed
function callGeocoder(marker_id, query) {
if(query=="")
return;
//geo coordinates given -> directly draw results
if(query.match(/^\s*[-+]?[0-9]*\.?[0-9]+\s*[,;]\s*[-+]?[0-9]*\.?[0-9]+\s*$/)){
var coord = query.split(/[,;]/);
onclickGeocoderResult(marker_id, coord[0], coord[1]);
updateAddress( marker_id );
return;
}
//build request for geocoder
var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&q=" + query;
OSRM.JSONP.call( call, showGeocoderResults, showGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_"+marker_id, marker_id );
}
// helper function for clicks on geocoder search results
function onclickGeocoderResult(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();
getRoute(OSRM.C.FULL_DESCRIPTION);
}
// process geocoder response
function showGeocoderResults(response, marker_id) {
if(!response){
showGeocoderResults_Empty(marker_id);
return;
}
if(response.length == 0) {
showGeocoderResults_Empty(marker_id);
return;
}
// show possible results for input
var html = "";
html += '<table class="results-table">';
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 += '<tr class="'+rowstyle+'">';
html += '<td class="result-counter"><span">'+(i+1)+'.</span></td>';
html += '<td class="result-items">';
if(result.display_name){
html += '<div class="result-item" onclick="onclickGeocoderResult(\''+marker_id+'\', '+result.lat+', '+result.lon+');">'+result.display_name+'</div>';
}
html += "</td></tr>";
}
html += '</table>';
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
document.getElementById('information-box').innerHTML = html;
onclickGeocoderResult(marker_id, response[0].lat, response[0].lon);
}
function showGeocoderResults_Empty(marker_id) {
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
if(marker_id == OSRM.C.SOURCE_LABEL)
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND_SOURCE")+".<p>";
else if(marker_id == OSRM.C.TARGET_LABEL)
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND_TARGET")+".<p>";
else
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND")+".<p>";
}
function showGeocoderResults_Timeout() {
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("TIMED_OUT")+".<p>";
}
// [reverse geocoding]
//update geo coordinates in input boxes
function updateLocation(marker_id) {
if (marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource()) {
document.getElementById("input-source-name").value = OSRM.G.markers.route[0].getPosition().lat.toFixed(6) + ", " + OSRM.G.markers.route[0].getPosition().lng.toFixed(6);
} else if (marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget()) {
document.getElementById("input-target-name").value = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lat.toFixed(6) + ", " + OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lng.toFixed(6);
}
}
// update address in input boxes
function updateAddress(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].getPosition().lat;
lng = OSRM.G.markers.route[0].getPosition().lng;
} else if(marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget() ) {
lat = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lat;
lng = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getPosition().lng;
} else
return;
var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json" + "&lat=" + lat + "&lon=" + lng;
OSRM.JSONP.call( call, showReverseGeocoderResults, showReverseGeocoderResults_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
function showReverseGeocoderResults(response, parameters) {
if(!response) {
showReverseGeocoderResults_Timeout(response, parameters);
return;
}
if(response.address == undefined) {
showReverseGeocoderResults_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 ) {
showReverseGeocoderResults_Timeout(response, parameters);
return;
}
// add result to DOM
if(parameters.marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource() )
document.getElementById("input-source-name").value = address;
else if(parameters.marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget() )
document.getElementById("input-target-name").value = address;
}
function showReverseGeocoderResults_Timeout(response, parameters) {
if(!parameters.do_fallback)
return;
updateLocation(parameters.marker_id);
}
+44
View File
@@ -0,0 +1,44 @@
/*
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 GUI
// [base GUI class, all other GUI modules extend this class]
OSRM.GUI = {
// initialization functions of all GUI parts
init_functions: [],
// init GUI
init: function() {
for(var i=0, size=OSRM.GUI.init_functions.length; i<size; i++) {
OSRM.GUI.init_functions[i]();
}
},
//extend GUI class and add init functions to the array
extend: function( properties ) {
for( property in properties ) {
if( property == 'init' )
OSRM.GUI.init_functions.push( properties[property] );
else
OSRM.GUI[property] = properties[property];
}
}
};
+121
View File
@@ -0,0 +1,121 @@
/*
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 MainGUI
// [handles all GUI events that interact with appearance of main window]
OSRM.GUI.extend( {
// defaults
visible: null,
width: null,
// init GUI
init: function() {
OSRM.GUI.visible = true;
OSRM.GUI.width = document.getElementById("main-wrapper").clientWidth;
// init starting source/target
document.getElementById('gui-input-source').value = OSRM.DEFAULTS.ONLOAD_SOURCE;
document.getElementById('gui-input-target').value = OSRM.DEFAULTS.ONLOAD_TARGET;
// init events
document.getElementById("gui-toggle-in").onclick = OSRM.GUI.toggleMain;
document.getElementById("gui-toggle-out").onclick = OSRM.GUI.toggleMain;
// gui after transition events
if( OSRM.Browser.FF3==-1 && OSRM.Browser.IE6_9==-1 ) {
document.getElementById('main-wrapper').addEventListener("transitionend", OSRM.GUI._onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("webkitTransitionEnd", OSRM.GUI._onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("oTransitionEnd", OSRM.GUI._onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("MSTransitionEnd", OSRM.GUI._onMainTransitionEnd, false);
}
// set default language
OSRM.Localization.setLanguage( OSRM.DEFAULTS.LANGUAGE );
},
// set language dependent labels
setLabels: function() {
document.getElementById("open-josm").innerHTML = OSRM.loc("OPEN_JOSM");
document.getElementById("open-osmbugs").innerHTML = OSRM.loc("OPEN_OSMBUGS");
document.getElementById("gui-reset").innerHTML = OSRM.loc("GUI_RESET");
document.getElementById("gui-reverse").innerHTML = OSRM.loc("GUI_REVERSE");
document.getElementById("gui-option-highlight-nonames-label").innerHTML = OSRM.loc("GUI_HIGHLIGHT_UNNAMED_ROADS");
document.getElementById("gui-options-toggle").innerHTML = OSRM.loc("GUI_OPTIONS");
document.getElementById("gui-search-source").innerHTML = OSRM.loc("GUI_SEARCH");
document.getElementById("gui-search-target").innerHTML = OSRM.loc("GUI_SEARCH");
document.getElementById("gui-search-source-label").innerHTML = OSRM.loc("GUI_START")+":";
document.getElementById("gui-search-target-label").innerHTML = OSRM.loc("GUI_END")+":";
document.getElementById("gui-input-source").title = OSRM.loc("GUI_START_TOOLTIP");
document.getElementById("gui-input-target").title = OSRM.loc("GUI_END_TOOLTIP");
document.getElementById("legal-notice").innerHTML = OSRM.loc("GUI_LEGAL_NOTICE");
},
//clear output area
clearResults: function() {
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-header').innerHTML = "";
},
//show/hide small options bubble
toggleOptions: function() {
if(document.getElementById('options-box').style.visibility=="visible") {
document.getElementById('options-box').style.visibility="hidden";
} else {
document.getElementById('options-box').style.visibility="visible";
}
},
// show/hide main-gui
toggleMain: function() {
// show main-gui
if( OSRM.GUI.visible == false ) {
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="hidden";
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.left=(OSRM.GUI.width+10)+"px";;
document.getElementById('blob-wrapper').style.visibility="hidden";
document.getElementById('main-wrapper').style.left="5px";
// hide main-gui
} else {
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="hidden";
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="30px";
document.getElementById('main-wrapper').style.left=-OSRM.GUI.width+"px";
}
// execute after animation (old browser support)
if( OSRM.Browser.FF3!=-1 || OSRM.Browser.IE6_9!=-1 )
OSRM.GUI._onMainTransitionEnd();
},
// do stuff after main-gui animation finished
_onMainTransitionEnd: function() {
// after hiding main-gui
if( OSRM.GUI.visible == true ) {
document.getElementById('blob-wrapper').style.visibility="visible";
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
OSRM.GUI.visible = false;
// after showing main-gui
} else {
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
OSRM.GUI.visible = true;
}
}
});
+139
View File
@@ -0,0 +1,139 @@
/*
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 RoutingGUI
// [handles all GUI events that interact with routing in main window]
OSRM.GUI.extend( {
// init
init: function() {
// init events
document.getElementById("gui-input-source").onchange = function() {OSRM.GUI.inputChanged(OSRM.C.SOURCE_LABEL);};
document.getElementById("gui-delete-source").onclick = function() {OSRM.GUI.deleteMarker(OSRM.C.SOURCE_LABEL);};
document.getElementById("gui-search-source").onclick = function() {OSRM.GUI.showMarker(OSRM.C.SOURCE_LABEL);};
document.getElementById("gui-input-target").onchange = function() {OSRM.GUI.inputChanged(OSRM.C.TARGET_LABEL);};
document.getElementById("gui-delete-target").onclick = function() {OSRM.GUI.deleteMarker(OSRM.C.TARGET_LABEL);};
document.getElementById("gui-search-target").onclick = function() {OSRM.GUI.showMarker(OSRM.C.TARGET_LABEL);};
document.getElementById("gui-reset").onclick = OSRM.GUI.resetRouting;
document.getElementById("gui-reverse").onclick = OSRM.GUI.reverseRouting;
document.getElementById("gui-options-toggle").onclick = OSRM.GUI.toggleOptions;
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;
},
// click: button "reset"
resetRouting: function() {
document.getElementById('gui-input-source').value = "";
document.getElementById('gui-input-target').value = "";
OSRM.G.route.hideAll();
OSRM.G.markers.removeAll();
OSRM.G.markers.highlight.hide();
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-header').innerHTML = "";
OSRM.JSONP.reset();
},
// click: button "reverse"
reverseRouting: function() {
// invert input boxes
var tmp = document.getElementById("gui-input-source").value;
document.getElementById("gui-input-source").value = document.getElementById("gui-input-target").value;
document.getElementById("gui-input-target").value = tmp;
// 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.G.markers.route.reverse();
OSRM.G.markers.highlight.hide();
OSRM.RoutingDescription.showSimple( OSRM.G.response );
// simply reverse markers
} else {
OSRM.G.markers.reverseMarkers();
}
},
// click: button "show"
showMarker: function(marker_id) {
if( OSRM.JSONP.fences["geocoder_source"] || OSRM.JSONP.fences["geocoder_target"] )
return;
if( marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource() )
OSRM.G.markers.route[0].centerView();
else if( marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget() )
OSRM.G.markers.route[OSRM.G.markers.route.length-1].centerView();
},
// changed: any inputbox (is called when enter is pressed [after] or focus is lost [before])
inputChanged: function(marker_id) {
if( marker_id == OSRM.C.SOURCE_LABEL)
OSRM.Geocoder.call(OSRM.C.SOURCE_LABEL, document.getElementById('gui-input-source').value);
else if( marker_id == OSRM.C.TARGET_LABEL)
OSRM.Geocoder.call(OSRM.C.TARGET_LABEL, document.getElementById('gui-input-target').value);
},
// click: button "open JOSM"
openJOSM: function() {
var center = OSRM.G.map.getCenterUI();
var bounds = OSRM.G.map.getBoundsUI();
var xdelta = Math.min(0.02, Math.abs(bounds.getSouthWest().lng - center.lng) );
var ydelta = Math.min(0.01, Math.abs(bounds.getSouthWest().lat - center.lat) );
var p = [ 'left=' + (center.lng - xdelta).toFixed(6), 'bottom=' + (center.lat - ydelta).toFixed(6), 'right=' + (center.lng + xdelta).toFixed(6), 'top=' + (center.lat + ydelta).toFixed(6)];
var url = 'http://127.0.0.1:8111/load_and_zoom?' + p.join('&');
var frame = document.getElementById('josm-frame');
if(!frame) {
frame = L.DomUtil.create('iframe', null, document.body);
frame.style.display = "none";
frame.id = 'josm-frame';
}
frame.src = url;
},
//click: button "open OSM Bugs"
openOSMBugs: function() {
var position = OSRM.G.map.getCenterUI();
window.open( "http://osmbugs.org/?lat="+position.lat.toFixed(6)+"&lon="+position.lng.toFixed(6)+"&zoom="+OSRM.G.map.getZoom() );
},
//click: button "delete marker"
deleteMarker: function(marker_id) {
var id = null;
if(marker_id == 'source' && OSRM.G.markers.hasSource() )
id = 0;
else if(marker_id == 'target' && OSRM.G.markers.hasTarget() )
id = OSRM.G.markers.route.length-1;
if( id == null)
return;
OSRM.G.markers.removeMarker( id );
OSRM.Routing.getRoute();
OSRM.G.markers.highlight.hide();
}
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 617 B

After

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

+93
View File
@@ -0,0 +1,93 @@
/*
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 localization
// [German language support]
OSRM.Localization["de"] = {
//gui
"OPEN_JOSM": "JOSM",
"OPEN_OSMBUGS": "OSM Bugs",
"GUI_START": "Start",
"GUI_END": "Ziel",
"GUI_RESET": "Reset",
"GUI_SEARCH": "Zeigen",
"GUI_REVERSE": "Umdrehen",
"GUI_OPTIONS": "Kartenwerkzeuge",
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Unbenannte Straßen hervorheben",
"GUI_START_TOOLTIP": "Startposition eingeben",
"GUI_END_TOOLTIP": "Zielposition eingeben",
"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
// geocoder
"SEARCH_RESULTS": "Suchergebnisse",
"FOUND_X_RESULTS": "%i Ergebnisse gefunden",
"TIMED_OUT": "Zeitüberschreitung",
"NO_RESULTS_FOUND": "Keine Ergebnisse gefunden",
"NO_RESULTS_FOUND_SOURCE": "Keine Ergebnisse gefunden für Start",
"NO_RESULTS_FOUND_TARGET": "Keine Ergebnisse gefunden für Ziel",
// routing
"ROUTE_DESCRIPTION": "Routenbeschreibung",
"GET_LINK_TO_ROUTE": "Generiere Link",
"GENERATE_LINK_TO_ROUTE": "Warte auf Antwort",
"LINK_TO_ROUTE_TIMEOUT": "nicht möglich",
"GPX_FILE": "GPX Datei",
"DISTANCE": "Distanz",
"DURATION": "Dauer",
"YOUR_ROUTE_IS_BEING_COMPUTED": "Ihre Route wird berechnet",
"NO_ROUTE_FOUND": "Keine Route hierher möglich",
// printing
"OVERVIEW_MAP": "Übersichtskarte",
// directions
"N": "Norden",
"E": "Ost",
"S": "Süden",
"W": "Westen",
"NE": "Nordost",
"SE": "Südost",
"SW": "Südwest",
"NW": "Nordwest",
// driving directions
// %s: road name
// %d: direction
// [*]: will only be printed when there actually is a road name
"DIRECTION_0":"Unbekannte Anweisung[ auf <b>%s</b>]",
"DIRECTION_1":"Geradeaus weiterfahren[ auf <b>%s</b>]",
"DIRECTION_2":"Leicht rechts abbiegen[ auf <b>%s</b>]",
"DIRECTION_3":"Rechts abbiegen[ auf <b>%s</b>]",
"DIRECTION_4":"Scharf rechts abbiegen[ auf <b>%s</b>]",
"DIRECTION_5":"Wenden[ auf <b>%s</b>]",
"DIRECTION_6":"Leicht links abbiegen[ auf <b>%s</b>]",
"DIRECTION_7":"Links abbiegen[ auf <b>%s</b>]",
"DIRECTION_8":"Scharf links abbiegen[ auf <b>%s</b>]",
"DIRECTION_10":"Fahren Sie Richtung <b>%d</b>[ auf <b>%s</b>]",
"DIRECTION_11-1":"In den Kreisverkehr einfahren und bei erster Möglichkeit[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_11-2":"In den Kreisverkehr einfahren und bei zweiter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_11-3":"In den Kreisverkehr einfahren und bei dritter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_11-4":"In den Kreisverkehr einfahren und bei vierter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_11-5":"In den Kreisverkehr einfahren und bei fünfter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_11-6":"In den Kreisverkehr einfahren und bei sechster Möglichkeit[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_11-7":"In den Kreisverkehr einfahren und bei siebter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_11-8":"In den Kreisverkehr einfahren und bei achter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_11-9":"In den Kreisverkehr einfahren und bei neunter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_11-x":"In den Kreisverkehr einfahren und bei einer der vielen Möglichkeiten[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_15":"Sie haben Ihr Ziel erreicht"
};
// set GUI language on load
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING==true )
OSRM.Localization.setLanguage("de");
@@ -16,82 +16,26 @@ or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM localization
// [basic localization options]
// [English language support]
OSRM.Localization = {
// if existing, return localized string -> English string -> input string
translate: function(text) {
if( OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text] )
return OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text];
else if( OSRM.Localization["en"][text] )
return OSRM.Localization["en"][text];
else
return text;
}
};
// shorter call to translate function
OSRM.loc = OSRM.Localization.translate;
// German language support
OSRM.Localization["de"] = {
//gui
"GUI_START": "Start",
"GUI_END": "Ziel",
"GUI_RESET": "Reset",
"GUI_SEARCH": "Zeigen",
"GUI_REVERSE": "Umdrehen",
"GUI_OPTIONS": "Optionen",
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Unbenannte Straßen hervorheben",
"GUI_START_TOOLTIP": "Startposition eingeben",
"GUI_END_TOOLTIP": "Zielposition eingeben",
"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
// geocoder
"SEARCH_RESULTS": "Suchergebnisse",
"TIMED_OUT": "Zeitüberschreitung",
"NO_RESULTS_FOUND": "Keine Ergebnisse gefunden",
"NO_RESULTS_FOUND_SOURCE": "Keine Ergebnisse gefunden für Start",
"NO_RESULTS_FOUND_TARGET": "Keine Ergebnisse gefunden für Ziel",
// routing
"ROUTE_DESCRIPTION": "Routenbeschreibung",
"GET_LINK_TO_ROUTE": "Generiere Link",
"GENERATE_LINK_TO_ROUTE": "Warte auf Antwort",
"LINK_TO_ROUTE_TIMEOUT": "nicht möglich",
"GPX_FILE": "GPX Datei",
"DISTANCE": "Distanz",
"DURATION": "Dauer",
"YOUR_ROUTE_IS_BEING_COMPUTED": "Ihre Route wird berechnet",
"NO_ROUTE_FOUND": "Keine Route hierher möglich",
// directions
"N": "Norden",
"O": "Ost",
"S": "Süden",
"W": "Westen",
"NO": "Nordost",
"SO": "Südost",
"SW": "Südwest",
"NW": "Nordwest"
};
// English language support
OSRM.Localization["en"] = {
//gui
"OPEN_JOSM": "JOSM",
"OPEN_OSMBUGS": "OSM Bugs",
"GUI_START": "Start",
"GUI_END": "End",
"GUI_RESET": "&nbsp;&nbsp;Reset&nbsp;&nbsp;",
"GUI_SEARCH": "&nbsp;&nbsp;Show&nbsp;&nbsp;",
"GUI_REVERSE": "Reverse",
"GUI_OPTIONS": "Options",
"GUI_OPTIONS": "Mapping Tools",
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Highlight unnamed streets",
"GUI_START_TOOLTIP": "Enter start",
"GUI_END_TOOLTIP": "Enter destination",
"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
// geocoder
"SEARCH_RESULTS": "Search Results",
"FOUND_X_RESULTS": "found %i results",
"TIMED_OUT": "Timed Out",
"NO_RESULTS_FOUND": "No results found",
"NO_RESULTS_FOUND_SOURCE": "No results found for start",
@@ -106,6 +50,8 @@ OSRM.Localization["en"] = {
"DURATION": "Duration",
"YOUR_ROUTE_IS_BEING_COMPUTED": "Your route is being computed",
"NO_ROUTE_FOUND": "No route possible",
//printing
"OVERVIEW_MAP": "Overview Map",
// directions
"N": "north",
"E": "east",
@@ -114,5 +60,34 @@ OSRM.Localization["en"] = {
"NE": "northeast",
"SE": "southeast",
"SW": "southwest",
"NW": "northwest"
};
"NW": "northwest",
// driving directions
// %s: road name
// %d: direction
// [*]: will only be printed when there actually is a road name
"DIRECTION_0":"Unknown instruction[ on <b>%s</b>]",
"DIRECTION_1":"Continue[ on <b>%s</b>]",
"DIRECTION_2":"Turn slight right[ on <b>%s</b>]",
"DIRECTION_3":"Turn right[ on <b>%s</b>]",
"DIRECTION_4":"Turn sharp right[ on <b>%s</b>]",
"DIRECTION_5":"U-Turn[ on <b>%s</b>]",
"DIRECTION_6":"Turn slight left[ on <b>%s</b>]",
"DIRECTION_7":"Turn left[ on <b>%s</b>]",
"DIRECTION_8":"Turn sharp left[ on <b>%s</b>]",
"DIRECTION_10":"Head <b>%d</b>[ on <b>%s</b>]",
"DIRECTION_11-1":"Enter roundabout and leave at first exit[ on <b>%s</b>]",
"DIRECTION_11-2":"Enter roundabout and leave at second exit[ on <b>%s</b>]",
"DIRECTION_11-3":"Enter roundabout and leave at third exit[ on <b>%s</b>]",
"DIRECTION_11-4":"Enter roundabout and leave at fourth exit[ on <b>%s</b>]",
"DIRECTION_11-5":"Enter roundabout and leave at fifth exit[ on <b>%s</b>]",
"DIRECTION_11-6":"Enter roundabout and leave at sixth exit[ on <b>%s</b>]",
"DIRECTION_11-7":"Enter roundabout and leave at seventh exit[ on <b>%s</b>]",
"DIRECTION_11-8":"Enter roundabout and leave at eighth exit[ on <b>%s</b>]",
"DIRECTION_11-9":"Enter roundabout and leave at nineth exit[ on <b>%s</b>]",
"DIRECTION_11-x":"Enter roundabout and leave at one of the too many exits[ on <b>%s</b>]",
"DIRECTION_15":"You have reached your destination"
};
//set GUI language on load
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING == true )
OSRM.Localization.setLanguage("en");
+93
View File
@@ -0,0 +1,93 @@
/*
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 localization
// [Finnish language support]
OSRM.Localization["fi"] = {
//gui
"OPEN_JOSM": "JOSM",
"OPEN_OSMBUGS": "OSM Bugs",
"GUI_START": "Lähtöpaikka",
"GUI_END": "Määränpää",
"GUI_RESET": "&nbsp;&nbsp;Tyhjennä&nbsp;&nbsp;",
"GUI_SEARCH": "&nbsp;&nbsp;Etsi&nbsp;&nbsp;",
"GUI_REVERSE": "Käänteinen reitti",
"GUI_OPTIONS": "Kartoitustyökalut",
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Korosta nimettömät tiet",
"GUI_START_TOOLTIP": "Syötä lähtöpaikka",
"GUI_END_TOOLTIP": "Syötä määränpää",
"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
// geocoder
"SEARCH_RESULTS": "Haun tulokset",
"FOUND_X_RESULTS": "Löytyi %i vaihtoehtoa",
"TIMED_OUT": "Aikakatkaisu",
"NO_RESULTS_FOUND": "Ei hakutuloksia",
"NO_RESULTS_FOUND_SOURCE": "Ei hakutuloksia lähtöpaikka",
"NO_RESULTS_FOUND_TARGET": "Ei hakutuloksia määränpäälle",
//routing
"ROUTE_DESCRIPTION": "Reittiohjeet",
"GET_LINK_TO_ROUTE": "Luo linkki",
"GENERATE_LINK_TO_ROUTE": "odotetaan linkkiä",
"LINK_TO_ROUTE_TIMEOUT": "ei saatavilla",
"GPX_FILE": "GPX-tiedosto",
"DISTANCE": "Etäisyys",
"DURATION": "Aika",
"YOUR_ROUTE_IS_BEING_COMPUTED": "Reittiä lasketaan",
"NO_ROUTE_FOUND": "Reittiä ei löytynyt",
//printing
"OVERVIEW_MAP": "Yleiskuvakartta",
// directions
"N": "pohjoiseen",
"E": "itään",
"S": "etelään",
"W": "länteen",
"NE": "koilliseen",
"SE": "kaakkoon",
"SW": "lounaaseen",
"NW": "luoteeseen",
// driving directions
// %s: road name
// %d: direction
// [*]: will only be printed when there actually is a road name
"DIRECTION_0":"Tuntematon ohje[ tielle <b>%s</b>]",
"DIRECTION_1":"Jatka[ tielle <b>%s</b>]",
"DIRECTION_2":"Käänny loivasti oikealle[ tielle <b>%s</b>]",
"DIRECTION_3":"Käänny oikealle[ tielle <b>%s</b>]",
"DIRECTION_4":"Käänny jyrkästi oikealle[ tielle <b>%s</b>]",
"DIRECTION_5":"Tee U-käännös[ tiellä <b>%s</b>]",
"DIRECTION_6":"Käänny loivasti vasemmalle[ tielle <b>%s</b>]",
"DIRECTION_7":"Käänny vasemmalle[ tielle <b>%s</b>]",
"DIRECTION_8":"Käänny jyrkästi vasemmalle [ tielle <b>%s</b>]",
"DIRECTION_10":"Aja <b>%d</b> [ tielle <b>%s</b>]",
"DIRECTION_11-1":"Aja liikenneympyrään ja poistu ensimmäisestä haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-2":"Aja liikenneympyrään ja poistu toisesta haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-3":"Aja liikenneympyrään ja poistu kolmannesta haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-4":"Aja liikenneympyrään ja poistu neljännestä haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-5":"Aja liikenneympyrään ja poistu viidennestä haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-6":"Aja liikenneympyrään ja poistu kuudennesta haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-7":"Aja liikenneympyrään ja poistu seitsemännestä haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-8":"Aja liikenneympyrään ja poistu kahdeksannesta haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-9":"Aja liikenneympyrään ja poistu yhdeksännestä haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-x":"Aja liikenneympyrään ja poistu monen haaran jälkeen[ tielle <b>%s</b>]",
"DIRECTION_15":"Saavuit määränpäähän"
};
//set GUI language tielle load
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING == true )
OSRM.Localization.setLanguage("fi");
+92
View File
@@ -0,0 +1,92 @@
/*
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 localization
// [French language support]
OSRM.Localization["fr"] = {
//gui
"OPEN_JOSM": "JOSM",
"OPEN_OSMBUGS": "Bugs OSM",
"GUI_START": "Départ",
"GUI_END": "Arrivée",
"GUI_RESET": "Réinitialiser",
"GUI_SEARCH": "Montrer",
"GUI_REVERSE": "Inverser",
"GUI_OPTIONS": "Outils de cartographie",
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Surligner les rues sans nom",
"GUI_START_TOOLTIP": "Entrez le lieu de départ",
"GUI_END_TOOLTIP": "Entrez le lieu darrivée",
"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - hébergement par <a href='http://algo2.iti.kit.edu/'>KIT</a> - géocodage par <a href='http://www.osm.org/'>OSM</a>",
// geocoder
"SEARCH_RESULTS": "Résultats de recherche",
"FOUND_X_RESULTS": "%i résultat(s)",
"TIMED_OUT": "La recherche na pas abouti",
"NO_RESULTS_FOUND": "Aucun résultat trouvé",
"NO_RESULTS_FOUND_SOURCE": "Aucun résultat pour le départ",
"NO_RESULTS_FOUND_TARGET": "Aucun résultat pour l'arrivée",
//routing
"ROUTE_DESCRIPTION": "Description de litinéraire",
"GET_LINK_TO_ROUTE": "Générer un lien",
"GENERATE_LINK_TO_ROUTE": "en attente du lien",
"LINK_TO_ROUTE_TIMEOUT": "indisponible",
"GPX_FILE": "Fichier GPX",
"DISTANCE": "Distance",
"DURATION": "Durée",
"YOUR_ROUTE_IS_BEING_COMPUTED": "Votre itinéraire est en cours de calcul",
"NO_ROUTE_FOUND": "Pas ditinéraire possible",
//printing
"OVERVIEW_MAP": "Overview Map",
// directions
"N": "nord",
"E": "est",
"S": "sud",
"W": "ouest",
"NE": "nord-est",
"SE": "sud-est",
"SW": "sud-ouest",
"NW": "nord-ouest",
// driving directions
// %s: road name
// [*]: will only be printed when there actually is a road name
"DIRECTION_0":"Instruction inconnue[ sur <b>%s</b>]",
"DIRECTION_1":"Continuez[ sur <b>%s</b>]",
"DIRECTION_2":"Tournez légèrement à droite[ sur <b>%s</b>]",
"DIRECTION_3":"Tournez à droite[ sur <b>%s</b>]",
"DIRECTION_4":"Tournez fortement à droite[ sur <b>%s</b>]",
"DIRECTION_5":"Faites demi-tour[ sur <b>%s</b>]",
"DIRECTION_6":"Tournez légèrement à gauche[ sur <b>%s</b>]",
"DIRECTION_7":"Tournez à gauche[ sur <b>%s</b>]",
"DIRECTION_8":"Tournez fortement à gauche[ sur <b>%s</b>]",
"DIRECTION_10":"Direction <b>%d</b>[ sur <b>%s</b>]",
"DIRECTION_11-1":"Au rond-point, prenez la première sortie[ sur <b>%s</b>]",
"DIRECTION_11-2":"Au rond-point, prenez la deuxième sortie[ sur <b>%s</b>]",
"DIRECTION_11-3":"Au rond-point, prenez la troisième sortie[ sur <b>%s</b>]",
"DIRECTION_11-4":"Au rond-point, prenez la quatrième sortie[ sur <b>%s</b>]",
"DIRECTION_11-5":"Au rond-point, prenez la cinquième sortie[ sur <b>%s</b>]",
"DIRECTION_11-6":"Au rond-point, prenez la sixième sortie[ sur <b>%s</b>]",
"DIRECTION_11-7":"Au rond-point, prenez la septième sortie[ sur <b>%s</b>]",
"DIRECTION_11-8":"Au rond-point, prenez la huitième sortie[ sur <b>%s</b>]",
"DIRECTION_11-9":"Au rond-point, prenez la neuvième sortie[ sur <b>%s</b>]",
"DIRECTION_11-x":"Au rond-point, prenez lune des trop nombreuses sorties[ sur <b>%s</b>]",
"DIRECTION_15":"Vous êtes arrivé"
};
//set GUI language on load
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING == true )
OSRM.Localization.setLanguage("fr");
@@ -0,0 +1,115 @@
/*
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 localization
// [basic localization options]
OSRM.Localization = {
current_language: OSRM.DEFAULTS.LANGUAGE,
// initialize localization
init: function() {
// create dropdown menu
var select = document.createElement('select');
select.id = "gui-language-toggle";
select.className = "top-left-button";
select.onchange = function() { OSRM.Localization.setLanguage(this.value); };
// fill dropdown menu
var supported_languages = OSRM.DEFAULTS.LANGUAGE_SUPPORTED;
for(var i=0, size=supported_languages.length; i<size; i++) {
var option=document.createElement("option");
option.innerHTML = supported_languages[i].display_name;
option.value = supported_languages[i].encoding;
select.appendChild(option);
}
select.value = OSRM.DEFAULTS.LANGUAGE;
// add element to DOM
var input_mask_header = document.getElementById('input-mask-header');
input_mask_header.insertBefore(select,input_mask_header.firstChild);
// create visible dropdown menu
var textnode = document.createTextNode(OSRM.DEFAULTS.LANGUAGE);
var myspan = document.createElement("span");
myspan.className = "styled-select";
myspan.id = "styled-select" + select.id;
myspan.appendChild(textnode);
select.parentNode.insertBefore(myspan, select);
myspan.style.width = (select.clientWidth-2)+"px";
myspan.style.height = (select.clientHeight)+"px";
},
// perform language change
setLanguage: function(language) {
if( OSRM.Localization[language]) {
OSRM.Localization.current_language = language;
// update selector
if( select = document.getElementById('gui-language-toggle') ) { // yes, = not == !
var option = select.getElementsByTagName("option");
select.value = language;
for(var i = 0; i < option.length; i++)
if(option[i].selected == true) {
document.getElementById("styled-select" + select.id).childNodes[0].nodeValue = option[i].childNodes[0].nodeValue;
break;
}
}
// change gui language
OSRM.GUI.setLabels();
// requery data
if( OSRM.G.markers == null )
return;
if( OSRM.G.markers.route.length > 1)
OSRM.Routing.getRoute();
else if(OSRM.G.markers.route.length > 0 && document.getElementById('information-box').innerHTML != "" ) {
OSRM.Geocoder.call( OSRM.C.SOURCE_LABEL, document.getElementById("gui-input-source").value );
OSRM.Geocoder.call( OSRM.C.TARGET_LABEL, document.getElementById("gui-input-target").value );
} else {
OSRM.Geocoder.updateAddress(OSRM.C.SOURCE_LABEL, false);
OSRM.Geocoder.updateAddress(OSRM.C.TARGET_LABEL, false);
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-header').innerHTML = "";
}
} else if(OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING==true) {
var supported_languages = OSRM.DEFAULTS.LANGUAGE_SUPPORTED;
for(var i=0, size=supported_languages.length; i<size; i++) {
if( supported_languages[i].encoding == language) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = OSRM.DEFAULTS.LANGUAGE_FILES_DIRECTORY + "OSRM.Locale."+language+".js";
document.head.appendChild(script);
break;
}
}
}
},
// if existing, return localized string -> English string -> input string
translate: function(text) {
if( OSRM.Localization[OSRM.Localization.current_language] && OSRM.Localization[OSRM.Localization.current_language][text] )
return OSRM.Localization[OSRM.Localization.current_language][text];
else if( OSRM.Localization[OSRM.DEFAULTS.LANGUAGE] && OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text] )
return OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text];
else
return text;
}
};
// shorter call to translate function
OSRM.loc = OSRM.Localization.translate;
+389 -177
View File
@@ -18,25 +18,19 @@ or see http://www.gnu.org/licenses/agpl.txt.
/* OSRM CSS styles */
/* map -> fullscreen */
body {
/* fullscreen map */
html, body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
}
#map {
height: 100%;
z-index: 0;
}
/* styles for gui */
.vquad
{
height:10px;
}
/* general styles for gui boxes */
.gui-wrapper
{
position:absolute;
@@ -63,11 +57,13 @@ html, body, #map {
padding:5px;
}
/* styles for specific gui boxes */
#main-wrapper
{
width:410px;
height:95%;
top:5px;
bottom:25px;
left:5px;
}
#main-input
@@ -78,10 +74,9 @@ html, body, #map {
#main-output
{
width:390px;
top:220px;
top:220px; /* main-input.height+2*gui-box.margin+2*gui-box.padding */
bottom:0px;
}
#blob-wrapper
{
left:-5px;
@@ -96,66 +91,102 @@ html, body, #map {
-webkit-border-bottom-left-radius:0px;
visibility:hidden;
}
#blob-input
#blob-content
{
width:26px;
height:26px;
width:16px;
height:16px;
border-top-left-radius:0px;
border-bottom-left-radius:0px;
-moz-border-radius-topleft:0px;
-moz-border-radius-bottomleft:0px;
-webkit-border-top-left-radius:0px;
-webkit-border-bottom-left-radius:0px;
padding:0px;
}
.main-toggle-out
/* styles for main-input areas */
#input-mask-header
{
cursor:pointer;
position:absolute;
right:5px;
top:5px;
width:16px;
height:16px;
background-image:url("images/cancel.png");
left:0px;
right:0px;
top:0px;
height:50px;
background-repeat:no-repeat;
background-position:center;
background-image:url("images/osrm-logo.png");
}
.main-toggle-out:hover
#input-mask
{
background-image:url("images/cancel_hover.png");
margin:3px;
}
.main-toggle-out:active
#input-mask-options
{
background-image:url("images/cancel_active.png");
}
.main-toggle-in
{
cursor:pointer;
position:absolute;
right:5px;
top:5px;
width:16px;
height:16px;
background-image:url("images/restore.png");
}
.main-toggle-in:hover
{
background-image:url("images/restore_hover.png");
}
.main-toggle-in:active
{
background-image:url("images/restore_active.png");
margin:3px;
}
.main-options
/* styles for main-input input-mask-header */
#gui-language-toggle
{
font-size:10px;
position:absolute;
border: 0px;
text-decoration:none;
opacity: 0;
filter: alpha(opacity=0);
z-index: 5;
}
#options-toggle
.styled-select
{
position:absolute;
background: url("images/selector.png");
background-repeat:no-repeat;
background-position: top right;
padding: 1px 1px 1px 1px;
overflow: hidden;
}
.top-left-button
{
float:left;
}
.top-right-button
{
float:right;
}
/* styles for main-input input-mask */
.input-marker
{
display:table-row;
}
.input-marker > div
{
padding-bottom:4px;
}
.input-label
{
margin:0px 2px 0px 0px;
}
.input-delete
{
margin:0px 15px 0px 8px;
visibility:hidden;
}
.input-box
{
width: 100%;
}
/* styles for main-input input-mask-options */
#gui-options-toggle
{
cursor:pointer;
color:#0000ff
}
#options-toggle:hover
#gui-options-toggle:hover
{
color:#ff0000
}
@@ -164,133 +195,303 @@ html, body, #map {
visibility:hidden;
}
#osrm-logo
{
display: block;
margin-left: auto;
margin-right: auto;
width: 200px;
height: 50px;
text-align:center;
vertical-align: middle;
}
.input-box
/* styles for main-output areas */
#information-box-header
{
width: 250px;
margin:5px;
height:60px;
}
.full
{
width:100%;
}
.right
{
text-align:right;
}
.center
{
text-align:center;
}
#information-box
{
position:absolute;
bottom:15px;
top:60px;
bottom:20px;
top:65px;
width:380px;
font-size:12px;
overflow:auto;
margin:5px;
}
.route-summary
{
font-size: 12px;
}
#gpx-link
{
color:#0000ff;
text-decoration:none;
cursor:pointer;
}
#gpx-link:hover
{
color:#ff0000;
}
.results-table
{
border-spacing:0px;
}
.results-odd
{
background-color: #FAF3E9; //#ffffff;
}
.results-even
{
background-color: #F2DE9C; //#ffffe0;
}
.result-counter
{
text-align:right;
vertical-align: top;
width:30px;
font-weight:bold;
padding-left:5px;
padding-right:5px;
padding-top:1px;
padding-bottom:1px;
}
.result-items
{
text-align:left;
vertical-align: middle;
width:100%;
padding-left:1px;
padding-right:1px;
padding-top:1px;
padding-bottom:1px;
}
.result-direction
{
width:30px;
padding-left:1px;
padding-right:1px;
padding-top:1px;
padding-bottom:1px;
}
.result-distance
{
text-align:right;
vertical-align: middle;
width:30px;
padding-left:1px;
padding-right:1px;
padding-top:1px;
padding-bottom:1px;
}
.result-item
{
cursor:pointer;
color:#000000
}
.result-item:hover
{
color:#ff0000
}
#legal-notice
{
position:absolute;
right:0px;
bottom:0px;
padding:5px;
font-size:10px;
margin:5px;
}
/* workaround for invisible scrollbars in Chrome */
#information-box::-webkit-scrollbar {
height: 10px;
width: 10px;
}
#information-box::-webkit-scrollbar-track {
background: #FFFFFF;
}
#information-box::-webkit-scrollbar-thumb {
min-height: 30px;
background: #EEEEEE;
border: 1px solid #999999;
-webkit-border-radius: 5ex;
}
#information-box::-webkit-scrollbar-thumb:hover {
background: #F9F9F9;
}
#information-box::-webkit-scrollbar-thumb:active {
background: #F4F4F4;
}
/* styles for information-box-header */
.header-title
{
font-weight:bold;
margin-bottom:10px;
}
.header-label
{
font-weight:normal;
padding:0px 5px 0px 0px;
}
.header-content
{
font-weight:normal;
}
.route-link
{
color:#0000ff;
text-decoration:none;
cursor:pointer;
}
.route-link:hover
{
color:#ff0000;
}
/* style for information-box table (general) */
.no-results
{
text-align:center;
margin:28px;
}
/* style for information-box table (search results) */
.results
{
border-spacing:0px;
width:100%;
}
.results-body-odd
{
background-color: #FFFDE3;
}
.results-body-even
{
background-color: #FFF9BB;
}
.results-body-counter
{
text-align:right;
vertical-align:top;
font-weight:bold;
padding:1px 5px 1px 5px;
}
.results-body-items
{
text-align:left;
vertical-align: middle;
width:100%;
padding:1px;
}
.results-body-item
{
cursor:pointer;
color:#000000
}
.results-body-item:hover
{
color:#ff0000
}
/* style for information-box table (driving directions) */
.description
{
border-spacing:0px;
width:100%;
}
.description-body-odd
{
background-color: #FFFDE3;
}
.description-body-even
{
background-color: #FFF9BB;
}
.description-body-items
{
text-align:left;
vertical-align: middle;
width:100%;
padding:1px;
}
.description-body-directions
{
text-align:left;
vertical-align: middle;
padding:1px 5px 1px 5px;
}
.description-body-direction
{
width:18px;
height:18px;
}
.description-body-distance
{
text-align:right;
vertical-align: middle;
padding:1px 1px 1px 5px;
}
.description-body-item
{
cursor:pointer;
color:#000000
}
.description-body-item:hover
{
color:#ff0000
}
/* buttons */
.button
{
cursor:pointer;
padding:2px 10px 2px 10px;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
background-color:#EEEEEE;
border:1px solid #999999;
color:#333333;
text-decoration:none;
font-size:9px;
outline-style:none;
vertical-align:1px;
}
.button:hover
{
background-color:#F9F9F9;
color:#000000;
}
.button:active
{
background-color:#F4F4F4;
color:#FF0000;
}
/* iconic buttons */
.iconic-button
{
cursor:pointer;
width:16px;
height:16px;
background-repeat:no-repeat;
background-position:center;
}
#gui-toggle-out
{
background-image:url("images/cancel.png");
}
#gui-toggle-out:hover
{
background-image:url("images/cancel_hover.png");
}
#gui-toggle-out:active
{
background-image:url("images/cancel_active.png");
}
#gui-toggle-in
{
background-image:url("images/restore.png");
}
#gui-toggle-in:hover
{
background-image:url("images/restore_hover.png");
}
#gui-toggle-in:active
{
background-image:url("images/restore_active.png");
}
#gui-printer
{
background-image:url("images/printer.png");
}
#gui-printer-inactive
{
cursor:default;
background-image:url("images/printer_inactive.png");
}
#gui-printer:hover
{
background-image:url("images/printer_hover.png");
}
#gui-printer:active
{
background-image:url("images/printer_active.png");
}
.delete-marker
{
background-image:url("images/cancel.png");
}
.delete-marker:hover
{
background-image:url("images/cancel_hover.png");
}
.delete-marker:active
{
background-image:url("images/cancel_active.png");
}
/* fonts */
.base-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
}
.big-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
}
.medium-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10.5px;
font-weight: normal;
}
.small-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;
font-weight: normal;
}
/* utility styles (defined above buttons, so that buttons retain cursor:pointer)*/
.quad
{
min-width:10px;
min-height:10px;
}
.not-selectable
{
cursor:default;
@@ -309,28 +510,39 @@ html, body, #map {
user-select: text;
}
.checkbox-label
{
vertical-align:2px;
}
/* buttons */
.button
.full
{
cursor:pointer;
padding:2px 10px 2px 10px;
border-radius:5px;
-moz-border-radius:5px;
background-color:#EEEEEE;
border:1px solid #999999;
color:#333333;
text-decoration:none;
font-size:11px;
outline-style:none;
display:table;
width:100%;
}
.button:hover
.row
{
background-color:#F9F9F9;
color:#000000;
display:table-row;
}
.button:active
.left
{
background-color:#F4F4F4;
color:#FF0000;
display:table-cell;
text-align:left;
vertical-align:middle;
}
.right
{
display:table-cell;
text-align:right;
vertical-align:middle;
}
.center
{
display:table-cell;
text-align:center;
vertical-align:middle;
}
.stretch
{
width:100%;
}
+88 -57
View File
@@ -1,4 +1,4 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
-->
<html>
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- head -->
@@ -29,9 +29,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
<meta name="description" content="OSRM Website"/>
<meta name="author" content="Dennis Schieferdecker" />
<!-- favicon -->
<link rel="shortcut icon" href="images/osrm-favicon.ico" type="image/x-icon" />
<!-- stylesheets -->
<link rel="stylesheet" href="leaflet/leaflet.css" type="text/css"/>
<!--[if lte IE 8]><link rel="stylesheet" href="leaflet/leaflet.ie.css" type="text/css"/><![endif]-->
@@ -39,88 +36,122 @@ or see http://www.gnu.org/licenses/agpl.txt.
<!-- scripts -->
<script src="leaflet/leaflet-src.js" type="text/javascript"></script>
<script src="L.DashedPolyline.js" type="text/javascript"></script>
<script src="L.MouseMarker.js" type="text/javascript"></script>
<script src="base/leaflet/L.Bugfixes.js" type="text/javascript"></script>
<script src="base/leaflet/L.Control.QueryableLayers.js" type="text/javascript"></script>
<script src="base/leaflet/L.DashedPolyline.js" type="text/javascript"></script>
<script src="base/leaflet/L.MouseMarker.js" type="text/javascript"></script>
<script src="base/leaflet/L.SwitchableIcon.js" type="text/javascript"></script>
<script src="OSRM.base.js" type="text/javascript"></script>
<script src="OSRM.config.js" type="text/javascript"></script>
<!-- <script defer="defer" src="OSRM.debug.js" type="text/javascript"></script> -->
<script src="OSRM.Browser.js" type="text/javascript"></script>
<script src="OSRM.GUI.js" type="text/javascript"></script>
<script src="OSRM.JSONP.js" type="text/javascript"></script>
<script src="OSRM.Markers.js" type="text/javascript"></script>
<script src="OSRM.Route.js" type="text/javascript"></script>
<script src="OSRM.Localization.js" type="text/javascript"></script>
<script src="utils/OSRM.browsers.js" type="text/javascript"></script>
<script src="utils/OSRM.classes.js" type="text/javascript"></script>
<script src="main.js" type="text/javascript"></script>
<script src="routing.js" type="text/javascript"></script>
<!-- <script defer="defer" src="OSRM.debug.js" type="text/javascript"></script> -->
<script src="geocoder.js" type="text/javascript"></script>
<script src="via.js" type="text/javascript"></script>
<script src="base/osrm/OSRM.MapView.js" type="text/javascript"></script>
<script src="base/osrm/OSRM.Marker.js" type="text/javascript"></script>
<script src="base/osrm/OSRM.Route.js" type="text/javascript"></script>
<script src="utils.js" type="text/javascript"></script>
<script src="base/OSRM.Map.js" type="text/javascript"></script>
<script src="base/OSRM.Markers.js" type="text/javascript"></script>
<script src="base/OSRM.Routes.js" type="text/javascript"></script>
<script src="gui/OSRM.GUI.js" type="text/javascript"></script>
<script src="gui/OSRM.MainGUI.js" type="text/javascript"></script>
<script src="routing/OSRM.Routing.js" type="text/javascript"></script>
<script src="routing/OSRM.RoutingDescription.js" type="text/javascript"></script>
<script src="routing/OSRM.RoutingGeometry.js" type="text/javascript"></script>
<script src="gui/OSRM.RoutingGUI.js" type="text/javascript"></script>
<script src="routing/OSRM.RoutingNoNames.js" type="text/javascript"></script>
<script src="base/OSRM.Via.js" type="text/javascript"></script>
<script src="base/OSRM.Geocoder.js" type="text/javascript"></script>
<script src="utils/OSRM.JSONP.js" type="text/javascript"></script>
<script src="localization/OSRM.Localization.js" type="text/javascript"></script>
<script src="printing/OSRM.Printing.js" type="text/javascript"></script>
<script src="utils/OSRM.Utils.js" type="text/javascript"></script>
</head>
<!-- body -->
<body onload="init();">
<body class="base-font not-selectable">
<!--map-->
<div id="map"></div>
<!-- show ui blob -->
<div id="blob-wrapper" class="gui-wrapper">
<div id="blob-input" class="gui-box">
<div class="main-toggle-in" onclick="OSRM.GUI.toggleMain()"></div>
<div id="blob-content" class="gui-box">
<div id="gui-toggle-in" class="iconic-button"></div>
</div>
</div>
<!-- show main gui -->
<div id="main-wrapper" class="gui-wrapper">
<div id="main-wrapper" class="gui-wrapper not-selectable">
<!-- input box -->
<div class="gui-box not-selectable" id="main-input">
<div class="main-toggle-out" onclick="OSRM.GUI.toggleMain()"></div>
<img id="osrm-logo" alt="OSRM Logo" src="images/osrm-logo.png" />
<div id="main-input" class="gui-box">
<!-- header -->
<div id="input-mask-header">
<div id="gui-toggle-out" class="iconic-button top-right-button"></div>
</div>
<!-- input mask -->
<div id="input-mask">
<!-- source/target input -->
<table class="full">
<tr>
<td id="gui-search-source-label">Start:</td>
<td><input id="input-source-name" class="input-box" type="text" maxlength="200" value="" title="Startposition eingeben" onchange="inputChanged(OSRM.C.SOURCE_LABEL);" /></td>
<td class="right"><a class="button not-selectable" id="gui-search-source" onclick="showMarker('source')">Zeigen</a></td>
</tr>
<tr>
<td id="gui-search-target-label">Ende:</td>
<td><input id="input-target-name" class="input-box" type="text" maxlength="200" value="" title="Zielposition eingeben" onchange="inputChanged(OSRM.C.TARGET_LABEL);" /></td>
<td class="right"><a class="button not-selectable" id="gui-search-target" onclick="showMarker('target');">Zeigen</a></td>
</tr>
</table>
<div class="full">
<div id="input-source" class="input-marker">
<div class="left"><span id="gui-search-source-label" class="input-label">Start:</span></div>
<div class="center input-box"><input id="gui-input-source" class="input-box" type="text" maxlength="200" value="" title="Enter start" /></div>
<div class="left"><div id="gui-delete-source" class="iconic-button delete-marker input-delete"></div></div>
<div class="right"><a class="button" id="gui-search-source">Show</a></div>
</div>
<div id="input-target" class="input-marker">
<div class="left"><span id="gui-search-target-label" class="input-label">End:</span></div>
<div class="center input-box"><input id="gui-input-target" class="input-box" type="text" maxlength="200" value="" title="Enter destination" /></div>
<div class="left"><div id="gui-delete-target" class="iconic-button delete-marker input-delete"></div></div>
<div class="right"><a class="button" id="gui-search-target">Show</a></div>
</div>
</div>
<div class="quad"></div>
<!-- action buttons -->
<div class="vquad"></div>
<table style="width:100%">
<tr>
<td> <a class="button not-selectable" id="gui-reset" onclick="resetRouting();">Reset</a></td>
<td class="right"> <a class="button not-selectable" id="gui-reverse" onclick="reverseRouting();">Umdrehen</a></td>
</tr>
</table>
<!-- options -->
<div class="vquad"></div>
<div class="main-options not-selectable" id="options-toggle" onclick="OSRM.GUI.toggleOptions()">Options</div>
<div class="main-options not-selectable" id="options-box">
<input type="checkbox" id="option-highlight-nonames" name="main-options" value="highlight-nonames" onclick="getRoute(OSRM.C.FULL_DESCRIPTION)" /><span id="gui-option-highlight-nonames-label">Unbenannte Straßen hervorheben</span>
<div class="full">
<div class="left"><a class="button" id="gui-reset">Reset</a></div>
<div class="right"><a class="button" id="gui-reverse">Reverse</a></div>
</div>
</div>
<div class="quad"></div>
<!-- options -->
<div id="input-mask-options">
<!-- option toggle -->
<span id="gui-options-toggle" class="small-font">Mapping Tools</span>
<!-- actual options -->
<div id="options-box" class="full">
<div class="left">
<input type="checkbox" id="option-highlight-nonames" value="highlight-nonames" />
<span id="gui-option-highlight-nonames-label" class="checkbox-label small-font">Highlight unnamed streets</span>
</div>
<div class="right">
<a class="button" id="open-josm">JOSM</a>
<a class="button" id="open-osmbugs">OSM Bugs</a>
</div>
</div>
</div>
</div>
<!-- output box -->
<div class="gui-box not-selectable" id="main-output">
<div id="information-box-headline"></div>
<div id="main-output" class="gui-box">
<div id="information-box-header"></div>
<div id="information-box"></div>
<div id="legal-notice">GUI2 v0.1.1 120316 - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a></div>
<div id="legal-notice" class="small-font">GUI2 - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a></div>
</div>
</div>
+132 -181
View File
@@ -16,178 +16,114 @@ or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM initialization
// [initialization of maps, local strings, image prefetching]
// will hold the Leaflet map object
OSRM.GLOBALS.map = null;
// [initialization, image prefetching]
// onload initialization routine
function init() {
prefetchImages();
prefetchIcons();
OSRM.init = function() {
OSRM.prefetchImages();
OSRM.prefetchIcons();
initLocale();
initMap();
initRouting();
// check if the URL contains some GET parameter, e.g. for the route
checkURL();
}
OSRM.Localization.init();
OSRM.GUI.init();
OSRM.Map.init();
OSRM.Printing.init();
OSRM.Routing.init();
// check if the URL contains some GET parameter, e.g. for showing a route
OSRM.parseParameters();
// only init default position / geolocation position if GET parameters do not specify a different one
if( OSRM.G.initial_position_override == false )
OSRM.Map.initPosition();
};
// prefetch images
OSRM.images = Array();
function prefetchImages() {
var images = [ 'images/marker-source.png',
'images/marker-target.png',
'images/marker-via.png',
'images/marker-highlight.png',
'images/cancel.png',
'images/cancel_active.png',
'images/cancel_hover.png',
'images/restore.png',
'images/restore_active.png',
'images/restore_hover.png'
];
for(var i=0; i<images.length; i++) {
OSRM.images[i] = new Image();
OSRM.images[i].src = images[i];
OSRM.GLOBALS.images = {};
OSRM.prefetchImages = function() {
var image_list = [ {id:'marker-shadow', url:L.RELATIVE_ROOT_URL + 'images/marker-shadow.png'},
{id:'marker-source', url:'images/marker-source.png'},
{id:'marker-target', url:'images/marker-target.png'},
{id:'marker-via', url:'images/marker-via.png'},
{id:'marker-highlight', url:'images/marker-highlight.png'},
{id:'marker-source-drag', url:'images/marker-source-drag.png'},
{id:'marker-target-drag', url:'images/marker-target-drag.png'},
{id:'marker-via-drag', url:'images/marker-via-drag.png'},
{id:'marker-highlight-drag', url:'images/marker-highlight-drag.png'},
{id:'marker-drag', url:'images/marker-drag.png'},
{id:'cancel', url:'images/cancel.png'},
{id:'cancel_active', url:'images/cancel_active.png'},
{id:'cancel_hover', url:'images/cancel_hover.png'},
{id:'restore', url:'images/restore.png'},
{id:'restore_active', url:'images/restore_active.png'},
{id:'restore_hover', url:'images/restore_hover.png'},
{id:'printer', url:'images/printer.png'},
{id:'printer_active', url:'images/printer_active.png'},
{id:'printer_hover', url:'images/printer_hover.png'},
{id:'printer_inactive', url:'images/printer_inactive.png'},
{id:'direction_0', url:'images/default.png'},
{id:'direction_1', url:'images/continue.png'},
{id:'direction_2', url:'images/slight-right.png'},
{id:'direction_3', url:'images/turn-right.png'},
{id:'direction_4', url:'images/sharp-right.png'},
{id:'direction_5', url:'images/u-turn.png'},
{id:'direction_6', url:'images/slight-left.png'},
{id:'direction_7', url:'images/turn-left.png'},
{id:'direction_8', url:'images/sharp-left.png'},
{id:'direction_10', url:'images/head.png'},
{id:'direction_11', url:'images/round-about.png'},
{id:'direction_15', url:'images/target.png'}
];
for(var i=0; i<image_list.length; i++) {
OSRM.G.images[image_list[i].id] = new Image();
OSRM.G.images[image_list[i].id].src = image_list[i].url;
}
}
};
// prefetch icons
OSRM.icons = Array();
function prefetchIcons() {
var images = [ 'marker-source',
'marker-target',
'marker-via',
'marker-highlight',
OSRM.GLOBALS.icons = {};
OSRM.prefetchIcons = function() {
var icon_list = [ {id:'marker-source', image_id:'marker-source'},
{id:'marker-target', image_id:'marker-target'},
{id:'marker-via', image_id:'marker-via'},
{id:'marker-highlight', image_id:'marker-highlight'},
{id:'marker-source-drag', image_id:'marker-source-drag'},
{id:'marker-target-drag', image_id:'marker-target-drag'},
{id:'marker-via-drag', image_id:'marker-via-drag'},
{id:'marker-highlight-drag', image_id:'marker-highlight-drag'}
//{id:'marker-drag', image_id:'marker-drag'} // special treatment because of size
];
for(var i=0; i<images.length; i++)
OSRM.icons[images[i]] = new L.Icon('images/'+images[i]+'.png');
}
// init localization
function initLocale() {
document.getElementById("gui-reset").innerHTML = OSRM.loc("GUI_RESET");
document.getElementById("gui-reverse").innerHTML = OSRM.loc("GUI_REVERSE");
document.getElementById("gui-option-highlight-nonames-label").innerHTML = OSRM.loc("GUI_HIGHLIGHT_UNNAMED_ROADS");
document.getElementById("options-toggle").innerHTML = OSRM.loc("GUI_OPTIONS");
document.getElementById("gui-search-source").innerHTML = OSRM.loc("GUI_SEARCH");
document.getElementById("gui-search-target").innerHTML = OSRM.loc("GUI_SEARCH");
document.getElementById("gui-search-source-label").innerHTML = OSRM.loc("GUI_START")+":";
document.getElementById("gui-search-target-label").innerHTML = OSRM.loc("GUI_END")+":";
document.getElementById("input-source-name").title = OSRM.loc("GUI_START_TOOLTIP");
document.getElementById("input-target-name").title = OSRM.loc("GUI_END_TOOLTIP");
document.getElementById("legal-notice").innerHTML = OSRM.loc("GUI_LEGAL_NOTICE");
for(var i=0; i<icon_list.length; i++) {
var icon = {
iconUrl: OSRM.G.images[icon_list[i].image_id].getAttribute("src"), iconSize: new L.Point(25, 41), iconAnchor: new L.Point(13, 41),
shadowUrl: OSRM.G.images["marker-shadow"].getAttribute("src"), shadowSize: new L.Point(41, 41),
popupAnchor: new L.Point(0, -33)
};
OSRM.G.icons[icon_list[i].id] = new L.SwitchableIcon(icon);
}
document.getElementById('input-source-name').value = OSRM.DEFAULTS.ONLOAD_SOURCE;
document.getElementById('input-target-name').value = OSRM.DEFAULTS.ONLOAD_TARGET;
}
// special values for drag marker
OSRM.G.icons['marker-drag'] = new L.SwitchableIcon( {iconUrl: OSRM.G.images["marker-drag"].getAttribute("src"), iconSize: new L.Point(18, 18) } );
};
// centering on geolocation
function callbak_centerOnGeolocation( position ) {
OSRM.G.map.setView( new L.LatLng( position.coords.latitude, position.coords.longitude), OSRM.DEFAULTS.ZOOM_LEVEL);
}
function centerOnGeolocation() {
if (navigator.geolocation)
navigator.geolocation.getCurrentPosition( callbak_centerOnGeolocation );
}
// init map
function initMap() {
// setup tile servers
var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmorgAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 Mapnik',
osmorgOptions = {maxZoom: 18, attribution: osmorgAttribution};
var osmdeURL = 'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png',
osmdeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 Mapnik',
osmdeOptions = {maxZoom: 18, attribution: osmdeAttribution};
var mapquestURL = 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png',
mapquestAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 MapQuest',
mapquestOptions = {maxZoom: 18, attribution: mapquestAttribution, subdomains: '1234'};
var cloudmadeURL = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade',
cloudmadeOptions = {maxZoom: 18, attribution: cloudmadeAttribution};
var osmorg = new L.TileLayer(osmorgURL, osmorgOptions),
osmde = new L.TileLayer(osmdeURL, osmdeOptions),
mapquest = new L.TileLayer(mapquestURL, mapquestOptions),
cloudmade = new L.TileLayer(cloudmadeURL, cloudmadeOptions);
// setup map
OSRM.G.map = new L.Map('map', {
center: new L.LatLng(51.505, -0.09),
zoom: 13,
zoomAnimation: false, // false: removes animations and hiding of routes during zoom
fadeAnimation: false,
layers: [osmorg]
});
// add tileservers
var baseMaps = {
"osm.org": osmorg,
"osm.de": osmde,
"MapQuest": mapquest,
"CloudMade": cloudmade
};
var overlayMaps = {};
var layersControl = new L.Control.Layers(baseMaps, overlayMaps);
OSRM.G.map.addControl(layersControl);
// move zoom markers
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="420px";
getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
// initial map position and zoom
OSRM.G.map.setView( new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE), OSRM.DEFAULTS.ZOOM_LEVEL);
OSRM.G.map.on('zoomend', function(e) { getRoute(OSRM.C.FULL_DESCRIPTION); });
OSRM.G.map.on('contextmenu', function(e) {});
// click on map to set source and target nodes
OSRM.G.map.on('click', function(e) {
if( !OSRM.G.markers.hasSource() ) {
var index = OSRM.G.markers.setSource( e.latlng );
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() );
getRoute( OSRM.C.FULL_DESCRIPTION );
} else if( !OSRM.G.markers.hasTarget() ) {
var index = OSRM.G.markers.setTarget( e.latlng );
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() );
getRoute( OSRM.C.FULL_DESCRIPTION );
}
} );
}
// parse URL GET parameters if any exist
function checkURL(){
//parse URL GET parameters
OSRM.parseParameters = function(){
var called_url = document.location.search.substr(1,document.location.search.length);
// reject messages that are clearly too long or too small
// state, if GET parameters specify a different initial position
OSRM.G.initial_position_override = false;
// reject messages that are clearly too long or too small
if( called_url.length > 1000 || called_url.length == 0)
return;
// storage for parameter values
var positions = [];
var zoom = null;
var center = null;
var destination = null;
var destination_name = null;
var params = {};
// parse input
var splitted_url = called_url.split('&');
@@ -195,72 +131,87 @@ function checkURL(){
var name_val = splitted_url[i].split('=');
if(name_val.length!=2)
continue;
if(name_val[0] == 'loc') {
if(name_val[0] == 'hl') {
OSRM.Localization.setLanguage(name_val[1]);
}
else if(name_val[0] == 'loc') {
var coordinates = unescape(name_val[1]).split(',');
if(coordinates.length!=2 || !isLatitude(coordinates[0]) || !isLongitude(coordinates[1]) )
if(coordinates.length!=2 || !OSRM.Utils.isLatitude(coordinates[0]) || !OSRM.Utils.isLongitude(coordinates[1]) )
return;
positions.push ( new L.LatLng( coordinates[0], coordinates[1]) );
params.positions = params.positions || [];
params.positions.push ( new L.LatLng( coordinates[0], coordinates[1]) );
}
else if(name_val[0] == 'dest') {
var coordinates = unescape(name_val[1]).split(',');
if(coordinates.length!=2 || !isLatitude(coordinates[0]) || !isLongitude(coordinates[1]) )
if(coordinates.length!=2 || !OSRM.Utils.isLatitude(coordinates[0]) || !OSRM.Utils.isLongitude(coordinates[1]) )
return;
destination = new L.LatLng( coordinates[0], coordinates[1]);
params.destination = new L.LatLng( coordinates[0], coordinates[1]);
}
else if(name_val[0] == 'destname') {
destination_name = decodeURI(name_val[1]).replace(/<\/?[^>]+(>|$)/g ,""); // discard tags
params.destination_name = decodeURI(name_val[1]).replace(/<\/?[^>]+(>|$)/g ,""); // discard tags
}
else if(name_val[0] == 'z') {
zoom = name_val[1];
if( zoom<0 || zoom > 18)
var zoom_level = Number(name_val[1]);
if( zoom_level<0 || zoom_level > 18)
return;
params.zoom = zoom_level;
}
else if(name_val[0] == 'center') {
var coordinates = unescape(name_val[1]).split(',');
if(coordinates.length!=2 || !isLatitude(coordinates[0]) || !isLongitude(coordinates[1]) )
if(coordinates.length!=2 || !OSRM.Utils.isLatitude(coordinates[0]) || !OSRM.Utils.isLongitude(coordinates[1]) )
return;
center = new L.LatLng( coordinates[0], coordinates[1]);
params.center = new L.LatLng( coordinates[0], coordinates[1]);
}
}
// case 1: destination given
if( destination != undefined ) {
var index = OSRM.G.markers.setTarget( e.latlng );
if( destination_name == null )
updateAddress( OSRM.C.TARGET_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG );
if( params.destination ) {
var index = OSRM.G.markers.setTarget( params.destination.latlng );
if( params.destination_name )
document.getElementById("gui-input-target").value = params.destination_name;
else
document.getElementById("input-target-name").value = destination_name;
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.initial_position_override = true;
return;
}
// case 2: locations given
if( positions != []) {
if( params.positions ) {
// draw via points
if( positions.length > 0) {
OSRM.G.markers.setSource( positions[0] );
updateAddress( OSRM.C.SOURCE_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG );
if( params.positions.length > 0 ) {
OSRM.G.markers.setSource( params.positions[0] );
OSRM.Geocoder.updateAddress( OSRM.C.SOURCE_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG );
}
if(positions.length > 1) {
OSRM.G.markers.setTarget( positions[positions.length-1] );
updateAddress( OSRM.C.TARGET_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG );
if( params.positions.length > 1 ) {
OSRM.G.markers.setTarget( params.positions[params.positions.length-1] );
OSRM.Geocoder.updateAddress( OSRM.C.TARGET_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG );
}
for(var i=1; i<positions.length-1;i++)
OSRM.G.markers.setVia( i-1, positions[i] );
for(var i=1; i<params.positions.length-1;i++)
OSRM.G.markers.setVia( i-1, params.positions[i] );
for(var i=0; i<OSRM.G.markers.route.length;i++)
OSRM.G.markers.route[i].show();
// center on route (support for old links) / move to given view (new behaviour)
if(zoom == null || center == null) {
var bounds = new L.LatLngBounds( positions );
OSRM.G.map.fitBounds( bounds );
if( params.zoom == null || params.center == null ) {
var bounds = new L.LatLngBounds( params.positions );
OSRM.G.map.fitBoundsUI( bounds );
} else {
OSRM.G.map.setView(center, zoom);
OSRM.G.map.setView(params.center, params.zoom);
}
// compute route
getRoute(OSRM.C.FULL_DESCRIPTION);
OSRM.Routing.getRoute();
OSRM.G.initial_position_override = true;
return;
}
}
// default case: do nothing
return;
};
// onload event
OSRM.Browser.onLoadHandler( OSRM.init );
+184
View File
@@ -0,0 +1,184 @@
/*
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 printing
// [printing support]
OSRM.Printing = {
// create UI for printing in mainwindow
init: function() {
var icon = document.createElement('div');
icon.id = "gui-printer-inactive";
icon.className = "iconic-button top-right-button";
var spacer = document.createElement('div');
spacer.className = "quad top-right-button";
var input_mask_header = document.getElementById('input-mask-header');
input_mask_header.appendChild(spacer,input_mask_header.lastChild);
input_mask_header.appendChild(icon,input_mask_header.lastChild);
document.getElementById("gui-printer-inactive").onclick = OSRM.Printing.openPrintWindow;
},
// switch printer button on/off
activate: function() { // use showing route description as trigger
if( document.getElementById("gui-printer-inactive") )
document.getElementById("gui-printer-inactive").id = "gui-printer";
},
deactivate: function() { // use hide route as trigger
if( document.getElementById("gui-printer") )
document.getElementById("gui-printer").id = "gui-printer-inactive";
},
// create UI in printwindow
show: function(response) {
// create header
var header =
'<thead class="description-header"><tr><td colspan="3">' +
'<div class="full">' +
'<div class="row">' +
'<div class="left stretch">' +
'<div class="full">' +
'<div class="row">' +
'<div class="left description-header-label">' + OSRM.loc("GUI_START")+ ': </div>' +
'<div class="left description-header-content stretch">' + document.getElementById("gui-input-source").value + '</div>' +
'</div>' +
'<div class="row">' +
'<div class="left description-header-label">' + OSRM.loc("GUI_END")+ ': </div>' +
'<div class="left description-header-content stretch">' + document.getElementById("gui-input-target").value + '</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="left">' +
'<div class="full">' +
'<div class="row">' +
'<div class="left description-header-label">' + OSRM.loc("DISTANCE")+': </div>' +
'<div class="left description-header-content">' + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '</div>' +
'</div>' +
'<div class="row">' +
'<div class="left description-header-label">' + OSRM.loc("DURATION")+': </div>' +
'<div class="left description-header-content">' + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="quad"></div>' +
'</td></tr></thead>';
// create route description
var body = '<tbody class="description-body">';
for(var i=0; i < response.route_instructions.length; i++){
//odd or even ?
var rowstyle='description-body-odd';
if(i%2==0) { rowstyle='description-body-even'; }
body += '<tr class="'+rowstyle+'">';
body += '<td class="description-body-directions">';
body += '<img class="description-body-direction" src="../'+OSRM.RoutingDescription._getDrivingInstructionIcon(response.route_instructions[i][0])+'" alt="" />';
body += "</td>";
// build route description
body += '<td class="description-body-items">';
if( response.route_instructions[i][1] != "" )
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]).replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
else
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"").replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
body += "</td>";
body += '<td class="description-body-distance">';
if( i != response.route_instructions.length-1 )
body += '<b>'+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+'</b>';
body += "</td>";
body += "</tr>";
}
body += '</tbody>';
// put everything in DOM
var print_window = OSRM.G.printwindow;
print_window.document.getElementById('description').innerHTML = '<table class="description medium-font">' + header + body + '</table>';
print_window.document.getElementById('overview-map-description').innerHTML = '<table class="description medium-font">' + header + '</table>';
// draw map
var positions = OSRM.G.route.getPositions();
var tile_server_id = OSRM.G.map.getActiveLayerId();
var zoom = print_window.drawMap( OSRM.DEFAULTS.TILE_SERVERS[tile_server_id], new L.LatLngBounds( positions ) );
// draw markers
print_window.prefetchIcons( OSRM.G.images );
print_window.drawMarkers( OSRM.G.markers.route );
// draw route & query for better geometry
print_window.drawRoute( positions );
OSRM.JSONP.call(OSRM.Routing._buildCall()+'&z='+zoom+'&instructions=false', OSRM.Printing.drawRoute, OSRM.Printing.timeoutRoute, OSRM.DEFAULTS.JSONP_TIMEOUT, 'print');
},
timeoutRoute: function() {},
drawRoute: function(response) {
if(!response)
return;
var positions = OSRM.RoutingGeometry._decode(response.route_geometry, 5);
OSRM.G.printwindow.drawRoute( positions );
},
// opens the print window and closes old instances
openPrintWindow: function() {
// do not open window if there is no route to draw
if( !OSRM.G.route.isRoute() || !OSRM.G.route.isShown() )
return;
// close old window (should we really do this?)
if( OSRM.G.printwindow )
OSRM.G.printwindow.close();
// generate a new window and wait till it has finished loading
OSRM.G.printwindow = window.open("printing/printing.html","","width=540,height=500,left=100,top=100,dependent=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes");
},
// add content to printwindow after it has finished loading
printWindowLoaded: function(){
var print_window = OSRM.G.printwindow;
var print_document = print_window.document;
// add events
print_document.getElementById('gui-printer').onclick = print_window.printWindow;
// localization
print_document.getElementById('description-label').innerHTML = OSRM.loc( "ROUTE_DESCRIPTION" );
print_document.getElementById('overview-map-label').innerHTML = OSRM.loc( "OVERVIEW_MAP" );
// add routing content
OSRM.Printing.show( OSRM.G.response );
// finally, focus on printwindow
print_window.focus();
}
};
+253
View File
@@ -0,0 +1,253 @@
/*
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 CSS styles for printing*/
/* page setup */
body
{
margin: 8px;
}
/* header area */
#printing-header
{
left:0px;
right:0px;
top:0px;
height:20px;
}
.top-left-button
{
float:left;
}
.top-right-button
{
float:right;
}
/* content area */
div.label
{
font-weight:bold;
margin-bottom:10px;
}
.box
{
width:500px;
margin:5px;
}
#overview-map
{
width:500px;
height:500px;
margin:5px;
}
/* description content */
.description
{
border-spacing:0px;
width:100%;
}
/* styles for description header */
.description-header
{
display:table-header-group;
}
.description-header-label
{
padding:0px 5px 0px 0px;
}
.description-header-content
{
font-weight:bold;
}
/* styles for description body */
.description-body
{
display:table-row-group;
}
.description-body-odd
{
background-color: #FFFDE3;
}
.description-body-even
{
background-color: #FFF9BB;
}
.description-body-items
{
text-align:left;
vertical-align: middle;
width:100%;
padding:1px;
}
.description-body-directions
{
text-align:left;
vertical-align: middle;
padding:1px 5px 1px 5px;
}
.description-body-direction
{
height:36px;
width:36px;
}
.description-body-distance
{
text-align:right;
vertical-align: middle;
padding:1px 1px 1px 5px;
}
@media print {
.description-body-even > td,
.description-body-odd > td
{
border-bottom: 1px solid black;
}
}
/* utility styles */
.quad
{
min-width:10px;
min-height:10px;
}
@media print {
.pagebreak
{
page-break-before:always;
}
.noprint
{
display:none;
}
}
/* fonts */
@media print {
.base-font {
font-family: Times New Roman, Times, serif;
font-size: 16px;
font-weight: normal;
}
.big-font {
font-family: Times New Roman, Times, serif;
font-size: 18px;
font-weight: bold;
}
.medium-font {
font-family: Times New Roman, Times, serif;
font-size: 14px;
font-weight: normal;
}
.small-font {
font-family: Times New Roman, Times, serif;
font-size: 12px;
font-weight: normal;
}
}
@media screen {
.base-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
}
.big-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
}
.medium-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10.5px;
font-weight: normal;
}
.small-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;
font-weight: normal;
}
}
/* iconic buttons */
.iconic-button
{
cursor:pointer;
width:16px;
height:16px;
background-repeat:no-repeat;
background-position:center;
}
#gui-printer
{
background-image:url("../images/printer.png");
}
#gui-printer:hover
{
background-image:url("../images/printer_hover.png");
}
#gui-printer:active
{
background-image:url("../images/printer_active.png");
}
/* table */
.full
{
display:table;
width:100%;
}
.row
{
display:table-row;
}
.left
{
display:table-cell;
text-align:left;
vertical-align:top;
}
.right
{
display:table-cell;
text-align:right;
vertical-align:top;
}
.center
{
display:table-cell;
text-align:center;
vertical-align:top;
}
.stretch
{
width:100%;
}
+68
View File
@@ -0,0 +1,68 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
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.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- head -->
<head>
<!-- metatags -->
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>OSRM Website</title>
<meta name="description" content="OSRM Website"/>
<meta name="author" content="Dennis Schieferdecker" />
<!-- stylesheets -->
<link rel="stylesheet" href="../leaflet/leaflet.css" type="text/css"/>
<!--[if lte IE 8]><link rel="stylesheet" href="../leaflet/leaflet.ie.css" type="text/css"/><![endif]-->
<link rel="stylesheet" href="printing.css" type="text/css"/>
<!-- scripts -->
<script src="printing.js" type="text/javascript"></script>
<script src="../leaflet/leaflet-src.js" type="text/javascript"></script>
<script src="../base/leaflet/L.DashedPolyline.js" type="text/javascript"></script>
<script src="../base/leaflet/L.MouseMarker.js" type="text/javascript"></script>
<script src="../base/leaflet/L.SwitchableIcon.js" type="text/javascript"></script>
<script src="../base/osrm/OSRM.MapView.js" type="text/javascript"></script>
</head>
<!-- body -->
<body class="base-font">
<!-- header -->
<div id="printing-header" class="noprint">
<div id="gui-printer" class="iconic-button top-right-button"></div>
</div>
<!--description-->
<div id="description-label" class="label">Route Description</div>
<div id="description" class="box"></div>
<!--map-->
<div class="pagebreak"></div>
<div class="quad noprint"></div>
<div class="quad noprint"></div>
<div id="overview-map-label" class="label">Overview Map</div>
<div id="overview-map-description" class="box"></div>
<div id="overview-map"></div>
</body>
</html>
+98
View File
@@ -0,0 +1,98 @@
/*
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 initialization
// [for printing window]
OSRM = {};
OSRM.GLOBALS = {};
OSRM.GUI = { visible:false };
OSRM.G = OSRM.GLOBALS;
//print the window
function printWindow() {
window.print();
}
//prefetch icons
OSRM.GLOBALS.icons = {};
prefetchIcons = function(images_list) {
var icon_list = [ {id:'marker-source', image_id:'marker-source'},
{id:'marker-target', image_id:'marker-target'},
{id:'marker-via', image_id:'marker-via'},
{id:'marker-highlight', image_id:'marker-highlight'}
];
for(var i=0; i<icon_list.length; i++) {
var icon = {
iconUrl: "../"+images_list[icon_list[i].image_id].getAttribute("src"), iconSize: new L.Point(25, 41), iconAnchor: new L.Point(13, 41),
shadowUrl: "../"+images_list["marker-shadow"].getAttribute("src"), shadowSize: new L.Point(41, 41),
popupAnchor: new L.Point(0, -33)
};
OSRM.G.icons[icon_list[i].id] = new L.SwitchableIcon(icon);
}
};
// function to initialize a map in the new window
function drawMap(tile_server, bounds) {
// setup map
var tile_layer = new L.TileLayer(tile_server.url, tile_server.options);
OSRM.G.map = new OSRM.MapView("overview-map", {
center: new L.LatLng(48.84, 10.10),
zoom: 13,
zoomAnimation: false,
fadeAnimation: false,
layers: [tile_layer],
attributionControl: false,
zoomControl: false,
dragging:false,
scrollWheelZoom:false,
touchZoom:false,
doubleClickZoom:false
});
OSRM.G.map.fitBoundsUI(bounds);
return OSRM.G.map.getBoundsZoom(bounds);
}
// manage makers
function drawMarkers( markers ) {
OSRM.G.map.addLayer( new L.MouseMarker( markers[0].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-source']} ) );
for(var i=1, size=markers.length-1; i<size; i++)
OSRM.G.map.addLayer( new L.MouseMarker( markers[i].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-via']} ) );
OSRM.G.map.addLayer( new L.MouseMarker( markers[markers.length-1].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-target']} ) );
}
// manage route
function drawRoute( positions ) {
OSRM.G.route = new L.DashedPolyline();
OSRM.G.route.setLatLngs( positions );
OSRM.G.route.setStyle( {dashed:false,clickable:false,color:'#0033FF', weight:5} );
OSRM.G.map.addLayer( OSRM.G.route );
}
function updateRoute( positions ) {
OSRM.G.route.setLatLngs( positions );
}
// start populating the window when it is fully loaded
window.opener.OSRM.Browser.onLoadHandler( window.opener.OSRM.Printing.printWindowLoaded, window );
-490
View File
@@ -1,490 +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 routing routines
// [management of routing/direction requests and processing of responses]
// [TODO: major refactoring scheduled]
// some variables
OSRM.GLOBALS.route = null;
OSRM.GLOBALS.markers = null;
OSRM.CONSTANTS.NO_DESCRIPTION = 0;
OSRM.CONSTANTS.FULL_DESCRIPTION = 1;
OSRM.G.dragging = null;
OSRM.GLOBALS.dragid = null;
OSRM.GLOBALS.pending = false;
OSRM.GLOBALS.pendingTimer = null;
// init routing data structures
function initRouting() {
OSRM.G.route = new OSRM.Route();
OSRM.G.markers = new OSRM.Markers();
}
// -- JSONP processing --
// process JSONP response of routing server
function timeoutRouteSimple() {
showNoRouteGeometry();
showNoRouteDescription();
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("TIMED_OUT")+".<p>";
}
function timeoutRoute() {
showNoRouteGeometry();
OSRM.G.route.hideUnnamedRoute();
showNoRouteDescription();
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("TIMED_OUT")+".<p>";
}
function showRouteSimple(response) {
if(!response)
return;
if( !OSRM.G.dragging ) // prevent simple routing when no longer dragging
return;
if( response.status == 207) {
showNoRouteGeometry();
showNoRouteDescription();
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED")+".<p>";
} else {
showRouteGeometry(response);
showRouteDescriptionSimple(response);
}
updateHints(response);
// // TODO: hack to process final drag event, if it was fenced, but we are still dragging (alternative approach)
// if(OSRM.G.pending) {
// clearTimeout(OSRM.G.pendingTimer);
// OSRM.G.pendingTimer = setTimeout(timeoutDrag,100);
// }
}
function showRoute(response) {
if(!response)
return;
if(response.status == 207) {
showNoRouteGeometry();
OSRM.G.route.hideUnnamedRoute();
showNoRouteDescription();
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_ROUTE_FOUND")+".<p>";
} else {
showRouteGeometry(response);
showRouteNonames(response);
showRouteDescription(response);
snapRoute();
}
updateHints(response);
}
// show route geometry
function showNoRouteGeometry() {
var positions = [];
for(var i=0; i<OSRM.G.markers.route.length;i++)
positions.push( OSRM.G.markers.route[i].getPosition() );
OSRM.G.route.showRoute(positions, OSRM.Route.NOROUTE);
}
function showRouteGeometry(response) {
OSRM.G.via_points = response.via_points.slice(0);
var geometry = decodeRouteGeometry(response.route_geometry, 5);
var points = [];
for( var i=0; i < geometry.length; i++) {
points.push( new L.LatLng(geometry[i][0], geometry[i][1]) );
}
OSRM.G.route.showRoute(points, OSRM.Route.ROUTE);
}
// route description display (and helper functions)
function onClickRouteDescription(geometry_index) {
var positions = OSRM.G.route.getPositions();
OSRM.G.markers.highlight.setPosition( positions[geometry_index] );
OSRM.G.markers.highlight.show();
OSRM.G.markers.highlight.centerView(OSRM.DEFAULTS.HIGHLIGHT_ZOOM_LEVEL);
}
function onClickCreateShortcut(src){
src += '&z='+ OSRM.G.map.getZoom() + '&center=' + OSRM.G.map.getCenter().lat + ',' + OSRM.G.map.getCenter().lng;
OSRM.JSONP.call(OSRM.DEFAULTS.HOST_SHORTENER_URL+src, showRouteLink, showRouteLink_TimeOut, 2000, 'shortener');
document.getElementById('route-prelink').innerHTML = '['+OSRM.loc("GENERATE_LINK_TO_ROUTE")+']';
}
function showRouteLink(response){
document.getElementById('route-prelink').innerHTML = '[<a id="gpx-link" class = "text-selectable" href="' +response.ShortURL+ '">'+response.ShortURL+'</a>]';
}
function showRouteLink_TimeOut(){
document.getElementById('route-prelink').innerHTML = '['+OSRM.loc("LINK_TO_ROUTE_TIMEOUT")+']';
}
function showRouteDescription(response) {
// compute query string
var query_string = '?rebuild=1';
for(var i=0; i<OSRM.G.markers.route.length; i++)
query_string += '&loc=' + OSRM.G.markers.route[i].getLat() + ',' + OSRM.G.markers.route[i].getLng();
// create link to the route
var route_link ='<span class="route-summary" id="route-prelink">[<a id="gpx-link" onclick="onClickCreateShortcut(\'' + OSRM.DEFAULTS.WEBSITE_URL + query_string + '\')">'+OSRM.loc("GET_LINK_TO_ROUTE")+'</a>]</span>';
// create GPX link
var gpx_link = '<span class="route-summary">[<a id="gpx-link" onClick="document.location.href=\'' + OSRM.DEFAULTS.HOST_ROUTING_URL + query_string + '&output=gpx\';">'+OSRM.loc("GPX_FILE")+'</a>]</span>';
// create route description
var route_desc = "";
route_desc += '<table class="results-table">';
for(var i=0; i < response.route_instructions.length; i++){
//odd or even ?
var rowstyle='results-odd';
if(i%2==0) { rowstyle='results-even'; }
route_desc += '<tr class="'+rowstyle+'">';
route_desc += '<td class="result-directions">';
route_desc += '<img width="18px" src="images/'+getDirectionIcon(response.route_instructions[i][0])+'"/>';
route_desc += "</td>";
route_desc += '<td class="result-items">';
route_desc += '<span class="result-item" onclick="onClickRouteDescription('+response.route_instructions[i][3]+')">';
route_desc += response.route_instructions[i][0];
if( i == 0 )
route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] );
if( response.route_instructions[i][1] != "" ) {
route_desc += ' on ';
route_desc += '<b>' + response.route_instructions[i][1] + '</b>';
}
//route_desc += ' for ';
route_desc += '</span>';
route_desc += "</td>";
route_desc += '<td class="result-distance">';
if( i != response.route_instructions.length-1 )
route_desc += '<b>'+getDistanceWithUnit(response.route_instructions[i][2])+'</b>';
route_desc += "</td>";
route_desc += "</tr>";
}
route_desc += '</table>';
headline = "";
headline += OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
headline += '<div style="float:left;width:40%">';
headline += "<span class='route-summary'>"
+ OSRM.loc("DISTANCE")+": " + getDistanceWithUnit(response.route_summary.total_distance)
+ "<br>"
+ OSRM.loc("DURATION")+": " + secondsToTime(response.route_summary.total_time)
+ "</span>";
headline += '</div>';
headline += '<div style="float:left;text-align:right;width:60%;">'+route_link+'<br>'+gpx_link+'</div>';
var output = "";
output += route_desc;
document.getElementById('information-box-headline').innerHTML = headline;
document.getElementById('information-box').innerHTML = output;
}
function showRouteDescriptionSimple(response) {
headline = OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
headline += "<span class='route-summary'>"
+ OSRM.loc("DISTANCE")+": " + getDistanceWithUnit(response.route_summary.total_distance)
+ "<br>"
+ OSRM.loc("DURATION")+": " + secondsToTime(response.route_summary.total_time)
+ "</span>";
headline += '<br><br>';
document.getElementById('information-box-headline').innerHTML = headline;
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED")+".<p>";
}
function showNoRouteDescription() {
headline = OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
headline += "<span class='route-summary'>"
+ OSRM.loc("DISTANCE")+": N/A"
+ "<br>"
+ OSRM.loc("DURATION")+": N/A"
+ "</span>";
headline += '<br><br>';
document.getElementById('information-box-headline').innerHTML = headline;
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED")+".<p>";
}
// unnamed streets display
function showRouteNonames(response) {
// do not display unnamed streets?
if( document.getElementById('option-highlight-nonames').checked == false) {
OSRM.G.route.hideUnnamedRoute();
return;
}
// mark geometry positions where unnamed/named streets switch
var named = [];
for (var i = 0; i < response.route_instructions.length; i++) {
if( response.route_instructions[i][1] == '' )
named[ response.route_instructions[i][3] ] = false; // no street name
else
named[ response.route_instructions[i][3] ] = true; // yes street name
}
// aggregate geometry for unnamed streets
var geometry = decodeRouteGeometry(response.route_geometry, 5);
var is_named = true;
var current_positions = [];
var all_positions = [];
for( var i=0; i < geometry.length; i++) {
current_positions.push( new L.LatLng(geometry[i][0], geometry[i][1]) );
// still named/unnamed?
if( (named[i] == is_named || named[i] == undefined) && i != geometry.length-1 )
continue;
// switch between named/unnamed!
if(is_named == false)
all_positions.push( current_positions );
current_positions = [];
current_positions.push( new L.LatLng(geometry[i][0], geometry[i][1]) );
is_named = named[i];
}
// display unnamed streets
OSRM.G.route.showUnnamedRoute(all_positions);
}
//-- main function --
// generate server calls to query routes
function getRoute(do_description) {
// if source or target are not set -> hide route
if( OSRM.G.markers.route.length < 2 ) {
OSRM.G.route.hideRoute();
return;
}
// prepare JSONP call
var type = null;
var callback = null;
var timeout = null;
var source = OSRM.DEFAULTS.HOST_ROUTING_URL;
source += '?z=' + OSRM.G.map.getZoom() + '&output=json' + '&geomformat=cmp';
if(OSRM.G.markers.checksum)
source += '&checksum=' + OSRM.G.markers.checksum;
for(var i=0; i<OSRM.G.markers.route.length; i++) {
source += '&loc=' + OSRM.G.markers.route[i].getLat() + ',' + OSRM.G.markers.route[i].getLng();
if( OSRM.G.markers.route[i].hint)
source += '&hint=' + OSRM.G.markers.route[i].hint;
}
// decide whether it is a dragging call or a normal one
if (do_description) {
callback = showRoute;
timeout = timeoutRoute;
source +='&instructions=true';
type = 'route';
} else {
callback = showRouteSimple;
timeout = timeoutRouteSimple;
source +='&instructions=false';
type = 'dragging';
}
// do call
var called = OSRM.JSONP.call(source, callback, timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, type);
// TODO: hack to process final drag event, if it was fenced, but we are still dragging
if(called == false && !do_description) {
clearTimeout(OSRM.G.pendingTimer);
OSRM.G.pendingTimer = setTimeout(timeoutDrag,OSRM.DEFAULTS.JSONP_TIMEOUT);
}
else {
clearTimeout(OSRM.G.pendingTimer);
}
// // TODO: hack to process final drag event, if it was fenced, but we are still dragging (alternative approach)
// if(called == false && !do_description) {
// OSRM.G.pending = true;
// } else {
// clearTimeout(OSRM.G.pendingTimer);
// OSRM.G.pending = false;
// }
}
function timeoutDrag() {
OSRM.G.markers.route[OSRM.G.dragid].hint = null;
getRoute(OSRM.C.NO_DESCRIPTION);
}
//-- helper functions --
//decode compressed route geometry
function decodeRouteGeometry(encoded, precision) {
precision = Math.pow(10, -precision);
var len = encoded.length, index=0, lat=0, lng = 0, array = [];
while (index < len) {
var b, shift = 0, result = 0;
do {
b = encoded.charCodeAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
var dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = encoded.charCodeAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
var dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
lng += dlng;
array.push([lat * precision, lng * precision]);
}
return array;
}
// update hints of all markers
function updateHints(response) {
var hint_locations = response.hint_data.locations;
OSRM.G.markers.checksum = response.hint_data.checksum;
for(var i=0; i<hint_locations.length; i++)
OSRM.G.markers.route[i].hint = hint_locations[i];
}
// snap all markers to the received route
function snapRoute() {
var positions = OSRM.G.route.getPositions();
OSRM.G.markers.route[0].setPosition( positions[0] );
OSRM.G.markers.route[OSRM.G.markers.route.length-1].setPosition( positions[positions.length-1] );
for(var i=0; i<OSRM.G.via_points.length; i++)
OSRM.G.markers.route[i+1].setPosition( new L.LatLng(OSRM.G.via_points[i][0], OSRM.G.via_points[i][1]) );
updateAddress(OSRM.C.SOURCE_LABEL);
updateAddress(OSRM.C.TARGET_LABEL);
}
// map driving instructions to icons
// [TODO: better implementation, language-safe]
function getDirectionIcon(name) {
var directions = {
"Turn left":"turn-left.png",
"Turn right":"turn-right.png",
"U-Turn":"u-turn.png",
"Head":"continue.png",
"Continue":"continue.png",
"Turn slight left":"slight-left.png",
"Turn slight right":"slight-right.png",
"Turn sharp left":"sharp-left.png",
"Turn sharp right":"sharp-right.png",
"Enter roundabout and leave at first exit":"round-about.png",
"Enter roundabout and leave at second exit":"round-about.png",
"Enter roundabout and leave at third exit":"round-about.png",
"Enter roundabout and leave at fourth exit":"round-about.png",
"Enter roundabout and leave at fifth exit":"round-about.png",
"Enter roundabout and leave at sixth exit":"round-about.png",
"Enter roundabout and leave at seventh exit":"round-about.png",
"Enter roundabout and leave at eighth exit":"round-about.png",
"Enter roundabout and leave at nineth exit":"round-about.png",
"Enter roundabout and leave at tenth exit":"round-about.png",
"Enter roundabout and leave at one of the too many exit":"round-about.png",
"You have reached your destination":"target.png"
};
if( directions[name] )
return directions[name];
else
return "default.png";
}
// -- gui functions --
// click: button "reset"
function resetRouting() {
document.getElementById('input-source-name').value = "";
document.getElementById('input-target-name').value = "";
OSRM.G.route.hideAll();
OSRM.G.markers.removeAll();
OSRM.G.markers.highlight.hide();
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-headline').innerHTML = "";
OSRM.JSONP.reset();
}
// click: button "reverse"
function reverseRouting() {
// invert input boxes
var tmp = document.getElementById("input-source-name").value;
document.getElementById("input-source-name").value = document.getElementById("input-target-name").value;
document.getElementById("input-target-name").value = tmp;
// invert route
OSRM.G.markers.route.reverse();
if(OSRM.G.markers.route.length == 1) {
if(OSRM.G.markers.route[0].label == OSRM.C.TARGET_LABEL) {
OSRM.G.markers.route[0].label = OSRM.C.SOURCE_LABEL;
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') );
} else if(OSRM.G.markers.route[0].label == OSRM.C.SOURCE_LABEL) {
OSRM.G.markers.route[0].label = OSRM.C.TARGET_LABEL;
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-target.png') );
}
} else if(OSRM.G.markers.route.length > 1){
OSRM.G.markers.route[0].label = OSRM.C.SOURCE_LABEL;
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') );
OSRM.G.markers.route[OSRM.G.markers.route.length-1].label = OSRM.C.TARGET_LABEL;
OSRM.G.markers.route[OSRM.G.markers.route.length-1].marker.setIcon( new L.Icon('images/marker-target.png') );
}
// recompute route
if( OSRM.G.route.isShown() ) {
getRoute(OSRM.C.FULL_DESCRIPTION);
OSRM.G.markers.highlight.hide();
} else {
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-headline').innerHTML = "";
}
}
// click: button "show"
function showMarker(marker_id) {
if( OSRM.JSONP.fences["geocoder_source"] || OSRM.JSONP.fences["geocoder_target"] )
return;
if( marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource() )
OSRM.G.markers.route[0].centerView();
else if( marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget() )
OSRM.G.markers.route[OSRM.G.markers.route.length-1].centerView();
}
// changed: any inputbox (is called when return is pressed [after] or focus is lost [before])
function inputChanged(marker_id) {
if( marker_id == OSRM.C.SOURCE_LABEL)
callGeocoder(OSRM.C.SOURCE_LABEL, document.getElementById('input-source-name').value);
else if( marker_id == OSRM.C.TARGET_LABEL)
callGeocoder(OSRM.C.TARGET_LABEL, document.getElementById('input-target-name').value);
}
+183
View File
@@ -0,0 +1,183 @@
/*
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 routing
// [management of routing requests and processing of responses]
// some variables
OSRM.GLOBALS.route = null;
OSRM.GLOBALS.markers = null;
OSRM.GLOBALS.dragging = null;
OSRM.GLOBALS.dragid = null;
OSRM.GLOBALS.pending = false;
OSRM.Routing = {
// init routing data structures
init: function() {
OSRM.G.route = new OSRM.Route();
OSRM.G.markers = new OSRM.Markers();
},
// -- JSONP processing --
// process JSONP response of routing server
timeoutRouteSimple: function() {
OSRM.RoutingGeometry.showNA();
OSRM.RoutingDescription.showNA( OSRM.loc("TIMED_OUT") );
},
timeoutRoute: function() {
OSRM.RoutingGeometry.showNA();
OSRM.RoutingNoNames.showNA();
OSRM.RoutingDescription.showNA( OSRM.loc("TIMED_OUT") );
OSRM.Routing._snapRoute();
},
timeoutRouteReverse: function() {
OSRM.G.markers.reverseMarkers();
timeoutRoute();
},
showRouteSimple: function(response) {
if(!response)
return;
if( !OSRM.G.dragging ) // prevent simple routing when not dragging (required as there can be drag events after a dragstop event!)
return;
if( response.status == 207) {
OSRM.RoutingGeometry.showNA();
OSRM.RoutingDescription.showNA( OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED") );
} else {
OSRM.RoutingGeometry.show(response);
OSRM.RoutingDescription.showSimple(response);
}
OSRM.Routing._updateHints(response);
if(OSRM.G.pending)
setTimeout(OSRM.Routing.draggingTimeout,1);
},
showRoute: function(response) {
if(!response)
return;
OSRM.G.response = response;
OSRM.G.via_points = response.via_points.slice(0);
if(response.status == 207) {
OSRM.RoutingGeometry.showNA();
OSRM.RoutingNoNames.showNA();
OSRM.RoutingDescription.showNA( OSRM.loc("NO_ROUTE_FOUND") );
OSRM.Routing._snapRoute();
} else {
OSRM.RoutingGeometry.show(response);
OSRM.RoutingNoNames.show(response);
OSRM.RoutingDescription.show(response);
OSRM.Routing._snapRoute();
}
OSRM.Routing._updateHints(response);
},
showRouteZooming: function(response) {
if(!response)
return;
if(response.status != 207) {
OSRM.RoutingGeometry.show(response);
OSRM.RoutingNoNames.show(response);
}
OSRM.Routing._updateHints(response);
},
//-- main function --
//generate server calls to query routes
getRoute: function() {
// if source or target are not set -> hide route
if( OSRM.G.markers.route.length < 2 ) {
OSRM.G.route.hideRoute();
return;
}
OSRM.JSONP.clear('dragging');
OSRM.JSONP.clear('zooming');
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() {
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('route');
OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=true', OSRM.Routing.showRoute, OSRM.Routing.timeoutRouteReverse, OSRM.DEFAULTS.JSONP_TIMEOUT, 'route');
},
draggingTimeout: function() {
OSRM.G.markers.route[OSRM.G.dragid].hint = null;
OSRM.Routing.getDragRoute();
},
_buildCall: function() {
var source = OSRM.DEFAULTS.HOST_ROUTING_URL;
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<size; i++) {
source += '&loc=' + OSRM.G.markers.route[i].getLat().toFixed(6) + ',' + OSRM.G.markers.route[i].getLng().toFixed(6);
if( OSRM.G.markers.route[i].hint)
source += '&hint=' + OSRM.G.markers.route[i].hint;
}
return source;
},
//-- helper functions --
// update hints of all markers
_updateHints: function(response) {
var hint_locations = response.hint_data.locations;
OSRM.G.markers.checksum = response.hint_data.checksum;
for(var i=0; i<hint_locations.length; i++)
OSRM.G.markers.route[i].hint = hint_locations[i];
},
// snap all markers to the received route
_snapRoute: function() {
var positions = OSRM.G.route.getPositions();
OSRM.G.markers.route[0].setPosition( positions[0] );
OSRM.G.markers.route[OSRM.G.markers.route.length-1].setPosition( positions[positions.length-1] );
for(var i=0; i<OSRM.G.via_points.length; i++)
OSRM.G.markers.route[i+1].setPosition( new L.LatLng(OSRM.G.via_points[i][0], OSRM.G.via_points[i][1]) );
OSRM.Geocoder.updateAddress(OSRM.C.SOURCE_LABEL);
OSRM.Geocoder.updateAddress(OSRM.C.TARGET_LABEL);
}
};
@@ -0,0 +1,206 @@
/*
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 routing description
// [renders routing description and manages events]
OSRM.RoutingDescription = {
// route description events
onClickRouteDescription: function(geometry_index) {
var positions = OSRM.G.route.getPositions();
OSRM.G.markers.highlight.setPosition( positions[geometry_index] );
OSRM.G.markers.highlight.show();
OSRM.G.markers.highlight.centerView(OSRM.DEFAULTS.HIGHLIGHT_ZOOM_LEVEL);
},
onClickCreateShortcut: function(src){
src += '&z='+ OSRM.G.map.getZoom() + '&center=' + OSRM.G.map.getCenter().lat.toFixed(6) + ',' + OSRM.G.map.getCenter().lng.toFixed(6);
var source = OSRM.DEFAULTS.SHORTENER_PARAMETERS.replace(/%url/, OSRM.DEFAULTS.HOST_SHORTENER_URL+src);
OSRM.JSONP.call(source, OSRM.RoutingDescription.showRouteLink, OSRM.RoutingDescription.showRouteLink_TimeOut, OSRM.DEFAULTS.JSONP_TIMEOUT, 'shortener');
document.getElementById('route-link').innerHTML = '['+OSRM.loc("GENERATE_LINK_TO_ROUTE")+']';
},
showRouteLink: function(response){
if(!response[OSRM.DEFAULTS.SHORTENER_REPLY_PARAMETER])
OSRM.RoutingDescription.showRouteLink_TimeOut();
else
document.getElementById('route-link').innerHTML = '[<a class="route-link text-selectable" href="' +response[OSRM.DEFAULTS.SHORTENER_REPLY_PARAMETER]+ '">'+response[OSRM.DEFAULTS.SHORTENER_REPLY_PARAMETER]+'</a>]';
},
showRouteLink_TimeOut: function(){
document.getElementById('route-link').innerHTML = '['+OSRM.loc("LINK_TO_ROUTE_TIMEOUT")+']';
},
// handling of routing description
show: function(response) {
// activate printing
OSRM.Printing.activate();
// compute query string
var query_string = '?hl=' + OSRM.Localization.current_language;
for(var i=0; i<OSRM.G.markers.route.length; i++)
query_string += '&loc=' + OSRM.G.markers.route[i].getLat().toFixed(6) + ',' + OSRM.G.markers.route[i].getLng().toFixed(6);
// create link to the route
var route_link ='[<a class="route-link" onclick="OSRM.RoutingDescription.onClickCreateShortcut(\'' + OSRM.DEFAULTS.WEBSITE_URL + query_string + '\')">'+OSRM.loc("GET_LINK_TO_ROUTE")+'</a>]';
// create GPX link
var gpx_link = '[<a class="route-link" onClick="document.location.href=\'' + OSRM.DEFAULTS.HOST_ROUTING_URL + query_string + '&output=gpx\';">'+OSRM.loc("GPX_FILE")+'</a>]';
// create route description
var body = "";
body += '<table class="description medium-font">';
for(var i=0; i < response.route_instructions.length; i++){
//odd or even ?
var rowstyle='description-body-odd';
if(i%2==0) { rowstyle='description-body-even'; }
body += '<tr class="'+rowstyle+'">';
body += '<td class="description-body-directions">';
body += '<img class="description-body-direction" src="'+ OSRM.RoutingDescription._getDrivingInstructionIcon(response.route_instructions[i][0]) + '" alt=""/>';
body += '</td>';
body += '<td class="description-body-items">';
body += '<div class="description-body-item" onclick="OSRM.RoutingDescription.onClickRouteDescription('+response.route_instructions[i][3]+')">';
// build route description
if( response.route_instructions[i][1] != "" )
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]).replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
else
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"").replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
body += '</div>';
body += "</td>";
body += '<td class="description-body-distance">';
if( i != response.route_instructions.length-1 )
body += '<b>'+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+'</b>';
body += "</td>";
body += "</tr>";
}
body += '</table>';
// build header
header = OSRM.RoutingDescription._buildHeader(OSRM.Utils.metersToDistance(response.route_summary.total_distance), OSRM.Utils.secondsToTime(response.route_summary.total_time), route_link, gpx_link);
// update DOM
document.getElementById('information-box-header').innerHTML = header;
document.getElementById('information-box').innerHTML = body;
},
// simple description
showSimple: function(response) {
// build header
header = OSRM.RoutingDescription._buildHeader(OSRM.Utils.metersToDistance(response.route_summary.total_distance), OSRM.Utils.secondsToTime(response.route_summary.total_time), "", "");
// update DOM
document.getElementById('information-box-header').innerHTML = header;
document.getElementById('information-box').innerHTML = "<div class='no-results big-font'>"+OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED")+"</div>";
},
// no description
showNA: function( display_text ) {
// build header
header = OSRM.RoutingDescription._buildHeader("N/A", "N/A", "", "");
// update DOM
document.getElementById('information-box-header').innerHTML = header;
document.getElementById('information-box').innerHTML = "<div class='no-results big-font'>"+display_text+"</div>";
},
// build header
_buildHeader: function(distance, duration, route_link, gpx_link) {
var temp =
'<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
'<div class="full">' +
'<div class="row">' +
'<div class="left">' +
'<div class="full">' +
'<div class="row">' +
'<div class="left header-label">' + OSRM.loc("DISTANCE")+":" + '</div>' +
'<div class="left header-content stretch">' + distance + '</div>' +
'</div>' +
'<div class="row">' +
'<div class="left header-label">' + OSRM.loc("DURATION")+":" + '</div>' +
'<div class="left header-content stretch">' + duration + '</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="left">' +
'<div class="full">' +
'<div class="row">' +
'<div class="right header-content" id="route-link">' + route_link + '</div>' +
'</div>' +
'<div class="row">' +
'<div class="right header-content">' + gpx_link + '</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
// '<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
// '<div class="full">' +
// '<div class="row">' +
// '<div class="left header-label">' + OSRM.loc("DISTANCE")+":" + '</div>' +
// '<div class="left header-content">' + distance + '</div>' +
// '<div class="right header-content" id="route-link">' + route_link + '</div>' +
// '</div>' +
// '<div class="row">' +
// '<div class="left header-label">' + OSRM.loc("DURATION")+":" + '</div>' +
// '<div class="left header-content">' + duration + '</div>' +
// '<div class="right header-content">' + gpx_link + '</div>' +
// '</div>' +
// '</div>';
return temp;
},
// retrieve driving instruction icon from instruction id
_getDrivingInstructionIcon: function(server_instruction_id) {
var local_icon_id = "direction_";
server_instruction_id = server_instruction_id.replace(/^11-\d{1,}$/,"11"); // dumb check, if there is a roundabout (all have the same icon)
local_icon_id += server_instruction_id;
if( OSRM.G.images[local_icon_id] )
return OSRM.G.images[local_icon_id].getAttribute("src");
else
return OSRM.G.images["direction_0"].getAttribute("src");
},
// retrieve driving instructions from instruction ids
_getDrivingInstruction: function(server_instruction_id) {
var local_instruction_id = "DIRECTION_";
server_instruction_id = server_instruction_id.replace(/^11-\d{2,}$/,"11-x"); // dumb check, if there are 10+ exits on a roundabout (say the same for exit 10+)
local_instruction_id += server_instruction_id;
var description = OSRM.loc( local_instruction_id );
if( description == local_instruction_id)
return OSRM.loc("DIRECTION_0");
return description;
}
};
@@ -0,0 +1,67 @@
/*
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 routing geometry
// [renders routing geometry]
OSRM.RoutingGeometry = {
// show route geometry - if there is a route
show: function(response) {
var geometry = OSRM.RoutingGeometry._decode(response.route_geometry, 5);
OSRM.G.route.showRoute(geometry, OSRM.Route.ROUTE);
},
//show route geometry - if there is no route
showNA: function() {
var positions = [];
for(var i=0, size=OSRM.G.markers.route.length; i<size; i++)
positions.push( OSRM.G.markers.route[i].getPosition() );
OSRM.G.route.showRoute(positions, OSRM.Route.NOROUTE);
},
//decode compressed route geometry
_decode: function(encoded, precision) {
precision = Math.pow(10, -precision);
var len = encoded.length, index=0, lat=0, lng = 0, array = [];
while (index < len) {
var b, shift = 0, result = 0;
do {
b = encoded.charCodeAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
var dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = encoded.charCodeAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
var dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
lng += dlng;
array.push( {lat: lat * precision, lng: lng * precision} );
}
return array;
}
};
+68
View File
@@ -0,0 +1,68 @@
/*
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 routing
// [renders route segments that are unnamed streets]
OSRM.RoutingNoNames = {
// displays route segments that are unnamed streets
show: function(response) {
// do not display unnamed streets?
if( document.getElementById('option-highlight-nonames').checked == false) {
OSRM.G.route.hideUnnamedRoute();
return;
}
// mark geometry positions where unnamed/named streets switch
var named = [];
for (var i = 0; i < response.route_instructions.length; i++) {
if( response.route_instructions[i][1] == '' )
named[ response.route_instructions[i][3] ] = false; // no street name
else
named[ response.route_instructions[i][3] ] = true; // yes street name
}
// aggregate geometry for unnamed streets
var geometry = OSRM.RoutingGeometry._decode(response.route_geometry, 5);
var is_named = true;
var current_positions = [];
var all_positions = [];
for( var i=0; i < geometry.length; i++) {
current_positions.push( geometry[i] );
// still named/unnamed?
if( (named[i] == is_named || named[i] == undefined) && i != geometry.length-1 )
continue;
// switch between named/unnamed!
if(is_named == false)
all_positions.push( current_positions );
current_positions = [];
current_positions.push( geometry[i] );
is_named = named[i];
}
// display unnamed streets
OSRM.G.route.showUnnamedRoute(all_positions);
},
showNA: function() {
OSRM.G.route.hideUnnamedRoute();
}
};
-105
View File
@@ -1,105 +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.
*/
// compatibility tools for old browsers
function getElementsByClassName(node, classname) {
var a = [];
var re = new RegExp('(^| )'+classname+'( |$)');
var els = node.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++)
if(re.test(els[i].className))a.push(els[i]);
return a;
}
document.head = document.head || document.getElementsByTagName('head')[0];
// ------------------------------------------------------
// human readable time
function secondsToTime(seconds){
seconds = parseInt(seconds);
minutes = parseInt(seconds/60);
seconds = seconds%60;
hours = parseInt(minutes/60);
minutes = minutes%60;
if(hours==0){
return minutes + '&nbsp;' + 'min';
}
else{
return hours + '&nbsp;' + 'h' + '&nbsp;' + minutes + '&nbsp;' + 'min';
}
}
// human readable distance
function getDistanceWithUnit(distance){
distance = parseInt(distance);
if(distance >= 100000){ return (parseInt(distance/1000))+'&nbsp;' + 'km'; }
else if(distance >= 10000){ return (parseInt(distance/1000).toFixed(1))+'&nbsp;' + 'km'; }
else if(distance >= 1000){ return (parseFloat(distance/1000).toFixed(2))+'&nbsp;' + 'km'; }
else{ return distance+'&nbsp;' + 'm'; }
}
//------------------------------------------------------
// verify angles
function isLatitude(value) {
if( value >=-90 && value <=90)
return true;
else
return false;
}
function isLongitude(value) {
if( value >=-180 && value <=180)
return true;
else
return false;
}
// ------------------------------------------------------
// distance between two points
function distanceBetweenPoint(x1, y1, x2, y2) {
var a = x1 - x2;
var b = y1 - y2;
return Math.sqrt(a*a + b*b);
}
// distance from a point to a line or segment
// (x,y) point
// (x0,y0) line point A
// (x1,y1) line point B
// o specifies if the distance should respect the limits of the segment (overLine = true)
// or if it should consider the segment as an infinite line (overLine = false);
// if false returns the distance from the point to the line,
// otherwise the distance from the point to the segment
function dotLineLength(x, y, x0, y0, x1, y1, o){
function lineLength(x, y, x0, y0){return Math.sqrt((x -= x0) * x + (y -= y0) * y);}
if(o && !(o = function(x, y, x0, y0, x1, y1){
if(!(x1 - x0)) return {x: x0, y: y};
else if(!(y1 - y0)) return {x: x, y: y0};
var left, tg = -1 / ((y1 - y0) / (x1 - x0));
return {x: left = (x1 * (x * tg - y + y0) + x0 * (x * - tg + y - y1)) / (tg * (x1 - x0) + y0 - y1), y: tg * left - tg * x + y};
}(x, y, x0, y0, x1, y1) && o.x >= Math.min(x0, x1) && o.x <= Math.max(x0, x1) && o.y >= Math.min(y0, y1) && o.y <= Math.max(y0, y1))){
var l1 = lineLength(x, y, x0, y0), l2 = lineLength(x, y, x1, y1);
return l1 > l2 ? l2 : l1;
}
else {
var a = y0 - y1, b = x1 - x0, c = x0 * y1 - y0 * x1;
return Math.abs(a * x + b * y + c) / Math.sqrt(a * a + b * b);
}
};
@@ -18,7 +18,6 @@ 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
@@ -29,8 +28,8 @@ OSRM.JSONP = {
// default callback routines
late: function() { /*OSRM.debug.log("[jsonp] reply too late");*/ },
empty: function() { /*OSRM.debug.log("[jsonp] empty callback");*/ },
late: function() {},
empty: function() {},
// init JSONP call
@@ -49,8 +48,6 @@ OSRM.JSONP = {
OSRM.JSONP.timeouts[id] = OSRM.JSONP.empty;
OSRM.JSONP.fences[id] = undefined; // clean fence
}
// OSRM.debug.log("[jsonp] timout handling: "+id);
};
// wrap callback function
@@ -65,11 +62,9 @@ OSRM.JSONP = {
OSRM.JSONP.timeouts[id] = OSRM.JSONP.late;
OSRM.JSONP.fences[id] = undefined; // clean fence
}
// OSRM.debug.log("[jsonp] response handling: "+id);
};
// clean DOM (unfortunately, script elements cannot be reused by all browsers)
// clean DOM
var jsonp = document.getElementById('jsonp_'+id);
if(jsonp)
jsonp.parentNode.removeChild(jsonp);
@@ -78,16 +73,26 @@ OSRM.JSONP = {
var script = document.createElement('script');
script.type = 'text/javascript';
script.id = 'jsonp_'+id;
script.src = source + "&json_callback=OSRM.JSONP.callbacks."+id + "&jsonp=OSRM.JSONP.callbacks."+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);
// OSRM.debug.log("[jsonp] init: "+id);
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 = {};
@@ -95,4 +100,4 @@ OSRM.JSONP = {
OSRM.JSONP.timeouts = {};
OSRM.JSONP.timers = {};
}
};
};
+67
View File
@@ -0,0 +1,67 @@
/*
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 + '&nbsp;' + 'min';
}
else{
return hours + '&nbsp;' + 'h' + '&nbsp;' + minutes + '&nbsp;' + 'min';
}
},
//human readable distance
metersToDistance: function(distance){
distance = parseInt(distance);
if(distance >= 100000){ return (parseInt(distance/1000))+'&nbsp;' + 'km'; }
else if(distance >= 10000){ return (parseInt(distance/1000).toFixed(1))+'&nbsp;' + 'km'; }
else if(distance >= 1000){ return (parseFloat(distance/1000).toFixed(2))+'&nbsp;' + 'km'; }
else{ return distance+'&nbsp;' + '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;
}
};
+70
View File
@@ -0,0 +1,70 @@
/*
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 old/cross browser support
// [browser detection and routines for old/cross browser support]
// browser detection (runs anonymous function to prevent local variables cluttering global namespace)
(function() {
var useragent = navigator.userAgent;
OSRM.Browser = {
FF3: useragent.search(/Firefox\/3/),
IE6_9: useragent.search(/MSIE (6|7|8|9)/)
};
}());
// compatibility tools
//add document.head reference for older browsers
document.head = document.head || document.getElementsByTagName('head')[0];
// supply getElementsByClassName method for older browser
OSRM.Browser.getElementsByClassName = function( node, classname ) {
var a = [];
var re = new RegExp('(^| )'+classname+'( |$)');
var els = node.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++)
if(re.test(els[i].className))a.push(els[i]);
return a;
};
// call a function when DOM has finished loading and remove event handler (optionally pass a different window object)
OSRM.Browser.onLoadHandler = function( function_pointer, the_window ) {
the_window = the_window || window; // default document
var the_document = the_window.document;
if(the_window.addEventListener) { // FF, CH, IE9+
var temp_function = function() {
the_window.removeEventListener("DOMContentLoaded", arguments.callee, false);
function_pointer.call();
};
the_window.addEventListener("DOMContentLoaded", temp_function, false);
}
else if(the_document.attachEvent) { // IE8-
var temp_function = function() {
if ( the_document.readyState === "interactive" || the_document.readyState === "complete" ) {
the_document.detachEvent("onreadystatechange", arguments.callee);
function_pointer.call();
}
};
the_document.attachEvent("onreadystatechange", temp_function);
}
};
+47
View File
@@ -0,0 +1,47 @@
/*
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 base class
// [support for inheritance]
// declare one class to be a subclass of another class
// (runs anonymous function to prevent local functions cluttering global namespace)
(function() {
var _inheritFromHelper = function() {};
OSRM.inheritFrom = function( sub_class, base_class ) {
_inheritFromHelper.prototype = base_class.prototype;
sub_class.prototype = new _inheritFromHelper();
sub_class.prototype.constructor = sub_class;
sub_class.prototype.base = base_class.prototype;
};
}());
// extend prototypes of a class -> used to add member values and functions
OSRM.extend = function( target_class, properties ) {
for( property in properties ) {
target_class.prototype[property] = properties[property];
}
};
// [usage of convenience functions]
// SubClass = function() {
// SubClass.prototype.base.constructor.apply(this, arguments);
// }
// OSRM.inheritFrom( SubClass, BaseClass );
// OSRM.extend( SubClass, { property:value } );
@@ -21,6 +21,16 @@ or see http://www.gnu.org/licenses/agpl.txt.
OSRM.debug = {};
// access functions
OSRM.debug.log = function(text) {
OSRM.debug.content.innerHTML += text + "<hr style='border:none; margin:2px; height:1px; color:#F0F0F0; background:#F0F0F0;'/>";
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
@@ -50,17 +60,7 @@ OSRM.debug.init = function() {
box.appendChild(clear);
box.appendChild(OSRM.debug.content);
};
if(document.addEventListener) // FF, CH
document.addEventListener("DOMContentLoaded", OSRM.debug.init, false);
else // IE
OSRM.debug.init();
// working functions
OSRM.debug.log = function(text) {
OSRM.debug.content.innerHTML += text + "<hr style='border:none; margin:2px; height:1px; color:#F0F0F0; background:#F0F0F0;'/>";
OSRM.debug.content.scrollTop = OSRM.debug.content.scrollHeight;
};
OSRM.debug.clear = function() {
OSRM.debug.content.innerHTML = "";
};
// onload event
OSRM.Browser.onLoadHandler( OSRM.debug.init );
-63
View File
@@ -1,63 +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.
*/
// store location of via points returned by server
OSRM.GLOBALS.via_points = null;
// find route segment of current route geometry that is closest to the new via node (marked by index of its endpoint)
function findNearestRouteSegment( new_via ) {
var min_dist = Number.MAX_VALUE;
var min_index = undefined;
var positions = OSRM.G.route.getPositions();
for(var i=0; i<positions.length-1; i++) {
var dist = dotLineLength( new_via.lng, new_via.lat, positions[i].lng, positions[i].lat, positions[i+1].lng, positions[i+1].lat, true);
if( dist < min_dist) {
min_dist = dist;
min_index = i+1;
}
}
return min_index;
}
// find the correct index among all via nodes to insert the new via node, and insert it
function findViaPosition( new_via_position ) {
// find route segment that is closest to click position (marked by last index)
var nearest_index = findNearestRouteSegment( new_via_position );
// find correct index to insert new via node
var new_via_index = OSRM.G.via_points.length;
var via_index = Array();
for(var i=0; i<OSRM.G.via_points.length; i++) {
via_index[i] = findNearestRouteSegment( new L.LatLng(OSRM.G.via_points[i][0], OSRM.G.via_points[i][1]) );
if(via_index[i] > nearest_index) {
new_via_index = i;
break;
}
}
// add via node
var index = OSRM.G.markers.setVia(new_via_index, new_via_position);
OSRM.G.markers.route[index].show();
getRoute(OSRM.C.FULL_DESCRIPTION);
return new_via_index;
}