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

242
3
05-25-2022 01:48 PM
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?

1 Solution

Accepted Solutions
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
}
};
3 Replies
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");``````

New Contributor II

the clone is still identified as isSelfIntersecting: false

I will keep looking into your suggestions. Thank you!

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