(Closes #982), comment/documentation/requires changes (Closes #983, #993, #988), Fixing post support in proxy.cgi (Closes #991), baseLayer zoom level change (Closes #990), typo in Layer.Image.setURL (Closes #985), and a fix or the Layer.Google bug caused by Google's changing internals (#994). RC2, here we come. git-svn-id: http://svn.openlayers.org/branches/openlayers/2.5@4390 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
184 lines
5.8 KiB
HTML
184 lines
5.8 KiB
HTML
<html>
|
|
<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);
|
|
t.ok( layer instanceof OpenLayers.Layer.TileCache, "returns OpenLayers.Layer.TileCache object" );
|
|
}
|
|
|
|
|
|
|
|
function test_03_Layer_TileCache_clearTiles (t) {
|
|
t.plan( 1 );
|
|
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));
|
|
|
|
//grab a reference to one of the tiles
|
|
var tile = layer.grid[0][0];
|
|
|
|
layer.clearGrid();
|
|
|
|
t.ok( layer.grid != null, "layer.grid does not get nullified" );
|
|
}
|
|
|
|
|
|
function test_04_Layer_TileCache_getTileCacheBounds(t) {
|
|
t.plan( 1 );
|
|
|
|
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)};
|
|
layer.grid = [ [6, tr],
|
|
[bl, 7]];
|
|
|
|
var bounds = layer.getGridBounds();
|
|
|
|
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 map = new OpenLayers.Map('map');
|
|
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");
|
|
}
|
|
|
|
function test_06_Layer_TileCache_getZoomForExtent(t) {
|
|
t.plan( 2 );
|
|
var bounds, zoom;
|
|
|
|
var map = new OpenLayers.Map('map');
|
|
layer = new OpenLayers.Layer.TileCache(name, url, layername, options);
|
|
map.addLayer(layer);
|
|
|
|
bounds = new OpenLayers.Bounds(10,10,12,12);
|
|
zoom = layer.getZoomForExtent(bounds);
|
|
/**
|
|
* ideal resolution: 2 map units / 500px = 0.004
|
|
* layer.resolutions = [0.703125, 0.3515625, 0.17578125,
|
|
* 0.087890625, 0.0439453125, 0.02197265625,
|
|
* 0.010986328125, 0.0054931640625, 0.00274658203125,
|
|
* 0.001373291015625, 0.0006866455078125, 0.00034332275390625,
|
|
* 0.000171661376953125, 0.0000858306884765625, 0.00004291534423828125,
|
|
* 0.000021457672119140625]
|
|
*
|
|
* So, we expect a zoom of 8 because it is the closest resolution.
|
|
*/
|
|
t.eq( zoom, 8, "getZoomForExtent() returns correct value");
|
|
|
|
bounds = new OpenLayers.Bounds(10,10,100,100);
|
|
zoom = layer.getZoomForExtent(bounds);
|
|
/**
|
|
* ideal resolution: 90 map units / 500px = 0.18
|
|
* So, we expect a zoom of 2 because it is the closest.
|
|
*/
|
|
|
|
t.eq( zoom, 2, "getZoomForExtent() returns correct value");
|
|
}
|
|
|
|
|
|
/** 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', 'type':'png'};
|
|
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));
|
|
t.eq(tileurl, "http://labs.metacarta.com/wms-c/Basic.py/basic/09/000/000/522/000/000/384.png", "Tile URL is correct");
|
|
|
|
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://tilecache3/basic/09/000/000/522/000/000/384.png", "Tile URL is deterministic");
|
|
}
|
|
|
|
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);
|
|
|
|
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");
|
|
}
|
|
|
|
function test_99_Layer_TileCache_destroy (t) {
|
|
|
|
t.plan( 3 );
|
|
|
|
var map = new OpenLayers.Map('map');
|
|
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" );
|
|
t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );
|
|
|
|
|
|
//test with tile creation
|
|
layer = new OpenLayers.Layer.TileCache(name, url, options);
|
|
map.addLayer(layer);
|
|
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
|
//grab a reference to one of the tiles
|
|
var tile = layer.grid[0][0];
|
|
|
|
layer.destroy();
|
|
|
|
t.ok( layer.grid == null, "tiles appropriately destroyed");
|
|
}
|
|
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="map" style="width:500px;height:550px"></div>
|
|
</body>
|
|
</html>
|