OSRM over sea doesn't work correctly

Hi guys, I’m relatively new with OSM and I have one small problem with OSRM.

I’m trying to have a map with routing between two points (London, UK & Reykjavik, IS).

However my problem is that routing ends on Faroe Islands (screenshot below).
I’m using OSRM api from https://routing.openstreetmap.de/.

It works “fine” when I try same route on OpenStreetMap Routing with Open Source Routing Machine

I also tried to take a look to OSRM api documentation (OSRM API Documentation) but nothing seems to work.

This is my code for whole map

    var mymap = L.map('mapid').setView([51.5074456,-0.1277653], 6);

    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(mymap);

    L.marker([63.902025,-22.190351]).addTo(mymap);
    L.marker([51.5074456,-0.1277653]).addTo(mymap);

    var route_json = JSON.parse(Get('https://routing.openstreetmap.de/routed-car/route/v1/driving/-0.1277653,51.5074456;-22.190351,63.902025?overview=full&geometries=geojson'));

    L.geoJSON(route_json.routes[0].geometry).addTo(mymap);

    function Get(URL) {
        var req = new XMLHttpRequest();
        req.open('GET', URL, false);
        req.send(null);

        return req.responseText;
    }

Has anyone idea what I’m doing wrong?

Thanks for your replies and have a nice day.

Two possibilities:

  1. The OSRM instance at routing.openstreetmap.de splits the world into three different zones (Europe/Asia, Africa/Oceania, Americas) in order to keep hardware requirements manageable. You can’t route between these zones.
  2. OSRM may not be finding a routable ferry connection to Iceland, depending on the tagging.

Tags enabling vehicle access on the ferry between Iceland and Faroe Islands were specified on the public transport relation but were missing form the route=ferry way itself. I now fixed the tagging. This should fix routing if there is no partitions/zones issue.

If you check your example in browser at https://routing.openstreetmap.de you will notice the straight dashed line between the Faroe Islands and Iceland. This happens because the demo instance cannot route across the three partitions/zones the demo instance uses as @Richard has stated (with Iceland being in the Americas zone). The turn-by-turn navigation instructions also stop at the harbor in Faroe Islands. (The dashed straight line means: “continue in direction of…”)

If you do enter the coordinates (or just London and Reykjavik, IS) at this OSRM demo here: https://fast-routing-api.demo.routingapi.net/ you will see the full route including the ferry between Faroe Islands and Iceland and the turn-by-turn instructions in Iceland.

So if you are dependent on these kind of edge routes you would have to look out at the list here: Open Source Routing Machine - OpenStreetMap Wiki for alternative OSRM sources that do not have the restrictions the demo instance at routing.openstreetmap.de has or run your own OSRM instance (if you only need Europe, you may use Geofabrik Download Server (Europe) as a data set as this has Iceland included).

Please also note that the demo instance may show more problems in regard to routing via ferries. E.g. compare Ystad (Sweden) to Rostock (Germany) routes on routing.openstreetmap.de against the OSRM instances listed on the wiki page linked above. This is also caused by hardware constraints at the demo instance that are mitigated by a slightly altered car profile resulting in some ferry routes not being used as expected.

Thank you all for replies. I solved it yesterday by condition.

It will draw line from the last coordinates to final destination if the last coordinates (from API call) isn’t same like coordinates for final destination.