maptiles/layers/outdoor_poi/layer.sql

19 lines
636 B
PL/PgSQL

CREATE OR REPLACE FUNCTION layer_outdoor_poi(bbox geometry, zoom_level int)
RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, name text) AS $$
SELECT
osm_id * 10 + 1,
geometry,
CASE
WHEN subclass = 'memorial'
THEN 'subclass'
ELSE class
END AS class,
CASE
WHEN subclass = 'memorial'
THEN NULLIF(memorial, '')
ELSE subclass
END AS subclass,
NULLIF(name, '') AS name
FROM osm_exploration_point
WHERE zoom_level >= 14 AND geometry && bbox;
$$ LANGUAGE SQL IMMUTABLE;