astar (#17) - Pgrouting 1.01 and shortest_path_astar2_as_geometry_internal_id (#100) - Message List
Dear forum,
it looks like that I have now enough time to get deeper in pgrouting and -hopefully- to be able to contribute to that project in a couple of month, in context of my dissertation. But by now I`m still a -more or less- Newbie......
I try to use the following application: http://www.tourismus-maps.de/behncke/routing_php/phtmls/routing_os_frida.phtml
that works with the function: $sql="the_geom from (select gid, the_geom from ".
"shortest_path_astar2_as_geometry_internal_id('fridastreets', ". $start.", ".$end.", ".$ll_x.", ".$ll_y.", ".$ur_x.", ". $ur_y.")) as g using unique gid using SRID=-1";
that comes from that tutorial: http://www.selbstverwaltung-bundesweit.de/mapserver/tutorial_routing_mapserver.zip
But in my case I dontt work with Windows (its Debian now) and it`s pgrouting 1.01.
Obviously there is no function like "shortest_path_astar2_as_geometry_internal_id" anomyore so I get an error message.
How can I visualize now the routes? I mean, if I use something like:
SELECT * FROM shortest_path_astar('SELECT gid AS id, source::int4,
target::int4, length::double precision AS cost, x1, y1, x2, y2
FROM dourol',3, 7, false, false);
I get:
vertex_id | edge_id | cost
3 | 2 | 0.000763954363701041 4 | 21 | 0.00150254971056274 6 | 5 | 0.000417442425988342 7 | -1 | 0
But for UMN MapServer I need at least "the_geom" with the geometry to visualize???
Is there a way to change "shortest_path_astar2_as_geometry_internal_id" to another funtion that gives me the geometry???
Thank you again.....
-
Message #383
I tried to put the function from the source of pgRouting 1.0.0a in my database:
CREATE OR REPLACE FUNCTION shortest_path_astar2_as_geometry_internal_id(
varchar,int4, int4, float8, float8, float8, float8) RETURNS SETOF GEOMS AS
$$ DECLARE
geom_table ALIAS FOR $1; sourceid ALIAS FOR $2; targetid ALIAS FOR $3; ll_x ALIAS FOR $4; ll_y ALIAS FOR $5; ur_x ALIAS FOR $6; ur_y ALIAS FOR $7;
rec record; r record; path_result record; v_id integer; e_id integer; geom geoms;
srid integer;
BEGIN
FOR path_result IN EXECUTE 'SELECT gid,the_geom FROM '
'shortest_path_astar2_as_geometry_internal_id_directed(
quote_ident(geom_table)
, ' quote_literal(sourceid) ', ' quote_literal(targetid)
', ' ll_x ', ' ll_y ', ' ur_x
', ' ur_y ', false, false)' LOOP
geom.gid := path_result.gid; geom.the_geom := path_result.the_geom;
RETURN NEXT geom;
END LOOP; RETURN;
END; $$ LANGUAGE 'plpgsql' VOLATILE STRICT;
But I still get the error message that the function doesn`t exist???
Kai-Behncke01/18/08 23:10:19 (3 years ago)-
Message #397
To the question how to visualize the routes:
In MapServer it works like: DATA "the_geom from (SELECT gid, the_geom FROM astar_sp_delta('fridastreets', 5846, 4504, 3000)) as foo using unique gid using srid=-1"
Of course its possible to write an own function with Pg/pgsql. I did like:
CREATE OR REPLACE function give_me_geom(varchar,int,int) RETURNS SETOF GEOMS AS $$ DECLARE table_name ALIAS FOR $1; source_id ALIAS FOR $2; target_id ALIAS FOR $3; id int; edge_id int; query text; pg_query record; r record; geom geoms;
BEGIN id:=0; edge_id:=0;
query := 'SELECT * FROM '
'shortest_path_astar(SELECT gid as id, source::integer, ' 'target::integer, length::double precision as cost, ' 'x1::double precision, y1::double precision, x2::double ' 'precision, y2::double precision '
'FROM '
quote_ident(table_name)
,' source_id ',' target_id ',false,false)'; FOR pg_query IN EXECUTE query LOOP
edge_id:=pg_query.edge_id;
FOR r IN EXECUTE 'SELECT gid,the_geom FROM '
quote_ident(table_name)
' WHERE gid =' edge_id LOOP geom.gid := r.gid;
geom.the_geom := r.the_geom;
id := id+1;
geom.id := id;
RETURN NEXT geom;
END LOOP;
END LOOP;
RETURN;
END; $$ LANGUAGE 'plpgsql';
.....and then DATA "the_geom from (SELECT gid, the_geom FROM give_me_geom('fridastreets', 5846, 4504) as foo using unique gid using srid=-1"
Kai-Behncke01/27/08 23:28:53 (3 years ago)Message #578Hi,
I have try to do tutorial : http://www.selbstverwaltung-bundesweit.de/mapserver/tutorial_routing_mapserver.zip
I have problems when run routing_os_frida.phtml because to appear error : Warning: Error: msDrawMap(): Failed to draw layer named 'path'. in C:\ms4w\Apache\htdocs\baru\phtmls\routing_os_frida.phtml on line 62
Warning: Error: msPOSTGISLayerWhichShapes(): Error executing POSTGIS SQL statement (in FETCH ALL): DECLARE mycursor BINARY CURSOR FOR SELECT asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text from (select gid, the_geom from shortest_path_astar2_as_geometry_internal_id('fridastreets', 7750, 5264, 3427000.25, 5785733.375, 3444004, 5802737.125)) as g WHERE the_geom && setSRID('BOX3D(3427000.25 5785733.375,3444004 5802737.125)'::BOX3D, -1 ) -ERROR: operator does not exist: text
boolean LINE 1: ...l( $8 ) ' , ' quote_literal( $9 ) ' , $10 '... HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. QUERY: SELECT $1 'FROM ' quote_ident( $2 ) ' where setSRID('BOX3D(' $3 ' ' $4 ',' $5 ' ' $6 ')'::BOX3D, ' $7 ') && the_geom, ' quote_literal( $8 ) ' , ' quote_literal( $9 ) ' , $10 , $11 ),' in C:\ms4w\Apache\htdocs\baru\phtmls\routing_os_frida.phtml on line 62 Fatal error: Call to a member function saveWebImage() on a non-object in C:\ms4w\Apache\htdocs\baru\phtmls\routing_os_frida.phtml on line 63
I use work with Windows, pgRouting-1.0.0.a-0_win32, postgre 8.2.5 and postgis-pg82-setup-1.3.3-1
Thanks
yuni08/25/08 14:22:39 (2 years ago)
Powered by Trac 0.11.5rc1
By Edgewall Software.pgRouting is a project of PostLBS
http://www.postlbs.org/
-