Skip to content

Commit 6b5ef9e

Browse files
author
Muhammad Imran Siddique
committed
'id_update'
1 parent 13db172 commit 6b5ef9e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/model/pgRouting.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ const {pool, query} = require('../config/database');
22
const {config_pg} = require('../config/config');
33

44
function distanceQuery(start, end) {
5+
// ST_GeomFromText('POINT(24.240194 60.008345)', 4326)
56
const query = `SELECT * FROM pgr_dijkstra(
6-
'SELECT gid as id, source, target, cost_len as cost FROM ${config_pg.table}',
7+
'SELECT id, source, target, cost_len as cost FROM ${config_pg.table}',
78
(SELECT id FROM ${config_pg.vertices_table} ORDER BY st_distance(the_geom, st_setsrid(st_makepoint(${start}), ${config_pg.input_srid})) LIMIT 1),
89
(SELECT id FROM ${config_pg.vertices_table} ORDER BY st_distance(the_geom, st_setsrid(st_makepoint(${end}), ${config_pg.input_srid})) LIMIT 1)
910
, false)`;
@@ -13,10 +14,10 @@ function distanceQuery(start, end) {
1314
function routeQuery(start, end) {
1415
const query = `
1516
SELECT *, st_transform(geom, ${config_pg.output_srid}) as geom, st_asgeojson(st_transform(geom, ${config_pg.output_srid})) geojson, st_astext(st_transform(geom, ${config_pg.output_srid})) wkt FROM pgr_dijkstra(
16-
'SELECT gid as id, source, target, cost_len as cost, rcost_len as reverse_cost FROM ${config_pg.table}',
17+
'SELECT id, source, target, cost_len as cost, rcost_len as reverse_cost FROM ${config_pg.table}',
1718
(SELECT id FROM ${config_pg.vertices_table} ORDER BY st_distance(the_geom, st_setsrid(st_makepoint(${start}), ${config_pg.input_srid})) LIMIT 1),
1819
(SELECT id FROM ${config_pg.vertices_table} ORDER BY st_distance(the_geom, st_setsrid(st_makepoint(${end}), ${config_pg.input_srid})) LIMIT 1),
19-
false) as dj, ${config_pg.table} as ln where dj.edge=ln."gid";`;
20+
false) as dj, ${config_pg.table} as ln where dj.edge=ln."id";`;
2021
return query;
2122
}
2223

0 commit comments

Comments
 (0)