Skip to content

Instantly share code, notes, and snippets.

@jnicho02
Created November 3, 2012 17:45
Show Gist options
  • Save jnicho02/4008095 to your computer and use it in GitHub Desktop.
Save jnicho02/4008095 to your computer and use it in GitHub Desktop.
OSM train stations that are buildings
SELECT
t1.way_id, name_tags.v AS name
FROM way_tags AS t1
INNER JOIN way_tags AS t2 ON (t1.way_id = t2.way_id
and t2.k = 'railway' and t2.v in ('station','train_station','railway_station','railway station','train_station;bus_station','train station','underground_station','rail_station','trian station')
)
LEFT OUTER JOIN way_tags AS name_tags ON (t1.way_id=name_tags.way_id AND name_tags.k='name')
WHERE t1.k = 'building' and t1.v in ('yes','true')
UNION
SELECT
t1.way_id, name_tags.v AS name
FROM way_tags AS t1
LEFT OUTER JOIN way_tags AS name_tags ON (t1.way_id=name_tags.way_id AND name_tags.k='name')
WHERE t1.k = 'building' and t1.v in ('station','train_station','railway_station')
ORDER BY name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment