[postgis-users] Re: pgRouting Query : Shooting Star

Matthew Pulis mpulis at gmail.com
Fri Nov 30 02:05:57 PST 2007


Just would like to say that I have tried many different combinations and am
still getting the same outcome :(

Any help would be extremely appreciated! :)

On 11/27/07, Matthew Pulis <mpulis at gmail.com> wrote:
>
> Hi,
>
>
>
>
>
> I am trying to play a bit with the Shooting Star Query of pgRouting, since
> I need it to use it for one-way streets.
>
>
>
> I am trying this query :
>
> SELECT gid, the_geom
>
> FROM shootingstar_sp('streets',
>
> give_source('POINT(640905 225230)',1000,200),
>
> give_target('POINT(640982 225439)',1000,200), 2000,
>
> 'length',true,true);
>
>
>
> and also tried this query :
>
> select rt.gid, rt.the_geom, length(rt.the_geom), streets.gid
>
> from streets,
>
>  (select gid, the_geom
>
>  from shootingstar_sp(
>
>  'streets',
>
> give_source('POINT(640905 225230)',1000,200),
>
> give_target('POINT(640982 225439)',1000,200), 5000, 'length', true, true
>
> )
>
> )as rt
>
>
>
> For half of the results both edge_ids are the same, however when I project
> the result on a shapefile then on QGis on my map, the points where the route
> should start and end are FAR from the points I selected.
>
>
>
> The functions give_source and give_target are functions I gave to
> transfrom the Point to the source colum and this is the function : --
> Function: give_source(text, integer, integer)
>
>
>
> -- DROP FUNCTION give_source(text, integer, integer);
>
>
>
> CREATE OR REPLACE FUNCTION give_source(text, integer, integer)
>
>
>
> RETURNS integer AS
>
>
>
> $BODY$
>
>
>
> DECLARE
>
>
>
> pojnt ALIAS FOR $1; box ALIAS FOR $2; dist ALIAS FOR $3;
>
>
>
> r_source INTEGER;
>
>
>
> BEGIN
>
>
>
> SELECT source INTO r_source FROM streets s WHERE
>
>
>
> ( the_geom && expand (pointfromtext(pojnt),box) and distance (s.the_geom ,
> pointfromtext(pojnt)) < dist )
>
>
>
> ORDER BY distance (s.the_geom , pointfromtext(pojnt)) ASC LIMIT 1;
>
>
>
> RETURN r_source;
>
>
>
> END; $BODY$
>
>
>
> LANGUAGE 'plpgsql' VOLATILE;
>
>
>
> ALTER FUNCTION give_source(text, integer, integer) OWNER TO yancho;
>
>
>
> I know it should be something stupid that I am doing, but really am out of
> ideas why it is not working. For sure the routing is being done well, but
> the start / end points are wrong, so it should be something from the
> give_source / give_target problem. BTW I used these two functions for my
> astar_sp_delta testing and it worked perfectly :
>
>
>
> SELECT gid, AsText?(the_geom) AS wkt
>
>
>
> FROM astar_sp_delta(
>
>
>
> 'streets', (select give_source('POINT(640905 225230)',1000,200), (select
> give_target('POINT(640982 225439)',1000,200), 3000 );
>
>
>
> ";
>
>
>
>
>
> As you can see on the paste here : http://yancho.pastebin.com/f7f44a0c2
>
>
>
> The first result row of astar_sp_delta is : 40617;"MULTILINESTRING((
> 640920.707155369 225441.381903503,640919.710413482 225419.024734874,
> 640904.400352 225231.230885577))"
>
>
>
> .. Which is very near the POINT : POINT(640905 225230),
>
>
>
> However the first result row of shootingstar_sp is :
> 791;"MULTILINESTRING((629357.137492173 222486.61416491,629357.137492172
> 222526.524103276))" followed by these two :
>
>
>
> 47462;"MULTILINESTRING((629357.137492172 222526.524103276,629355.842055444
> 222559.004436553))" 44423;"MULTILINESTRING((629355.842055444
> 222559.004436553,629354.394306192 222605.962730528))"
>
>
>
> Which shows clearly how far it is from the starting point : POINT(640905
> 225230)
>
>
>
> Also I tried this function :
>
>
>
> SELECT * FROM shortest_path_shooting_star('
>
>
>
> SELECT gid as id,
>
>
>
> source::integer, target::integer, length::double precision as cost,
> rcost::double precision as reverse_cost, x1, y1, x2, y2, rule, to_cost
>
>
>
> FROM streets',
>
>
>
> give_source('POINT(640905 225230)',1000,200), give_target('POINT(640982
> 225439)',1000,200),
>
>
>
> false,true);
>
>
>
> Highted and pasted here : http://yancho.pastebin.com/d216a2408
>
>
>
> Which is giving me these 3 rows as my first resultset :
> 13065;791;39.9099383660941 13066;47462;32.5061564333317
> 21733;44423;46.9806061157797
>
>
>
> Which have the same gid as the first 3 resultset given from
> shootingstar_sp .. so it is quite obvious I am giving the functions the
> wrong starting location / ending .. any one can shed some light on what I
> should fix please?
>
>
>
> Any ideas will be extremely appreciated and keep up the good work :)
>
>
>
> Thanks and regards
>
>
>
> Matthew
>
>
>
>
>
>
>
>
> ------------------------------
>
> I am using the free version of SPAMfighter for private users.
> It has removed 18348 spam emails to date.
> Paying users do not have this message in their emails.
> Try SPAMfighter <http://www.spamfighter.com/len> for free now!
>



-- 
Matthew Pulis
URL : http://www.solutions-lab.net
MSN : pulis_matthew[@]hotmail.com
ICQ : 145951110
Skype : solutions-lab.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20071130/bc4178a5/attachment.html>


More information about the postgis-users mailing list