3 <script src="../../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
7 var name = 'Test Layer';
8 var url = "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/${z}/${x}/${y}.png";
9 var options = {'layername':'basic', 'type':'png'};
12 function test_Layer_XYZ_constructor (t) {
15 layer = new OpenLayers.Layer.XYZ(name, url, options);
16 t.ok( layer instanceof OpenLayers.Layer.XYZ, "returns OpenLayers.Layer.XYZ object" );
21 function test_Layer_XYZ_clearTiles (t) {
23 var map = new OpenLayers.Map('map');
24 layer = new OpenLayers.Layer.XYZ(name, url, options);
27 map.setCenter(new OpenLayers.LonLat(0,0));
29 //grab a reference to one of the tiles
30 var tile = layer.grid[0][0];
34 t.ok( layer.grid != null, "layer.grid does not get nullified" );
39 function test_Layer_XYZ_getXYZBounds(t) {
42 layer = new OpenLayers.Layer.XYZ(name, url, options);
44 var bl = { bounds: new OpenLayers.Bounds(1,2,0,0)};
45 var tr = { bounds: new OpenLayers.Bounds(0,0,3,4)};
46 layer.grid = [ [6, tr],
49 var bounds = layer.getTilesBounds();
51 var testBounds = new OpenLayers.Bounds(1,2,3,4);
53 t.ok( bounds.equals(testBounds), "getXYZBounds() returns correct bounds")
58 function test_Layer_XYZ_getResolution(t) {
61 var map = new OpenLayers.Map('map');
62 layer = new OpenLayers.Layer.XYZ(name, url, options);
67 t.eq( layer.getResolution(), 0.0439453125, "getResolution() returns correct value");
71 function test_Layer_XYZ_getZoomForExtent(t) {
75 var map = new OpenLayers.Map('map');
76 layer = new OpenLayers.Layer.XYZ(name, url, options);
79 bounds = new OpenLayers.Bounds(10,10,12,12);
80 zoom = layer.getZoomForExtent(bounds);
82 t.eq( zoom, 8, "getZoomForExtent() returns correct value");
84 bounds = new OpenLayers.Bounds(10,10,100,100);
85 zoom = layer.getZoomForExtent(bounds);
87 t.eq( zoom, 2, "getZoomForExtent() returns correct value");
92 /** THIS WOULD BE WHERE THE TESTS WOULD GO FOR
98 function 07_Layer_XYZ_moveTo(t) {
101 function 08_Layer_XYZ_insertColumn(t) {
104 function 09_Layer_XYZ_insertRow(t) {
109 function test_Layer_XYZ_getURL(t) {
113 var map = new OpenLayers.Map('map');
114 layer = new OpenLayers.Layer.XYZ(name, url);
116 map.setCenter(new OpenLayers.LonLat(0,0), 9);
117 var tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125));
118 t.eq(tileurl, "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/9/261/63.png", "Tile URL is correct");
120 layer.url = ["http://tilecache1/", "http://tilecache2/", "http://tilecache3/"];
121 tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125));
122 t.eq(tileurl, "http://tilecache1/", "Tile URL is deterministic");
125 function test_Layer_XYZ_Rounding(t) {
127 m = new OpenLayers.Map("map", {'maxExtent':new OpenLayers.Bounds(-122.6579,37.4901,-122.0738,37.8795)});
128 layer = new OpenLayers.Layer.XYZ( "XYZ",
129 url, {layername: 'basic', type:'png', resolutions:[0.000634956337608418]} );
132 t.eq(layer.getURL(layer.grid[3][3].bounds), "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/0/1/0.png", "XYZ tiles around rounded properly.");
136 function test_Layer_XYZ_setMap(t) {
140 var map = new OpenLayers.Map('map');
141 layer = new OpenLayers.Layer.XYZ(name, url);
143 t.eq(layer.tileOrigin, null, "Tile origin starts out null");
146 t.eq(layer.tileOrigin.lat, -90, "lat is -90");
147 t.eq(layer.tileOrigin.lon, -180, "lon is -180");
151 function test_Layer_XYZ_destroy (t) {
155 var map = new OpenLayers.Map('map');
156 layer = new OpenLayers.Layer.XYZ(name, url, options);
159 t.eq( layer.grid, null, "layer.grid is null after destroy" );
160 t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );
163 //test with tile creation
164 layer = new OpenLayers.Layer.XYZ(name, url, options);
166 map.setCenter(new OpenLayers.LonLat(0,0), 5);
167 //grab a reference to one of the tiles
168 var tile = layer.grid[0][0];
172 t.ok( layer.grid == null, "tiles appropriately destroyed");
180 <div id="map" style="width:500px;height:550px"></div>