Home arrow GIS Data & Resources arrow Scripts and Code arrow C# Code arrow C# - Digitizing user defined shape to web ADF polygon gotcha
C# - Digitizing user defined shape to web ADF polygon gotcha PDF Print E-mail

Written by Steve Gourley,


I've been using the same method CreatePolygonFromPolygonEventArgs for about 2 years to take user drawn shapes and turn them into web adf polygons.  Everything has been running fine from storing the shape in SDE to adding the shape to a graphics layer and displaying it - until today. 

I was using the method to get a web adf polygon, then converting it to an igeometry to be able to use the itopological operator to do some unioning and intersecting.  When testing the intersection method, I was getting some crazy results.  Keep in mind that positive polygon verticies are stored in a clockwise fashion.  Counter-clockwise vertices indicate negative geometry or a hole.

The first sign that something was wrong was that I was getting negative area on the intersected shape.  I slapped the Math.abs bandaid on that and kept on going.  Then, the intersect method was giving me not the intersected geometry but the inverse of the intersected geometry.  This is where things got funky.  There was no good bandaid to throw on this one so I had to look a little deeper.  

Turns out that when testing depending on which direction the user digitized their shape, clockwise or counter clockwise, the results would differ.  Ok, so the error is in the creation of the web adf polygon.  Then I stumbled across the web adf polygon method CorrectSegmentOrientation.  This makes the positive geometry rings become clockwise and negative geometry rings counter clockwise. 

If you're working with the IPolygon objects or anything that inherits from ICurve there is also the ReverseOrientation method which could be used.

It's a bit odd it took this long to find this error but thanks to the itopologicaloperator.intersect method it has now been remedied and I hope you can benefit from my error.



Users' Comments  
 

No comment posted

Add your comment

23, Apr. 2009
Last Updated ( 23, Apr. 2009 )
 
< Prev   Next >

AGRC Contacts | UGIC Contacts

feed image feed image

Utah GIS Portal © 2010 AGRC

Optimized for