@@ -2,8 +2,9 @@ const {pool, query} = require('../config/database');
2
2
const { config_pg} = require ( '../config/config' ) ;
3
3
4
4
function distanceQuery ( start , end ) {
5
+ // ST_GeomFromText('POINT(24.240194 60.008345)', 4326)
5
6
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 } ',
7
8
(SELECT id FROM ${ config_pg . vertices_table } ORDER BY st_distance(the_geom, st_setsrid(st_makepoint(${ start } ), ${ config_pg . input_srid } )) LIMIT 1),
8
9
(SELECT id FROM ${ config_pg . vertices_table } ORDER BY st_distance(the_geom, st_setsrid(st_makepoint(${ end } ), ${ config_pg . input_srid } )) LIMIT 1)
9
10
, false)` ;
@@ -13,10 +14,10 @@ function distanceQuery(start, end) {
13
14
function routeQuery ( start , end ) {
14
15
const query = `
15
16
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 } ',
17
18
(SELECT id FROM ${ config_pg . vertices_table } ORDER BY st_distance(the_geom, st_setsrid(st_makepoint(${ start } ), ${ config_pg . input_srid } )) LIMIT 1),
18
19
(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 ";` ;
20
21
return query ;
21
22
}
22
23
0 commit comments