Select to view content in your preferred language

feature.Store() label not updating when it's a polygon.. C#.net Arcgis Engine

913
5
10-09-2012 08:01 PM
TomaCasa
Occasional Contributor
Hi I'm using Arcgis Engine to create my geometry into one of my featureLayer's

IFeatureClass m_featureClass = featureLayer.FeatureClass;           
IFeature feature = m_featureClass.CreateFeature();
feature.Shape = geometry;   //  this is an IGeometry
feature.Store();


that works fine for Point and Line Class, and the labels update perfectly in the map, but when writing a Polygon
the feature stores and displays, but however is missing the Label...
am i missing something special I should be doing for the Polygon's ?

I tried to turn on and off labels in ArcMap in the mxd.. but the labels are still not showing up for those specific Polygon's I draw with my arcGIS engine tool....

I've also tried starting an Edit Session, and stopping an Edit Session when storing the feature (makes no difference)... and i've tried refresh(), partialRefresh(), and Invalidate() to get them to draw...

any help would be greatly appreciated 🙂

Tomas
0 Kudos
5 Replies
NeilClemmons
Honored Contributor
What are your labels based on?  For example, if you have labels turned on for a layer and your label field is set to "SomeField" then you will need to assign a value to "SomeField" when creating the feature.  Otherwise, the field will be null and no label will be generated for that feature.
0 Kudos
TomaCasa
Occasional Contributor
ok i've figured out whats happening... the polygon that is drawn in a "left hand" direction gives a 'negative' Area
and in return won't label... i.e. something funny is happening
how do I reverse the area if a user draws in a reverse direction ? (basically inverting it???)
0 Kudos
ChrisWelch
Emerging Contributor
Can you try something like:

ESRI.Geometry.ICurve pCurve = (ICurve) geometry;
pCurve.ReverseOrientation();
feature.shape = (IGeometry) pCurve;


Just a thought. I'm not sure if it will work, but it might get you closer.
0 Kudos
TomaCasa
Occasional Contributor
my solution:

      
     
            IArea pArea = (IArea)m_poly;

            //because labels don't show on anti-clockwise drawn polygons (negative area)
            //check the area and then reverse the order of points if it is negative..

            if (pArea.Area < 0)
     {
                ESRI.ArcGIS.Geometry.Polygon m_poly_reverse = new PolygonClass();

                m_poly_reverse.AddPoint(m_poly.Point[0]);

                for (int i = 1; i < m_poly.PointCount; i++)
                {
                    m_poly_reverse.AddPoint(m_poly.Point[m_poly.PointCount-1-i]);
                }
            }
0 Kudos
NeilClemmons
Honored Contributor
An easier way to do this is to call IPolygon.ReverseOrientation on the polygon geometry.
0 Kudos