phase 2 : travail
This commit is contained in:
parent
6aed076f5e
commit
11bf6990d0
|
@ -220,8 +220,53 @@ CREATE INDEX osm_roads_pgr_target_idx ON osm_roads_pgr (target);
|
|||
SELECT topology.CreateTopology('osm_roads_topo', 2154);
|
||||
|
||||
|
||||
-- la table qui va recevoir le résultat du calcul d'itinéraire
|
||||
DROP TABLE IF EXISTS phase_2_trace_pgr ;
|
||||
CREATE TABLE phase_2_trace_pgr
|
||||
(
|
||||
-- info de routage
|
||||
id bigint,
|
||||
path_seq bigint,
|
||||
node bigint,
|
||||
cost double precision,
|
||||
agg_cost double precision,
|
||||
-- info OSM
|
||||
osm_id bigint,
|
||||
highway text,
|
||||
type text,
|
||||
oneway text,
|
||||
ref text,
|
||||
name_fr text,
|
||||
name_br text,
|
||||
the_geom geometry,
|
||||
CONSTRAINT phase_2_trace_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'LINESTRING'::text OR geometrytype(the_geom) = 'MULTILINESTRING'::text),
|
||||
CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 2154)
|
||||
);
|
||||
|
||||
|
||||
|
||||
-- la table qui va contenir des tronçons de x m
|
||||
DROP TABLE IF EXISTS phase_2_trace_troncons ;
|
||||
CREATE TABLE phase_2_trace_troncons
|
||||
(
|
||||
uid bigint,
|
||||
secteur_id int,
|
||||
ordre bigint,
|
||||
km bigint,
|
||||
km_reel bigint,
|
||||
longueur integer,
|
||||
-- info OSM
|
||||
osm_id bigint,
|
||||
highway text,
|
||||
type text,
|
||||
oneway text,
|
||||
ref text,
|
||||
name_fr text,
|
||||
name_br text,
|
||||
the_geom geometry,
|
||||
CONSTRAINT phase_2_trace_troncons_pkey PRIMARY KEY (uid),
|
||||
CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'LINESTRING'::text),
|
||||
CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 2154)
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ SELECT topology.AddTopoGeometryColumn('osm_roads_topo', 'public', 'osm_roads', '
|
|||
-- le 2e chiffre est la tolérance en mètres
|
||||
UPDATE osm_roads SET topo_geom = topology.toTopoGeom(the_geom, 'osm_roads_topo', 1, 0.00001);
|
||||
-- 1.0 = 18 min
|
||||
-- 0.00001 = 18 min
|
||||
-- 0.00001 = 2 min
|
||||
|
||||
-- à ce stade on a un graphe topologique dans le schema osm_roads_topo
|
||||
|
||||
|
@ -73,24 +73,29 @@ SELECT pgr_nodeNetwork('osm_roads_pgr', 1.0);
|
|||
|
||||
|
||||
-- il ne reste plus qu'à faire des calculs d'itinéraires
|
||||
|
||||
-- on met le résultat dans une table
|
||||
TRUNCATE TABLE phase_2_trace_pgr ;
|
||||
INSERT INTO phase_2_trace_pgr
|
||||
SELECT
|
||||
-- info de routage
|
||||
a.seq AS id,
|
||||
a.path_seq,
|
||||
a.node,
|
||||
a.cost,
|
||||
a.agg_cost,
|
||||
-- infos OSM
|
||||
b.osm_id,
|
||||
b.highway,
|
||||
b."type",
|
||||
b.oneway,
|
||||
b.ref,
|
||||
b.name_fr,
|
||||
b.name_br,
|
||||
b.the_geom
|
||||
FROM pgr_dijkstra(
|
||||
'SELECT id, source, target, cost, reverse_cost FROM osm_roads_pgr',
|
||||
12872, 12145) as a
|
||||
JOIN osm_roads_pgr b
|
||||
ON a.edge = b.id
|
||||
7632, 687) as a
|
||||
JOIN osm_roads_pgr b ON a.edge = b.id ;
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue