[postgis-users] solving the where am i problem in postgis

Stephen Woodbridge woodbri at swoodbridge.com
Sat Jan 24 08:37:53 PST 2009


Smith Roman wrote:
> 
> 
> Hi everyone,
> 
> How can i solve the where am i problem using the postgis nearest 
> neighbour query ?
> If I have my current location in coordinates how can i get the name of 
> the street i am on  ? (not the other streets close to me)

select *, ST_Distance(the_geom, setsrid(makepoint(X,Y), 4326)) as dist
   from streets
  where expand(setsrid(makepoint(X,Y), 4326), RADIUS) && the_geom
  order by dist
  limit 1;

Should do the trick. You have to supply values for X, Y, RADIUS.

-Steve W



More information about the postgis-users mailing list