2019-05-04 10:19:32 +00:00
|
|
|
/*
|
|
|
|
==========================================================================
|
|
|
|
|
|
|
|
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 couche support des calculs d'itinéraire
|
|
|
|
-- 30 s
|
2019-05-05 15:30:05 +00:00
|
|
|
-- on commence par vider les couches existantes
|
2019-05-04 10:19:32 +00:00
|
|
|
TRUNCATE TABLE osm_roads_pgr ;
|
2019-06-16 21:35:36 +00:00
|
|
|
DROP TABLE IF EXISTS osm_roads_pgr_noded ;
|
|
|
|
DROP TABLE IF EXISTS osm_roads_pgr_vertices_pgr ;
|
|
|
|
|
2019-05-05 15:30:05 +00:00
|
|
|
|
|
|
|
-- on remplit la couche de lignes
|
2019-05-04 10:19:32 +00:00
|
|
|
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)
|
2019-05-09 13:39:09 +00:00
|
|
|
UPDATE osm_roads_pgr SET cost = st_length(the_geom), reverse_cost = st_length(the_geom);
|
2019-05-04 10:19:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- calcul du graphe routier par pgRouting
|
2019-05-05 15:30:05 +00:00
|
|
|
-- cela va remplir les tables osm_roads_pgr_noded et osm_roads_pgr_vertices_pgr
|
2019-05-04 10:19:32 +00:00
|
|
|
-- 30 s
|
2019-05-19 10:12:37 +00:00
|
|
|
SELECT pgr_createTopology('osm_roads_pgr', 0.001);
|
2019-05-04 10:19:32 +00:00
|
|
|
|
|
|
|
-- vérification
|
2019-05-19 10:12:37 +00:00
|
|
|
SELECT pgr_analyzegraph('osm_roads_pgr', 0.001);
|
|
|
|
SELECT pgr_nodeNetwork('osm_roads_pgr', 0.001);
|
2019-05-04 10:19:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|