diff --git a/lib/OpenLayers/Geometry/LinearRing.js b/lib/OpenLayers/Geometry/LinearRing.js index b6dfa1991b..409ecee690 100644 --- a/lib/OpenLayers/Geometry/LinearRing.js +++ b/lib/OpenLayers/Geometry/LinearRing.js @@ -212,8 +212,10 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class( * 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 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class( var crosses = 0; for(var i=0; i= y1 && py <= y2) || // upward @@ -267,7 +269,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class( // 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; } diff --git a/tests/data/geos_wkt_intersects.js b/tests/data/geos_wkt_intersects.js index 5ccb7dd05f..cdf6bf7d0f 100644 --- a/tests/data/geos_wkt_intersects.js +++ b/tests/data/geos_wkt_intersects.js @@ -488,5 +488,8 @@ var geos_test_data = [ {'wkt1':'MULTIPOINT (20 20,80 70,140 120,200 170)', 'wkt2':'MULTIPOINT (80 70,140 120)', result:true}, {'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (140 120,80 70)', result:true}, {'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (80 170,140 120,200 80)', result:true}, -{'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (80 170,140 120,200 80,80 70)', result:true} +{'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (80 170,140 120,200 80,80 70)', result:true}, +{'wkt1':'POLYGON((-8239529.462853361 4980952.065110421,-8224242.057199065 4980952.065110421,-8224242.057199064 4988844.188279452,-8239529.462853361 4988844.188279452,-8239529.462853361 4980952.065110421))', 'wkt2':'POINT(-8225445.94039435 4982695.78481786)', result:true}, +{'wkt1':'POLYGON((-8239529.462853361 4980952.065110421,-8224242.057199065 4980952.065110421,-8224242.057199064 4988844.188279452,-8239529.462853361 4988844.188279452,-8239529.462853361 4980952.065110421))', 'wkt2':'POINT(-8224242.0571985 4982695.78481786)', result:false}, +{'wkt1':'POLYGON((-8239529.462853361 4980952.065110421,-8224242.057199065 4980952.065110421,-8224242.057199064 4988844.188279452,-8239529.462853361 4988844.188279452,-8239529.462853361 4980952.065110421))', 'wkt2':'POINT(-8224242.0571995 4982695.78481786)', result:true} ];