Update public.logbook_update_geojson_fn formating

This commit is contained in:
xbgmsharp
2023-10-13 15:58:40 +02:00
parent 0697acb940
commit 3e70283221

View File

@@ -117,9 +117,9 @@ CREATE FUNCTION public.logbook_update_geojson_fn(IN _id integer, IN _start text,
metrics_geojson jsonb; metrics_geojson jsonb;
_map jsonb; _map jsonb;
begin begin
-- GeoJson Feature Logbook linestring -- GeoJson Feature Logbook linestring
SELECT SELECT
ST_AsGeoJSON(log.*) into log_geojson ST_AsGeoJSON(log.*) into log_geojson
FROM FROM
( select ( select
id,name, id,name,
@@ -134,11 +134,11 @@ CREATE FUNCTION public.logbook_update_geojson_fn(IN _id integer, IN _start text,
FROM api.logbook FROM api.logbook
WHERE id = _id WHERE id = _id
) AS log; ) AS log;
-- GeoJson Feature Metrics point -- GeoJson Feature Metrics point
SELECT SELECT
json_agg(ST_AsGeoJSON(t.*)::json) into metrics_geojson json_agg(ST_AsGeoJSON(t.*)::json) into metrics_geojson
FROM ( FROM (
( SELECT ( SELECT
time, time,
courseovergroundtrue, courseovergroundtrue,
speedoverground, speedoverground,
@@ -152,17 +152,17 @@ CREATE FUNCTION public.logbook_update_geojson_fn(IN _id integer, IN _start text,
AND time <= _end::TIMESTAMP WITHOUT TIME ZONE AND time <= _end::TIMESTAMP WITHOUT TIME ZONE
AND vessel_id = current_setting('vessel.id', false) AND vessel_id = current_setting('vessel.id', false)
ORDER BY m.time ASC ORDER BY m.time ASC
) )
) AS t; ) AS t;
-- Merge jsonb -- Merge jsonb
select log_geojson::jsonb || metrics_geojson::jsonb into _map; SELECT log_geojson::jsonb || metrics_geojson::jsonb into _map;
-- output -- output
SELECT SELECT
json_build_object( json_build_object(
'type', 'FeatureCollection', 'type', 'FeatureCollection',
'features', _map 'features', _map
) into _track_geojson; ) into _track_geojson;
END; END;
$logbook_geojson$ LANGUAGE plpgsql; $logbook_geojson$ LANGUAGE plpgsql;
-- Description -- Description