Render POIs for large universities at low zoom (#1479)

This PR adapts the code used in #1457 to allow POIs to render up to z10 for very large features. I set the threshold at a very conservative value of 10% of a tile. Thus, it will render if an area POI covers at least 10% of a tile at a given zoom. Only for 'university' and  'college'.

Additionally, this consolidates a double UNION ALL on the same table with a WHERE/CASE combination, which is simpler.
pull/1361/head^2
Brian Sperlongano 2023-01-19 13:29:29 -05:00 zatwierdzone przez GitHub
rodzic f9e358c962
commit efa6b27fba
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 17 dodań i 16 usunięć

Wyświetl plik

@ -327,6 +327,8 @@ def_poi_fields: &poi_fields
type: id type: id
- name: geometry - name: geometry
type: geometry type: geometry
- name: area
type: area
- name: name - name: name
key: name key: name
type: string type: string

Wyświetl plik

@ -68,20 +68,6 @@ FROM (
-- etldoc: osm_poi_polygon -> layer_poi:z12 -- etldoc: osm_poi_polygon -> layer_poi:z12
-- etldoc: osm_poi_polygon -> layer_poi:z13 -- etldoc: osm_poi_polygon -> layer_poi:z13
SELECT *,
NULL::integer AS agg_stop,
CASE
WHEN osm_id < 0 THEN -osm_id * 10 + 4
ELSE osm_id * 10 + 1
END AS osm_id_hash
FROM osm_poi_polygon
WHERE geometry && bbox
AND zoom_level BETWEEN 12 AND 13
AND ((subclass = 'station' AND mapping_key = 'railway')
OR subclass IN ('halt', 'ferry_terminal'))
UNION ALL
-- etldoc: osm_poi_polygon -> layer_poi:z14_ -- etldoc: osm_poi_polygon -> layer_poi:z14_
SELECT *, SELECT *,
NULL::integer AS agg_stop, NULL::integer AS agg_stop,
@ -90,8 +76,21 @@ FROM (
ELSE osm_id * 10 + 1 ELSE osm_id * 10 + 1
END AS osm_id_hash END AS osm_id_hash
FROM osm_poi_polygon FROM osm_poi_polygon
WHERE geometry && bbox WHERE geometry && bbox AND
AND zoom_level >= 14 CASE
WHEN zoom_level >= 14 THEN TRUE
WHEN zoom_level >= 12 AND
((subclass = 'station' AND mapping_key = 'railway')
OR subclass IN ('halt', 'ferry_terminal')) THEN TRUE
WHEN zoom_level BETWEEN 10 AND 14 THEN
subclass IN ('university', 'college') AND
POWER(4,zoom_level)
-- Compute percentage of the earth's surface covered by this feature (approximately)
-- The constant below is 111,842^2 * 180 * 180, where 111,842 is the length of one degree of latitude at the equator in meters.
* area / (405279708033600 * COS(ST_Y(ST_Transform(geometry,4326))*PI()/180))
-- Match features that are at least 10% of a tile at this zoom
> 0.10
ELSE FALSE END
) AS poi_union ) AS poi_union
ORDER BY "rank" ORDER BY "rank"
$$ LANGUAGE SQL STABLE $$ LANGUAGE SQL STABLE