This commit is contained in:
ahocevar
2011-09-30 17:31:45 -06:00
2 changed files with 50 additions and 18 deletions

View File

@@ -372,27 +372,21 @@ OpenLayers.Bounds = OpenLayers.Class({
* {Boolean} The passed-in lonlat is within this bounds.
*/
containsLonLat: function(ll, options) {
options = options || {};
if (typeof options === "boolean") {
options.inclusive = options;
options = {inclusive: options};
}
options = options || {};
var contains = this.contains(ll.lon, ll.lat, options.inclusive),
worldBounds = options.worldBounds;
if (worldBounds && !contains) {
var worldWidth = worldBounds.getWidth();
ll = ll.clone();
while(!contains && ll.lon > worldBounds.right) {
ll.lon -= worldWidth;
contains = worldBounds.containsLonLat(
ll, {inclusive: options.inclusive}
);
}
while(!contains && ll.lon < worldBounds.left) {
ll.lon += worldWidth;
contains = worldBounds.containsLonLat(
ll, {inclusive: options.inclusive}
);
}
var worldCenterX = (worldBounds.left + worldBounds.right) / 2;
var worldsAway = Math.round((ll.lon - worldCenterX) / worldWidth);
ll.lon -= (worldsAway * worldWidth);
contains = this.containsLonLat(
ll, {inclusive: options.inclusive}
);
}
return contains;
},
@@ -472,10 +466,10 @@ OpenLayers.Bounds = OpenLayers.Class({
* {Boolean} The passed-in bounds object intersects this bounds.
*/
intersectsBounds:function(bounds, options) {
options = options || {};
if (typeof options === "boolean") {
options = {inclusive: true};
if (typeof options === "boolean") {
options = {inclusive: options};
}
options = options || {};
if (options.worldBounds) {
var self = this.wrapDateLine(options.worldBounds);
bounds = bounds.wrapDateLine(options.worldBounds);