[mapserver-commits] r7958 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Sun Oct 5 04:03:13 EDT 2008


Author: tbonfort
Date: 2008-10-05 04:03:12 -0400 (Sun, 05 Oct 2008)
New Revision: 7958

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/maputil.c
Log:
fix some integer rounding errors in the agg line offseter (#2659)


Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2008-10-04 15:45:36 UTC (rev 7957)
+++ trunk/mapserver/HISTORY.TXT	2008-10-05 08:03:12 UTC (rev 7958)
@@ -11,6 +11,8 @@
 
 Current Version (5.3-dev, SVN trunk):
 ------------------------------------
+- fix some integer rounding errors in the agg line offseter (#2659)
+
 - fix a bug with shapes with duplicate end points. was causing nans
   in the angle follow placement code (#2695)
 

Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c	2008-10-04 15:45:36 UTC (rev 7957)
+++ trunk/mapserver/maputil.c	2008-10-05 08:03:12 UTC (rev 7958)
@@ -1472,7 +1472,7 @@
 
 shapeObj* msOffsetPolyline(shapeObj *p, int offsetx, int offsety) {
     int i, j, first,idx;
-    int ox=0, oy=0, limit;
+    double ox=0, oy=0, limit;
     double dx,dy,dx0=0, dy0=0,x, y, x0=0.0, y0=0.0, k=0.0, k0=0.0, q=0.0, q0=0.0;
     float par=(float)0.71;
     shapeObj *ret = (shapeObj*)malloc(sizeof(shapeObj));
@@ -1500,15 +1500,15 @@
                     }
                     ox=(dy>0) ? -offsetx : offsetx;
                 } else {
-                    k = (double)dy/(double)dx;
+                    k = dy/dx;
                     if(MS_ABS(k)<0.5) {
                         oy = (dx>0) ? offsetx : -offsetx;
                     } else {
                         if (MS_ABS(k)<2.1) {
-                            oy = (int) ((dx>0) ? offsetx*par : -offsetx*par);
-                            ox = (int) ((dy>0) ? -offsetx*par : offsetx*par);
+                            oy = (dx>0) ? offsetx*par : -offsetx*par;
+                            ox = (dy>0) ? -offsetx*par : offsetx*par;
                         } else
-                            ox = (int)((dy>0) ? -offsetx : offsetx);
+                            ox = (dy>0) ? -offsetx : offsetx;
                     }
                     q = p->line[i].point[j-1].y+oy - k*(p->line[i].point[j-1].x+ox);
                 }



More information about the mapserver-commits mailing list