I have this query, which works well, for an OSM database:
SELECT row_to_json(fc)
FROM (
SELECT ST_AsGeoJSON(ST_Transform(ST_Intersection(lg.geometry, bbox.geom), 4326))::json As geometry,
(
SELECT row_to_json(t)
FROM (
SELECT name, type, admin_level
) t
)
As properties
FROM
osm_admin As lg,
(SELECT ST_Transform(ST_MakeEnvelope(10.735445022583008, 59.913428634991995,
10.776472091674805, 59.933989460416115, 4326),3857) as geom) as bbox
WHERE ST_Intersects(lg.geometry, bbox.geom)
) fc;
I'd like to filter this generic query a bit, depending on the zoom level. E.g. I'd like to add filter for zoom level WHERE admin_level < 4
. I also need to add other filters for other queries, based on this template (where admin_level
is a property of the osm_admin
table).
Where can I insert such a WHERE
clause?
WHERE ST_Intersects(lg.geometry, bbox.geom) AND admin_level < 4
?...) fc WHERE admin_level < 4;