[mapguide-internals] PATCH: fix for the cut-off labels problem

Martin Miller (Consultant) Martin.Miller at autodesk.com
Mon Sep 10 18:21:03 EDT 2007


For polygons that span at least 3 tiles in either the horizontal or vertical direction, the code attempts to cover them with labels by placing them in regular intervals, one label each1.5 tiles in both the X and Y directions.
 
An offset is applied in the X direction to every second row of labels (I guess to enhance the appearance of the spacing).
However, before placing the labels a check is made to "reject labels that are far outside the current tile and also make sure the point is inside the polygon". When a label falls on a tile border, that label position may be an odd number in the sequence of tested labels for one tile, but an even number in the sequence of tested labels for the neighboring tile, resulting in the offset being applied only to one of them and thus one part of the label being shifted by the offset from the other part. When a number of tiles are displayed together (as is usually the case), it looks like the labels that fall on the (invisible) tile boundary are cut off.
 
I have applied and tested a simple fix - disabling the offset of every second row of labels.
 
Comment out line 264:
  offset = !offset;
in LabelRendererLocal::ProcessLabelGroup() in file Common\Stylization\LabelRendererLocal.cpp
 
Note that this is just a simple fix to disable the alternating X-offset. 
If we do need the 'enhanced spacing' - which applies the offset to every other row of labels, the code will need to be enhanced to ensure that the offset is the same for each part of an actual placement of the label.
 


More information about the mapguide-internals mailing list