[postgis-users] Need help with a query

Pedro Doria Meunier pdoria at netmadeira.com
Wed Jul 16 01:54:08 PDT 2008


Hi all,

I need help with an unusual query (at least for me :] )

The objective is to find road segments with a type defined to tunnel
within a given distance.
This is needed because of gps signal spikes (speed-wise) at tunnel
exits...

Now given the following scenario of road segments:


=====*-----------------*==========
====V===*========================*
*======

=====*-----------------*==========
                    |
                    |
                    |
                    |
                    |
                    |
                    |
                    |
                    |
                    |
==========-----------------------=======================

= | road
- tunnel
* nodes
V vehicle

Now when I execute a distance-based query (for road segments of tunnel
type) I get the lower tunnel, which is closer.
But I want the upper one which is actually the one on the top.

the actual query is as follows (tunnels (road type=67) within a 150
metres radius) -- the road map is in WGS84:
SELECT name, road_type FROM $road_net WHERE 
transform(geometry,$srid) &&
setsrid(expand(transform(geomfromtext('POINT($lon $lat)',4326),
$srid),150),$srid) 
AND distance(transform(geomfromtext('POINT($lon $lat)',4326),$srid),
transform(geometry,$srid)) <=150 AND road_type=67;

Already thankful for any tips,

-- 
Pedro Doria Meunier <pdoria at netmadeira.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080716/79ab6bec/attachment.html>


More information about the postgis-users mailing list