I need to be able to merge features on the condition that the selected features are adjacent to each other.
How can I achieve this using Open Layers version 5?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
You can select the geometries on front end using openlayers and then write a postgres query to check if they intersect with each other by using ST_Intersects and apply ST_UNION if the intersects is true. This works if the backend is postgres. If you use any other DB, use appropriate spatial queries and return the result to front-end for providing appropriate user information
turf.js#intersect method you can find out if two features share a border.
from their docs:
Takes two polygons and finds their intersection. If they share a border, returns the border; if they don't intersect, returns undefined.
Using this, you can convert open layer features to
turf.js#polygonand feed them to the
intersect method. If the return value is not
null, the items are adjacent (share a border) or intersect.
However this will not distinguish between whether they intersect or just share a border.