Skip to content

Instantly share code, notes, and snippets.

@giacecco
Created August 9, 2015 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giacecco/d8faae19c59b30b8a5ab to your computer and use it in GitHub Desktop.
Save giacecco/d8faae19c59b30b8a5ab to your computer and use it in GitHub Desktop.
DROP VIEW IF EXISTS os_open_names_with_towns;
CREATE VIEW os_open_names_with_towns AS
SELECT a.*, b.town AS lr_town
FROM
(SELECT * FROM os_open_names WHERE type = 'transportNetwork') AS a,
(SELECT town, bounding_box FROM lr_pp_town_definition) AS b
WHERE ST_Contains(b.bounding_box, a.mbr)
UNION
SELECT *, NULL AS lr_town FROM os_open_names WHERE type != 'transportNetwork';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment