Why does my custom OSRM server not give alternative routes as map.project-osrm.org?

509 Views Asked by At

I have set up a custom OSRM server using docker as explained here. And I have a web application which shows routes between 2 locations. I am using leaflet routing machine which pointed to the custom OSRM server as follows,

L.Routing.control({
    waypoints: [
      L.latLng(lat, long),
      L.latLng(lat, long)
    ],
    router: L.Routing.osrmv1({
      serviceUrl: "url",
    }),
    draggableWaypoints: false,
    routeWhileDragging: true,
    showAlternatives: true,
  });

The issue I am facing is that I tried exactly the same 3 different routes with my custom server and also with map.project-osrm.org free demo version. Following are the alternative route differences I got,

New York to Syracuse

(OSRM Free Demo Version Result) and this shows an alternative route but my custom server doesn't.

ny-sy

(My Custom OSRM Server Result)

ny-sy

New York to Maryland

(OSRM Free Demo Version Result) and this shows an alternative route but my custom server doesn't.

ny-md

(My Custom OSRM Server Result)

ny-md

New York to Los Angeles

(OSRM Free Demo Version Result) and this is a bit strange because I am getting an alternative route in my custom server but it is a little different to one shows on this Free Demo Version as follows,

ny-la

(My Custom OSRM Server Result)

ny-la

I need to know why is this happening. Anything I am doing wrong or is there a way to resolve this issue? Thanks in advance.

1

There are 1 best solutions below

0
Curtisy On

There could be a few reasons I could think of:

  1. The docker image isn't up to date with the latest release. Looking at the latest tag, it was published two months before the GitHub release. Although the changes do not look like much has changed, it could be that with 5.26.0 is able to find an alternative that 5.25.0 can't

  2. The OSM data is different. I'm not sure about this since I'm fairly certain that OSRM updates their OSM data on a regular basis but it might be that either you or the demo server have differing data sets (that would explain the NY to LA route)

  3. Some request parameters or server settings are different. This could potentially lead to a mismatch in results too

Your best bet at this point would be trying two things:

  1. Use the osrm demo server url to serve your requests. This will verify whether you get alternatives using the official demo with your web app and more or less eliminate the third reason

  2. Use the official osrm frontend with your docker backend. If you get alternatives there, then something is missing in your frontend code, although it looks correct to me

If you get alternatives with 1. but not with 2. it's likely that the docker version is outdated, so maybe you could build it from source? This is all under the pretense, that your osm-data is fairly up-to-date. If it isn't I'd suggest updating it first with tools like osmupdate, osmosis or pyosmium