Mise à jour des couches de routage
This commit is contained in:
parent
b7f891856e
commit
4c50956dce
|
@ -115,5 +115,14 @@ ON a.edge = b.id
|
|||
-- si besoin : nettoyage par Drop du schéma
|
||||
SELECT topology.DropTopology('osm_roads_topo');
|
||||
|
||||
-- permissions
|
||||
ALTER SCHEMA osm_roads_topo OWNER TO redadeg ;
|
||||
ALTER TABLE osm_roads_topo.edge_data OWNER TO redadeg ;
|
||||
ALTER TABLE osm_roads_topo.face OWNER TO redadeg ;
|
||||
ALTER TABLE osm_roads_topo.node OWNER TO redadeg ;
|
||||
ALTER TABLE osm_roads_topo.relation OWNER TO redadeg ;
|
||||
ALTER VIEW osm_roads_topo.edge OWNER TO redadeg ;
|
||||
ALTER SEQUENCE osm_roads_topo.layer_id_seq OWNER TO redadeg ;
|
||||
ALTER SEQUENCE osm_roads_topo.topogeo_s_1 OWNER TO redadeg ;
|
||||
|
||||
|
||||
|
|
32
scripts/update_osm_roads_pgr.sh
Executable file
32
scripts/update_osm_roads_pgr.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
PSQL=/usr/bin/psql
|
||||
DB_HOST=localhost
|
||||
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 ""
|
||||
echo " prend environ 5 min"
|
||||
echo ""
|
||||
|
||||
# cette couche vient d'une base osm donc il faut la recharger
|
||||
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME -c "TRUNCATE TABLE public.osm_roads;"
|
||||
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME < data/osm_roads.sql
|
||||
|
||||
|
||||
# maj de la topologie de la couche osm_roads_pgr qui sert au routage
|
||||
$PSQL -h $DB_HOST -U $DB_USER -d $DB_NAME < update_osm_roads_pgr.sql
|
||||
|
||||
echo "fini"
|
||||
echo ""
|
||||
|
||||
|
58
scripts/update_osm_roads_pgr.sql
Executable file
58
scripts/update_osm_roads_pgr.sql
Executable file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
==========================================================================
|
||||
|
||||
phase 2 : Mise à jour des couches de routage
|
||||
|
||||
==========================================================================
|
||||
*/
|
||||
|
||||
-- /!\
|
||||
-- cela suppose que la couche osm_roads est à jour !!
|
||||
-- or cette couche est calculée à partir d'une BD osm cf la documentation
|
||||
|
||||
|
||||
-- maj de la topologie de la couche osm_roads_pgr qui sert au routage
|
||||
-- 3 min
|
||||
UPDATE osm_roads SET topo_geom = topology.toTopoGeom(the_geom, 'osm_roads_topo', 1, 0.00001);
|
||||
|
||||
|
||||
-- maj de la couche support des calculs d'itinéraire
|
||||
-- 30 s
|
||||
TRUNCATE TABLE osm_roads_pgr ;
|
||||
INSERT INTO osm_roads_pgr
|
||||
( SELECT
|
||||
row_number() over() as id,
|
||||
o.osm_id,
|
||||
o.highway,
|
||||
o.type,
|
||||
o.oneway,
|
||||
o.ref,
|
||||
o.name_fr,
|
||||
o.name_br,
|
||||
NULL as source,
|
||||
NULL as target,
|
||||
NULL as cost,
|
||||
NULL as reverse_cost,
|
||||
e.geom as the_geom
|
||||
FROM osm_roads_topo.edge e,
|
||||
osm_roads_topo.relation rel,
|
||||
osm_roads o
|
||||
WHERE e.edge_id = rel.element_id
|
||||
AND rel.topogeo_id = (o.topo_geom).id
|
||||
);
|
||||
|
||||
-- calcul des 2 attributs de coût (= longueur)
|
||||
UPDATE osm_roads_pgr SET cost = st_length(the_geom);
|
||||
UPDATE osm_roads_pgr SET reverse_cost = st_length(the_geom);
|
||||
|
||||
|
||||
-- calcul du graphe routier par pgRouting
|
||||
-- 30 s
|
||||
SELECT pgr_createTopology('osm_roads_pgr', 1.0);
|
||||
|
||||
-- vérification
|
||||
SELECT pgr_analyzegraph('osm_roads_pgr', 1.0);
|
||||
SELECT pgr_nodeNetwork('osm_roads_pgr', 1.0);
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue