Scenario:
Several WMS layers with polygon features.
Objective:
Draw a polygon with OpenLayers and allow it only if doesn't not cut any features in WMS layer. It can contain the features as a whole though.
Possible solutions:
1) Send drawn geometry server side via AJAX and return a validation response.
select count(id) FROM wms_layer_1_table,
where ST_Intersects(<drawn geom>,the_geom)
and ST_Contains(<drawn geom>,the_geom)=false;
if above count is zero then the drawn polygon is valid.
2) I intend to send geometries of all WMS features as text(ie,. POLYGON((x y,x1 y1)) etc) to the client side when the application loads in the browser and on addition of new ones.
With this in mind, I would like to know if and how I could validate the drawn polygon with these geometries just with OpenLayers/Javascript alone?
Thanks.