GIScience / openrouteservice

🌍 The open source route planner api with plenty of features.
https://openrouteservice.org
GNU General Public License v3.0
1.44k stars 397 forks source link

Difference in duration between ORS and Graphhopper/OSRM/.. #44

Closed nguyen-dinh-dh closed 6 years ago

nguyen-dinh-dh commented 6 years ago

Hi ORS team,

I've set up a local ORS using Germany pbf file, with all services (including Geocode by Nominatim) running. I did some comparison between the local service and your online ORS service, and the results are not the same.

Here are the test points:

localhost:8080/ors/routes?coordinates=13.392786,52.524078|13.411185,52.521321&elevation=true&extra_info=steepness|waytype|surface&geometry=true&geometry_format=geojson&instructions=true&preference=fastest&profile=driving-car&units=m

https://www.openrouteservice.org/directions?n1=52.522456&n2=13.401335&n3=16&a=52.524078,13.392786,52.521321,13.411185&b=0&c=0&k1=en-US&k2=km

This is the result of local ORS: {"routes":[{"elevation":true,"summary":{"distance":1822.1,"duration":210,"ascent":18,"descent":14.3},"geometry_format":"geojson","geometry":{"type":"LineString","coordinates":[[13.392433,52.524147,38],[13.392549,52.524365,39.5],[13.392788,52.524806,40.4],[13.392821,52.524865,40.5],[13.392884,52.524984,40.6],[13.393062,52.524938,40.6],[13.393123,52.524923,40.6],[13.393509,52.52483,40.6],[13.394047,52.524695,40.5],[13.394634,52.524549,40.6],[13.394876,52.524491,40.7],[13.395219,52.524407,40.8],[13.395416,52.524355,40.8],[13.395591,52.524308,40.9],[13.396704,52.524011,40.5],[13.397627,52.52377,39.8],[13.397887,52.52366,39.5],[13.398205,52.523563,39.1],[13.398472,52.52346,38.7],[13.398642,52.523382,38.5],[13.398734,52.523336,38.4],[13.39879,52.523306,38.2],[13.398864,52.523264,38.1],[13.399023,52.523211,37.9],[13.399912,52.522878,37.9],[13.400042,52.522809,38.1],[13.400105,52.522745,38.2],[13.400166,52.522681,38.4],[13.400189,52.522622,38.5],[13.400268,52.522465,38.6],[13.400331,52.522358,38.7],[13.400344,52.522261,38.8],[13.400415,52.522127,38.9],[13.400437,52.52209,39],[13.400572,52.521936,39.1],[13.400595,52.521833,39.3],[13.400581,52.521645,39.1],[13.400651,52.521365,38.6],[13.400776,52.521068,37.9],[13.400865,52.520922,37.9],[13.40096,52.520787,37.5],[13.401004,52.520775,37.1],[13.401046,52.520781,36.7],[13.402863,52.521371,36.2],[13.403637,52.520792,39.4],[13.403686,52.520756,39.9],[13.404451,52.520176,42.9],[13.404628,52.520044,43.2],[13.404811,52.519918,43.6],[13.404987,52.520013,43.8],[13.405218,52.52014,44.6],[13.405246,52.520154,45],[13.405629,52.520343,46.2],[13.40612,52.520594,47.8],[13.408318,52.521707,45],[13.408721,52.521911,43.1],[13.409061,52.522084,41.6],[13.409315,52.522213,40.9],[13.409421,52.522267,40.6],[13.409511,52.52231,40.3],[13.40981,52.522451,39.9],[13.409941,52.522514,39.7],[13.409996,52.522539,39.7],[13.410091,52.522595,39.8],[13.410248,52.522508,39.9],[13.410755,52.522213,40.6],[13.411355,52.521842,41.7]]},"segments":[{"distance":1822.1,"duration":210,"ascent":18,"descent":14.3,"steps":[{"distance":98,"duration":7.8,"type":11,"instruction":"Head north on Tucholskystraße","name":"Tucholskystraße","way_points":[0,4]},{"distance":348.6,"duration":50.2,"type":1,"instruction":"Turn right onto Oranienburger Straße","name":"Oranienburger Straße","way_points":[4,15]},{"distance":212.7,"duration":30.6,"type":5,"instruction":"Turn slight right onto Monbijouplatz","name":"Monbijouplatz","way_points":[15,27]},{"distance":37.7,"duration":5.4,"type":5,"instruction":"Turn slight right onto Kleine Präsidentenstraße","name":"Kleine Präsidentenstraße","way_points":[27,30]},{"distance":184.1,"duration":26.5,"type":5,"instruction":"Turn slight right onto Burgstraße","name":"Burgstraße","way_points":[30,40]},{"distance":145.7,"duration":21,"type":4,"instruction":"Turn slight left onto Anna-Louisa-Karsch-Straße","name":"Anna-Louisa-Karsch-Straße","way_points":[40,43]},{"distance":208.7,"duration":16.7,"type":1,"instruction":"Turn right onto Spandauer Straße","name":"Spandauer Straße","way_points":[43,48]},{"distance":466.7,"duration":37.3,"type":0,"instruction":"Turn left onto Karl-Liebknecht-Straße, B 2, B 5","name":"Karl-Liebknecht-Straße, B 2, B 5","way_points":[48,63]},{"distance":119.9,"duration":14.4,"type":1,"instruction":"Turn right onto Dircksenstraße","name":"Dircksenstraße","way_points":[63,66]},{"distance":0,"duration":0,"type":10,"instruction":"Arrive at Dircksenstraße, on the right","name":"","way_points":[66,66]}]}],"way_points":[0,66],"extras":{"surface":{"values":[[0,66,3]],"summary":[{"value":3,"distance":1822.1,"amount":100}]},"waytypes":{"values":[[0,15,2],[15,43,3],[43,48,2],[48,63,1],[63,66,3]],"summary":[{"value":3,"distance":700.1,"amount":38.42},{"value":2,"distance":655.3,"amount":35.96},{"value":1,"distance":466.7,"amount":25.62}]},"steepness":{"values":[[0,66,0]],"summary":[{"value":0,"distance":1822.1,"amount":100}]}},"bbox":[13.392433,52.519918,13.411355,52.524984]}],"bbox":[13.392433,52.519918,13.411355,52.524984],"info":{"attribution":"openrouteservice.org, OpenStreetMap contributors, tmc - BASt","engine":{"version":"4.4.0","build_date":"2017-11-19T21:30:48Z"},"service":"routing","timestamp":1511254898877,"query":{"profile":"driving-car","preference":"fastest","coordinates":[[13.392786,52.524078,0],[13.411185,52.521321,0]],"language":"en","units":"m","geometry":true,"geometry_format":"geojson","geometry_simplify":false,"instructions_format":"text","instructions":true,"elevation":true}}}

The distance is 1.8km, while online ORS (and google maps) returns 1.7km.

Are there any config/settings to be set before deploying ORS?

Thank you

nguyen-dinh-dh commented 6 years ago

Also, I notice that ORS returns the duration time around 3-4 minutes, while OSRM and Google Maps return 7-8 minutes, both use driving car.

http://router.project-osrm.org/route/v1/driving/13.392786,52.524078;13.411185,52.521321

TimMcCauley commented 6 years ago

Regarding the duration times, I am not sure what OSRM and Google Maps use as average speeds for different function classes of segments (edges). You can check the limits we use here:

https://github.com/GIScience/openrouteservice/blob/master/openrouteservice/src/main/resources/resources/services/routing/speed_limits/car.json

TimMcCauley commented 6 years ago

In terms of the distances, I compared your geojson output with the output generated by openrouteservice.org and I can see that the snapped destination point is behind bahnhof Alexanderplatz which results in a different route. This could have to do with changes of the underlying graph structure which might have been changed by OpenStreetMap users.

screen shot 2017-11-21 at 17 33 42

screen shot 2017-11-21 at 17 35 28

nguyen-dinh-dh commented 6 years ago

Thank you for your explanation about the routing distance.

I checked your car profile and the max speed for Germany is only 130 km/h, while OSRM produces 1.7km in 0:03, which results in 340 km/h. Can you check again?

TimMcCauley commented 6 years ago

The speeds you have to check are

        "motorway_link": 60,
        "motorroad": 90,
        "trunk": 85,
        "trunk_link": 60,
        "primary": 65,
        "primary_link": 50,
        "secondary": 60,
        "secondary_link": 50,
        "tertiary": 50,
        "tertiary_link": 40,
        "unclassified": 30,
        "residential": 30,
        "living_street": 10,
        "service": 20,
        "road": 20,
        "track": 15

Depending on the OSM street attribute types of the segments the algorithm traverses it will use different speeds.

nguyen-dinh-dh commented 6 years ago

I checked all the values, the maximum values I can find are still less than 150, not even close to 300 km/h in the result.

TimMcCauley commented 6 years ago

@nguyen-dinh-dh this is definitely a bug, we will fix by the end of next week - thanks for pointing this out!

nguyen-dinh-dh commented 6 years ago

@TimMcCauley Thank you for your quick reply :)

rabidllama commented 6 years ago

@nguyen-dinh-dh I just double checked and with regards to the speed at 340km/h, I believe this is a misunderstanding with regards to the units shown on the website (I presume that when you say OSRM you mean the OpenRouteService page). The 00:03 does not mean 3 seconds, but 3 minutes (the numbers are rounded to the nearest minute). Taking that into account, traveling 1.7km in 3 minutes results in a speed of ~0.6km/min which equates to 36km/h.

For the other time differences between ORS and Google (the 3-4min in ORS and 7-8min in Google), this is due to Google taking into account more factors with regards to driving within urban areas. In ORS, it is currently assumed that you travel close to the speed limit of 30km/h whereas Google appears to indicate travel closer to half the speed limit. We are currently looking into implementing an additional step in our speed calculations that will hopefully provide a bit more realistic results within urban areas.

Hope that covers things :)

nguyen-dinh-dh commented 6 years ago

My bad, thank you for your explanation :)

nguyen-dinh-dh commented 6 years ago

@rabidllama As far as I know, ORS is using a forked version of graphhopper for routing, however when I use graphhopper: https://graphhopper.com/maps/?point=52.524078%2C13.392786&point=52.521321%2C13.411185&locale=en-US&vehicle=car&weighting=fastest&elevation=true&use_miles=false&layer=Omniscale

It returns duration of 6 min (similar to OSRM and GoogleMaps), while ORS returns 3min. Are there any difference in your graphhopper which causes this problem? Also, does this affect the isochrone service too?

TimMcCauley commented 6 years ago

@nguyen-dinh-dh it is a forked but changed version and as mentioned above we use different speed limits. It does effect the isochrone service, yes.

nguyen-dinh-dh commented 6 years ago

@TimMcCauley I tried modifying the car.json by halving all the speed for testing, but the duration is still around 3min, here is the car.json

{
    default: 
    {
        "motorway": 50,
        "motorway_link": 30,
        "motorroad": 45,
        "trunk": 43,
        "trunk_link": 30,
        "primary": 33,
        "primary_link": 25,
        "secondary": 30,
        "secondary_link": 25,
        "tertiary": 25,
        "tertiary_link": 20,
        "unclassified": 15,
        "residential": 15,
        "living_street": 5,
        "service": 10,
        "road": 10,
        "track": 8
    },
    surface:
    {
        "asphalt": -1, 
        "concrete": -1,
        "concrete:plates": -1,
        "concrete:lanes": -1,
        "paved": -1,
        "cement": 40,
        "compacted": 40,
        "fine_gravel": 30,
        "paving_stones":20,
        "metal": 20,
        "bricks": 20,
        "grass": 20,
        "wood": 20,
        "sett": 20,
        "grass_paver": 15,
        "gravel": 15,
        "unpaved": 15,
        "ground": 15,
        "dirt": 15,
        "pebblestone": 15,
        "tartan": 15,
        "cobblestone": 10,
        "clay": 10,
        "earth": 8,
        "stone": 8,
        "rocky": 8,
        "sand": 8,
        "mud": 5,
        "unknown" : 15
    },
    tracktype:
    {
        "grade1": 20,
        "grade2": 15,
        "grade3": 10,
        "grade4": 8,
        "grade5": 5
    },
    max_speeds: {
        "AT:urban": 50,
        "AT:rural": 100,
        "AT:trunk": 100,
        "AT:motorway": 130,
        "CH:urban": 50,
        "CH:rural": 80,
        "CH:trunk": 100,
        "CH:motorway": 120,
        "CZ:urban": 50,
        "CZ:rural": 90,
        "CZ:trunk": 80,
        "CZ:motorway": 80,
        "DK:urban": 50,
        "DK:rural": 80,
        "DK:motorway": 130,
        "DE:living_street": 4,
        "DE:urban": 25,
        "DE:rural": 50,
        "DE:motorway": 65,
        "FI:urban": 50,
        "FI:rural": 80,
        "FI:trunk": 100,
        "FI:motorway": 120,
        "FR:urban": 50,
        "FR:rural": 90,
        "FR:trunk": 110,
        "FR:motorway": 130,
        "GR:urban": 50,
        "GR:rural": 90,
        "GR:trunk": 110,
        "GR:motorway": 130,
        "HU:urban": 50,
        "HU:rural": 90,
        "HU:trunk": 110,
        "HU:motorway": 130,
        "IT:urban": 50,
        "IT:rural": 90,
        "IT:trunk": 110,
        "IT:motorway": 130,
        "JP:national": 60,
        "JP:motorway": 100,
        "PL:living_street": 20,
        "PL:urban": 50,
        "PL:rural": 90,
        "PL:motorway": 140,
        "RO:urban": 50,
        "RO:rural": 90,
        "RO:trunk": 100,
        "RO:motorway": 130,
        "RU:living_street": 20,
        "RU:rural": 90,
        "RU:urban": 60,
        "RU:motorway": 110,
        "SK:urban": 50,
        "SK:rural": 90,
        "SK:trunk": 90,
        "SK:motorway": 90,
        "SI:urban": 50,
        "SI:rural": 90,
        "SI:trunk": 110,
        "SI:motorway": 130,
        "ES:urban": 50,
        "ES:rural": 90,
        "ES:trunk": 100,
        "ES:motorway": 120,
        "SE:urban": 50,
        "SE:rural": 70,
        "SE:trunk": 90,
        "SE:motorway": 110,
        "GB:nsl_single": 95,
        "GB:nsl_dual": 112,
        "GB:motorway": 112,
        "UA:urban": 60,
        "UA:rural": 90,
        "UA:trunk": 110,
        "UA:motorway": 130,
        "UZ:living_street": 30,
        "UZ:urban": 70,
        "UZ:rural": 100,
        "UZ:motorway": 110
    }
}
rabidllama commented 6 years ago

@nguyen-dinh-dh The fork we are using in our version is a bit behind that of the main Graphhopper because of the enhancements we have made to our core to allow many of the additional functionalities that we provide. As such it may well be that the reason for difference between ours and the main Graphhopper is something that they have changed in a newer version.

The main reason for difference between ORS and Google (for example) is that when routing through urbanised areas, Google uses complex algorithms to determine the travel speed. In ORS, currently it assumes that you travel close to the allowed speed, hence why there is a difference between speeds (Google appears to indicate that you travel around half of the designated speed limit. We have a fix to make the results more similar to those of other engines, but this is not in the production version yet.