Removing the explicit maxResolution from the TileCache layer. We now depend on resolutions being properly set on the map or directly on the layer. r=crschmidt (closes #1212).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5525 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -13,12 +13,17 @@
|
||||
function init(){
|
||||
map = new OpenLayers.Map( $('map'));
|
||||
layer = new OpenLayers.Layer.TileCache("TileCache Layer",
|
||||
["http://c0.labs.metacarta.com/wms-c/cache/",
|
||||
"http://c1.labs.metacarta.com/wms-c/cache/",
|
||||
"http://c2.labs.metacarta.com/wms-c/cache/",
|
||||
"http://c3.labs.metacarta.com/wms-c/cache/",
|
||||
"http://c4.labs.metacarta.com/wms-c/cache/"],
|
||||
"basic", {'format': 'image/png'});
|
||||
["http://c0.labs.metacarta.com/wms-c/cache/",
|
||||
"http://c1.labs.metacarta.com/wms-c/cache/",
|
||||
"http://c2.labs.metacarta.com/wms-c/cache/",
|
||||
"http://c3.labs.metacarta.com/wms-c/cache/",
|
||||
"http://c4.labs.metacarta.com/wms-c/cache/"],
|
||||
"basic",
|
||||
{
|
||||
'format': 'image/png',
|
||||
maxResolution: 180/256 // same as the TileCache config
|
||||
}
|
||||
);
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
|
||||
}
|
||||
@@ -41,12 +46,17 @@
|
||||
<div id="tags"></div>
|
||||
|
||||
<p id="shortdesc">
|
||||
Demonstrates a TileCache layer that loads tiles from from a web accessible disk-based cache only.
|
||||
Demonstrates a TileCache layer that loads tiles from from a web
|
||||
accessible disk-based cache only.
|
||||
</p>
|
||||
|
||||
<div id="map">
|
||||
<div id="map"></div>
|
||||
|
||||
<div id="docs">
|
||||
This layer should be used for web accessible disk-based caches only.
|
||||
It is not used to request new tiles from TileCache. Note that you
|
||||
should specify resolutions explicitly on this layer so that they match
|
||||
your TileCache configuration.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -31,7 +31,7 @@ OpenLayers.Layer.TileCache = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
* bottom left of the maxExtent.
|
||||
*/
|
||||
tileOrigin: null,
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: format
|
||||
* {String} Mime type of the images returned. Default is image/png.
|
||||
@@ -48,10 +48,13 @@ OpenLayers.Layer.TileCache = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
* your tilecache script!)
|
||||
* layername - {String} Layer name as defined in the TileCache
|
||||
* configuration
|
||||
* options - {Object} Hashtable of extra options to tag onto the layer
|
||||
* options - {Object} Optional object with properties to be set on the
|
||||
* layer. Note that you should speficy your resolutions to match
|
||||
* your TileCache configuration. This can be done by setting
|
||||
* the resolutions array directly (here or on the map), by setting
|
||||
* maxResolution and numZoomLevels, or by using scale based properties.
|
||||
*/
|
||||
initialize: function(name, url, layername, options) {
|
||||
options = OpenLayers.Util.extend({maxResolution: 180/256}, options);
|
||||
this.layername = layername;
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this,
|
||||
[name, url, {}, options]);
|
||||
|
||||
@@ -2,37 +2,47 @@
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
|
||||
var name = 'Test Layer';
|
||||
var url = "http://labs.metacarta.com/wms-c/Basic.py/";
|
||||
var layername = "basic";
|
||||
var options = {'type':'png'};
|
||||
|
||||
|
||||
function test_01_Layer_TileCache_constructor (t) {
|
||||
t.plan( 1 );
|
||||
|
||||
layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
|
||||
var name = 'Test Layer';
|
||||
var url = "http://labs.metacarta.com/wms-c/Basic.py/";
|
||||
var layername = "basic";
|
||||
var options = {'type':'png'};
|
||||
|
||||
var layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
t.ok( layer instanceof OpenLayers.Layer.TileCache, "returns OpenLayers.Layer.TileCache object" );
|
||||
layer.destroy();
|
||||
}
|
||||
|
||||
function test__Layer_TileCache_clone(t) {
|
||||
t.plan(3);
|
||||
|
||||
layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
var name = 'Test Layer';
|
||||
var url = "http://labs.metacarta.com/wms-c/Basic.py/";
|
||||
var layername = "basic";
|
||||
var options = {'type':'png'};
|
||||
var layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
|
||||
var clone = layer.clone();
|
||||
t.eq(layer.name, clone.name, "clone() correctly copy the 'name' property");
|
||||
t.eq(layer.url, clone.url, "clone() correctly copy the 'url' property");
|
||||
t.eq(layer.layername, clone.layername, "clone() correctly copy the 'layername' property");
|
||||
clone.destroy();
|
||||
layer.destroy();
|
||||
}
|
||||
|
||||
function test_03_Layer_TileCache_clearTiles (t) {
|
||||
t.plan( 1 );
|
||||
var name = 'Test Layer';
|
||||
var url = "http://labs.metacarta.com/wms-c/Basic.py/";
|
||||
var layername = "basic";
|
||||
var options = {'type':'png'};
|
||||
var layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
map.addLayer(layer);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(0,0));
|
||||
@@ -43,13 +53,18 @@
|
||||
layer.clearGrid();
|
||||
|
||||
t.ok( layer.grid != null, "layer.grid does not get nullified" );
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
|
||||
function test_04_Layer_TileCache_getTileCacheBounds(t) {
|
||||
t.plan( 1 );
|
||||
|
||||
layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
var name = 'Test Layer';
|
||||
var url = "http://labs.metacarta.com/wms-c/Basic.py/";
|
||||
var layername = "basic";
|
||||
var options = {'type':'png'};
|
||||
var layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
|
||||
var bl = { bounds: new OpenLayers.Bounds(1,2,0,0)};
|
||||
var tr = { bounds: new OpenLayers.Bounds(0,0,3,4)};
|
||||
@@ -61,28 +76,36 @@
|
||||
var testBounds = new OpenLayers.Bounds(1,2,3,4);
|
||||
|
||||
t.ok( bounds.equals(testBounds), "getTileCacheBounds() returns correct bounds")
|
||||
|
||||
layer.grid = null;
|
||||
|
||||
}
|
||||
|
||||
function test_05_Layer_TileCache_getResolution(t) {
|
||||
t.plan( 1 );
|
||||
|
||||
var name = 'Test Layer';
|
||||
var url = "http://labs.metacarta.com/wms-c/Basic.py/";
|
||||
var layername = "basic";
|
||||
var options = {'type':'png', maxResolution: 180/256};
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
var layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
map.addLayer(layer);
|
||||
|
||||
map.zoom = 5;
|
||||
|
||||
t.eq( layer.getResolution(), 0.02197265625, "getResolution() returns correct value");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_06_Layer_TileCache_getZoomForExtent(t) {
|
||||
t.plan( 2 );
|
||||
var bounds, zoom;
|
||||
|
||||
var name = 'Test Layer';
|
||||
var url = "http://labs.metacarta.com/wms-c/Basic.py/";
|
||||
var layername = "basic";
|
||||
var options = {'type':'png', maxResolution: 180/256};
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
var layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
map.addLayer(layer);
|
||||
|
||||
bounds = new OpenLayers.Bounds(10,10,12,12);
|
||||
@@ -94,33 +117,19 @@
|
||||
zoom = layer.getZoomForExtent(bounds);
|
||||
|
||||
t.eq( zoom, 1, "getZoomForExtent() returns correct value");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
|
||||
/** THIS WOULD BE WHERE THE TESTS WOULD GO FOR
|
||||
*
|
||||
* -moveTo
|
||||
* -insertColumn
|
||||
* -insertRow
|
||||
|
||||
function 07_Layer_TileCache_moveTo(t) {
|
||||
}
|
||||
|
||||
function 08_Layer_TileCache_insertColumn(t) {
|
||||
}
|
||||
|
||||
function 09_Layer_TileCache_insertRow(t) {
|
||||
}
|
||||
|
||||
*
|
||||
*/
|
||||
function test_10_Layer_TileCache_getURL(t) {
|
||||
|
||||
t.plan(2);
|
||||
|
||||
var map = new OpenLayers.Map('map', options);
|
||||
var options = {'layername':'basic', 'format':'image/jpg'};
|
||||
layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var name = 'Test Layer';
|
||||
var url = "http://labs.metacarta.com/wms-c/Basic.py/";
|
||||
var layername = "basic";
|
||||
var options = {'layername':'basic', 'format':'image/jpg', maxResolution: 180/256};
|
||||
var layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 9);
|
||||
var tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125));
|
||||
@@ -129,28 +138,38 @@
|
||||
layer.url = ["http://tilecache1/", "http://tilecache2/", "http://tilecache3/"];
|
||||
tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125));
|
||||
t.eq(tileurl, "http://tilecache2/basic/09/000/000/522/000/000/384.jpeg", "Tile URL is deterministic");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_11_Layer_TileCache_setMap(t) {
|
||||
|
||||
t.plan(3);
|
||||
|
||||
var map = new OpenLayers.Map('map', options);
|
||||
layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
var name = 'Test Layer';
|
||||
var url = "http://labs.metacarta.com/wms-c/Basic.py/";
|
||||
var layername = "basic";
|
||||
var options = {'layername':'basic', 'format':'image/jpg', maxResolution: 180/256};
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
|
||||
t.eq(layer.tileOrigin, null, "Tile origin starts out null");
|
||||
layer.setMap(map);
|
||||
|
||||
t.eq(layer.tileOrigin.lat, -90, "lat is -90");
|
||||
t.eq(layer.tileOrigin.lon, -180, "lon is -180");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_99_Layer_TileCache_destroy (t) {
|
||||
|
||||
t.plan( 3 );
|
||||
|
||||
var name = 'Test Layer';
|
||||
var url = "http://labs.metacarta.com/wms-c/Basic.py/";
|
||||
var layername = "basic";
|
||||
var options = {'layername':'basic', 'format':'image/jpg', maxResolution: 180/256};
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
var layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
||||
map.addLayer(layer);
|
||||
layer.destroy();
|
||||
t.eq( layer.grid, null, "layer.grid is null after destroy" );
|
||||
@@ -167,6 +186,7 @@
|
||||
layer.destroy();
|
||||
|
||||
t.ok( layer.grid == null, "tiles appropriately destroyed");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user