prise en charge millesime database

This commit is contained in:
MaelREBOUX 2021-03-10 08:57:08 +01:00
parent abf59743b4
commit 302f85f726
3 changed files with 23 additions and 15 deletions

View file

@ -3,27 +3,31 @@
# utiliser un compte SUPERUSER pour exécuter ce script
dbhost=localhost
millesime=2022
#psql -h $dbhost -d postgres -c "DROP DATABASE IF EXISTS redadeg; DROP ROLE IF EXISTS redadeg;"
PSQL=/usr/bin/psql
DB_HOST=localhost
DB_NAME=redadeg_$millesime
psql -h $dbhost -d postgres -c "DROP DATABASE IF EXISTS $DB_NAME; DROP ROLE IF EXISTS redadeg;"
# create role
psql -h $dbhost -d postgres -c "CREATE USER redadeg WITH PASSWORD 'redadeg' SUPERUSER;"
# create database with owner redadeg
psql -h $dbhost -d postgres -c "CREATE DATABASE redadeg WITH OWNER = redadeg ENCODING = 'UTF8';"
psql -h $dbhost -d postgres -c "CREATE DATABASE $DB_NAME WITH OWNER = redadeg ENCODING = 'UTF8';"
# extensions postgis
psql -h $dbhost -d redadeg -c "CREATE EXTENSION postgis;"
psql -h $dbhost -d redadeg -c "CREATE EXTENSION postgis_topology;"
psql -h $dbhost -d redadeg -c "CREATE EXTENSION pgrouting;"
psql -h $dbhost -d $DB_NAME -c "CREATE EXTENSION postgis;"
psql -h $dbhost -d $DB_NAME -c "CREATE EXTENSION postgis_topology;"
psql -h $dbhost -d $DB_NAME -c "CREATE EXTENSION pgrouting;"
# permissions
psql -h $dbhost -d redadeg -c "ALTER SCHEMA public OWNER TO redadeg;"
psql -h $dbhost -d redadeg -c "ALTER TABLE topology.layer OWNER TO redadeg ;"
psql -h $dbhost -d redadeg -c "ALTER TABLE topology.topology OWNER TO redadeg ;"
psql -h $dbhost -d $DB_NAME -c "ALTER SCHEMA public OWNER TO redadeg;"
psql -h $dbhost -d $DB_NAME -c "ALTER TABLE topology.layer OWNER TO redadeg ;"
psql -h $dbhost -d $DB_NAME -c "ALTER TABLE topology.topology OWNER TO redadeg ;"
# vérifications
psql -h $dbhost -d redadeg -c "SELECT * FROM postgis_version();"
psql -h $dbhost -d redadeg -c "SELECT * FROM pgr_version();"
psql -h $dbhost -d $DB_NAME -c "SELECT * FROM postgis_version();"
psql -h $dbhost -d $DB_NAME -c "SELECT * FROM pgr_version();"

View file

@ -5,7 +5,7 @@ set -u
PSQL=/usr/bin/psql
DB_HOST=localhost
DB_NAME=redadeg
DB_NAME=redadeg_$millesime
DB_USER=redadeg
DB_PASSWD=redadeg

View file

@ -3,19 +3,23 @@
set -e
set -u
millesime=2022
PSQL=/usr/bin/psql
DB_HOST=localhost
DB_NAME=redadeg
DB_NAME=redadeg_$millesime
DB_USER=redadeg
DB_PASSWD=redadeg
# ce script récupère une couche des communes de France et la charge dans la base de données
cd data
mkdir -p ../data/$millesime/
cd ../data/$millesime/
# récupérer la couche communales OSM
# https://www.data.gouv.fr/fr/datasets/decoupage-administratif-communal-francais-issu-d-openstreetmap/
curl -sS http://osm13.openstreetmap.fr/~cquest/openfla/export/communes-20210101-shp.zip > communes-20210101-shp.zip
#curl -sS http://osm13.openstreetmap.fr/~cquest/openfla/export/communes-20210101-shp.zip > communes-20210101-shp.zip
wget http://osm13.openstreetmap.fr/~cquest/openfla/export/communes-20210101-shp.zip
unzip -o communes-20210101-shp.zip