raido

Microservice for shortest path routing on Norwegian trails

Usage no npm install needed!

<script type="module">
  import raido from 'https://cdn.skypack.dev/raido';
</script>

README

Raidō

Build status Codacy grade Codacy coverage NPM downloads NPM version Node version Dependency status

Microservice for shortest path routing on Norwegian trails using pgRouting and waymarked trails from the Norwegian Mapping Authority (Kartverket).

The name Raidō means "ride, journey" in the runic alphabets is the reconstructed Proto-Germanic name of the r- rune of the Elder Futhark ᚱ. The name is attested for the same rune in all three rune poems, Old Norwegian Ræið Icelandic Reið, Anglo-Saxon Rad.

ᚱ Ræið kveða rossom væsta; Reginn sló sværðet bæzta.

API

GET /v1/routing

  • string source - start point coordinate on the format x,y
  • string target - end point coordinate on the format x,y
  • number path_buffer - route sensitivity / buffer (default 2000)
  • number point_buffer - point sensitivity / buffer (default 10)
  • string bbox - bbox bounding bounds on the format x1,y1,x2,y2
  • number limit - max number of shortest path to return (default 1)

Return shortest path from source to target. Returns a GeometryCollection if a route is found.

Returned route

{
  "type": "GeometryCollection",
  "geometries": [{
    "type": "LineString",
    "coordinates": [...],
    "properties": {
      "cost": 1510.05825002283
    }
  }]
}

Mutliple routes

If you want multiple shortest path you can use the limit query parameter to control the number of routes returned. By default only the shortest route will be returned.

{
  "type": "GeometryCollection",
  "geometries": [{
    "type": "LineString",
    "coordinates": [...],
    "properties": {
      "cost": 1510.05825002283
    }
  },{
    "type": "LineString",
    "coordinates": [...],
    "properties": {
      "cost": 1610.06825002284
    }
  }]
}

Route not found

If the source or target points can not be found or a route between them could not be found the routing will return an empty GeometryCollection.

{
  "type": "GeometryCollection",
  "geometries": []
}

Production

docker run --name postgres turistforeningen/pgrouting-n50:latest
docker run --link postgres turistforeningen/raido:latest -p 8080

Development

Requirements

  • Docker 1.10+
  • Docker Compose v1.4+

Start

docker-compose up

Test

docker-compose run --rm node npm run test
docker-compose run --rm node npm run lint

MIT lisenced