Fix split roads for usage_count
This commit is contained in:
parent
6ef233a2a2
commit
36fd8c492c
|
@ -1,3 +1,5 @@
|
||||||
|
DROP FUNCTION IF EXISTS layer_obs_roads(geometry, int);
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION layer_obs_roads(bbox geometry, zoom_level int)
|
CREATE OR REPLACE FUNCTION layer_obs_roads(bbox geometry, zoom_level int)
|
||||||
RETURNS TABLE(
|
RETURNS TABLE(
|
||||||
way_id bigint,
|
way_id bigint,
|
||||||
|
@ -22,7 +24,8 @@ 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,
|
(select count(id) from road_usage where road_usage.way_id = road.way_id and
|
||||||
|
(road.directionality != 0 or road_usage.direction_reversed = r.rev)) 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
|
||||||
|
@ -30,6 +33,6 @@ RETURNS TABLE(
|
||||||
FULL OUTER JOIN overtaking_event ON (road.way_id = overtaking_event.way_id and (road.directionality != 0 or overtaking_event.direction_reversed = r.rev))
|
FULL OUTER JOIN overtaking_event ON (road.way_id = overtaking_event.way_id and (road.directionality != 0 or overtaking_event.direction_reversed = r.rev))
|
||||||
-- WHERE road.name = 'Merzhauser Straße'
|
-- WHERE road.name = 'Merzhauser Straße'
|
||||||
WHERE road.geometry && bbox
|
WHERE road.geometry && bbox
|
||||||
GROUP BY road.name, road.way_id, road.geometry, road.directionality, r.dir;
|
GROUP BY road.name, road.way_id, road.geometry, road.directionality, r.dir, r.rev;
|
||||||
|
|
||||||
$$ LANGUAGE SQL IMMUTABLE;
|
$$ LANGUAGE SQL IMMUTABLE;
|
||||||
|
|
Loading…
Reference in a new issue