<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.16.3">
</HEAD>
<BODY>
Hi all,<BR>
<BR>
I need help with an unusual query (at least for me :] )<BR>
<BR>
The objective is to find road segments with a type defined to tunnel within a given distance.<BR>
This is needed because of gps signal spikes (speed-wise) at tunnel exits...<BR>
<BR>
Now given the following scenario of road segments:<BR>
<BR>
                                                                                =====*-----------------*==========<BR>
====V===*========================*                                                             *======<BR>
                                                                                =====*-----------------*==========<BR>
                    |<BR>
                    |<BR>
                    |<BR>
                    |<BR>
                    |<BR>
                    |<BR>
                    |<BR>
                    |<BR>
                    |<BR>
                    |==========-----------------------=======================<BR>
<BR>
= | road<BR>
- tunnel<BR>
* nodes<BR>
V vehicle<BR>
<BR>
Now when I execute a distance-based query (for road segments of tunnel type) I get the lower tunnel, which is closer.<BR>
But I want the upper one which is actually the one on the top.<BR>
<BR>
the actual query is as follows (tunnels (road type=67) within a 150 metres radius) -- the road map is in WGS84:<BR>
SELECT name, road_type FROM $road_net WHERE <BR>
transform(geometry,$srid) && setsrid(expand(transform(geomfromtext('POINT($lon $lat)',4326),$srid),150),$srid) <BR>
AND distance(transform(geomfromtext('POINT($lon $lat)',4326),$srid), transform(geometry,$srid)) <=150 AND road_type=67;<BR>
<BR>
Already thankful for any tips,<BR>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
-- <BR>
Pedro Doria Meunier <<A HREF="mailto:pdoria@netmadeira.com">pdoria@netmadeira.com</A>>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>