14.7.2023
Selecting (geo)json from postgis
Postgis does not support selecting feature collections, thus I had to build one on my own. This is the resulting query I used:
SELECT json_build_object(
'type', 'FeatureCollection',
'properties', json_build_object(),
'features', json_agg(st_asgeojson(field.geometry)::json)
)
FROM field
WHERE farm_id = 'XYZ';
Useful postgis functions here are json_build_object()
which creates a new object and json_agg()
which creates a new array.
Other json operations can be found in the postgres documentation.
Standort Hannover
newcubator GmbH
Bödekerstraße 22
30161 Hannover
Standort Dortmund
newcubator GmbH
Westenhellweg 85-89
44137 Dortmund