How to detect the self-intersection of one polygon after drawing(mapwingis))

that’s easy: to detect, if you digitize a hole in a polygon or an island it was defined that the right side of a drawn line is considered INSIDE, while left is OUTSIDE. With this definition the determination if island or hole is easy.
but that means also, that a single polygon without a hole has to be digitized in the way, an island has to be digitized.
It’s just a standard, - so to say.

Thanks for your reply! I had installed the QGIS, a wonderful software! I used the QGIS to check validity (polygon–anticlockwise created by my program), the result as the below picture:


From the QGIS result, I think it is valid. But my program debug code show: isvalid is false .IsValidReason is “Polygon must be clockwise”. So I think I’m a little confused. :face_with_spiral_eyes:

It think QGis is not checking for the order (clockwise or not).
MapWinGIS is a bit more strict about this.

You can use Shape.PartIsClockWise() to test your part and use Shape.ReversePointsOrder() to reverse if necessary.

A polygon shape may have several parts. An example of this would be a doughnut shape. The outermost perimeter would be one part, and the hole cut out of the center making up the innermost perimeter would be the second part. The outermost perimeter would be specified by a series of points arranged in clockwise order, meaning that this part will be filled. The innermost perimeter would be specified by a series of points arranged in counter-clockwise order, meaning that this part will not be filled.
When you have two parts in clockwise order those will both be filled. An example would be the state of Hawaii which has multiple islands.

Thanks :grin: I understand your mean. But I was confused whether the return (polygon is valid or not) makes sense or not when no hole(s) in the created polygon. When I draw one polygon without holes (clockwise or anticlockwise) by mapwingis program, the polygon was possibility open and operated by other GIS softwares, whether the order affects the further operation.

Thanks Jerry, pmeems, and Stefan for your enthusiasm. The question on the polygon valid had been solved. I think the question can be closed. Other issues, I will learn more about through the internet.

Thanks Jerry, pmeems, and Stefan for your enthusiasm. The question on the polygon valid had been solved. I think the question can be closed. Other issues, I will learn more about through the internet.