Skip to content

Raidō; a microservice for shortest path routing on Norwegian waymerked trails

License

Notifications You must be signed in to change notification settings

Turistforeningen/Raido

Repository files navigation

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

When starting the project for the first time, you'll see the following error while the database is initialized.

/usr/src/app/index.js:73
    if (err) { throw err; }
               ^

Error: connect ECONNREFUSED 172.17.0.9:5432
    at Object.exports._errnoException (util.js:1034:11)
    at exports._exceptionWithHostPort (util.js:1057:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1096:14)
Program node index.js exited with code 1

Wait a few minutes for the init script to finish, and the node service to connect to Postgres.

Connected to Postgres Database
Server listening on port 8080

Test

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

About

Raidō; a microservice for shortest path routing on Norwegian waymerked trails

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •