Skip to content

Commit

Permalink
Merge pull request #304 from OpenHistoricalMap/tiler-imposm
Browse files Browse the repository at this point in the history
Update layers and execute query for tiler-imposm
  • Loading branch information
Rub21 authored May 8, 2024
2 parents f67dbfc + cc23702 commit 6c4468a
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 71 deletions.
25 changes: 24 additions & 1 deletion images/tiler-imposm/config/postgis_post_import.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CREATE OR REPLACE FUNCTION update_admin_areas()
RETURNS void AS $$
BEGIN
UPDATE osm_admin_areas
SET has_label = TRUE
SET has_label = 1
WHERE osm_id IN (
SELECT osm_id
FROM osm_relation_members
Expand All @@ -16,3 +16,26 @@ $$ LANGUAGE plpgsql;
SELECT update_admin_areas();


-- Create a function and trigger that will update every time a new admin area is inserted or updated in osm_admin_areas table

CREATE OR REPLACE FUNCTION update_has_label_row()
RETURNS TRIGGER AS $$
BEGIN
IF EXISTS (
SELECT 1
FROM osm_relation_members
WHERE osm_id = NEW.osm_id AND role = 'label'
) THEN
NEW.has_label := 1;
ELSE
NEW.has_label := 0;
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;


CREATE TRIGGER trigger_update_has_label
BEFORE INSERT OR UPDATE ON osm_admin_areas
FOR EACH ROW
EXECUTE FUNCTION update_has_label_row();
126 changes: 63 additions & 63 deletions images/tiler-imposm/scripts/natural_earth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,74 +58,74 @@ psql "dbname='postgres' host='$DB_HOST' port='$DB_PORT' user='$DB_USER' password

# array of natural earth dataset URLs
dataurls=(
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_admin_0_boundary_lines_land.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_admin_0_countries.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_admin_1_states_provinces_lines.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_populated_places.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_coastline.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_geography_marine_polys.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_geography_regions_polys.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_rivers_lake_centerlines.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_lakes.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_glaciated_areas.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_land.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_ocean.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_0_boundary_lines_land.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_0_boundary_lines_disputed_areas.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_0_boundary_lines_maritime_indicator.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_0_countries.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_0_map_subunits.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_1_states_provinces_lakes.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_1_states_provinces_lines.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_populated_places.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_geographic_lines.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_coastline.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_antarctic_ice_shelves_lines.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_antarctic_ice_shelves_polys.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_geography_marine_polys.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_geography_regions_elevation_points.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_geography_regions_polys.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_rivers_lake_centerlines_scale_rank.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_rivers_lake_centerlines.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_admin_0_boundary_lines_land.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_admin_0_countries.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_admin_1_states_provinces_lines.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_populated_places.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_coastline.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_geography_marine_polys.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_geography_regions_polys.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_rivers_lake_centerlines.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_lakes.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_glaciated_areas.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_land.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_110m_ocean.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_0_boundary_lines_land.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_0_boundary_lines_disputed_areas.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_0_boundary_lines_maritime_indicator.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_0_countries.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_0_map_subunits.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_1_states_provinces_lakes.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_admin_1_states_provinces_lines.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_populated_places.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_geographic_lines.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_coastline.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_antarctic_ice_shelves_lines.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_antarctic_ice_shelves_polys.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_geography_marine_polys.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_geography_regions_elevation_points.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_geography_regions_polys.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_rivers_lake_centerlines_scale_rank.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_rivers_lake_centerlines.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_lakes.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_glaciated_areas.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_land.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_ocean.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_boundary_lines_land.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_boundary_lines_disputed_areas.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_parks_and_protected_lands.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_boundary_lines_map_units.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_boundary_lines_maritime_indicator.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_label_points.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_countries.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_map_subunits.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_1_label_points.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_1_states_provinces_lines.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_populated_places.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_roads.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_urban_areas.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_geographic_lines.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_coastline.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_antarctic_ice_shelves_lines.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_antarctic_ice_shelves_polys.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_geography_marine_polys.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_geography_regions_elevation_points.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_geography_regions_points.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_geography_regions_polys.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_rivers_north_america.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_rivers_europe.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_rivers_lake_centerlines_scale_rank.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_rivers_lake_centerlines.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_playas.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_reefs.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_glaciated_areas.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_land.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_50m_ocean.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_boundary_lines_land.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_boundary_lines_disputed_areas.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_parks_and_protected_lands.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_boundary_lines_map_units.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_boundary_lines_maritime_indicator.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_label_points.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_countries.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_0_map_subunits.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_1_label_points.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_admin_1_states_provinces_lines.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_populated_places.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_roads.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_urban_areas.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_geographic_lines.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_coastline.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_antarctic_ice_shelves_lines.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_antarctic_ice_shelves_polys.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_geography_marine_polys.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_geography_regions_elevation_points.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_geography_regions_points.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_geography_regions_polys.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_rivers_north_america.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_rivers_europe.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_rivers_lake_centerlines_scale_rank.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_rivers_lake_centerlines.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_playas.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_reefs.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_lakes_historic.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_lakes_north_america.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_lakes_europe.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_lakes.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_glaciated_areas.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_land.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_minor_islands.zip"
"https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_ocean.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_glaciated_areas.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_land.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_minor_islands.zip"
# "https://osmseed-staging.s3.amazonaws.com/naciscdn/ne_10m_ocean.zip"
)

# remove old database if -d flag is set and create a new one
Expand Down
1 change: 1 addition & 0 deletions images/tiler-imposm/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ function importData() {

# These index will help speed up tegola tile generation
psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB" -a -f config/postgis_index.sql
psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB" -a -f config/postgis_post_import.sql

touch $INIT_FILE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM
osm_admin_areas
WHERE
admin_level IN (1,2)
AND has_label = FALSE
AND has_label = 0
AND geometry && !BBOX!
"""

Expand All @@ -46,7 +46,7 @@ FROM
osm_admin_areas
WHERE
admin_level IN (1,2,3,4)
AND has_label = FALSE
AND has_label = 0
AND geometry && !BBOX!
"""

Expand All @@ -72,7 +72,7 @@ FROM
osm_admin_areas
WHERE
admin_level IN (1,2,3,4,5,6)
AND has_label = FALSE
AND has_label = 0
AND geometry && !BBOX!
"""

Expand All @@ -98,7 +98,7 @@ FROM
osm_admin_areas
WHERE
admin_level IN (1,2,3,4,5,6,7,8,9)
AND has_label = FALSE
AND has_label = 0
AND geometry && !BBOX!
"""

Expand All @@ -124,6 +124,6 @@ FROM
osm_admin_areas
WHERE
admin_level IN (1,2,3,4,5,6,7,8,9,10)
AND has_label = FALSE
AND has_label = 0
AND geometry && !BBOX!
"""
4 changes: 2 additions & 2 deletions values.staging.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ osm-seed:
POSTGRES_DB_MAINTENANCE_WORK_MEM: 750MB
POSTGRES_DB_EFFECTIVE_CACHE_SIZE: 7GB
persistenceDisk:
enabled: true
enabled: false
accessMode: ReadWriteOnce
mountPath: /var/lib/postgresql/data
subPath: postgresql-d
Expand Down Expand Up @@ -403,7 +403,7 @@ osm-seed:
IMPORT_NATURAL_EARTH: true
IMPORT_OSM_LAND: true
persistenceDisk:
enabled: true
enabled: false
accessMode: ReadWriteOnce
mountPath: /mnt/data
# In case cloudProvider: aws
Expand Down

0 comments on commit 6c4468a

Please sign in to comment.