routing : id column

pour rester plus près du modèle standard attendu par pgrouting
This commit is contained in:
MaelReboux 2019-03-17 11:35:17 +01:00
parent fd92b18934
commit e369c275a9
3 changed files with 7 additions and 4 deletions

View file

@ -29,10 +29,11 @@
-- 2. création de la table qui va accueillir les tronçons de routes -- 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 ; DROP TABLE IF EXISTS osm_roads ;
CREATE TABLE osm_roads CREATE TABLE osm_roads
( (
uid bigint,
osm_id bigint, osm_id bigint,
highway text, highway text,
type text, type text,
@ -41,7 +42,7 @@ CREATE TABLE osm_roads
name_fr text, name_fr text,
name_br text, name_br text,
the_geom geometry, 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_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) CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 2154)
); );
@ -64,6 +65,7 @@ WITH trace_buffer AS (
INSERT INTO osm_roads INSERT INTO osm_roads
( (
SELECT SELECT
row_number() over() as id,
osm_id, osm_id,
highway, highway,
CASE CASE

View file

@ -171,6 +171,7 @@ CREATE VIEW phase_1_tdb AS
DROP TABLE IF EXISTS osm_roads ; DROP TABLE IF EXISTS osm_roads ;
CREATE TABLE osm_roads CREATE TABLE osm_roads
( (
id bigint,
osm_id bigint, osm_id bigint,
highway text, highway text,
type text, type text,
@ -179,7 +180,7 @@ CREATE TABLE osm_roads
name_fr text, name_fr text,
name_br text, name_br text,
the_geom geometry, 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_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) CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 2154)
); );

View file

@ -18,6 +18,6 @@ ALTER TABLE osm_roads ADD COLUMN source integer ;
ALTER TABLE osm_roads ADD COLUMN target integer ; ALTER TABLE osm_roads ADD COLUMN target integer ;
-- calcul de la topologie -- calcul de la topologie
SELECT pgr_createTopology('osm_roads', 0.000001, 'the_geom', 'osm_id'); SELECT pgr_createTopology('osm_roads', 0.000001);