Tests with a description of the updated method.

The old `containsPoint` method was sensitive to failure when looking for ray crossings with nearly vertical edges.  These added tests demonstrate the simple cases where `containsPoint` succeeds.  The tests also now include a case that covers the failure for polygons with nearly vertical edges.  The previous `getX` method (within the `containsPoint` method) and the new one are mathematically equivalent.  The updated version performs better in cases using coordinates with many significant figures.
This commit is contained in:
tschaub
2012-01-16 16:59:54 -07:00
parent 7a0336a9ef
commit 02aa9bcc36
2 changed files with 98 additions and 10 deletions

View File

@@ -294,7 +294,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
var px = approx(point.x, digs);
var py = approx(point.y, digs);
function getX(y, x1, y1, x2, y2) {
return (y-y2)*((x2-x1)/(y2-y1)) + x2;
return (y - y2) * ((x2 - x1) / (y2 - y1)) + x2;
}
var numSeg = this.components.length - 1;
var start, end, x1, y1, x2, y2, cx, cy;