2020-02-15 10:19:28 +00:00
|
|
|
#!/bin/bash
|
2019-01-01 19:52:23 +00:00
|
|
|
|
2020-02-15 10:19:28 +00:00
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
|
2021-03-22 11:11:43 +00:00
|
|
|
# argument 1 = millesime redadeg
|
|
|
|
millesime=$1
|
|
|
|
|
2020-02-15 10:19:28 +00:00
|
|
|
PSQL=/usr/bin/psql
|
|
|
|
DB_HOST=localhost
|
2021-03-22 11:11:43 +00:00
|
|
|
DB_NAME=redadeg_$millesime
|
2020-02-15 10:19:28 +00:00
|
|
|
DB_USER=redadeg
|
|
|
|
DB_PASSWD=redadeg
|
2019-01-01 19:52:23 +00:00
|
|
|
|
2021-03-22 11:11:43 +00:00
|
|
|
# varaibles liées au millésimes
|
|
|
|
echo "millesime de travail = $1"
|
2021-03-22 11:18:59 +00:00
|
|
|
rep_data=../data/$millesime
|
2021-03-22 11:11:43 +00:00
|
|
|
echo "rep_data = $rep_data"
|
|
|
|
echo "base de données = $DB_NAME"
|
|
|
|
echo ""
|
2019-01-01 19:52:23 +00:00
|
|
|
|
2020-02-15 10:10:23 +00:00
|
|
|
|
|
|
|
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
echo " Récupération des fichiers geojson depuis umap"
|
|
|
|
|
2021-03-22 11:11:43 +00:00
|
|
|
# traitement des tracés manuels
|
2019-01-01 19:52:23 +00:00
|
|
|
|
2021-03-22 11:11:43 +00:00
|
|
|
# on commence par supprimer la table
|
|
|
|
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "DROP TABLE IF EXISTS phase_1_trace_3857 CASCADE;"
|
|
|
|
#$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "DROP TABLE IF EXISTS phase_1_pk_vip_3857;"
|
2020-02-15 10:10:23 +00:00
|
|
|
echo ""
|
2019-01-01 19:52:23 +00:00
|
|
|
|
|
|
|
|
2021-03-22 11:11:43 +00:00
|
|
|
# on va lire le fichier de config des couches umap pour boucler
|
|
|
|
IFS="="
|
|
|
|
while read -r line
|
|
|
|
do
|
|
|
|
layer=$line
|
2019-01-01 19:52:23 +00:00
|
|
|
|
2021-03-22 11:11:43 +00:00
|
|
|
echo " umap layer id = $layer"
|
|
|
|
wget -q -O $rep_data/phase_1_umap_trace_$layer.geojson https://umap.openstreetmap.fr/fr/datalayer/$layer
|
|
|
|
echo " recup ok"
|
2020-02-15 10:10:23 +00:00
|
|
|
|
2021-03-22 11:11:43 +00:00
|
|
|
# on charge dans postgis
|
|
|
|
# note : les coordonnées sont en 3857 mais la déclaration de la table = 4326
|
2019-01-01 19:52:23 +00:00
|
|
|
|
2021-03-22 11:11:43 +00:00
|
|
|
echo " chargement dans la couche d'import"
|
|
|
|
ogr2ogr -f "PostgreSQL" PG:"host=$DB_HOST user=$DB_USER password=$DB_PASSWD dbname=$DB_NAME" $rep_data/phase_1_umap_trace_$layer.geojson -nln phase_1_trace_3857 -lco GEOMETRY_NAME=the_geom -explodecollections
|
|
|
|
echo " fait"
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
# fin de la boucle de lecture des layers umap
|
|
|
|
done < $rep_data/umap_phase_1_layers.txt
|
|
|
|
|
|
|
|
|
|
|
|
# PK VIP
|
|
|
|
# pas besoin en 2021
|
|
|
|
#ogr2ogr -f "PostgreSQL" PG:"host=$DB_HOST user=$DB_USER password=$DB_PASSWD dbname=$DB_NAME" data/phase_1_umap_pk_vip.geojson -nln phase_1_pk_vip_3857 -lco GEOMETRY_NAME=the_geom -explodecollections -overwrite
|
2019-01-01 19:52:23 +00:00
|
|
|
|
2020-02-15 10:10:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
echo " Application des traitements SQL "
|
|
|
|
echo ""
|
2019-01-01 19:52:23 +00:00
|
|
|
|
|
|
|
# on crée les tables en 3948
|
2020-02-15 10:19:28 +00:00
|
|
|
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME < traitements_phase_1.sql
|
2019-01-01 19:52:23 +00:00
|
|
|
|
2020-02-15 10:10:23 +00:00
|
|
|
echo " fait"
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
2021-03-22 11:11:43 +00:00
|
|
|
echo " Exports "
|
2020-02-15 10:10:23 +00:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo " exports geojson"
|
|
|
|
echo ""
|
2019-01-01 19:52:23 +00:00
|
|
|
|
|
|
|
# et on exporte vers Geojson
|
2021-03-22 11:18:59 +00:00
|
|
|
rm -f $rep_data/phase_1_pk_auto.geojson
|
2021-03-22 11:11:43 +00:00
|
|
|
ogr2ogr -f "GeoJSON" $rep_data/phase_1_pk_auto.geojson PG:"host=$DB_HOST user=$DB_USER password=$DB_PASSWD dbname=$DB_NAME" phase_1_pk_auto_4326
|
2021-03-22 11:20:13 +00:00
|
|
|
rm -f $rep_data/phase_1_trace_4326.geojson
|
2021-03-22 11:11:43 +00:00
|
|
|
ogr2ogr -f "GeoJSON" $rep_data/phase_1_trace_4326.geojson PG:"host=$DB_HOST user=$DB_USER password=$DB_PASSWD dbname=$DB_NAME" phase_1_trace_4326
|
2019-01-01 19:52:23 +00:00
|
|
|
# les fichiers sont ensuite tout de suite visible dans umap
|
|
|
|
|
2019-01-13 16:20:26 +00:00
|
|
|
# exports supplémentaires
|
2021-03-22 11:18:59 +00:00
|
|
|
rm -f $rep_data/phase_1_pk_auto.xlsx
|
2021-03-22 11:11:43 +00:00
|
|
|
ogr2ogr -f "XLSX" $rep_data/phase_1_pk_auto.xlsx PG:"host=$DB_HOST user=$DB_USER password=$DB_PASSWD dbname=$DB_NAME" phase_1_pk_auto_4326
|
2020-02-15 10:10:23 +00:00
|
|
|
|
|
|
|
echo " fait"
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
echo " F I N traitements phase 1"
|
|
|
|
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
echo ""
|