2

I have a number of blocks that are lying next to each other in all directions.

enter image description here

So, the user can select individual and multiple blocks. There is a "must" requirement to select multiple blocks:

block have to touch each other by their walls, like this:

enter image description here

this is ok, but these are not okay, enter image description here enter image description here

because some blocks touch only by edges. So, I have been using the st_numgeometries(st_union(geom)) and when it return 1 it is okay, otherwise not. However, for the selection (the user selected all blocks) enter image description here

I am getting multi polygon which contains two polygons,

enter image description here

How should look like my query to get 1 (so they should be ok with this kind of selection)?

  • 1
    This sounds to me like you rather want to implement an on-click check based on row & column cell indices on the frontend - that way you could easily provide live info on, and check overall, validity before issuing any queries. – geozelot Feb 21 '23 at 14:55
  • @geozelot how can I implement that? using openlayers? – Manap Shymyr Feb 21 '23 at 15:04
  • 2
    looks like a rounding issue - try snapping to a fixed precision grid – Ian Turton Feb 21 '23 at 16:22
  • Well, the actual logic would be plain JavaScript - two objects, one holding valid cell ids, one holding invalid cell ids and for each feature selection, check both maps for adjacent cells (by row_index +- 1 or column_index +- 1), then update the maps if needed (valid to invalid or vice versa). – geozelot Feb 21 '23 at 17:54
  • seems to be too complex – Manap Shymyr Feb 21 '23 at 20:58
  • @IanTurton can you give more details, pls? – Manap Shymyr Feb 21 '23 at 20:58
  • see https://gis.stackexchange.com/questions/165421/some-geometries-dont-work-with-st-union-and-gives-a-non-noded-intersection – Ian Turton Feb 22 '23 at 08:32

0 Answers0