Skip to content

Commit

Permalink
Merge pull request #737 from mapzen/nvkelso/399-add-island-labels
Browse files Browse the repository at this point in the history
add island labels (#399, #646, #703)
  • Loading branch information
zerebubuth committed Apr 28, 2016
2 parents f4b222b + 6403cb2 commit 7718f17
Show file tree
Hide file tree
Showing 19 changed files with 787 additions and 49 deletions.
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);


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

0 comments on commit 7718f17

Please sign in to comment.