Project-OSRM / osrm-backend

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

Wild routing oddity #4221

Closed joovel closed 7 years ago

joovel commented 7 years ago

Here's a brief script to capture this odd result I'm getting from a routing:

mkdir -p data/osrm
pushd data/osrm
wget https://s3.amazonaws.com/metro-extracts.mapzen.com/los-angeles_california.osm.pbf
popd
docker run --tty --volume `pwd`/data/osrm:/data osrm/osrm-backend:v5.8.0 osrm-extract -p /opt/foot.lua /data/los-angeles_california.osm.pbf
docker run --tty --volume `pwd`/data/osrm:/data osrm/osrm-backend:v5.8.0 osrm-contract /data/los-angeles_california.osrm
docker run --detach -v `pwd`/data/osrm:/data -p 45000:5000 osrm/osrm-backend:v5.8.0 osrm-routed /data/los-angeles_california.osrm

Then I issue this curl:

curl 'http://localhost:45000/route/v1/walking/-117.70203,33.46642;-117.691793,33.460241'

The result is a crazy route taking the user over two ferries (I think) and then back down the PCH. The polyline shows the rough route.

{
  "code": "Ok",
  "routes": [
    {
      "geometry": "klgkEvtkmUj@|p@yxMdiMq_BxvEalFbcIy_BzuAwzAboKg{DjeIe_DlrEa}IppIor@vhBolAhh@ev@nkNre@fz@v`BcuCr|@RxkBp`AbzgAjsYoySudzBav@_@",
      "legs": [
        {
          "steps": [],
          "distance": 172320.3,
          "duration": 53331.8,
          "summary": "",
          "weight": 53331.8
        }
      ],
      "distance": 172320.3,
      "duration": 53331.8,
      "weight_name": "duration",
      "weight": 53331.8
    }
  ],
  "waypoints": [
    {
      "hint": "JNEJgB02F4CCAAAAfwAAAAAAAABHAQAAggAAAH8AAAAAAAAARwEAAAEAAABnAvz4Xqj-AXIC_Pg0qP4BAAAPAEFVQIU=",
      "name": "Pacific Coast Highway",
      "location": [
        -117.702041,
        33.466462
      ]
    },
    {
      "hint": "HJYOgB-WDoBYAAAAfgAAAP8BAAAAAAAAWAAAAH4AAAD_AQAAAAAAAAEAAAAJK_z47o_-AW8q_PgRkP4BBgAPAEFVQIU=",
      "name": "",
      "location": [
        -117.691639,
        33.460206
      ]
    }
  ]
}

The two points are only 1.5km apart.

When I run this on openstreetmap.org (http://www.openstreetmap.org/directions?engine=mapzen_foot&route=33.4662%2C-117.7025%3B33.4602%2C-117.6918#map=17/33.46324/-117.69720) using "Foot (MapZen)", I get realistic directions.

I expect to get similar realistic directions from OSRM.

We first experienced this issue with 5.6.0 and 5.6.5.

oxidase commented 7 years ago

@joovel it is an effect of OSRM snapping behavior (the route end point is a projection onto the nearest segment) and a data issue (https://www.openstreetmap.org/way/46788688#map=10/33.4023/-118.0062 is not connected to any footway). "Foot (MapZen)" also provides an unrealistic route for slightly shifted edpoint https://www.openstreetmap.org/directions?engine=mapzen_foot&route=33.46620%2C-117.70250%3B33.46009%2C-117.69174#map=10/33.5562/-118.0062

joovel commented 7 years ago

@oxidase Thanks for the quick and detailed analysis! Will someone fix the OSM data, or is that on me? Also, is there a way to tell OSRM to do a fuzzier search for a footway?

oxidase commented 7 years ago

data issues usually fixed by local OSM communities. OSRM demo server http://map.project-osrm.org/?z=14&center=33.468144%2C-117.670956&hl=en&alt=0 has "Small Components" layer that highlights unconnected or partially connected ways.

Without OSM changes ferries can be disabled as a quick fix by removing handle_ferries. Also https://github.com/Project-OSRM/osrm-backend/issues/4006 is in progress and will allow avoiding ferries in query time.

joovel commented 7 years ago

@oxidase : Thanks. I've sketched in a few sidewalks that should be more helpful. Thanks for adding the pointer to handle_ferries.