[pgrouting-users] question : Shortest Path Shooting star using python

bino oetomo bino at indoakses-online.com
Thu Feb 2 22:41:12 EST 2012


Dear all ...
I learning from http://workshop.pgrouting.org/chapters/php_server.html , 
but need to adopt it to python.

I want to count the total length of route between :
--Start at lat/lon = -7.779954532607184,110.37820327878194
--end at lat/lon = -7.777881661899044,110.36775339245992

First I try to got nearest edges , using :
--------START----------
------start_edge
SELECT gid, source, target, the_geom,
             distance(the_geom, GeometryFromText(
             'POINT(110.378203279 -7.77995453261)', 4326)) AS dist
             FROM "ways"
             WHERE the_geom && setsrid(
             'BOX3D(110.278203279 -7.87995453261,110.478203279 
-7.67995453261)'::box3d, 4326)
             ORDER BY dist LIMIT 1 ;
------end_edge
SELECT gid, source, target, the_geom,
             distance(the_geom, GeometryFromText(
             'POINT(110.367753392 -7.7778816619)', 4326)) AS dist
             FROM "ways"
             WHERE the_geom && setsrid(
             'BOX3D(110.267753392 -7.8778816619,110.467753392 
-7.6778816619)'::box3d, 4326)
             ORDER BY dist LIMIT 1 ;
--------STOP-----------

I got  195690 as my start-edge gid and 11690 end_edge gid


for 'Shortest Path Shooting*',  my sql query :
------Start-------
SELECT rt.gid, ST_AsGeoJSON(rt.the_geom) AS geojson,
         length(rt.the_geom) AS length, ways.gid
         FROM "ways",
         (SELECT gid, the_geom
         FROM shootingstar_sp(
         'ways',
         195690, 11690,
         0.1, 'length', true, true)
         ) as rt
         WHERE ways.gid=rt.gid;
------stop-----------

I got returns lines like :
-------START------------
(195690, 
'{"type":"MultiLineString","coordinates":[[[110.3776917,-7.7799519],[110.378560500000006,-7.7800485]]]}', 
0.00087415387662070204, 195690)
(228202, 
'{"type":"MultiLineString","coordinates":[[[110.377695599999996,-7.7799235],[110.3776917,-7.7799519]]]}', 
2.8666531007453801e-05, 228202)
(226891, 
'{"type":"MultiLineString","coordinates":[[[110.375391800000003,-7.7796208],[110.377695599999996,-7.7799235]]]}', 
0.0023236010264171799, 226891)
(208736, 
'{"type":"MultiLineString","coordinates":[[[110.375391800000003,-7.7796208],[110.375979000000001,-7.7762031]]]}', 
0.0034677769723553001, 208736)
(151742, 
'{"type":"MultiLineString","coordinates":[[[110.375979000000001,-7.7762031],[110.375815299999999,-7.7761449],[110.375752199999994,-7.7759897]]]}', 
0.00034127511834667598, 151742)
(151712, 
'{"type":"MultiLineString","coordinates":[[[110.375752199999994,-7.7759897],[110.375602700000002,-7.7761528],[110.374589200000003,-7.7761589],[110.374242199999998,-7.7760816]]]}', 
0.0015902747114182199, 151712)
(211523, 
'{"type":"MultiLineString","coordinates":[[[110.374242199999998,-7.7760816],[110.372598400000001,-7.7754287]]]}', 
0.0017687161586837799, 211523)
(7597, 
'{"type":"MultiLineString","coordinates":[[[110.371240599999993,-7.7785458],[110.371377600000002,-7.7783286],[110.371773099999999,-7.7769228],[110.372203200000001,-7.7762957],[110.372598400000001,-7.7754287]]]}', 
0.00343041625268363, 7597)
(213679, 
'{"type":"MultiLineString","coordinates":[[[110.371114800000001,-7.7785313],[110.371240599999993,-7.7785458]]]}', 
0.00012663289461284301, 213679)
(213678, 
'{"type":"MultiLineString","coordinates":[[[110.370803300000006,-7.7784871],[110.371114800000001,-7.7785313]]]}', 
0.00031462023138529102, 213678)
(213676, 
'{"type":"MultiLineString","coordinates":[[[110.369984299999999,-7.7784011],[110.370803300000006,-7.7784871]]]}', 
0.00082350288403354205, 213676)
(180690, 
'{"type":"MultiLineString","coordinates":[[[110.3675791,-7.7781225],[110.369984299999999,-7.7784011]]]}', 
0.0024212816853872699, 180690)
(11690, 
'{"type":"MultiLineString","coordinates":[[[110.3675791,-7.7781225],[110.369018800000006,-7.7665256],[110.369872299999997,-7.7544829],[110.371099400000006,-7.7512179]]]}', 
0.027246810615796702, 11690)
-------STOP-------------

Taking the third element of each line (that is '0.00087415387662070204' 
for the first line) as what I think as 'road length',
I got total value of  0.0447577289587.

If '0.0447577289587' the total length of route, what is it's 'Unit of 
measure' ? How to got value in 'Kilometers/meters' ?

Note : When I try to count the route using same start Lat/Lon and end 
lat/lon, google map said it was about 2.1 km

Sincerely
-bino-



More information about the Pgrouting-users mailing list