From b6fc402951dd8f46162178b135f58df4d4f95836 Mon Sep 17 00:00:00 2001 From: MaelReboux Date: Thu, 9 May 2019 15:17:06 +0200 Subject: [PATCH] maj de osm_roads + la topologie pas facile... --- scripts/create_osm_roads.sh | 6 ++++-- scripts/create_osm_roads_pgr.sh | 27 +++------------------------ scripts/routing.sql | 10 +++++----- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/scripts/create_osm_roads.sh b/scripts/create_osm_roads.sh index 5eb4d1e..ad48fe6 100755 --- a/scripts/create_osm_roads.sh +++ b/scripts/create_osm_roads.sh @@ -99,10 +99,12 @@ echo "" echo "transfert 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 +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 -psql -h $HOST_DB_redadeg -U redadeg -d redadeg -c "TRUNCATE TABLE public.osm_roads;" +psql -h $HOST_DB_redadeg -U redadeg -d redadeg -c "DROP TABLE IF EXISTS public.osm_roads;" psql -h $HOST_DB_redadeg -U redadeg -d redadeg < data/osm_roads.sql echo "" diff --git a/scripts/create_osm_roads_pgr.sh b/scripts/create_osm_roads_pgr.sh index 18e2870..93ade41 100755 --- a/scripts/create_osm_roads_pgr.sh +++ b/scripts/create_osm_roads_pgr.sh @@ -14,37 +14,15 @@ HOST_DB_osm=192.168.56.1 echo ">> suppression de la topologie existante" echo "" -#psql -h $HOST_DB_redadeg -U redadeg -d redadeg -c "SELECT DropTopology('osm_roads_topo') ;" +psql -h $HOST_DB_redadeg -U redadeg -d redadeg -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 $HOST_DB_redadeg -U redadeg -d redadeg -c "SELECT topology.CreateTopology('osm_roads_topo', 2154);" -# on a donc un nouveau schéma osm_roads_topo qui contient 4 tables : edge_data, face, node, relation -# et un nouvel enregistrement dans la table topology.layer -# logiquement : c'est 1 mais on va quand même faire une requête - -psql -X -h $HOST_DB_redadeg -U redadeg -d redadeg \ - -c "SELECT layer_id FROM topology.layer WHERE table_name = 'osm_roads' ;" \ - --single-transaction \ - --set AUTOCOMMIT=off \ - --set ON_ERROR_STOP=on \ - --no-align \ - -t \ - --field-separator ' ' \ - --quiet | while read -a Record ; do - - layer_id=${Record[0]} - - echo "" - echo "layer_id de osm_roads = $layer_id" - echo "" - -done - 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');" @@ -52,5 +30,6 @@ echo "" echo "fait" echo "" + echo "fini >> exécuter update_osm_roads_pgr.sh " echo "" diff --git a/scripts/routing.sql b/scripts/routing.sql index 7ef8db1..f2f1c57 100644 --- a/scripts/routing.sql +++ b/scripts/routing.sql @@ -16,14 +16,14 @@ SELECT DropTopology('osm_roads_topo') ; -- 1. création d'un schéma qui va accueillir le réseau topologique de la couche osm_roads SELECT topology.CreateTopology('osm_roads_topo', 2154); +-- 2. ajout d'un nouvel attribut sur la table osm_roads +SELECT topology.AddTopoGeometryColumn('osm_roads_topo', 'public', 'osm_roads', 'topo_geom', 'LINESTRING'); + + -- on a donc un nouveau schéma osm_roads_topo qui contient 4 tables : edge_data, face, node, relation -- et un nouvel enregistrement dans la table topology.layer -- logiquement : c'est 1 --- SELECT * FROM topology.layer ORDER BY layer_id desc ; - - --- 2. ajout d'un nouvel attribut sur la table osm_roads -SELECT topology.AddTopoGeometryColumn('osm_roads_topo', 'public', 'osm_roads', 'topo_geom', 'LINESTRING'); +SELECT layer_id FROM topology.layer WHERE table_name = 'osm_roads' ; -- 3. on calcule le graphe topologique