Skip to content

Commit

Permalink
#57 update routing for missing int nodes sql
Browse files Browse the repository at this point in the history
  • Loading branch information
chmnata committed Aug 3, 2022
1 parent 21c34b8 commit 55af6d1
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions congestion_network_creation/route_node_w_no_int.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
-- all segments info
WITH segment_info AS (
select segment_id, start_vid, end_vid, fnode.int_id as start_int, tnode.int_id as end_int
from congestion.network_segments
left join congestion.network_int_px_21_1 fnode on fnode.node_id = network_segments.start_vid
left join congestion.network_int_px_21_1 tnode on tnode.node_id = network_segments.end_vid
where (fnode.int_id is not null AND tnode.int_id is not null)
)
-- segments with missing int_id
, missing_segment AS (
create table congestion.segments_centreline_routed_21_1_missing as

-- all segments with missing int_id info
WITH missing_segment AS (
select segment_id, start_vid, end_vid, fnode.int_id as start_int, tnode.int_id as end_int
from congestion.network_segments
left join congestion.network_int_px_21_1 fnode on fnode.node_id = network_segments.start_vid
Expand All @@ -16,19 +10,21 @@ WITH segment_info AS (
)
-- nodes with no int_id matches
, missing_int AS (

select node_id, int_id
from congestion.network_int_px_21_1
where int_id is null and node_id = 967857265
where int_id is null
)
-- finding segments that are connected to the node with no int_id matches
, matches AS (
select a1.segment_id as first_seg, a2.segment_id as sec_seg, a2.start_vid, a1.end_vid, a2.start_int, a1.end_int
from missing_int m
left join missing_segment a1 on m.node_id = a1.start_vid
left join missing_segment a2 on m.node_id = a2.end_vid
where a2.start_vid != a1.end_vid)

select ARRAY[first_seg, sec_seg], start_vid, end_vid, start_int, end_int,
array_agg(geo_id),
select ARRAY[first_seg, sec_seg] as segment_set, start_vid, end_vid, start_int, end_int,
array_agg(geo_id) as geo_id_set,
ST_linemerge(ST_union(a.geom)) as geom
from matches
CROSS JOIN LATERAL pgr_dijkstra('SELECT id, source::int, target::int, cost
Expand Down

0 comments on commit 55af6d1

Please sign in to comment.