Add usage_count to map layer obs_roads

This commit is contained in:
Paul Bienkowski 2022-03-16 22:05:58 +01:00
parent 9a1c412597
commit 85fcdea403
2 changed files with 5 additions and 0 deletions

View file

@ -8,6 +8,7 @@ RETURNS TABLE(
distance_overtaker_median float, distance_overtaker_median float,
distance_overtaker_array float[], distance_overtaker_array float[],
overtaking_event_count int, overtaking_event_count int,
usage_count bigint,
direction int, direction int,
offset_direction int offset_direction int
) AS $$ ) AS $$
@ -21,6 +22,7 @@ RETURNS TABLE(
PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY distance_overtaker) as distance_overtaker_median, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY distance_overtaker) as distance_overtaker_median,
array_agg(distance_overtaker) as distance_overtaker_array, array_agg(distance_overtaker) as distance_overtaker_array,
count(overtaking_event.id)::int as distance_overtaker_count, count(overtaking_event.id)::int as distance_overtaker_count,
(select count(id) from road_usage where road_usage.way_id = road.way_id) as usage_count,
r.dir as direction, r.dir as direction,
case when road.directionality = 0 then r.dir else 0 end as offset_direction case when road.directionality = 0 then r.dir else 0 end as offset_direction
FROM road FROM road

View file

@ -16,6 +16,8 @@ layer:
All overtaker distance values in meters. All overtaker distance values in meters.
overtaking_event_count: | overtaking_event_count: |
Number of overtaking events. Number of overtaking events.
usage_count: |
Number of times the road was traveled on.
direction: | direction: |
Contains -1 for events while going along the way backwards, 1 for Contains -1 for events while going along the way backwards, 1 for
forwards. Each road is emitted twice, if it has data for both directions, forwards. Each road is emitted twice, if it has data for both directions,
@ -40,6 +42,7 @@ layer:
distance_overtaker_median, distance_overtaker_median,
distance_overtaker_array, distance_overtaker_array,
overtaking_event_count, overtaking_event_count,
usage_count,
direction, direction,
offset_direction offset_direction
FROM layer_obs_roads(!bbox!, z(!scale_denominator!)) FROM layer_obs_roads(!bbox!, z(!scale_denominator!))