I need a spatial function to detect given polygon is overlapping with existing polygons in the database.
I tried to use ST_Intersects(). It returns true if polygons touch each other. But In my case touching i okay. I also tried ST_Overlaps(). This one returns false if 2 polygons same or contain one another. which is unacceptable.
Currently I'm using SELECT COUNT(f) > 0 FROM fences f WHERE GeometryType(ST_INTERSECTION(f.region, :region)) = 'POLYGON'
But this looks like can't use rtree indexes.
Is there a better way to detect polygons overlapping?