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

add island labels (#399, #646, #703) #737

Merged
merged 36 commits into from
Apr 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
77e5983
[filter] remove continent place labels from places layer
nvkelso Apr 21, 2016
3949c71
[filter] init earth YAML filter, add continent place label to earth l…
nvkelso Apr 21, 2016
1306fb5
[query] add earth queary JINJA
nvkelso Apr 21, 2016
e287f5d
[migration] add custom migration for new earth layer features, includ…
nvkelso Apr 21, 2016
841fdaf
[query] hook up schema prefunction for new earth layer
nvkelso Apr 21, 2016
ed2f448
[query] hook up create sql functions and sql.jinja to new earth layer
nvkelso Apr 21, 2016
933c809
[apply] hook up data/apply functions, set new fields for new earth layer
nvkelso Apr 21, 2016
478d994
[tests] add full set of island label tests
nvkelso Apr 21, 2016
a32f242
[filter] adjust island, islet zoom ranges
nvkelso Apr 21, 2016
a3bf4af
improve legibility
nvkelso Apr 21, 2016
b3efd26
improve legibility
nvkelso Apr 21, 2016
a9f760c
correct typo
nvkelso Apr 21, 2016
34e47eb
rename way_area to test, since it is a fakeout
nvkelso Apr 21, 2016
0046ec4
[docs] add new earth kinds (label placements)
nvkelso Apr 21, 2016
18b4ef1
use else, drop unused label_placement & etc in selects
nvkelso Apr 25, 2016
17944dc
remove junk & add comments
nvkelso Apr 25, 2016
ffccbbe
calculate label placement for islands as a transform, drop the src
nvkelso Apr 25, 2016
3bd9499
add island names to tests, reformatting, fix z17 tests to z16
nvkelso Apr 25, 2016
0d3e119
update migrations
nvkelso Apr 25, 2016
9a6fb43
update data/apply
nvkelso Apr 25, 2016
5f58f70
target shp table type
nvkelso Apr 25, 2016
6a01957
fids (like gids) are ints
nvkelso Apr 25, 2016
dd1e417
remove junk left over from rebase
nvkelso Apr 25, 2016
484e730
allow points in EARTH layer, and apply normal transforms
nvkelso Apr 25, 2016
85b422a
null names, sum the way area when grouping, and allow OSM features to…
nvkelso Apr 25, 2016
f9179b1
add label_placement: yes
nvkelso Apr 25, 2016
183516f
comment out failing tests
nvkelso Apr 25, 2016
98cc13d
restore failing tests
nvkelso Apr 25, 2016
3225802
Merge remote-tracking branch 'origin/master' into nvkelso/399-add-isl…
zerebubuth Apr 27, 2016
dd27f86
Fix whitespace.
zerebubuth Apr 27, 2016
d2eca3d
Clean up migrations, add new columns for earth.
zerebubuth Apr 27, 2016
2e8055f
Revert some whitespace changes to make the diff readable.
zerebubuth Apr 27, 2016
3782656
Land tables should have earth column, not water.
zerebubuth Apr 27, 2016
0bf0a87
Undoing more whitespace changes.
zerebubuth Apr 27, 2016
26dbf47
Fix up zoom levels to match tests. Don't use way_area on tables that …
zerebubuth Apr 27, 2016
6403cb2
Remove unnecessary synthetic columns now that way_area has been removed.
zerebubuth Apr 27, 2016
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
8 changes: 7 additions & 1 deletion data/apply-planet_osm_line.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ UPDATE planet_osm_line
SET mz_transit_level = mz_calculate_min_zoom_transit(planet_osm_line.*)
WHERE mz_calculate_min_zoom_transit(planet_osm_line.*) IS NOT NULL;

UPDATE planet_osm_line
SET mz_earth_min_zoom = mz_calculate_min_zoom_earth(planet_osm_line.*)
WHERE mz_calculate_min_zoom_earth(planet_osm_line.*) IS NOT NULL;

UPDATE planet_osm_line
SET mz_water_min_zoom = mz_calculate_min_zoom_water(planet_osm_line.*)
WHERE mz_calculate_min_zoom_water(planet_osm_line.*) IS NOT NULL;
Expand Down Expand Up @@ -41,7 +45,9 @@ CREATE INDEX planet_osm_line_transit_geom_15_index ON planet_osm_line USING gist

CREATE INDEX planet_osm_line_waterway_geom_index ON planet_osm_line USING gist(way) WHERE waterway IN ('canal', 'river', 'stream', 'dam', 'ditch', 'drain');

CREATE INDEX planet_osm_line_natural_geom_index ON planet_osm_line USING gist(way) WHERE "natural" IN ('cliff','arete','ridge','valley');
CREATE INDEX planet_osm_line_earth_geom_9_index ON planet_osm_line USING gist(way) WHERE mz_earth_min_zoom <= 9;
CREATE INDEX planet_osm_line_earth_geom_12_index ON planet_osm_line USING gist(way) WHERE mz_earth_min_zoom <= 12;
CREATE INDEX planet_osm_line_earth_geom_15_index ON planet_osm_line USING gist(way) WHERE mz_earth_min_zoom <= 15;

CREATE INDEX planet_osm_line_piste_geom_index ON planet_osm_line USING gist(way) WHERE tags ? 'piste:type';

Expand Down
8 changes: 8 additions & 0 deletions data/apply-planet_osm_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ UPDATE planet_osm_point SET
mz_poi_min_zoom = mz_calculate_min_zoom_pois(planet_osm_point.*)
WHERE mz_calculate_min_zoom_pois(planet_osm_point.*) IS NOT NULL;

UPDATE planet_osm_point
SET mz_earth_min_zoom = mz_calculate_min_zoom_earth(planet_osm_point.*)
WHERE mz_calculate_min_zoom_earth(planet_osm_point.*) IS NOT NULL;

UPDATE planet_osm_point
SET mz_water_min_zoom = mz_calculate_min_zoom_water(planet_osm_point.*)
WHERE mz_calculate_min_zoom_water(planet_osm_point.*) IS NOT NULL;
Expand All @@ -27,6 +31,10 @@ CREATE INDEX planet_osm_point_min_zoom_way_9_index ON planet_osm_point USING gis
CREATE INDEX planet_osm_point_min_zoom_way_12_index ON planet_osm_point USING gist(way) WHERE mz_poi_min_zoom <= 12;
CREATE INDEX planet_osm_point_min_zoom_way_15_index ON planet_osm_point USING gist(way) WHERE mz_poi_min_zoom <= 15;

CREATE INDEX planet_osm_point_min_zoom_earth_9_index ON planet_osm_point USING gist(way) WHERE mz_earth_min_zoom <= 9;
CREATE INDEX planet_osm_point_min_zoom_earth_12_index ON planet_osm_point USING gist(way) WHERE mz_earth_min_zoom <= 12;
CREATE INDEX planet_osm_point_min_zoom_earth_15_index ON planet_osm_point USING gist(way) WHERE mz_earth_min_zoom <= 15;

CREATE INDEX planet_osm_point_min_zoom_water_9_index ON planet_osm_point USING gist(way) WHERE mz_water_min_zoom <= 9;
CREATE INDEX planet_osm_point_min_zoom_water_12_index ON planet_osm_point USING gist(way) WHERE mz_water_min_zoom <= 12;
CREATE INDEX planet_osm_point_min_zoom_water_15_index ON planet_osm_point USING gist(way) WHERE mz_water_min_zoom <= 15;
Expand Down
68 changes: 68 additions & 0 deletions data/apply-planet_osm_polygon.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,94 @@ CREATE INDEX planet_osm_polygon_wayarea_index ON planet_osm_polygon(way_area);
CREATE INDEX planet_osm_polygon_building_index ON planet_osm_polygon(building) WHERE building IS NOT NULL;
CREATE INDEX planet_osm_polygon_is_building_or_part_index ON planet_osm_polygon(mz_calculate_is_building_or_part(building, "building:part")) WHERE mz_calculate_is_building_or_part(building, "building:part") = TRUE;


UPDATE planet_osm_polygon SET
mz_landuse_min_zoom = mz_calculate_min_zoom_landuse(planet_osm_polygon.*)
WHERE mz_calculate_min_zoom_landuse(planet_osm_polygon.*) IS NOT NULL;


UPDATE planet_osm_polygon SET
mz_poi_min_zoom = mz_calculate_min_zoom_pois(planet_osm_polygon.*)
WHERE mz_calculate_min_zoom_pois(planet_osm_polygon.*) IS NOT NULL;


UPDATE planet_osm_polygon SET
mz_transit_level = mz_calculate_min_zoom_transit(planet_osm_polygon.*)
WHERE mz_calculate_min_zoom_transit(planet_osm_polygon.*) IS NOT NULL;


UPDATE ne_110m_land
SET mz_earth_min_zoom = mz_calculate_min_zoom_earth(ne_110m_land.*)
WHERE mz_calculate_min_zoom_earth(ne_110m_land.*) IS NOT NULL;

UPDATE ne_50m_land
SET mz_earth_min_zoom = mz_calculate_min_zoom_earth(ne_50m_land.*)
WHERE mz_calculate_min_zoom_earth(ne_50m_land.*) IS NOT NULL;

UPDATE ne_10m_land
SET mz_earth_min_zoom = mz_calculate_min_zoom_earth(ne_10m_land.*)
WHERE mz_calculate_min_zoom_earth(ne_10m_land.*) IS NOT NULL;

UPDATE land_polygons
SET mz_earth_min_zoom = mz_calculate_min_zoom_earth(land_polygons.*)
WHERE mz_calculate_min_zoom_earth(land_polygons.*) IS NOT NULL;

UPDATE planet_osm_polygon
SET mz_earth_min_zoom = mz_calculate_min_zoom_earth(planet_osm_polygon.*)
WHERE mz_calculate_min_zoom_earth(planet_osm_polygon.*) IS NOT NULL;


UPDATE ne_110m_ocean
SET mz_water_min_zoom = mz_calculate_min_zoom_water(ne_110m_ocean.*)
WHERE mz_calculate_min_zoom_water(ne_110m_ocean.*) IS NOT NULL;

UPDATE ne_50m_ocean
SET mz_water_min_zoom = mz_calculate_min_zoom_water(ne_50m_ocean.*)
WHERE mz_calculate_min_zoom_water(ne_50m_ocean.*) IS NOT NULL;

UPDATE ne_10m_ocean
SET mz_water_min_zoom = mz_calculate_min_zoom_water(ne_10m_ocean.*)
WHERE mz_calculate_min_zoom_water(ne_10m_ocean.*) IS NOT NULL;

UPDATE ne_110m_lakes
SET mz_water_min_zoom = mz_calculate_min_zoom_water(ne_110m_lakes.*)
WHERE mz_calculate_min_zoom_water(ne_110m_lakes.*) IS NOT NULL;

UPDATE ne_50m_lakes
SET mz_water_min_zoom = mz_calculate_min_zoom_water(ne_50m_lakes.*)
WHERE mz_calculate_min_zoom_water(ne_50m_lakes.*) IS NOT NULL;

UPDATE ne_10m_lakes
SET mz_water_min_zoom = mz_calculate_min_zoom_water(ne_10m_lakes.*)
WHERE mz_calculate_min_zoom_water(ne_10m_lakes.*) IS NOT NULL;

UPDATE ne_50m_playas
SET mz_water_min_zoom = mz_calculate_min_zoom_water(ne_50m_playas.*)
WHERE mz_calculate_min_zoom_water(ne_50m_playas.*) IS NOT NULL;

UPDATE ne_10m_playas
SET mz_water_min_zoom = mz_calculate_min_zoom_water(ne_10m_playas.*)
WHERE mz_calculate_min_zoom_water(ne_10m_playas.*) IS NOT NULL;

UPDATE water_polygons
SET mz_water_min_zoom = mz_calculate_min_zoom_water(water_polygons.*)
WHERE mz_calculate_min_zoom_water(water_polygons.*) IS NOT NULL;

UPDATE planet_osm_polygon
SET mz_water_min_zoom = mz_calculate_min_zoom_water(planet_osm_polygon.*)
WHERE mz_calculate_min_zoom_water(planet_osm_polygon.*) IS NOT NULL;


UPDATE planet_osm_polygon
SET mz_boundary_min_zoom = mz_calculate_min_zoom_boundaries(planet_osm_polygon.*)
WHERE mz_calculate_min_zoom_boundaries(planet_osm_polygon.*) IS NOT NULL;


UPDATE planet_osm_polygon
SET mz_building_min_zoom = mz_calculate_min_zoom_buildings(planet_osm_polygon.*)
WHERE mz_calculate_min_zoom_buildings(planet_osm_polygon.*) IS NOT NULL;


CREATE INDEX planet_osm_polygon_landuse_geom_9_index ON planet_osm_polygon USING gist(way) WHERE mz_landuse_min_zoom <= 9;
CREATE INDEX planet_osm_polygon_landuse_geom_12_index ON planet_osm_polygon USING gist(way) WHERE mz_landuse_min_zoom <= 12;
CREATE INDEX planet_osm_polygon_landuse_geom_15_index ON planet_osm_polygon USING gist(way) WHERE mz_landuse_min_zoom <= 15;
Expand All @@ -46,6 +110,10 @@ CREATE INDEX planet_osm_polygon_transit_geom_9_index ON planet_osm_polygon USING
CREATE INDEX planet_osm_polygon_transit_geom_12_index ON planet_osm_polygon USING gist(way) WHERE mz_transit_level <= 12;
CREATE INDEX planet_osm_polygon_transit_geom_15_index ON planet_osm_polygon USING gist(way) WHERE mz_transit_level <= 15;

CREATE INDEX planet_osm_polygon_earth_geom_9_index ON planet_osm_polygon USING gist(way) WHERE mz_earth_min_zoom <= 9;
CREATE INDEX planet_osm_polygon_earth_geom_12_index ON planet_osm_polygon USING gist(way) WHERE mz_earth_min_zoom <= 12;
CREATE INDEX planet_osm_polygon_earth_geom_15_index ON planet_osm_polygon USING gist(way) WHERE mz_earth_min_zoom <= 15;

CREATE INDEX planet_osm_polygon_water_geom_9_index ON planet_osm_polygon USING gist(way) WHERE mz_water_min_zoom <= 9;
CREATE INDEX planet_osm_polygon_water_geom_12_index ON planet_osm_polygon USING gist(way) WHERE mz_water_min_zoom <= 12;
CREATE INDEX planet_osm_polygon_water_geom_15_index ON planet_osm_polygon USING gist(way) WHERE mz_water_min_zoom <= 15;
Expand Down
20 changes: 17 additions & 3 deletions data/apply-schema-update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@ ALTER TABLE planet_osm_polygon ADD COLUMN mz_poi_min_zoom REAL;
ALTER TABLE planet_osm_polygon ADD COLUMN mz_landuse_min_zoom REAL;
ALTER TABLE planet_osm_polygon ADD COLUMN mz_transit_level REAL;
ALTER TABLE planet_osm_polygon ADD COLUMN mz_water_min_zoom SMALLINT;
ALTER TABLE planet_osm_polygon ADD COLUMN mz_earth_min_zoom SMALLINT;

-- same for line table
ALTER TABLE planet_osm_line ADD COLUMN mz_road_level SMALLINT;
ALTER TABLE planet_osm_line ADD COLUMN mz_transit_level SMALLINT;
ALTER TABLE planet_osm_line ADD COLUMN mz_water_min_zoom SMALLINT;
ALTER TABLE planet_osm_line ADD COLUMN mz_earth_min_zoom SMALLINT;
ALTER TABLE planet_osm_line ADD COLUMN mz_landuse_min_zoom SMALLINT;

-- same for point
ALTER TABLE planet_osm_point ADD COLUMN mz_poi_min_zoom REAL;
ALTER TABLE planet_osm_point ADD COLUMN mz_water_min_zoom SMALLINT;
ALTER TABLE planet_osm_point ADD COLUMN mz_places_min_zoom SMALLINT;
ALTER TABLE planet_osm_point ADD COLUMN mz_earth_min_zoom SMALLINT;

-- and pre-calculated areas for all the polygonal NE and static OSM
-- tables.
ALTER TABLE ne_10m_urban_areas ADD COLUMN way_area REAL;
ALTER TABLE ne_50m_urban_areas ADD COLUMN way_area REAL;
ALTER TABLE ne_10m_parks_and_protected_lands ADD COLUMN way_area REAL;

ALTER TABLE ne_110m_ocean ADD COLUMN way_area REAL;
ALTER TABLE ne_110m_lakes ADD COLUMN way_area REAL;
ALTER TABLE ne_50m_ocean ADD COLUMN way_area REAL;
Expand All @@ -25,9 +32,6 @@ ALTER TABLE ne_50m_playas ADD COLUMN way_area REAL;
ALTER TABLE ne_10m_ocean ADD COLUMN way_area REAL;
ALTER TABLE ne_10m_lakes ADD COLUMN way_area REAL;
ALTER TABLE ne_10m_playas ADD COLUMN way_area REAL;
ALTER TABLE ne_10m_urban_areas ADD COLUMN way_area REAL;
ALTER TABLE ne_50m_urban_areas ADD COLUMN way_area REAL;
ALTER TABLE ne_10m_parks_and_protected_lands ADD COLUMN way_area REAL;
ALTER TABLE water_polygons ADD COLUMN way_area REAL;

ALTER TABLE ne_110m_ocean ADD COLUMN mz_water_min_zoom SMALLINT;
Expand All @@ -40,6 +44,16 @@ ALTER TABLE ne_10m_lakes ADD COLUMN mz_water_min_zoom SMALLINT;
ALTER TABLE ne_10m_playas ADD COLUMN mz_water_min_zoom SMALLINT;
ALTER TABLE water_polygons ADD COLUMN mz_water_min_zoom SMALLINT;

ALTER TABLE ne_110m_land ADD COLUMN way_area REAL;
ALTER TABLE ne_50m_land ADD COLUMN way_area REAL;
ALTER TABLE ne_10m_land ADD COLUMN way_area REAL;
ALTER TABLE land_polygons ADD COLUMN way_area REAL;

ALTER TABLE ne_110m_land ADD COLUMN mz_earth_min_zoom SMALLINT;
ALTER TABLE ne_50m_land ADD COLUMN mz_earth_min_zoom SMALLINT;
ALTER TABLE ne_10m_land ADD COLUMN mz_earth_min_zoom SMALLINT;
ALTER TABLE land_polygons ADD COLUMN mz_earth_min_zoom SMALLINT;

ALTER TABLE ne_10m_populated_places ADD COLUMN mz_places_min_zoom SMALLINT;

ALTER TABLE planet_osm_polygon ADD COLUMN mz_boundary_min_zoom SMALLINT;
Expand Down
30 changes: 22 additions & 8 deletions data/apply-updates-non-planet-tables.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
DO $$
BEGIN

UPDATE ne_10m_urban_areas SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX ne_10m_urban_areas_way_area_index ON ne_10m_urban_areas(way_area);

UPDATE ne_50m_urban_areas SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX ne_50m_urban_areas_way_area_index ON ne_50m_urban_areas(way_area);

UPDATE ne_10m_parks_and_protected_lands SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX ne_10m_parks_and_protected_lands_way_area_index ON ne_10m_parks_and_protected_lands(way_area);


UPDATE ne_110m_ocean SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX ne_110m_ocean_wayarea_index ON ne_110m_ocean(way_area);

Expand All @@ -25,17 +35,21 @@ CREATE INDEX ne_10m_lakes_wayarea_index ON ne_10m_lakes(way_area);
UPDATE ne_10m_playas SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX ne_10m_playas_wayarea_index ON ne_10m_playas(way_area);

UPDATE ne_10m_urban_areas SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX ne_10m_urban_areas_way_area_index ON ne_10m_urban_areas(way_area);
UPDATE water_polygons SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX water_polygons_wayarea_index ON water_polygons(way_area);

UPDATE ne_50m_urban_areas SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX ne_50m_urban_areas_way_area_index ON ne_50m_urban_areas(way_area);

UPDATE ne_10m_parks_and_protected_lands SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX ne_10m_parks_and_protected_lands_way_area_index ON ne_10m_parks_and_protected_lands(way_area);
UPDATE ne_110m_land SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX ne_110m_land_wayarea_index ON ne_110m_land(way_area);

UPDATE water_polygons SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX water_polygons_wayarea_index ON water_polygons(way_area);
UPDATE ne_50m_land SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX ne_50m_land_wayarea_index ON ne_50m_land(way_area);

UPDATE ne_10m_land SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX ne_10m_land_way_area_index ON ne_10m_land(way_area);

UPDATE land_polygons SET way_area=ST_Area(the_geom) WHERE the_geom IS NOT NULL;
CREATE INDEX land_polygons_wayarea_index ON land_polygons(way_area);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these also need a UPDATE table SET mz_earth_min_zoom = mz_calculate_min_zoom_earth(table.*)?


CREATE INDEX ne_10m_populated_places_scalerank_index ON ne_10m_populated_places(scalerank);
Expand Down
4 changes: 2 additions & 2 deletions data/migrations/create-sql-functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def create_case_statement_output(matchers):
script_root = os.path.dirname(__file__)

for layer in ('landuse', 'pois', 'transit', 'water', 'places', 'boundaries',
'buildings', 'roads'):
'buildings', 'roads', 'earth'):
kind_rules = []
min_zoom_rules = []
# synthetic columns are ones that we generate in the SQL functions, usually
Expand All @@ -347,7 +347,7 @@ def create_case_statement_output(matchers):
- synthetic_columns)
for column in columns:
if not column.startswith('tags'):
if column == 'gid':
if column == 'gid' or column == 'fid':
typ = 'integer'
elif column == 'scalerank' or column == 'labelrank':
typ = 'smallint'
Expand Down
Loading