I can currently identify if a polygon is invalid through wps as per below code. What I want to know is how to remove the last sketch polygon if it returns invalid?
To give you an idea, here is the code that is run on "sketchcomplete".
farmpaddocks.events.on({
sketchcomplete: function (e) {
var poly = e.feature.geometry;//var of sketch geom
//check if geom valid through wps
wpsClient.execute({
server: 'local', //from server address
process: 'JTS:isValid', //wps function
inputs: {
geom: poly //geom input for testing if valid
},
success: function(outputs) {
//on completion of testing check if false = invalid geom
if(outputs.result==false){
$('#noti').append("Invalid Polygon").show(1000);
$('#noti').css("color", "red");
$('#noti').fadeOut(5000);
draw.deactivate();
}
}
});