ThinkGeo.com    |     Documentation    |     Premium Support

Label does not display on intersecting polygon

When we have an intersecting polygon, the label does not display. I am attaching a bitmap of the bad and good polygons. In addition, we also set the DefaultTextStyle properties as follows:


TextLineSegmentRatio = 1000

DuplicateRule = Unlimited

OverlappingRule = AllowOverlapping

SuppressPartialLabels = False

PointPlacement = LowerRight.


 


This time without the XML tags that your site is blocking :-)


For example, a polygon with the following vertices will not display its legend:


                SinglePointShape X="-96.564682448814963" Y="32.942703723280594" 

                SinglePointShape X="-96.564681108263386" Y="32.942703723280594" 

                SinglePointShape X="-96.564791033491943" Y="32.942770750858983"

                SinglePointShape X="-96.564933131958128" Y="32.942698361074321"

                SinglePointShape X="-96.564919726442454" Y="32.942768069755843"

                SinglePointShape X="-96.564682448814963" Y="32.942703723280594"


while a polygon with the following vertics will display its legend:


                SinglePointShape X="-80.059330656414033" Y="26.849625013561248"

                SinglePointShape X="-80.059408440475465" Y="26.849340699405669"

                SinglePointShape X="-80.059110715274812" Y="26.849311195106505"

                SinglePointShape X="-80.058952464942934" Y="26.849611602516173"

                SinglePointShape X="-80.059483542327882" Y="26.84944530555725"

                SinglePointShape X="-80.059330656414033" Y="26.849625013561248"

 


Your input is greatly appreciated.



Sorry, the copy and paste bug in the discussion forum editor wiped out some of my post. Here it is in its entirety: 
  
 When we have an intersecting polygon, the label does not display. I am attaching a bitmap of the bad and good polygons. In addition, we also set the DefaultTextStyle properties as follows: 
  
 TextLineSegmentRatio = 1000 
 DuplicateRule = Unlimited 
 OverlappingRule = AllowOverlapping 
 SuppressPartialLabels = False 
 PointPlacement = LowerRight. 
  
 For example, a polygon with the following vertices will not display its legend: 
  
                 <SinglePointShape X="-96.564682448814963" Y="32.942703723280594" /> 
  
                 <SinglePointShape X="-96.564681108263386" Y="32.942703723280594" /> 
  
                 <SinglePointShape X="-96.564791033491943" Y="32.942770750858983" /> 
  
                 <SinglePointShape X="-96.564933131958128" Y="32.942698361074321" /> 
  
                 <SinglePointShape X="-96.564919726442454" Y="32.942768069755843" /> 
  
                 <SinglePointShape X="-96.564682448814963" Y="32.942703723280594" /> 
  
 while a polygon with the following vertics will display its legend: 
  
                 <SinglePointShape X="-80.059330656414033" Y="26.849625013561248" /> 
  
                 <SinglePointShape X="-80.059408440475465" Y="26.849340699405669" /> 
  
                 <SinglePointShape X="-80.059110715274812" Y="26.849311195106505" /> 
  
                 <SinglePointShape X="-80.058952464942934" Y="26.849611602516173" /> 
  
                 <SinglePointShape X="-80.059483542327882" Y="26.84944530555725" /> 
  
                 <SinglePointShape X="-80.059330656414033" Y="26.849625013561248" /> 
  
  
  
 Your input is greatly appreciated. 


  
  
  
 For example, a polygon with the following vertices will not display its legend: 
  
                 <SinglePointShape X="-96.564682448814963" Y="32.942703723280594" /> 
  
                 <SinglePointShape X="-96.564681108263386" Y="32.942703723280594" /> 
  
                 <SinglePointShape X="-96.564791033491943" Y="32.942770750858983" /> 
  
                 <SinglePointShape X="-96.564933131958128" Y="32.942698361074321" /> 
  
                 <SinglePointShape X="-96.564919726442454" Y="32.942768069755843" /> 
  
                 <SinglePointShape X="-96.564682448814963" Y="32.942703723280594" /> 
  
 while a polygon with the following vertics will display its legend: 
  
                 <SinglePointShape X="-80.059330656414033" Y="26.849625013561248" /> 
  
                 <SinglePointShape X="-80.059408440475465" Y="26.849340699405669" /> 
  
                 <SinglePointShape X="-80.059110715274812" Y="26.849311195106505" /> 
  
                 <SinglePointShape X="-80.058952464942934" Y="26.849611602516173" /> 
  
                 <SinglePointShape X="-80.059483542327882" Y="26.84944530555725" /> 
  
                 <SinglePointShape X="-80.059330656414033" Y="26.849625013561248" /> 
 


This time without the XML tags that your site is blocking :-) 
  
 For example, a polygon with the following vertices will not display its legend: 
  
                 SinglePointShape X="-96.564682448814963" Y="32.942703723280594"  
                 SinglePointShape X="-96.564681108263386" Y="32.942703723280594"  
                 SinglePointShape X="-96.564791033491943" Y="32.942770750858983" 
                 SinglePointShape X="-96.564933131958128" Y="32.942698361074321" 
                 SinglePointShape X="-96.564919726442454" Y="32.942768069755843" 
                 SinglePointShape X="-96.564682448814963" Y="32.942703723280594" 
  
 while a polygon with the following vertics will display its legend: 
  
                 SinglePointShape X="-80.059330656414033" Y="26.849625013561248" 
                 SinglePointShape X="-80.059408440475465" Y="26.849340699405669" 
                 SinglePointShape X="-80.059110715274812" Y="26.849311195106505" 
                 SinglePointShape X="-80.058952464942934" Y="26.849611602516173" 
                 SinglePointShape X="-80.059483542327882" Y="26.84944530555725" 
                 SinglePointShape X="-80.059330656414033" Y="26.849625013561248" 


Gregory, 
  
   You can always attach a text file with the WKT version of the polygon for examples.  I just wanted to let you know.  Please respond to this so it stays on the radar for the other support people. 
  
 Happy Holidays 
  
 David

Thanks for the tip, David. I will keep that in mind the next time I need to send coordinates. 
  
 Concerning the circumstances preventing the label from displaying, I look forward to further feedback!

 


Gregory,
 
Thanks for your sample data!
 
This problem is caused by shape.GetCenterPoint(), we know the center point should be inside the bounding box of the shape, but the first polygon is not like this. You can try to test, first you get center point and then you compare the bounding box and center point , you will find that the center point is out of bounding box.
 
It’s a bug actually, but we can not fix it easily because internal we call the NTS method to get the center point of polygon.
 
So I have an workaround idea to fix this problem that corrects the center point by following code:
 
        private void ProcessBadPolygon(FeatureLayer layer, TextStyle textStyle, string textColumnName)
        {
            layer.Open();
            Collection<Feature> features = layer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
            layer.Close();

            foreach (Feature feature in features)
            {
                BaseShape shape = feature.GetShape();
                PointShape centerPoint = shape.GetCenterPoint();
                RectangleShape boundingBox = shape.GetBoundingBox();
                if (!boundingBox.Contains(centerPoint))
                {
                    centerPoint = boundingBox.GetCenterPoint();
                    textStyle.LabelPositions.Add(feature.Id, new WorldLabelingCandidate(textColumnName, centerPoint));
                }
            }
        }

 
Please let me know if you have more questions.
 
Thanks
 
James

We followed your suggestion and it works perfectly! One thing to add is that if your map is using a different projection than your layer you will have to convert from the layer projection to the map projection. Other than that it was flawless!

Gregory, 
  
 It’s great that you solve your problem. 
  
 Thanks for your more information. 
  
 James

Hello,


Does anyone know if there are plans to provide something similar to the ClipPolygonForLabling property in 3.0 that was available in 2.x?  That was an outstanding feature that allowed you to label polygons when their centroid was outside of the map extent with just one line of code.  Thanks,


Chad



You are right. The ClipPolygonForLabeling property was very handy in the way it would always label the polygon regardless of where you were zoomed in on the polygon. We have the logic for that and we need to implement that for 3.x. I don’t think it would take too much work. I added this topic to our Issue Tracker. I let the development team have the last word on that. Thank you.

I'm just bumping this to see where you're at with adding this capability.  Maybe I'm missing it, but I don't see it in the 4.0 API.  Thanks!


Chad



Chad, 
  
 I do not think we have added this feature in our public release. Sorry for the inconvenience now. 
  
 Thanks. 
  
 Yale