I have a polygon and I would like to find all polygons from the table planet_osm_polygon
which my polygon lies in or touches. I tried to use st_intersects
function but it doesn't work as I would expect. See my command below..
WITH bbox AS
(SELECT st_transform(st_makeenvelope(9.3183939, 48.8282700, 9.5182078, 48.9375419, 4326), 3857) AS geom)
SELECT p.*
FROM
(SELECT * FROM planet_osm_polygon WHERE boundary IS NOT NULL AND admin_level IS NOT NULL) p,
bbox b
WHERE st_intersects(p.way, b.geom);
It seems that by my query I receive only polygons which are crossing my bbox
(see image below) however I would need to receive also polygons which are not just crossing my bbox
but also polygons which are completely around my bbox
.
bbox
lies in -> this country is not on the image but you can imagine it as a bit polygon which is around of all of selected polygons.