[pgrouting-users] sort result
Stephen Woodbridge
woodbri at swoodbridge.com
Tue Mar 20 09:52:31 EDT 2012
On 3/20/2012 8:50 AM, Sven Schroeter wrote:
> Hi,
>
> I’m playing with Pgrouting using my own routing network (for bicycle) to
> navigate from sub-line A to sub-line B:
>
> SELECT rt.gid, AsText(rt.the_geom) AS wkt,
> length(rt.the_geom) AS length, routen_sub.id
> FROM routen_sub,
> (SELECT gid, the_geom
> FROM dijkstra_sp_directed(
> 'routen_sub',
> 5,
> 22,
> true, true)
> ) as rt
> WHERE routen_sub.gid=rt.gid;
>
> First Question:
> This works fine but the result geometry of my direction is unsorted. Is
> there a possibility to sort the result directly via SQL?
The results should be sorted, but the geometry may be reversed with
resprct to the direction of travel and the geometry order in the
database. I would write a simple stored procedure to reverse the
segments as needed.
- check if the first edge needs to be reversed, ie if the source is in
the 2nd edge (source or target).
- for the rest of the edges if last.target != this.source then reverse
> Second Question:
> Is it possible to set a "via" point directly in the SQL? With
> dijkstra_sp_directed is it only possible to set a start and a endpoint.
If you are asking if you can specify the a start or end somewhere on an
edge rather than a vertex, then consider using TRSP (it is in a branch
in git and you will need to build it yourself).
If you are asking if you can create a route from A to B to C to ...,
then you need to compute each leg as a separate query.
-Steve
> Thanks
> Sven
>
>
>
>
>
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/pgrouting-users
More information about the Pgrouting-users
mailing list