[OSM-Devserver] PostGIS nächstes Objekt

Alexander Matheisen AlexanderMatheisen at ish.de
Fr Nov 12 19:01:48 CET 2010


> > Das schaut super aus. Habs noch ein wenig modifiziert und jetzt ist es
> > perfekt:
> >
> > SELECT * FROM (SELECT DISTINCT ON (nameH)
> >      h.osm_id,
> >      h.tags->'name' AS nameH,
> > ST_Distance_Sphere(ST_Transform(s.way,4326), ST_Transform(h.way,4326))
> > AS distance
> > FROM
> >      planet_point AS s,
> >      planet_point AS h
> > WHERE
> >      s.osm_id = 613578611
> >      AND
> >      h.tags->'highway' = 'bus_stop'
> >      AND h.way&&  ST_Buffer(s.way, 2000)
> > ORDER BY nameH, distance LIMIT 2) AS foo ORDER BY foo.distance;

Kleine Korrektur, aber jetzt stimmts: ;)

SELECT * FROM (SELECT DISTINCT ON (nameH)
    h.osm_id,
    h.tags->'name' AS nameH, 
ST_Distance_Sphere(ST_Transform(s.way,4326), ST_Transform(h.way,4326)) 
AS distance
FROM
    planet_point AS s,
    planet_point AS h
WHERE
    s.osm_id = 613578611
    AND
    h.tags->'highway' = 'bus_stop'
    AND h.way && ST_Buffer(s.way, 2000)
ORDER BY nameH, distance) AS foo ORDER BY foo.distance LIMIT 2;



Alex