Update create_osm_roads.sh

ajout gestion des hosts pour différencier BD osm / redadeg
This commit is contained in:
MaelReboux 2019-05-04 14:21:36 +02:00
parent 519c741356
commit b491468c5a

View file

@ -6,24 +6,35 @@ echo " Création de la couche osm_roads"
echo "" echo ""
echo "" echo ""
HOST_DB_redadeg=localhost
HOST_DB_osm=192.168.56.1
# 1. export du tracé depuis la base redadeg # suppose le le .pgpass est correctement configuré pour le compte qui lance ce script
pg_dump --file data/redadeg_trace.sql --host localhost --username redadeg --no-password --format=p --no-owner --section=pre-data --section=data --no-privileges --no-tablespaces --no-unlogged-table-data --no-comments --table public.phase_1_trace redadeg
echo "import phase_1_trace dans la base OSM"
echo ""
# 1. export du tracé phase 1 depuis la base redadeg
pg_dump --file data/redadeg_trace.sql --host $HOST_DB_redadeg --username redadeg --no-password --format=p --no-owner --section=pre-data --section=data --no-privileges --no-tablespaces --no-unlogged-table-data --no-comments --table public.phase_1_trace redadeg
# 2. import dans la base OSM # 2. import dans la base OSM
psql -h $HOST_DB_osm -U osmbr -d osm -c "DROP TABLE public.phase_1_trace;"
psql -h $HOST_DB_osm -U osmbr -d osm < data/redadeg_trace.sql
psql -h localhost -U osmbr -d osm -c "DROP TABLE public.phase_1_trace;" echo ""
psql -h localhost -U osmbr -d osm < data/redadeg_trace.sql echo "fait"
echo ""
# 3. calcul de la couche osm_roads = intersection buffer trace et routes OSM # 3. calcul de la couche osm_roads = intersection buffer trace et routes OSM
psql -h localhost -U osmbr -d osm -c "TRUNCATE TABLE osm_roads ;" echo "calcul de la couche osm_roads"
psql -h localhost -U osmbr -d osm -c "WITH trace_buffer AS ( echo ""
psql -h $HOST_DB_osm -U osmbr -d osm -c "TRUNCATE TABLE osm_roads ;"
psql -h $HOST_DB_osm -U osmbr -d osm -c "WITH trace_buffer AS (
SELECT SELECT
secteur_id, secteur_id,
ST_Union(ST_Buffer(the_geom, 25, 'quad_segs=2')) AS the_geom ST_Union(ST_Buffer(the_geom, 25, 'quad_segs=2')) AS the_geom
@ -54,22 +65,25 @@ INSERT INTO osm_roads
WHERE highway IS NOT NULL AND ST_INTERSECTS(t.the_geom, ST_Transform(o.way,2154)) WHERE highway IS NOT NULL AND ST_INTERSECTS(t.the_geom, ST_Transform(o.way,2154))
) ;" ) ;"
echo ""
echo "fait"
echo ""
# 4. export de osm_roads depuis la base OSM # 4. export de osm_roads depuis la base OSM
pg_dump --file data/osm_roads.sql --host localhost --username osmbr --no-password --format=p --no-owner --section=pre-data --section=data --no-privileges --no-tablespaces --no-unlogged-table-data --no-comments --table public.osm_roads osm echo "import de osm_roads depuis la base OSM vers la base redadeg"
echo ""
pg_dump --file data/osm_roads.sql --host $HOST_DB_osm --username osmbr --no-password --format=p --no-owner --section=pre-data --section=data --no-privileges --no-tablespaces --no-unlogged-table-data --no-comments --table public.osm_roads osm
# 5. import dans la base redadeg # 5. import dans la base redadeg
psql -h $HOST_DB_redadeg -U redadeg -d redadeg -c "TRUNCATE TABLE public.osm_roads;"
psql -h $HOST_DB_redadeg -U redadeg -d redadeg < data/osm_roads.sql
psql -h localhost -U redadeg -d redadeg -c "DROP TABLE public.phase_1_trace;" echo ""
psql -h localhost -U redadeg -d redadeg < data/redadeg_trace.sql echo "fait"
echo ""
psql -h localhost -U redadeg -d redadeg -c "TRUNCATE TABLE public.osm_roads;"
psql -h localhost -U redadeg -d redadeg < data/osm_roads.sql
echo "fini" echo "fini"