Push dateline wrapping to intersectsBounds method.

It should simplify things by pushing the dateline wrapping stuff into the intersectsBounds method.
This commit is contained in:
tschaub
2011-09-29 12:21:05 -06:00
parent c53374c797
commit 516914c935
3 changed files with 76 additions and 47 deletions

View File

@@ -175,29 +175,10 @@ OpenLayers.Tile = OpenLayers.Class({
var withinMaxExtent = false,
maxExtent = this.layer.maxExtent;
if (maxExtent) {
// prepare up to 3 versions of the layer's maxExtent, to make sure
// that the intersectsBounds check below catches all cases of
// extents that cross the dateline:
// (1) left bound positive, right bound negative (wrapped)
// (2) left bound positive, right bound positive (exceeding world)
// (3) left bound negative (exceeding world), right bound positive
var maxExtents = [maxExtent];
if (this.layer.map.baseLayer.wrapDateLine) {
if (maxExtent.left > maxExtent.right) {
var worldWidth = this.layer.map.getMaxExtent().getWidth();
maxExtent = this.layer.maxExtent.clone();
maxExtent.left -= worldWidth;
maxExtents.push(maxExtent);
maxExtent = this.layer.maxExtent.clone();
maxExtent.right += worldWidth;
maxExtents.push(maxExtent);
}
}
for (var i=maxExtents.length-1; i>=0; --i) {
if (this.bounds.intersectsBounds(maxExtents[i], false)) {
withinMaxExtent = true;
break;
}
var map = this.layer.map;
var worldBounds = map.baseLayer.wrapDateLine && map.getMaxExtent();
if (this.bounds.intersectsBounds(maxExtent, {inclusive: false, worldBounds: worldBounds})) {
withinMaxExtent = true;
}
}