[OpenLayers-Commits] r5649 - sandbox/topp/nymap/lib/OpenLayers/Geometry

commits at openlayers.org commits at openlayers.org
Fri Jan 4 11:29:20 EST 2008


Author: tcoulter
Date: 2008-01-04 11:29:20 -0500 (Fri, 04 Jan 2008)
New Revision: 5649

Modified:
   sandbox/topp/nymap/lib/OpenLayers/Geometry/LinearRing.js
Log:
Applied tschaub's patch from here to remove a blink: http://trac.openlayers.org/attachment/ticket/1245/thirteen.patch

Modified: sandbox/topp/nymap/lib/OpenLayers/Geometry/LinearRing.js
===================================================================
--- sandbox/topp/nymap/lib/OpenLayers/Geometry/LinearRing.js	2008-01-03 11:30:39 UTC (rev 5648)
+++ sandbox/topp/nymap/lib/OpenLayers/Geometry/LinearRing.js	2008-01-04 16:29:20 UTC (rev 5649)
@@ -212,8 +212,10 @@
      *     the point is coincident with an edge.  Returns boolean otherwise.
      */
     containsPoint: function(point) {
-        var px = point.x;
-        var py = point.y;
+        var approx = OpenLayers.Number.limitSigDigs;
+        var digs = 14;
+        var px = approx(point.x, digs);
+        var py = approx(point.y, digs);
         function getX(y, x1, y1, x2, y2) {
             return (((x1 - x2) * y) + ((x2 * y1) - (x1 * y2))) / (y1 - y2);
         }
@@ -222,11 +224,11 @@
         var crosses = 0;
         for(var i=0; i<numSeg; ++i) {
             start = this.components[i];
-            x1 = start.x;
-            y1 = start.y;
+            x1 = approx(start.x, digs);
+            y1 = approx(start.y, digs);
             end = this.components[i + 1];
-            x2 = end.x;
-            y2 = end.y;
+            x2 = approx(end.x, digs);
+            y2 = approx(end.y, digs);
             
             /**
              * The following conditions enforce five edge-crossing rules:
@@ -253,7 +255,7 @@
                 // ignore other horizontal edges
                 continue;
             }
-            cx = getX(py, x1, y1, x2, y2);
+            cx = approx(getX(py, x1, y1, x2, y2), digs);
             if(cx == px) {
                 // point on line
                 if(y1 < y2 && (py >= y1 && py <= y2) || // upward
@@ -267,7 +269,7 @@
                 // no crossing to the right
                 continue;
             }
-            if(cx < Math.min(x1, x2) || cx > Math.max(x1, x2)) {
+            if(x1 != x2 && (cx < Math.min(x1, x2) || cx > Math.max(x1, x2))) {
                 // no crossing
                 continue;
             }



More information about the Commits mailing list