From 85fcdea4032d379b1acc709e6586aa310c58f479 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Wed, 16 Mar 2022 22:05:58 +0100 Subject: [PATCH] Add usage_count to map layer obs_roads --- tile-generator/layers/obs_roads/layer.sql | 2 ++ tile-generator/layers/obs_roads/obs_roads.yaml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/tile-generator/layers/obs_roads/layer.sql b/tile-generator/layers/obs_roads/layer.sql index 85f700a..75dbf97 100644 --- a/tile-generator/layers/obs_roads/layer.sql +++ b/tile-generator/layers/obs_roads/layer.sql @@ -8,6 +8,7 @@ RETURNS TABLE( distance_overtaker_median float, distance_overtaker_array float[], overtaking_event_count int, + usage_count bigint, direction int, offset_direction int ) AS $$ @@ -21,6 +22,7 @@ RETURNS TABLE( PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY distance_overtaker) as distance_overtaker_median, array_agg(distance_overtaker) as distance_overtaker_array, 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, case when road.directionality = 0 then r.dir else 0 end as offset_direction FROM road diff --git a/tile-generator/layers/obs_roads/obs_roads.yaml b/tile-generator/layers/obs_roads/obs_roads.yaml index 27ecf73..b246eb4 100644 --- a/tile-generator/layers/obs_roads/obs_roads.yaml +++ b/tile-generator/layers/obs_roads/obs_roads.yaml @@ -16,6 +16,8 @@ layer: All overtaker distance values in meters. overtaking_event_count: | Number of overtaking events. + usage_count: | + Number of times the road was traveled on. direction: | 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, @@ -40,6 +42,7 @@ layer: distance_overtaker_median, distance_overtaker_array, overtaking_event_count, + usage_count, direction, offset_direction FROM layer_obs_roads(!bbox!, z(!scale_denominator!))