[mapserver-users] get the closest feature in a point query
Andy Colson
andy at squeakycode.net
Thu Dec 9 09:17:19 PST 2010
On 12/9/2010 11:07 AM, Mark Volz wrote:
> Hello,
>
> I know we can use tolerance/ toleranceusnitsto control the sensitivity
> forspatial queries. Is there a way tofurthercontrol queries by getting
> the nearest feature, or the first feature found?
>
> Thanks
>
> Mark Volz
>
> GIS Specialist
>
> Lyon County, MN
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
Not sure if this'll help, but I use PostGIS for that, here is the query
I use to find the nearest road from a click point:
select roads, distance(the_geom, GeomFromText(point, -1)) as distance
from cadastralLine, ST_Buffer(GeomFromText(point, -1), 100) as g
where the_geom && g and roads is not null
order by distance
limit 1
point here is a text variable, like: POINT(1 100)
-Andy
More information about the MapServer-users
mailing list