From e369c275a9b57b7371cfe6d266cb63571b7ddde7 Mon Sep 17 00:00:00 2001 From: MaelReboux Date: Sun, 17 Mar 2019 11:35:17 +0100 Subject: [PATCH] routing : id column MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pour rester plus près du modèle standard attendu par pgrouting --- scripts/create_osm_roads.sql | 6 ++++-- scripts/create_tables.sql | 3 ++- scripts/traitements_phase_2.sql | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/create_osm_roads.sql b/scripts/create_osm_roads.sql index a539ef7..ade2b0e 100644 --- a/scripts/create_osm_roads.sql +++ b/scripts/create_osm_roads.sql @@ -29,10 +29,11 @@ -- 2. création de la table qui va accueillir les tronçons de routes --- table osm_roads +-- la table qui contient le graphe routier de OSM DROP TABLE IF EXISTS osm_roads ; CREATE TABLE osm_roads ( + uid bigint, osm_id bigint, highway text, type text, @@ -41,7 +42,7 @@ CREATE TABLE osm_roads name_fr text, name_br text, the_geom geometry, - CONSTRAINT osm_roads_pkey PRIMARY KEY (osm_id), + CONSTRAINT osm_roads_pkey PRIMARY KEY (uid), 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) ); @@ -64,6 +65,7 @@ WITH trace_buffer AS ( INSERT INTO osm_roads ( SELECT + row_number() over() as id, osm_id, highway, CASE diff --git a/scripts/create_tables.sql b/scripts/create_tables.sql index 072c0e6..aa157d1 100644 --- a/scripts/create_tables.sql +++ b/scripts/create_tables.sql @@ -171,6 +171,7 @@ CREATE VIEW phase_1_tdb AS DROP TABLE IF EXISTS osm_roads ; CREATE TABLE osm_roads ( + id bigint, osm_id bigint, highway text, type text, @@ -179,7 +180,7 @@ CREATE TABLE osm_roads name_fr text, name_br text, the_geom geometry, - CONSTRAINT osm_roads_pkey PRIMARY KEY (osm_id), + CONSTRAINT osm_roads_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) ); diff --git a/scripts/traitements_phase_2.sql b/scripts/traitements_phase_2.sql index 1b1c70e..b62057b 100644 --- a/scripts/traitements_phase_2.sql +++ b/scripts/traitements_phase_2.sql @@ -18,6 +18,6 @@ ALTER TABLE osm_roads ADD COLUMN source integer ; ALTER TABLE osm_roads ADD COLUMN target integer ; -- calcul de la topologie -SELECT pgr_createTopology('osm_roads', 0.000001, 'the_geom', 'osm_id'); +SELECT pgr_createTopology('osm_roads', 0.000001);