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

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Mar 14 12:50:32 EDT 2007


Author: traianstanev
Date: 2007-03-14 12:50:32 -0400 (Wed, 14 Mar 2007)
New Revision: 1222

Modified:
   trunk/MgDev/Common/Stylization/SE_Renderer.cpp
   trunk/MgDev/Common/Stylization/StylizationEngine.cpp
Log:
Workaround for some bugs in bounds union / convex hull computations. The bugs were causing crashes in a layer which tests simple highway shields by overlaying a text onto an image to make the shield symbol.

Modified: trunk/MgDev/Common/Stylization/SE_Renderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2007-03-14 16:42:43 UTC (rev 1221)
+++ trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2007-03-14 16:50:32 UTC (rev 1222)
@@ -103,7 +103,8 @@
             //single segment to the symbol repeat
             double len = lb->points()[2] - lb->points()[0];
             
-            if (fabs(len - style->repeat) < 0.001) //repeat must be within 1/100 of a pixel for us to assume solid line
+            if (fabs(len - style->repeat) < 0.001) //repeat must be within 1/1000 of a pixel for us to assume solid line
+                                                   //this is only to avoid FP precision issues, in reality they would be exactly equal
             {
                 //ok, it's only a solid line, just draw it and bail out of the
                 //layout function

Modified: trunk/MgDev/Common/Stylization/StylizationEngine.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/StylizationEngine.cpp	2007-03-14 16:42:43 UTC (rev 1221)
+++ trunk/MgDev/Common/Stylization/StylizationEngine.cpp	2007-03-14 16:50:32 UTC (rev 1222)
@@ -463,7 +463,6 @@
                 rr->extent[1] = r->extent[1].evaluate(m_exec)*xform.y1;
                 rr->angle = r->angle.evaluate(m_exec) * M_PI180;
 
-                rr->bounds = m_pool->NewBounds(5);
                 SE_Matrix rxf;
                 rxf.rotate(rr->angle);
                 rxf.translate(rr->position[0], rr->position[1]);
@@ -472,15 +471,17 @@
                 double h = 0.5 * rr->extent[1];
                 double sx, sy, x, y;
 
-                rxf.transform(w, h, sx, sy); // upper right
-                rr->bounds->Add(sx, sy);
-                rxf.transform(w, -h, x, y);  // lower right
-                rr->bounds->Add(x, y);
-                rxf.transform(-w, -h, x, y); // lower left
-                rr->bounds->Add(x, y);
-                rxf.transform(-w, h, x, y);  // upper left
-                rr->bounds->Add(x, y);
-                rr->bounds->Add(sx, sy);     // upper right
+                RS_F_Point pts[4];
+                rxf.transform( w,  h, pts[0].x, pts[0].y);
+                rxf.transform( w, -h, pts[1].x, pts[1].y);
+                rxf.transform(-w, -h, pts[2].x, pts[2].y);
+                rxf.transform(-w,  h, pts[3].x, pts[3].y);
+                
+                std::sort((std::pair<double,double>*)pts, (std::pair<double,double>*)(pts + 3), PointLess( ));
+                rr->bounds = AndrewHull<std::pair<double,double>*,SimplePOINT>
+                    ((std::pair<double,double>*)pts, 
+                    ((std::pair<double,double>*)(pts+3)) - 1, 
+                    4, m_pool);
             }
             break;
 



More information about the mapguide-commits mailing list