[postgis-users] help with a query

Fred Lehodey lehodey at gmail.com
Tue Nov 25 02:14:15 PST 2008


Hi Pedro,you are calculating the route with all roads and only after you are
filtering with the WHERE clause.

IMO, better is to create a field with high costs (Ex:10000) to roads when
road_type=22 and length for road_type != 22.
After that, you can run the function shortest_path() using your new cost
field.


Fred.


On Tue, Nov 25, 2008 at 2:16 AM, Pedro Doria Meunier
<pdoria at netmadeira.com>wrote:

> Hi guys :) -- a *special* wink to David Techer ;-)
>
> I'm having a bit of trouble figuring out what can I do with the wrapper
> functions of pgRouting... (blush)
>
> The thing is:
>
> I have everything perfectly in place, pgRouting working as it's supposed
> to, but!
>
> I have a dataset that describes the road type. I want to filter the results
> provided by pgRouting in a way that it *doesn't* return return pedestrian
> segments (btw: road_type=22).
>
> So, as to the query itself (basic) 1st try:
>
> SELECT gid, AsBinary(the_geom) AS the_geom
>   FROM dijkstra_sp_directed('pt_madeira_roads', 11780, 424, true, true);
>
> Works like a charm except that it returns pedestrian segments (of course).
>
> 2nd try:
>
> SELECT rt.gid, AsText(rt.the_geom) AS wkt,
>                  length(rt.the_geom) AS length, roads.gid
>               FROM my_roads as roads,
>                   (SELECT gid, the_geom
>                       FROM dijkstra_sp_directed(
>                           'my_roads',
>                           11780,
>                           424,
>                           true,true)
>                    ) as rt
>               WHERE roads.road_type<>22 and roads.gid=rt.gid;
>
> Leaves me with *holes* in the route.
>
> All of this is, of course, a consequence of my own stupidity and late hours
> but I'd surely appreciate if some brave soul could look into it. ;-)
>
> Already thankful in advance,
> Pedro Doria Meunier.
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20081125/2bd41dd6/attachment.html>


More information about the postgis-users mailing list