Revert "Merge pull request #304 from mpriour/singleTile"
This reverts commit84fb15e1d2, reversing changes made tod0d116efdf.
This commit is contained in:
@@ -792,7 +792,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
|||||||
|
|
||||||
//determine new tile bounds
|
//determine new tile bounds
|
||||||
var center = bounds.getCenterLonLat();
|
var center = bounds.getCenterLonLat();
|
||||||
|
|
||||||
var tileWidth = bounds.getWidth() * this.ratio;
|
var tileWidth = bounds.getWidth() * this.ratio;
|
||||||
var tileHeight = bounds.getHeight() * this.ratio;
|
var tileHeight = bounds.getHeight() * this.ratio;
|
||||||
|
|
||||||
@@ -802,26 +801,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
|||||||
center.lon + (tileWidth/2),
|
center.lon + (tileWidth/2),
|
||||||
center.lat + (tileHeight/2));
|
center.lat + (tileHeight/2));
|
||||||
|
|
||||||
// adjust tile bounds so they do not exceed maxExtent, except when the
|
|
||||||
// layer's maxExtent equals the world bounds or displayOutsideMaxExtent
|
|
||||||
// is set to true
|
|
||||||
var ignoreMaxExtent =
|
|
||||||
(this.map.baseLayer.wrapDateLine &&
|
|
||||||
this.maxExtent.equals(this.map.getMaxExtent())) ||
|
|
||||||
this.displayOutsideMaxExtent;
|
|
||||||
if(!ignoreMaxExtent) {
|
|
||||||
tileBounds.bottom = Math.max(this.maxExtent.bottom, tileBounds.bottom);
|
|
||||||
tileBounds.top = Math.min(this.maxExtent.top, tileBounds.top);
|
|
||||||
tileBounds.left = Math.max(this.maxExtent.left, tileBounds.left);
|
|
||||||
tileBounds.right = Math.min(this.maxExtent.right, tileBounds.right);
|
|
||||||
tileWidth = tileBounds.getWidth();
|
|
||||||
tileHeight = tileBounds.getHeight();
|
|
||||||
}
|
|
||||||
var resolution = this.map.getResolution(),
|
|
||||||
size = this.tileSize;
|
|
||||||
size.w = (tileWidth / resolution) | 0;
|
|
||||||
size.h = (tileHeight / resolution) | 0;
|
|
||||||
|
|
||||||
var px = this.map.getLayerPxFromLonLat({
|
var px = this.map.getLayerPxFromLonLat({
|
||||||
lon: tileBounds.left,
|
lon: tileBounds.left,
|
||||||
lat: tileBounds.top
|
lat: tileBounds.top
|
||||||
|
|||||||
+4
-55
@@ -452,7 +452,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_Layer_Grid_initSingleTile(t) {
|
function test_Layer_Grid_initSingleTile(t) {
|
||||||
t.plan( 24 );
|
t.plan( 11 );
|
||||||
|
|
||||||
layer = new OpenLayers.Layer.Grid(name, url, params, {
|
layer = new OpenLayers.Layer.Grid(name, url, params, {
|
||||||
singleTile: true,
|
singleTile: true,
|
||||||
@@ -465,17 +465,14 @@
|
|||||||
var desiredUL = new OpenLayers.LonLat(-40,145);
|
var desiredUL = new OpenLayers.LonLat(-40,145);
|
||||||
|
|
||||||
translatedPX = {};
|
translatedPX = {};
|
||||||
layer.tileSize = new OpenLayers.Size();
|
|
||||||
layer.map = {
|
layer.map = {
|
||||||
baseLayer: {wrapDateLine: true},
|
|
||||||
getMaxExtent: function() { return new OpenLayers.Bounds(-180,-90,180,90); },
|
|
||||||
getLayerPxFromLonLat: function(ul) {
|
getLayerPxFromLonLat: function(ul) {
|
||||||
t.ok(ul.lon === desiredUL.lon && ul.lat === desiredUL.lat, "correct ul passed to translation");
|
t.ok(ul.lon === desiredUL.lon && ul.lat === desiredUL.lat, "correct ul passed to translation");
|
||||||
return translatedPX;
|
return translatedPX;
|
||||||
},
|
},
|
||||||
getResolution:function(){return 1;}
|
getResolution: function() {
|
||||||
};
|
}
|
||||||
layer.maxExtent = layer.map.getMaxExtent();
|
}
|
||||||
|
|
||||||
var newTile = {
|
var newTile = {
|
||||||
draw: function() {
|
draw: function() {
|
||||||
@@ -509,54 +506,6 @@
|
|||||||
layer.grid = [[ tile ]];
|
layer.grid = [[ tile ]];
|
||||||
layer.initSingleTile(bounds);
|
layer.initSingleTile(bounds);
|
||||||
|
|
||||||
//test maxExtent restrictions
|
|
||||||
//reset grid
|
|
||||||
layer.grid = [];
|
|
||||||
//more useful mocks
|
|
||||||
layer.map = {
|
|
||||||
baseLayer: {wrapDateLine: false},
|
|
||||||
getMaxExtent: function() { return new OpenLayers.Bounds(-180,-90,180,90); },
|
|
||||||
getLayerPxFromLonLat: function(ul) {
|
|
||||||
return {
|
|
||||||
x:ul.lon,
|
|
||||||
y:ul.lat
|
|
||||||
};
|
|
||||||
},
|
|
||||||
getResolution: function(){return 1;}
|
|
||||||
};
|
|
||||||
layer.addTile = function(tileBounds, px) {
|
|
||||||
t.ok(tileBounds.equals(desiredTileBounds), "correct tile bounds passed to addTile to create new tile");
|
|
||||||
t.ok(px.x == translatedPX.x && px.y == translatedPX.y, "correct tile px passed to addTile to create new tile");
|
|
||||||
return newTile;
|
|
||||||
};
|
|
||||||
tile = {
|
|
||||||
moveTo: function(tileBounds, px) {
|
|
||||||
t.ok(tileBounds.equals(desiredTileBounds), "correct tile bounds passed to tile.moveTo()");
|
|
||||||
t.ok(px.x == translatedPX.x && px.y == translatedPX.y, "correct tile px passed to tile.moveTo()");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
//test bound fully contains the maxExtent
|
|
||||||
//tile bounds -10,10,50,100 -> apply ratio -40,-35,80,145
|
|
||||||
layer.maxExtent = new OpenLayers.Bounds(0,20,40,90);
|
|
||||||
desiredTileBounds = new OpenLayers.Bounds(0,20,40,90);
|
|
||||||
translatedPX = {x:0,y:90};
|
|
||||||
layer.initSingleTile(bounds);
|
|
||||||
|
|
||||||
//test bound overlaps the maxExtent
|
|
||||||
bounds = new OpenLayers.Bounds(-10,10,50,100);
|
|
||||||
//with ratio applied tile bounds are -40,-35,80,145
|
|
||||||
layer.maxExtent = new OpenLayers.Bounds(-50,20,40,150);
|
|
||||||
desiredTileBounds = new OpenLayers.Bounds(-40,20,40,145);
|
|
||||||
translatedPX = {x:-40,y:145};
|
|
||||||
layer.grid = [[ tile ]];
|
|
||||||
layer.initSingleTile(bounds);
|
|
||||||
t.ok(layer.tileSize.equals(new OpenLayers.Size(80, 125)), "tileSize correct.");
|
|
||||||
|
|
||||||
//test bounds where ratio will be applied on all edges
|
|
||||||
layer.displayOutsideMaxExtent = true;
|
|
||||||
desiredTileBounds = new OpenLayers.Bounds(-40,-35,80,145);
|
|
||||||
layer.initSingleTile(bounds);
|
|
||||||
t.ok(layer.tileSize.equals(new OpenLayers.Size(120, 180)), "tileSize correct.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Layer_Grid_addTileMonitoringHooks(t) {
|
function test_Layer_Grid_addTileMonitoringHooks(t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user