[OSM-talk] all POIs within a specific radius

kenneth gonsalves lawgon at thenilgiris.com
Tue Aug 9 09:49:23 BST 2011


On Mon, 2011-08-08 at 07:34 +0100, Graham Jones wrote:
> These questions might get a better response on the Dev list as they
> are quite technical.

but it is an end user question - I would not like to waste the time of
the devs.

> I am not very good at postgis so I may be wrong, but you might be
> comparing two identical points (way and way).  The postgis manual
> seems to do select. ... AS.. for each side of the comparison.
> You could check this by using the coordinates of bangalore explicitly
> rather than getting them from the database.

actually as Frederik pointed out the error was that the measurement has
to be in degrees and not metres as I had assumed. It works like a
charm. 
> 
> I quite fancy starting a tips and tricks wiki page for this sort of
> thing if you would like to ass the solution when you find it. 

Here it is (I am quite proud of the fact that I could do it with my
rudimentary knowledge of sql - it only took 4 days to write it):

select p.name,
f.lat*.0000001 as lat,
f.lon*.0000001 as lon
from 
planet_osm_point p,
planet_osm_nodes f 
where 
(p.place != 'city')
and
ST_DWithin(p.way,
(select way from planet_osm_point where name like '%Mysuru%'  limit
1),.15)
and 
p.osm_id = f.id 
order by p.name;

This selects all places within .15 degrees of Mysuru.




More information about the talk mailing list