2 problems with labels

Feb 12, 2009 at 3:23 PM
Hello,
I'm a beginner and I'm testing a lot of functions.
Now I have 2 problems with labels:
- When I zoom with the mouse wheel, the labels do not scale (like symbols by the way). This is ugly when the map is zoomed out. Is there any way to change this behavior ?
- The label is in the center of the polygon. but some polygons are like a C, and the center is not in the polygon, but in the other at the right side. Is it possible to have it always in ?

Thanks
Coordinator
Feb 13, 2009 at 9:18 AM
Edited Feb 13, 2009 at 9:19 AM
Hi Riccardo, the labels aren't scaled in 0.9, however there is collision detection which aims to remove overlapping labels based on their importance. Have a look at the LabelFilter property of the LableLayer class, by default it uses simple collision detection. You can change it to ThoroughCollisionDetection by delegating to the appropriate method of the LabelCollisionDetection class (or you can create your own algorithm if you like). To solve the 'C' shaped polygon issue you will have to either create a new dataset of proposed label points where you ensure that each point is inside the associated polygon or modify the CreateLabel method of the LabelLayer hth jd
Feb 13, 2009 at 1:15 PM
Hi
Thanks for the info.
About labels scaling, I've seen the workaround with collision detection. That's all right for me.
About the centroid, I would have a suggestion to do in the code in CreateLabel
if you change :
System.Drawing.PointF position = map.WorldToImage(feature.GetBoundingBox().GetCentroid());
into :
  System.Drawing.PointF position = map.WorldToImage(feature.GetCentroid());
adding this method to Geometry if possible. 
And then you can imagin any method to get the centroid, including boundingbox.centroid().

I don't have the time to write this function right now, but I understand how I can do it.
Thanks a lot.

Coordinator
Feb 13, 2009 at 2:11 PM
Edited Feb 13, 2009 at 2:16 PM
Hi Riccardo, Polygon geometries have a property centroid (which in turn gets the centroid of the bounding box as the geometry model is very simple) however lines and points do not have a centroid, which is why the current renderer uses the bounding box centroid.. hth jd
Feb 15, 2009 at 9:19 AM
Well I understand what you mean. I'm currently comparing products for the professionnal needs of my customer : within others , SharpMap and MapSuite (thinkgeo). They both provide the tools I need and they are both quality software. Of course they are compared in the respect of their license.
I'm not going to list all things I find in one product and complain that it is not in the other. I rather would like to help as much as I can. I have found some little particular points that would need some fixing in SharpMap, not compared to MapSuite but in general for the user community.

1) the center is not always in the polygon, which can be a problem
2) when in pan mode, clicking in the map will shift it in the direction given by the vector [mouseclic ; centermap], which can be surprising
3) there is no way to generate the legend automatically, which give more work to developers

For the first 2 points I don't think it is very difficult to implement, and I would love to do it, but unfortunately I'm not at all a .Net developer, I don't know at all SharpMap structures, and I have very few time these days. 
For the third point, I'm not expecting anything since it must be a big job, and anyway (or unfortunately) few editors pay attention to this absolutely necessary function : legend.

My english is not fluent enough to express all my thoughts with the correct emotional texture, but please consider my remarks as a positive an enthousiastics motivation, and thanks again to provide such a good peice of software.