[pgrouting-users] path not found

Luca Santaniello luca.santaniello at email.it
Fri Jan 21 05:12:10 EST 2011


Thanks for reply. I'm using shooting_star alghorithm. My cost is associated with an edge. Many edge have 'infinity' cost (update.... set cost = 'infinity').  I definited wrapper function.

I call my function using this sql:

select * from carto_shootingstar('carto_nw', 456824, 450370, 0.1, 'cost_time', 'reverse_cost_time', true, true)

Thanks

[CODE]
DECLARE
   	geom_table ALIAS FOR $1;
	sourceid ALIAS FOR $2;
	targetid ALIAS FOR $3;
	delta ALIAS FOR $4;
   	cost_column ALIAS FOR $5;
   	reverse_cost_column ALIAS FOR $6;
	dir ALIAS FOR $7;
	rc ALIAS FOR $8;

	rec record;
	r record;
         path_result record;
         v_id integer;
         e_id integer;
         geom geoms;
	
	srid integer;

	source_x float8;
	source_y float8;
	target_x float8;
	target_y float8;
	
	ll_x float8;
	ll_y float8;
	ur_x float8;
	ur_y float8;
	
	query text;

	id integer;
BEGIN
	
	id :=0;
	FOR rec IN EXECUTE
	    'select srid(the_geom) from ' ||
	    quote_ident(geom_table) || ' limit 1'
	LOOP
	END LOOP;
	srid := rec.srid;
	
	FOR rec IN EXECUTE
             'select x(startpoint(the_geom)) as source_x from ' ||
             quote_ident(geom_table) || ' where gid = '||sourceid
         LOOP
	END LOOP;
	source_x := rec.source_x;
	
	FOR rec IN EXECUTE
             'select y(startpoint(the_geom)) as source_y from ' ||
             quote_ident(geom_table) || ' where gid = ' ||sourceid
         LOOP
	END LOOP;

	source_y := rec.source_y;

	FOR rec IN EXECUTE
             'select x(startpoint(the_geom)) as target_x from ' ||
             quote_ident(geom_table) || ' where gid = ' ||targetid
         LOOP
	END LOOP;

	target_x := rec.target_x;
	
	FOR rec IN EXECUTE
             'select y(startpoint(the_geom)) as target_y from ' ||
             quote_ident(geom_table) || ' where gid = ' ||targetid
         LOOP
	END LOOP;
	target_y := rec.target_y;

	FOR rec IN EXECUTE 'SELECT CASE WHEN '||source_x||'<'||target_x||
            ' THEN '||source_x||' ELSE '||target_x||
            ' END as ll_x, CASE WHEN '||source_x||'>'||target_x||
            ' THEN '||source_x||' ELSE '||target_x||' END as ur_x'
         LOOP
	END LOOP;

	ll_x := rec.ll_x;
	ur_x := rec.ur_x;

	FOR rec IN EXECUTE 'SELECT CASE WHEN '||source_y||'<'||
             target_y||' THEN '||source_y||' ELSE '||
             target_y||' END as ll_y, CASE WHEN '||
             source_y||'>'||target_y||' THEN '||
             source_y||' ELSE '||target_y||' END as ur_y'
         LOOP
	END LOOP;

	ll_y := rec.ll_y;
	ur_y := rec.ur_y;

	query := 'SELECT gid, the_geom FROM ' ||
           'shortest_path_shooting_star(''SELECT gid as id, source::integer, ' ||
           'target::integer, '||cost_column||'::double precision as cost, ' ||
           'x1::double precision, y1::double precision, x2::double ' ||
           'precision, y2::double precision, rule::varchar, ' ||
	  			'to_cost::double precision ';
	
	IF rc THEN query := query || ' , ' || reverse_cost_column || ' as reverse_cost ';
	END IF;
	
	query := query || 'FROM ' || quote_ident(geom_table) || ' where setSRID(''''BOX3D('||
           ll_x-delta||' '||ll_y-delta||','||ur_x+delta||' '||
           ur_y+delta||')''''::BOX3D, ' || srid || ')&&  the_geom'', ' ||
           quote_literal(sourceid) || ' , ' ||
           quote_literal(targetid) || ' , '''||text(dir)||''', '''||text(rc)||''' ),' ||
           quote_ident(geom_table) || ' where edge_id = gid ';
	
	FOR path_result IN EXECUTE query
         LOOP
                  geom.gid      := path_result.gid;
                  geom.the_geom := path_result.the_geom;
		 id := id+1;
		 geom.id       := id;

                  RETURN NEXT geom;

         END LOOP;
         RETURN;
END;
[/CODE]

-- 
Luca Santaniello
email: luca.santaniello at email.it
phone: +39 3470373994
skype: luca.santaniello
msn: luketto81 at hotmail.com

>> Hi all,
>>
>> I use pgrouting 1.02. I have teleatlas table with cost and reverse cost.
>> When I have source cost infinity, my path is not found. Is it normal?
>> Why? If I start my path from source with cost not infinity, path is 
>> found.
>>
>
> Hi Luca,
>
> Please provide more information, I'm a little confused by your question.
>
> Cost is normally associated with an edge.
> What is your source? an edge or a node?
> How are you setting the the cost to infinity? what value are you using?
> Can you provide the sql query you are using?
> Which solution are you trying? dijkstra, astar, or shootingstar?
>
> Thanks,
>   -Steve
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/pgrouting-users
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/pgrouting-users/attachments/20110121/075a90c1/attachment.html


More information about the Pgrouting-users mailing list