I have a PostGIS database of polygons representing regions in a 2D space and I'm trying to find a way to generate the closest square of a given size to a given region that doesn't intersect with any of the existing regions. The size of the square is known in advance, its specific orientation doesn't matter, and all the relevant geometries are polygons. To make it more concrete, the regions in question represent search areas for an autonomous vehicle.
What I'm trying to do is identify a safe area for that vehicle to wait after searching a given region that doesn't interfere with any of the other regions or the region it just searched so that all of those regions are free to be searched by other vehicles.
I'm new to PostGIS, so this may just be a problem of not knowing the right search terms to find the correct built-in function. Obviously, I could generate the desired square with a center gradually further and further away and check for intersections until I find one that doesn't intersect, but I'm hoping there is a more efficient way.
ST_MaximumInscribedCircle(PG 3.1.0), and (K)NN search the closest one having a radius equal or greater than the squares diagonale. This assumes a more or less static regions data set, or a thorough automated pre-processing step. – geozelot Aug 12 '21 at 07:52