-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathplanet_osm_point.jinja2
98 lines (82 loc) · 2.73 KB
/
planet_osm_point.jinja2
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
SELECT
osm_id AS __id__,
{% filter geometry %}way{% endfilter %} AS __geometry__,
-- common properties across all layers
to_jsonb(tags) || extra_wikidata_properties(tags->'wikidata') || jsonb_build_object(
'source', 'openstreetmap.org'
) AS __properties__,
CASE WHEN mz_building_min_zoom IS NOT NULL
THEN jsonb_build_object(
'min_zoom', mz_building_min_zoom,
'label_placement', TRUE
)
END AS __buildings_properties__,
CASE WHEN mz_earth_min_zoom IS NOT NULL
THEN jsonb_build_object(
'min_zoom', mz_earth_min_zoom,
'label_placement', TRUE
)
END AS __earth_properties__,
CASE WHEN mz_places_min_zoom IS NOT NULL
THEN jsonb_build_object(
'min_zoom', mz_places_min_zoom
) ||
tz_get_ne_min_max_zoom(tags->'wikidata')
END AS __places_properties__,
CASE WHEN mz_poi_min_zoom IS NOT NULL
THEN jsonb_build_object(
'min_zoom', mz_poi_min_zoom,
'mz_transit_score', (transit_routes).score,
'mz_transit_root_relation_id', (transit_routes).root_relation_id,
'train_routes', (transit_routes).train_routes,
'subway_routes', (transit_routes).subway_routes,
'light_rail_routes', (transit_routes).light_rail_routes,
'tram_routes', (transit_routes).tram_routes
)
END AS __pois_properties__,
CASE WHEN mz_water_min_zoom IS NOT NULL
THEN jsonb_build_object(
'min_zoom', mz_water_min_zoom,
'label_placement', TRUE
)
END AS __water_properties__
FROM (
SELECT
osm_id,
way,
-- note: the mz_calculate_transit_routes_and_score function is pretty
-- expensive, so we only want to calculate it when we actually need the
-- result.
CASE
WHEN mz_poi_min_zoom IS NOT NULL AND
tags ? 'railway' AND tags->'railway'='station' AND osm_id > 0
THEN mz_calculate_transit_routes_and_score(osm_id, NULL)
END AS transit_routes,
mz_building_min_zoom,
mz_earth_min_zoom,
mz_places_min_zoom,
mz_poi_min_zoom,
mz_water_min_zoom,
tags
FROM planet_osm_point
WHERE
{{ bounds['point']|bbox_filter('way', 3857) }} AND
{% if zoom >= 16 %}
(mz_building_min_zoom IS NOT NULL OR
mz_earth_min_zoom IS NOT NULL OR
mz_places_min_zoom IS NOT NULL OR
mz_poi_min_zoom IS NOT NULL OR
mz_water_min_zoom IS NOT NULL
)
{% else %}
-- NOTE: we include all layers here, even below zoom 8, because the features
-- going into the earth and water layers are label placements and don't
-- conflict with the Natural Earth data at zoom < 8.
(mz_building_min_zoom < {{ zoom + 1 }} OR
mz_earth_min_zoom < {{ zoom + 1 }} OR
mz_places_min_zoom < {{ zoom + 1 }} OR
mz_poi_min_zoom < {{ zoom + 1 }} OR
mz_water_min_zoom < {{ zoom + 1 }}
)
{% endif %}
) p