Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show all buildings at z16 #562

Merged
merged 7 commits into from
Mar 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions data/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,11 @@ CREATE OR REPLACE FUNCTION mz_building_filter(
RETURNS BOOLEAN AS $$
BEGIN
RETURN CASE
-- if the min area is satisfied, then there's no
-- need to check the area.
WHEN way_area >= min_area
THEN TRUE

-- if height is present, and can be parsed as a
-- float, then we can filter right here.
WHEN mz_is_numeric(height)
Expand All @@ -757,9 +762,9 @@ BEGIN
WHEN height IS NOT NULL OR levels IS NOT NULL
THEN TRUE

-- height isn't present, so just filter on area
-- as we did before.
ELSE way_area >= min_area
-- height isn't present, and area doesn't satisfy
-- the minimum bound, so don't show this building.
ELSE FALSE
END;
END;
$$ LANGUAGE plpgsql IMMUTABLE;
Expand Down
1 change: 0 additions & 1 deletion queries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ post_process:
13: { area: 1600, volume: 300000 }
14: { area: 100, volume: 200000 }
15: { area: 100, volume: 100000 }
16: { area: 25, volume: 50000 }
- fn: TileStache.Goodies.VecTiles.transform.intercut
params:
base_layer: roads
Expand Down
11 changes: 9 additions & 2 deletions queries/buildings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ SELECT
"roof:orientation" AS roof_orientation,
"addr:housenumber" AS addr_housenumber,
"addr:street" AS addr_street,
{% if zoom >= 16 %}
CASE WHEN mz_building_filter(tags->'building:height', "building:levels", way_area, 50000, 25)
THEN 16
ELSE 17
END AS min_zoom,
{% endif %}
%#tags AS tags

FROM
Expand All @@ -50,8 +56,6 @@ WHERE
AND mz_building_filter(tags->'building:height', "building:levels", way_area, 200000, 100)
{% elif zoom == 15 %}
AND mz_building_filter(tags->'building:height', "building:levels", way_area, 100000, 100)
{% elif zoom == 16 %}
AND mz_building_filter(tags->'building:height', "building:levels", way_area, 50000, 25)
{% endif %}

AND {{ bounds|bbox_filter('way') }}
Expand Down Expand Up @@ -82,6 +86,9 @@ SELECT
NULL AS roof_orientation,
"addr:housenumber" AS addr_housenumber,
"addr:street" AS addr_street,
{% if zoom >= 16 %}
17 AS min_zoom,
{% endif %}
%#tags AS tags

FROM
Expand Down
14 changes: 14 additions & 0 deletions test/557-missing-buildings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Best Tile
assert_has_feature(
16, 10484, 25339, 'buildings',
{'id': 103383621})

# Miraloma School
assert_has_feature(
16, 10476, 25339, 'buildings',
{'id': 338881092})

# Tiny individual building (way_area = 5.4 sq.m.)
assert_has_feature(
16, 10474, 25343, 'buildings',
{'id': 278410540, 'min_zoom': 17})