maj process osm_roads_pgr
This commit is contained in:
parent
48b8d398f8
commit
dcb9a00d73
|
@ -1,31 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
PSQL=/usr/bin/psql
|
||||
DB_HOST=localhost
|
||||
DB_NAME=redadeg
|
||||
DB_USER=redadeg
|
||||
|
||||
|
||||
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||
echo " Création de la couche osm_roads_pgr"
|
||||
echo ""
|
||||
echo ""
|
||||
|
||||
HOST_DB_redadeg=localhost
|
||||
HOST_DB_osm=localhost
|
||||
|
||||
# suppose le le .pgpass est correctement configuré pour le compte qui lance ce script
|
||||
|
||||
|
||||
echo ">> suppression de la topologie existante"
|
||||
echo ""
|
||||
psql -h $HOST_DB_redadeg -U redadeg -d redadeg -c "SELECT DropTopology('osm_roads_topo') ;"
|
||||
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "SELECT DropTopology('osm_roads_topo') ;"
|
||||
echo ""
|
||||
|
||||
# création d'un schéma qui va accueillir le réseau topologique de la couche osm_roads
|
||||
echo ">> création d'une nouvelle topologie"
|
||||
echo ""
|
||||
psql -h $HOST_DB_redadeg -U redadeg -d redadeg -c "SELECT topology.CreateTopology('osm_roads_topo', 2154);"
|
||||
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "SELECT topology.CreateTopology('osm_roads_topo', 2154);"
|
||||
|
||||
|
||||
echo ">> ajout d'un nouvel attribut sur la table osm_roads"
|
||||
echo ""
|
||||
psql -h $HOST_DB_redadeg -U redadeg -d redadeg -c "SELECT topology.AddTopoGeometryColumn('osm_roads_topo', 'public', 'osm_roads', 'topo_geom', 'LINESTRING');"
|
||||
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "SELECT topology.AddTopoGeometryColumn('osm_roads_topo', 'public', 'osm_roads', 'topo_geom', 'LINESTRING');"
|
||||
echo ""
|
||||
echo "fait"
|
||||
echo ""
|
||||
|
|
|
@ -9,9 +9,6 @@ DB_NAME=redadeg
|
|||
DB_USER=redadeg
|
||||
|
||||
|
||||
#cd /data/www/vhosts/ar-redadeg_openstreetmap_bzh/htdocs/scripts/
|
||||
|
||||
|
||||
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||
echo " Mise à jour des couches de routage"
|
||||
echo ""
|
||||
|
@ -20,9 +17,19 @@ echo ""
|
|||
|
||||
# la couche osm_roads vient d'être mise à jour ou recrée
|
||||
|
||||
# on efface la topologie existante
|
||||
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "SELECT DropTopology('osm_roads_topo') ;"
|
||||
|
||||
# création d'un schéma qui va accueillir le réseau topologique de la couche osm_roads
|
||||
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "SELECT topology.CreateTopology('osm_roads_topo', 2154);"
|
||||
|
||||
# ajout d'un nouvel attribut sur la table osm_roads
|
||||
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "SELECT topology.AddTopoGeometryColumn('osm_roads_topo', 'public', 'osm_roads', 'topo_geom', 'LINESTRING');"
|
||||
|
||||
|
||||
# on a besoin du layer_id
|
||||
# au cas où ça change : on le récupère par requête
|
||||
$PSQL -X -h $DB_HOST -U redadeg -d redadeg \
|
||||
$PSQL -X -h $DB_HOST -U $DB_USER -d $DB_NAME \
|
||||
-c "SELECT layer_id FROM topology.layer WHERE table_name = 'osm_roads' ;" \
|
||||
--single-transaction \
|
||||
--set AUTOCOMMIT=off \
|
||||
|
@ -44,11 +51,12 @@ done
|
|||
# donc je remet ici à la main. A corriger… TODO
|
||||
layer_id=1
|
||||
|
||||
|
||||
# on calcule le graphe topologique en remplissant le nouvel attribut géométrique
|
||||
# le 1er chiffre est l'identifiant du layer dans la table topology.layer
|
||||
# le 2e chiffre est la tolérance en mètres
|
||||
echo ">> calcul du graphe topologique"
|
||||
$PSQL -h $DB_HOST -U redadeg -d redadeg -c "UPDATE osm_roads SET topo_geom = topology.toTopoGeom(the_geom, 'osm_roads_topo', $layer_id, 0.00001);"
|
||||
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "UPDATE osm_roads SET topo_geom = topology.toTopoGeom(the_geom, 'osm_roads_topo', $layer_id, 0.00001);"
|
||||
echo ""
|
||||
echo "fait"
|
||||
echo ""
|
||||
|
@ -59,7 +67,7 @@ $PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME < update_osm_roads_pgr.sql
|
|||
#echo ">> patch de la couche osm_roads_pgr pour les cas particuliers"
|
||||
#$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME < patch_osm_roads_pgr.sql
|
||||
|
||||
echp "/!\ patcher le filaire de voie si nécessaire"
|
||||
echo "/!\ patcher le filaire de voie si nécessaire"
|
||||
|
||||
echo ""
|
||||
echo "fini"
|
||||
|
|
Loading…
Reference in a new issue