-
Notifications
You must be signed in to change notification settings - Fork 0
/
osm-pois-extract.sql
71 lines (70 loc) · 2.97 KB
/
osm-pois-extract.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
-- get pois from OSM nodes
-- must get and insert them per distinct key because there are main keys and type keys, and the main keys are unique
DROP TABLE IF EXISTS graphs.pois_nodes CASCADE;
CREATE TABLE graphs.pois_nodes AS SELECT
id AS node_id, geom, 'leisure' AS key, (tags -> 'leisure') AS values, (tags -> 'name') AS name, tags
FROM nodes
WHERE (tags -> 'leisure') IS NOT NULL
;
INSERT INTO graphs.pois_nodes SELECT
id AS node_id, geom, 'sport' AS key, (tags -> 'sport') AS values, (tags -> 'name') AS name, tags
FROM nodes
WHERE (tags -> 'sport') IS NOT NULL
;
INSERT INTO graphs.pois_nodes SELECT
id AS node_id, geom, 'shop' AS key, (tags -> 'shop') AS values, (tags -> 'name') AS name, tags
FROM nodes
WHERE (tags -> 'shop') IS NOT NULL
;
INSERT INTO graphs.pois_nodes SELECT
id AS node_id, geom, 'office' AS key, (tags -> 'office') AS values, (tags -> 'name') AS name, tags
FROM nodes
WHERE (tags -> 'office') IS NOT NULL
;
INSERT INTO graphs.pois_nodes SELECT
id AS node_id, geom, 'amenity' AS key, (tags -> 'amenity') AS values, (tags -> 'name') AS name, tags
FROM nodes
WHERE (tags -> 'amenity') IS NOT NULL
;
INSERT INTO graphs.pois_nodes SELECT
id AS node_id, geom, 'craft' AS key, (tags -> 'craft') AS values, (tags -> 'name') AS name, tags
FROM nodes
WHERE (tags -> 'craft') IS NOT NULL
;
INSERT INTO graphs.pois_nodes SELECT
id AS node_id, geom, 'tourism' AS key, (tags -> 'tourism') AS values, (tags -> 'name') AS name, tags
FROM nodes
WHERE (tags -> 'tourism') IS NOT NULL
;
INSERT INTO graphs.pois_nodes SELECT
id AS node_id, geom, 'emergency' AS key, (tags -> 'emergency') AS values, (tags -> 'name') AS name, tags
FROM nodes
WHERE (tags -> 'emergency') IS NOT NULL
;
INSERT INTO graphs.pois_nodes SELECT
id AS node_id, geom, 'historic' AS key, (tags -> 'historic') AS values, (tags -> 'name') AS name, tags
FROM nodes
WHERE (tags -> 'historic') IS NOT NULL
;
-- get pois from OSM ways
DROP TABLE if eXISTS graphs.pois_ways CASCADE;
CREATE TABLE graphs.pois_ways AS SELECT
id AS way_id, linestring AS geom, 'leisure' AS key, (tags -> 'leisure') AS values, (tags -> 'name') AS name, tags
FROM ways
WHERE (tags -> 'leisure') IS NOT NULL AND (tags -> 'highway') IS NULL
;
INSERT INTO graphs.pois_ways SELECT
id AS way_id, linestring AS geom, 'landuse' AS key, (tags -> 'landuse') AS values, (tags -> 'name') AS name, tags
FROM ways
WHERE (tags -> 'landuse') IS NOT NULL AND (tags -> 'highway') IS NULL
;
INSERT INTO graphs.pois_ways SELECT
id AS way_id, linestring AS geom, 'sport' AS key, (tags -> 'sport') AS values, (tags -> 'name') AS name, tags
FROM ways
WHERE (tags -> 'sport') IS NOT NULL AND (tags -> 'highway') IS NULL
;
INSERT INTO graphs.pois_ways SELECT
id AS way_id, linestring AS geom, 'amenity' AS key, (tags -> 'amenity') AS values, (tags -> 'name') AS name, tags
FROM ways
WHERE (tags -> 'amenity') IS NOT NULL AND (tags -> 'highway') IS NULL
;