1

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();
    }
    }               
    });

1 Answer 1

1

Sorry, solved my own question again. Seems to happen every time I make the decision to post. Anyway, adding this line of code below the draw.deactivate(); solved the problem.

   farmpaddocks.removeFeatures(e.feature);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.