Changeset 5525
- Timestamp:
- 12/19/07 22:50:08 (1 year ago)
- Files:
-
- trunk/openlayers/examples/tilecache.html (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/TileCache.js (modified) (2 diffs)
- trunk/openlayers/tests/Layer/test_TileCache.html (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/examples/tilecache.html
r5362 r5525 14 14 map = new OpenLayers.Map( $('map')); 15 15 layer = new OpenLayers.Layer.TileCache("TileCache Layer", 16 ["http://c0.labs.metacarta.com/wms-c/cache/", 17 "http://c1.labs.metacarta.com/wms-c/cache/", 18 "http://c2.labs.metacarta.com/wms-c/cache/", 19 "http://c3.labs.metacarta.com/wms-c/cache/", 20 "http://c4.labs.metacarta.com/wms-c/cache/"], 21 "basic", {'format': 'image/png'}); 16 ["http://c0.labs.metacarta.com/wms-c/cache/", 17 "http://c1.labs.metacarta.com/wms-c/cache/", 18 "http://c2.labs.metacarta.com/wms-c/cache/", 19 "http://c3.labs.metacarta.com/wms-c/cache/", 20 "http://c4.labs.metacarta.com/wms-c/cache/"], 21 "basic", 22 { 23 'format': 'image/png', 24 maxResolution: 180/256 // same as the TileCache config 25 } 26 ); 22 27 map.addLayer(layer); 23 28 map.setCenter(new OpenLayers.LonLat(0, 0), 0); … … 42 47 43 48 <p id="shortdesc"> 44 Demonstrates a TileCache layer that loads tiles from from a web accessible disk-based cache only. 49 Demonstrates a TileCache layer that loads tiles from from a web 50 accessible disk-based cache only. 45 51 </p> 46 52 47 <div id="map"> 53 <div id="map"></div> 48 54 49 55 <div id="docs"> 56 This layer should be used for web accessible disk-based caches only. 57 It is not used to request new tiles from TileCache. Note that you 58 should specify resolutions explicitly on this layer so that they match 59 your TileCache configuration. 50 60 </div> 51 61 </body> trunk/openlayers/lib/OpenLayers/Layer/TileCache.js
r5328 r5525 32 32 */ 33 33 tileOrigin: null, 34 34 35 35 /** 36 36 * APIProperty: format … … 49 49 * layername - {String} Layer name as defined in the TileCache 50 50 * configuration 51 * options - {Object} Hashtable of extra options to tag onto the layer 51 * options - {Object} Optional object with properties to be set on the 52 * layer. Note that you should speficy your resolutions to match 53 * your TileCache configuration. This can be done by setting 54 * the resolutions array directly (here or on the map), by setting 55 * maxResolution and numZoomLevels, or by using scale based properties. 52 56 */ 53 57 initialize: function(name, url, layername, options) { 54 options = OpenLayers.Util.extend({maxResolution: 180/256}, options);55 58 this.layername = layername; 56 59 OpenLayers.Layer.Grid.prototype.initialize.apply(this, trunk/openlayers/tests/Layer/test_TileCache.html
r5328 r5525 3 3 <script src="../../lib/OpenLayers.js"></script> 4 4 <script type="text/javascript"> 5 var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);6 var layer;7 5 8 var name = 'Test Layer';9 var url = "http://labs.metacarta.com/wms-c/Basic.py/";10 var layername = "basic";11 var options = {'type':'png'};12 6 13 7 14 8 function test_01_Layer_TileCache_constructor (t) { 15 9 t.plan( 1 ); 16 17 layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 10 11 var name = 'Test Layer'; 12 var url = "http://labs.metacarta.com/wms-c/Basic.py/"; 13 var layername = "basic"; 14 var options = {'type':'png'}; 15 16 var layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 18 17 t.ok( layer instanceof OpenLayers.Layer.TileCache, "returns OpenLayers.Layer.TileCache object" ); 18 layer.destroy(); 19 19 } 20 20 … … 22 22 t.plan(3); 23 23 24 layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 24 var name = 'Test Layer'; 25 var url = "http://labs.metacarta.com/wms-c/Basic.py/"; 26 var layername = "basic"; 27 var options = {'type':'png'}; 28 var layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 25 29 26 30 var clone = layer.clone(); … … 28 32 t.eq(layer.url, clone.url, "clone() correctly copy the 'url' property"); 29 33 t.eq(layer.layername, clone.layername, "clone() correctly copy the 'layername' property"); 34 clone.destroy(); 35 layer.destroy(); 30 36 } 31 37 32 38 function test_03_Layer_TileCache_clearTiles (t) { 33 39 t.plan( 1 ); 40 var name = 'Test Layer'; 41 var url = "http://labs.metacarta.com/wms-c/Basic.py/"; 42 var layername = "basic"; 43 var options = {'type':'png'}; 44 var layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 34 45 var map = new OpenLayers.Map('map'); 35 layer = new OpenLayers.Layer.TileCache(name, url, layername, options);36 46 map.addLayer(layer); 37 47 … … 44 54 45 55 t.ok( layer.grid != null, "layer.grid does not get nullified" ); 56 map.destroy(); 46 57 } 47 58 … … 50 61 t.plan( 1 ); 51 62 52 layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 63 var name = 'Test Layer'; 64 var url = "http://labs.metacarta.com/wms-c/Basic.py/"; 65 var layername = "basic"; 66 var options = {'type':'png'}; 67 var layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 53 68 54 69 var bl = { bounds: new OpenLayers.Bounds(1,2,0,0)}; … … 62 77 63 78 t.ok( bounds.equals(testBounds), "getTileCacheBounds() returns correct bounds") 64 65 layer.grid = null; 79 66 80 } 67 81 … … 69 83 t.plan( 1 ); 70 84 85 var name = 'Test Layer'; 86 var url = "http://labs.metacarta.com/wms-c/Basic.py/"; 87 var layername = "basic"; 88 var options = {'type':'png', maxResolution: 180/256}; 71 89 var map = new OpenLayers.Map('map'); 72 layer = new OpenLayers.Layer.TileCache(name, url, layername, options);90 var layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 73 91 map.addLayer(layer); 74 92 … … 76 94 77 95 t.eq( layer.getResolution(), 0.02197265625, "getResolution() returns correct value"); 96 map.destroy(); 78 97 } 79 98 … … 82 101 var bounds, zoom; 83 102 103 var name = 'Test Layer'; 104 var url = "http://labs.metacarta.com/wms-c/Basic.py/"; 105 var layername = "basic"; 106 var options = {'type':'png', maxResolution: 180/256}; 84 107 var map = new OpenLayers.Map('map'); 85 layer = new OpenLayers.Layer.TileCache(name, url, layername, options);108 var layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 86 109 map.addLayer(layer); 87 110 … … 95 118 96 119 t.eq( zoom, 1, "getZoomForExtent() returns correct value"); 120 map.destroy(); 97 121 } 98 122 99 100 /** THIS WOULD BE WHERE THE TESTS WOULD GO FOR101 *102 * -moveTo103 * -insertColumn104 * -insertRow105 106 function 07_Layer_TileCache_moveTo(t) {107 }108 109 function 08_Layer_TileCache_insertColumn(t) {110 }111 112 function 09_Layer_TileCache_insertRow(t) {113 }114 115 *116 */117 123 function test_10_Layer_TileCache_getURL(t) { 118 124 119 125 t.plan(2); 120 126 121 var map = new OpenLayers.Map('map', options); 122 var options = {'layername':'basic', 'format':'image/jpg'}; 123 layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 127 var map = new OpenLayers.Map('map'); 128 var name = 'Test Layer'; 129 var url = "http://labs.metacarta.com/wms-c/Basic.py/"; 130 var layername = "basic"; 131 var options = {'layername':'basic', 'format':'image/jpg', maxResolution: 180/256}; 132 var layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 124 133 map.addLayer(layer); 125 134 map.setCenter(new OpenLayers.LonLat(0,0), 9); … … 130 139 tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125)); 131 140 t.eq(tileurl, "http://tilecache2/basic/09/000/000/522/000/000/384.jpeg", "Tile URL is deterministic"); 141 map.destroy(); 132 142 } 133 143 … … 136 146 t.plan(3); 137 147 138 var map = new OpenLayers.Map('map', options); 139 layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 148 var name = 'Test Layer'; 149 var url = "http://labs.metacarta.com/wms-c/Basic.py/"; 150 var layername = "basic"; 151 var options = {'layername':'basic', 'format':'image/jpg', maxResolution: 180/256}; 152 var map = new OpenLayers.Map('map'); 153 var layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 140 154 141 155 t.eq(layer.tileOrigin, null, "Tile origin starts out null"); … … 144 158 t.eq(layer.tileOrigin.lat, -90, "lat is -90"); 145 159 t.eq(layer.tileOrigin.lon, -180, "lon is -180"); 160 map.destroy(); 146 161 } 147 162 … … 150 165 t.plan( 3 ); 151 166 167 var name = 'Test Layer'; 168 var url = "http://labs.metacarta.com/wms-c/Basic.py/"; 169 var layername = "basic"; 170 var options = {'layername':'basic', 'format':'image/jpg', maxResolution: 180/256}; 152 171 var map = new OpenLayers.Map('map'); 153 layer = new OpenLayers.Layer.TileCache(name, url, layername, options);172 var layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 154 173 map.addLayer(layer); 155 174 layer.destroy(); … … 168 187 169 188 t.ok( layer.grid == null, "tiles appropriately destroyed"); 189 map.destroy(); 170 190 } 171 191
