[pgrouting-users] problem with query results

Daniel Kastl kastl at orkney.co.jp
Wed Feb 4 19:05:55 EST 2009


Hi Valeria,

I never had the case of wrong ordered result, but you could add the "id"
attribute to the select and order by it.

For example:
SELECT id, gid, AsText(the_geom) AS the_geom FROM astar_sp_delta('ways',
10, 20, 0.1);

... should return something like:

 id  |  gid |         the_geom 
-----+-------+----------------------------------------------------------------------------------------------------------------
   1 |     9 | MULTILINESTRING((18.421891 -33.9154821,18.4216313
-33.9151594))
   2 |     8 | MULTILINESTRING((18.4220472 -33.9156916,18.421891
-33.9154821))
   3 |     7 | MULTILINESTRING((18.4223323 -33.9159963,18.4220472
-33.9156916))
   4 |  2983 | MULTILINESTRING((...))
   5 |  2982 | MULTILINESTRING((...))

Also you might want to try to JOIN two tables this way if you need more
than the standard returned attributes:
http://pgrouting.postlbs.org/wiki/SQLTipsAndTricks

Daniel


Valeria Muñoz schrieb:
> Hi
>  
> I have problems with the query results, The results are not sorted.
>  
> my Query:
>  
> SELECT rt.gid,rt.the_geom AS tg, AsText(rt.the_geom) AS wkt,
> length(rt.the_geom) AS length, calle.gid FROM calle, (SELECT gid,
> the_geom FROM dijkstra_sp_delta( 'calle', 3429, 3406, 3000) ) as rt
> WHERE calle.gid=rt.gid;
>  
> result:
> "gid";"tg";"wkt";"length";"gid"
> *4416*;"0105000020B30F00000100000001020000000200000018E60A2187CC51C007069A16AD973EC0AA2CA7847ECC51C0EB933A5AA9973EC0";"MULTILINESTRING((-71.1957476240572
> -30.5924848676714,-71.1952220566333
> -30.5924278634083))";0.000528649792432027;4416
> *4414*;"0105000020B30F000001000000010200000002000000F9E3B4109BCC51C065E35F65B5973EC0656B43BC8ECC51C02D2D6B65B0973EC0";"MULTILINESTRING((-71.1969644323834
> -30.5926116332152,-71.1962118776697
> -30.5925353418981))";0.000756411899864822;4414
> *4415*;"0105000020B30F000001000000010200000002000000656B43BC8ECC51C02D2D6B65B0973EC018E60A2187CC51C007069A16AD973EC0";"MULTILINESTRING((-71.1962118776697
> -30.5925353418981,-71.1957476240572
> -30.5924848676714))";0.00046698936208239;4415
> *4417*;"0105000020B30F000001000000010200000002000000AA2CA7847ECC51C0EB933A5AA9973EC04DFDF22B7ACC51C0FD7FB373A7973EC0";"MULTILINESTRING((-71.1952220566333
> -30.5924278634083,-71.194956767363
> -30.5923988641007))";0.000266869550146504;4417
> should be given A, B and C gave me B, A and C, then I can not generate
> a guide of how to get from point A to B properly..
>  
> Can sort the results?..please help..
> RG
> ------------------------------------------------------------------------
>
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users at lists.postlbs.org
> http://lists.postlbs.org/mailman/listinfo/pgrouting-users
>   




More information about the Pgrouting-users mailing list