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.
- string
source
- start point coordinate on the formatx,y
- string
target
- end point coordinate on the formatx,y
- number
path_buffer
- route sensitivity / buffer (default2000
) - number
point_buffer
- point sensitivity / buffer (default10
) - string
bbox
- bbox bounding bounds on the formatx1,y1,x2,y2
- number
limit
- max number of shortest path to return (default1
)
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": []
}
docker run --name postgres turistforeningen/pgrouting-n50:latest
docker run --link postgres turistforeningen/raido:latest -p 8080
- Docker 1.10+
- Docker Compose v1.4+
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
docker-compose run --rm node npm run test
docker-compose run --rm node npm run lint