From 691e0dc90f6fae822fbcc6b53df331360e0af7b1 Mon Sep 17 00:00:00 2001 From: chmnata Date: Mon, 11 Mar 2024 17:18:10 +0000 Subject: [PATCH] #884 update routing centreline id --- ...te_view_routing_centreline_directional.sql | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/gis/centreline/sql/create_view_routing_centreline_directional.sql b/gis/centreline/sql/create_view_routing_centreline_directional.sql index 6e2c1e22e..bde5bc1cb 100644 --- a/gis/centreline/sql/create_view_routing_centreline_directional.sql +++ b/gis/centreline/sql/create_view_routing_centreline_directional.sql @@ -1,25 +1,32 @@ CREATE OR REPLACE VIEW gis_core.routing_centreline_directional AS -SELECT - centreline.centreline_id, - concat(centreline.centreline_id, 0)::integer AS id, - centreline.from_intersection_id AS source, - centreline.to_intersection_id AS target, - centreline.shape_length AS cost, - centreline.geom -FROM gis_core.centreline_latest AS centreline - -UNION - -SELECT - centreline.centreline_id, - concat(centreline.centreline_id, 1)::integer AS id, - centreline.to_intersection_id AS source, - centreline.from_intersection_id AS target, - centreline.shape_length AS cost, - st_reverse(centreline.geom) AS geom -FROM gis_core.centreline_latest AS centreline -WHERE centreline.oneway_dir_code = 0; +SELECT + centreline_id, + row_number() OVER () AS id, + source, + target, + cost, + geom + +FROM ( + SELECT + centreline.centreline_id, + centreline.from_intersection_id AS source, + centreline.to_intersection_id AS target, + centreline.shape_length AS cost, + centreline.geom + FROM gis_core.centreline_latest AS centreline + + UNION + + SELECT + centreline.centreline_id, + centreline.to_intersection_id AS source, + centreline.from_intersection_id AS target, + centreline.shape_length AS cost, + st_reverse(centreline.geom) AS geom + FROM gis_core.centreline_latest AS centreline + WHERE centreline.oneway_dir_code = 0) AS dup; ALTER TABLE gis_core.routing_centreline_directional OWNER TO gis_admins;