Project-OSRM / osrm-backend

Open Source Routing Machine - C++ backend
http://map.project-osrm.org
BSD 2-Clause "Simplified" License
6.36k stars 3.37k forks source link

Local version reporting nonsense distances #6727

Closed espoal closed 11 months ago

espoal commented 11 months ago

I'm trying to test OSRM as a distance calculation tool for my project, but I get very strange results. Let's take the distance between Berlin and Hamburg:

${OSRM_URL}/table/v1/driving/52.52000659999999,13.404954;53.5488282,9.987170299999999?sources=0&destinations=1

From http://router.project-osrm.org/ I get:

{"code":"Ok","destinations":[{"hint":"64AfgKX2zYUAAAAAqwAAAAAAAAAZNQAAAAAAAFe2PUIAAAAABftrRQAAAACrAAAAAAAAABk1AAAVHAAAd8UPA7mangAcFzEDYmSYAAAAbxNI4YXX","distance":243478.706294391,"name":"","location":[51.365239,10.394297]}],"durations":[[850912.5]],"sources":[{"hint":"KL8XiCm_F4gtAAAAAAAAAHgJAAAAAAAAN6NJQQAAAACOTChEAAAAAC0AAAAAAAAAeAkAAAAAAAAVHAAAlIwvAxhLwQBHZCEDGovMABsA_xBI4YXX","distance":129546.521843189,"name":"","location":[53.447828,12.667672]}]}

From my local instance I get:

{"code":"Ok","durations":[[1]],"destinations":[{"hint":"BKEGgGGhBoAAAAAAEQAAANEDAADcAAAAAAAAAPjTz0GPzb5EP-WrQwAAAAARAAAA0QMAANwAAABWFgAAG6fHADKZ1gIcFzEDYmSYAEMALw-XTeym","distance":5743920.314725,"name":"Roßfeldstraße","location":[13.084443,47.618354]}],"sources":[{"hint":"BKEGgGGhBoAIAAAAAAAAAL8DAAD3AAAASVVBQQAAAABXYbtEsYjAQwgAAAAAAAAAvwMAAPcAAABWFgAAsafHAI-Z1gJHZCEDGovMAEEAvw2XTeym","distance":5358237.061217,"name":"Roßfeldstraße","location":[13.084593,47.618447]}]}

Why is my local instance route me through Roßfeldstraße, which is completely out of the way, hence giving me a different result? Why do I get different distances when trying the online demo?

washaqq commented 11 months ago

i have the same issue,

farkli sonuclar

these 3 shows different result, for the same input.

URL(input): /route/v1/driving/39.9625,32.6795;40.0170,32.8974

danpat commented 11 months ago

@espoal Your input coordinates are swapped. You've provided <lat>,<lon> of 52.52000659999999,13.404954 in your request, which OSRM is interpreting as <lon>,<lat> and trying to route from here:

Screenshot 2023-11-03 at 6 51 20 am

On the public server router.project-osrm.org, the global map is available, so it's calculating the route from Yemen.

On your map, it appears you've only imported Germany. OSRM will snap to the "nearest edge", which from your coordinate in the ocean, appears to be 13.084443,47.618354 (<lon>,<lat>).

OSRM takes <lon>,<lat> order in the request URL. Flip your coordinates around and things should make a lot more sense.

washaqq commented 11 months ago

@espoal Your input coordinates are swapped. You've provided <lat>,<lon> of 52.52000659999999,13.404954 in your request, which OSRM is interpreting as <lon>,<lat> and trying to route from here:

Screenshot 2023-11-03 at 6 51 20 am

On the public server router.project-osrm.org, the global map is available, so it's calculating the route from Yemen.

On your map, it appears you've only imported Germany. OSRM will snap to the "nearest edge", which from your coordinate in the ocean, appears to be 13.084443,47.618354 (<lon>,<lat>).

OSRM takes <lon>,<lat> order in the request URL. Flip your coordinates around and things should make a lot more sense.

I flipped the numbers, now i am having same result with very slight difference. i got the numbers from openstreetmap's web site; image it doesnt tell which is lon. and which is lat. so i took them as it is.

it works now. Thank you.

espoal commented 11 months ago

I'm writing automatic tests to compare OSRM with other similar products (google maps, GraphHopper, HereMaps, ....) but for now it seems to work also for me. We can close the ticket and I will eventually update it / open a new one if I find any major discrepancies in the tests.

Thanks @danpat