[mapguide-commits] r5569 - trunk/MgDev/Common/Stylization

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Feb 28 02:20:29 EST 2011


Author: aleck
Date: 2011-02-27 23:20:29 -0800 (Sun, 27 Feb 2011)
New Revision: 5569

Modified:
   trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp
Log:
Fix Ticket 1607

This is an edge case that if a composite style contains only labels, it is not rendered correctly. All the labels are draws in the bottom-left corner.

This happens because when laying out the labels using eight-surrounding algorithm, it calls GetLastSymbolExtent to get the corresponding symbol extent as the base coordinate. However, in the case that this composite type style contains only labels, this LastSymbolExtent was never set. Thus, it'll use (0,0) as base coordinate of the algorithm while it should use the centroid of the geometry.

So I made this change that it'll check the returned value of GetLastSymbolExtent. if this value is zero, we'll use the centroid of the geometry instead.

Modified: trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp	2011-02-26 16:50:39 UTC (rev 5568)
+++ trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp	2011-02-28 07:20:29 UTC (rev 5569)
@@ -214,7 +214,19 @@
     // TODO: remove this assumption
     const RS_F_Point* cfpts = se_renderer->GetLastSymbolExtent();
     RS_F_Point fpts[4];
-    memcpy(fpts, cfpts, 4*sizeof(RS_F_Point));
+    if(cfpts[0].x == 0 && cfpts[0].y == 0 &&
+        cfpts[1].x == 0 && cfpts[1].y == 0 &&
+        cfpts[2].x == 0 && cfpts[2].y == 0 &&
+        cfpts[3].x == 0 && cfpts[3].y == 0)
+    {
+        for (int i=0; i<4; ++i)
+        {
+            fpts[i].x = cx;
+            fpts[i].y = cy;
+        }
+    }
+    else
+        memcpy(fpts, cfpts, 4*sizeof(RS_F_Point));
 
     double dx = fpts[1].x - fpts[0].x;
     double dy = fpts[1].y - fpts[0].y;



More information about the mapguide-commits mailing list