Handle left/right segment intersections for top/bottom spans

The ol.extent.intersectsSegment function was not correctly handling segments that span from above to below an extent while intersecting the sides.
This commit is contained in:
Tim Schaub
2015-04-19 09:43:06 -06:00
parent ed76bdb095
commit 941f53ec80
2 changed files with 22 additions and 3 deletions

View File

@@ -814,17 +814,20 @@ ol.extent.intersectsSegment = function(extent, start, end) {
// potentially intersects top
x = endX - ((endY - maxY) / slope);
intersects = x >= minX && x <= maxX;
} else if (!!(endRel & ol.extent.Relationship.RIGHT) &&
}
if (!intersects && !!(endRel & ol.extent.Relationship.RIGHT) &&
!(startRel & ol.extent.Relationship.RIGHT)) {
// potentially intersects right
y = endY - ((endX - maxX) * slope);
intersects = y >= minY && y <= maxY;
} else if (!!(endRel & ol.extent.Relationship.BELOW) &&
}
if (!intersects && !!(endRel & ol.extent.Relationship.BELOW) &&
!(startRel & ol.extent.Relationship.BELOW)) {
// potentially intersects bottom
x = endX - ((endY - minY) / slope);
intersects = x >= minX && x <= maxX;
} else if (!!(endRel & ol.extent.Relationship.LEFT) &&
}
if (!intersects && !!(endRel & ol.extent.Relationship.LEFT) &&
!(startRel & ol.extent.Relationship.LEFT)) {
// potentially intersects left
y = endY - ((endX - minX) * slope);