I'm currently creating a map in Openlayers for a customer that requires validation for drawing polygons inside another polygon (base-area). By using JSTS and Openlayers native methods, i'm able to validate that all shapes are drawn inside the polygon, and do not intersect with other shapes inside the polygon. This includes markers and polygons.
Another requirement is to check if the base-area is completely filled by other polygons, with pre-defined margins. I've not been able to think of any way to do this yet. What would be a good way to accomplish this?
EDIT:
Methods i used to check if polygon contains other polygon:
const geoJSONFormat = new GeoJSON();
const jstsGeoJSONReader = new jsts.io.GeoJSONReader();`
polygon1 = jstsGeoJSONReader.read(geoJSONFormat.writeFeatureObject(feature1)).geometry;
polygon2 = jstsGeoJSONReader.read(geoJSONFormat.writeFeatureObject(feature2)).geometry;
polygon1ContainsPolygon2= polygon1.contains(polygon2); `
First i pass the given feature the geoJSONFormat.writeFeatureObject which is imported from OL. And then assign this to a variable using the JSTS GeoJSON-reader.
contains
-method from JSTS will return a boolean indicating if polygon2 is contained inside polygon1