A complete solution of pgRouting direction Web API written in Node js (Javascript) Express
-
edit
src/config/config.js
file according to your postgres connection, pgRouting table name and express js settings. -
*if your pgrouting database table schema/name of columns is different, you have to change the query schema in
src/model/pgrouting.js
npm install
npm start
- http://localhost:3000
- http://localhost:3000/route?start=3078473.56,8206254.21&end=2780495.14,8423917.64
- http://localhost:3000/closest?lat=3078473.56&lng=8206254.21&buffer=3000000&limit=1
- http://localhost:3000/distance?start=3078473.56,8206254.21&end=2780495.14,8423917.64
- http://localhost:3000/api/v1
- http://localhost:3000/api/v1/route?start=99.99537,6.81322&end=100.00850,6.81125
- http://localhost:3000/api/v1/distance?start=99.99537,6.81322&end=100.00850,6.81125
- http://localhost:3000/api/v1/closest?lat=100.00855&lng=6.81122&buffer=1000&limit=1
- http://localhost:3000/api/v1/topo
- http://35.240.xxx.xxx:3300/api/route/6.81322/99.99537/6.81125/100.00850
- https://postgis.net/docs/ST_LineMerge.html
- https://gis.stackexchange.com/questions/19864/converting-multilinestring-to-linestring-with-postgis/19867
- https://stackoverflow.com/questions/43871083/convert-multilinestring-to-linestring-in-query-result
App is underdevelopment:
- Way Points
- Docker
- Handle other pgRouting capabilities.
SELECT st_asgeojson(st_transform(ST_LineMerge(st_union(geom)),4326)) geojson
FROM pgr_dijkstra(
'SELECT id, source, target, cost_len as cost, rcost_len as reverse_cost FROM line',
(SELECT id FROM line_vertices_pgr ORDER BY st_distance(the_geom, st_setsrid(st_makepoint(99.99537, 6.81322), 4326)) LIMIT 1),
(SELECT id FROM line_vertices_pgr ORDER BY st_distance(the_geom, st_setsrid(st_makepoint(100.00850, 6.81125), 4326)) LIMIT 1),
false) as dj, line as ln where dj.edge=ln."id";