2021-10-10 10:32:28 +00:00
|
|
|
CREATE OR REPLACE FUNCTION layer_obs_events(bbox geometry, zoom_level int)
|
|
|
|
RETURNS TABLE(event_id bigint, geometry geometry, distance_overtaker float, distance_stationary float, direction int, course float, speed float, way_id bigint) AS $$
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
id::bigint as event_id,
|
|
|
|
ST_Transform(overtaking_event.geometry, 3857) as geometry,
|
|
|
|
distance_overtaker,
|
|
|
|
distance_stationary,
|
|
|
|
(case when direction_reversed then -1 else 1 end)::int as direction,
|
|
|
|
course,
|
|
|
|
speed,
|
|
|
|
way_id::bigint as way_id
|
|
|
|
FROM overtaking_event
|
2022-04-03 14:06:34 +00:00
|
|
|
WHERE
|
|
|
|
zoom_level >= 10 AND
|
|
|
|
ST_Transform(overtaking_event.geometry, 3857) && bbox;
|
2021-10-10 10:32:28 +00:00
|
|
|
|
|
|
|
$$ LANGUAGE SQL IMMUTABLE;
|