kopia lustrzana https://github.com/kartoza/docker-osm
Added commands to cleanup geom errors in layers (#82)
* Fix import error due to differences in geom type * fix id missing in clip table and skipping importing shapefiles with geometry errors * fix clip id error in the sql * Change postgresql version from 9.6 to 11 * Added sql to validate geometry and other make commands to run them manuallypull/83/head^2
rodzic
804e8f4079
commit
7f66d35143
31
Makefile
31
Makefile
|
@ -112,12 +112,41 @@ timestamp:
|
||||||
@echo "------------------------------------------------------------------"
|
@echo "------------------------------------------------------------------"
|
||||||
@docker exec -t -i $(PROJECT_ID)_imposm cat /home/settings/timestamp.txt
|
@docker exec -t -i $(PROJECT_ID)_imposm cat /home/settings/timestamp.txt
|
||||||
|
|
||||||
|
###
|
||||||
|
# SQL FILES
|
||||||
|
###
|
||||||
|
|
||||||
|
|
||||||
|
import_sql: import_sql
|
||||||
|
@echo
|
||||||
|
@echo "------------------------------------------------------------------"
|
||||||
|
@echo "Importing SQL files"
|
||||||
|
@echo "------------------------------------------------------------------"
|
||||||
|
@docker exec -i $(PROJECT_ID)_db su - postgres -c "psql -f /home/settings/clip/clip.sql gis"
|
||||||
|
|
||||||
|
validate_geom: validate_geom
|
||||||
|
@echo
|
||||||
|
@echo "------------------------------------------------------------------"
|
||||||
|
@echo "Validating geom for all tables"
|
||||||
|
@echo "------------------------------------------------------------------"
|
||||||
|
@docker exec -t -i $(PROJECT_ID)_db /bin/su - postgres -c "psql gis -c 'Select validate_geom();'"
|
||||||
|
|
||||||
|
|
||||||
|
clip_tables: clip_tables
|
||||||
|
@echo
|
||||||
|
@echo "------------------------------------------------------------------"
|
||||||
|
@echo "Clip tables using the clip layer"
|
||||||
|
@echo "------------------------------------------------------------------"
|
||||||
|
@docker exec -t -i $(PROJECT_ID)_db /bin/su - postgres -c "psql gis -c 'Select clean_tables();'"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# STYLES
|
# STYLES
|
||||||
###
|
###
|
||||||
|
|
||||||
|
|
||||||
import_styles: remove_styles
|
import_styles: import_styles
|
||||||
@echo
|
@echo
|
||||||
@echo "------------------------------------------------------------------"
|
@echo "------------------------------------------------------------------"
|
||||||
@echo "Importing QGIS styles"
|
@echo "Importing QGIS styles"
|
||||||
|
|
|
@ -9,7 +9,7 @@ volumes:
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
# About the postgresql version, it should match in the dockerfile of docker-imposm3
|
# About the postgresql version, it should match in the dockerfile of docker-imposm3
|
||||||
image: kartoza/postgis:9.6-2.4
|
image: kartoza/postgis:11.0-2.5
|
||||||
hostname: db
|
hostname: db
|
||||||
container_name: dockerosm_db
|
container_name: dockerosm_db
|
||||||
environment:
|
environment:
|
||||||
|
@ -19,7 +19,8 @@ services:
|
||||||
# Uncomment to expose the postgis database on the network
|
# Uncomment to expose the postgis database on the network
|
||||||
# - ALLOW_IP_RANGE= 0.0.0.0/0
|
# - ALLOW_IP_RANGE= 0.0.0.0/0
|
||||||
volumes:
|
volumes:
|
||||||
- 'osm-postgis-data:/var/lib/postgresql'
|
- osm-postgis-data:/var/lib/postgresql
|
||||||
|
- ./settings:/home/settings
|
||||||
# Uncomment to use the postgis database from outside the docker network
|
# Uncomment to use the postgis database from outside the docker network
|
||||||
# ports:
|
# ports:
|
||||||
# - "35432:5432"
|
# - "35432:5432"
|
||||||
|
@ -68,8 +69,8 @@ services:
|
||||||
- DBSCHEMA_BACKUP=backup
|
- DBSCHEMA_BACKUP=backup
|
||||||
# Install some styles if you are using the default mapping. It can be 'yes' or 'no'
|
# Install some styles if you are using the default mapping. It can be 'yes' or 'no'
|
||||||
- QGIS_STYLE=yes
|
- QGIS_STYLE=yes
|
||||||
# Use clip in the database
|
# Use clip in the database - To use this you should have run make import_clip to add your clip to the DB
|
||||||
- CLIP=no
|
- CLIP=yes
|
||||||
|
|
||||||
osmupdate:
|
osmupdate:
|
||||||
build: docker-osmupdate
|
build: docker-osmupdate
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
FROM golang:1.10
|
FROM golang:1.10
|
||||||
MAINTAINER Etienne Trimaille <etienne.trimaille@gmail.com>
|
MAINTAINER Etienne Trimaille <etienne.trimaille@gmail.com>
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
RUN wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | apt-key add -
|
||||||
|
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
|
||||||
RUN apt update && apt install -y python3-pip \
|
RUN apt update && apt install -y python3-pip \
|
||||||
libprotobuf-dev libleveldb-dev libgeos-dev \
|
libprotobuf-dev libleveldb-dev libgeos-dev \
|
||||||
libpq-dev python3-dev postgresql-client-9.6 python-setuptools \
|
libpq-dev python3-dev postgresql-client-11 python-setuptools \
|
||||||
gdal-bin \
|
gdal-bin \
|
||||||
--no-install-recommends
|
--no-install-recommends
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,8 @@ make backup_styles
|
||||||
|
|
||||||
### SQL Trigger
|
### SQL Trigger
|
||||||
|
|
||||||
You can add PostGIS functions, triggers, materialized views in the SQL file.
|
You can add PostGIS functions, triggers, materialized views in the clip SQL file. You need to run
|
||||||
|
`make import_sql` to run the clip SQL file
|
||||||
|
|
||||||
### Build and run
|
### Build and run
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,32 @@ BEGIN
|
||||||
EXECUTE 'DELETE FROM ' || quote_ident(osm_table.table_name) || ' WHERE osm_id IN (
|
EXECUTE 'DELETE FROM ' || quote_ident(osm_table.table_name) || ' WHERE osm_id IN (
|
||||||
SELECT DISTINCT osm_id
|
SELECT DISTINCT osm_id
|
||||||
FROM ' || quote_ident(osm_table.table_name) || '
|
FROM ' || quote_ident(osm_table.table_name) || '
|
||||||
LEFT JOIN clip ON ST_Intersects(geometry, geom))
|
LEFT JOIN clip ON ST_Intersects(geometry, geom) where clip.ogc_fid is NULL)
|
||||||
;';
|
;';
|
||||||
END LOOP;
|
END LOOP;
|
||||||
END;
|
END;
|
||||||
$BODY$
|
$BODY$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Function to validate geometry of all tables. To run it after creating the function sinmply run Select validate_geom();
|
||||||
|
CREATE OR REPLACE FUNCTION validate_geom() RETURNS void AS
|
||||||
|
$BODY$
|
||||||
|
DECLARE osm_tables CURSOR FOR
|
||||||
|
SELECT table_name
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema='public'
|
||||||
|
AND table_type='BASE TABLE'
|
||||||
|
AND table_name LIKE 'osm_%';
|
||||||
|
BEGIN
|
||||||
|
FOR osm_table IN osm_tables LOOP
|
||||||
|
EXECUTE 'UPDATE ' || quote_ident(osm_table.table_name) || ' SET
|
||||||
|
geometry = ST_MakeValid(geometry) where ST_isValidreason(geometry) = ''F'' ;';
|
||||||
|
END LOOP;
|
||||||
|
END;
|
||||||
|
$BODY$
|
||||||
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue