Using the draw polygon, the isSelfIntersecting bool is only true after vertex-add but not draw-complete

242
3
Jump to solution
05-25-2022 01:48 PM
dogWater73
New Contributor II

Using the draw polygon (PolygonDrawAction), the isSelfIntersecting bool is only true after vertex-add but not draw-complete.  So if I draw a polygon and create a self intersecting polygon, if I just double click ie draw-complete event the  isSelfIntersecting bool stays false.  I need to add a vertex ie vertex-add after I draw a self intersecting polygon and then double click to draw complete and then the isSelfIntersecting bool is set to true.  so my question is there a way to force a vertex-add at the draw-complete location or do I need to evaluate the vertices and find the self intersecting geometry manually by evaluating the vertices?

dogWater73_1-1653674066862.png

 

dogWater73_0-1653674040914.png

 

0 Kudos
1 Solution

Accepted Solutions
dogWater73
New Contributor II

OK so I just check to see if the polygon isSimple  on draw complete and it is not .isSelfIntersecting.

 

    // function that checks if the polygon intersects itself
    public isSelfIntersecting = (polygon) => {
        // The quickest way to see if the poly is selfintersecting with out the esri .isSelfIntersecting bool is to check to see if the poly is simple
        const isSimplePoly = polygon.geometry as __esri.Polygon; // Avoids TypeScript errors when building the app
        if (this.esriLibrary.GeometryEngine.isSimple(isSimplePoly)) {
            return true; // Return true if the Polygon is Simple
        } else {
            return false; //Return false if it is not simple
        }
    };

View solution in original post

0 Kudos
3 Replies
JoelBennett
Occasional Contributor III

From your description, this appears to be a bug, but you shouldn't necessarily have to go through the effort of manually checking the vertices yourself.  One possible workaround may be to clone the polygon, and check the property of the cloned object.  Another workaround may be to call one or both of the following on the original geometry:

geometry.notifyChange("rings");
geometry.notifyChange("isSelfIntersecting");

 

0 Kudos
dogWater73
New Contributor II

the clone is still identified as isSelfIntersecting: false

I will keep looking into your suggestions. Thank you!

dogWater73_0-1654010264046.png

 

0 Kudos
dogWater73
New Contributor II

OK so I just check to see if the polygon isSimple  on draw complete and it is not .isSelfIntersecting.

 

    // function that checks if the polygon intersects itself
    public isSelfIntersecting = (polygon) => {
        // The quickest way to see if the poly is selfintersecting with out the esri .isSelfIntersecting bool is to check to see if the poly is simple
        const isSimplePoly = polygon.geometry as __esri.Polygon; // Avoids TypeScript errors when building the app
        if (this.esriLibrary.GeometryEngine.isSimple(isSimplePoly)) {
            return true; // Return true if the Polygon is Simple
        } else {
            return false; //Return false if it is not simple
        }
    };
0 Kudos