Skip to content

Commit

Permalink
Merge pull request #562 from mapzen/show-all-buildings-z16
Browse files Browse the repository at this point in the history
Show all buildings at z16
  • Loading branch information
rmarianski committed Mar 4, 2016
2 parents b87afc3 + bd69f96 commit 9523c11
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
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})

0 comments on commit 9523c11

Please sign in to comment.