Microservice for shortest path routing on Norwegian trails
5.6K

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.
source - start point coordinate on the format x,ytarget - end point coordinate on the format x,ypath_buffer - route sensitivity / buffer (default 2000)point_buffer - point sensitivity / buffer (default 10)bbox - bbox bounding bounds on the format x1,y1,x2,y2limit - 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": []
}
docker run --name postgres turistforeningen/pgrouting-n50:latest
docker run --link postgres turistforeningen/raido:latest -p 8080
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
Content type
Image
Digest
Size
87.4 MB
Last updated
almost 9 years ago
docker pull turistforeningen/raido