OpenLayers OpenLayers

Changeset 5525

Show
Ignore:
Timestamp:
12/19/07 22:50:08 (1 year ago)
Author:
tschaub
Message:

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).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/examples/tilecache.html

    r5362 r5525  
    1414            map = new OpenLayers.Map( $('map')); 
    1515            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            ); 
    2227            map.addLayer(layer); 
    2328            map.setCenter(new OpenLayers.LonLat(0, 0), 0); 
     
    4247 
    4348    <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. 
    4551    </p> 
    4652 
    47     <div id="map"> 
     53    <div id="map"></div> 
    4854 
    4955    <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. 
    5060    </div> 
    5161  </body> 
  • trunk/openlayers/lib/OpenLayers/Layer/TileCache.js

    r5328 r5525  
    3232     */ 
    3333    tileOrigin: null, 
    34      
     34 
    3535    /**  
    3636     * APIProperty: format 
     
    4949     * layername - {String} Layer name as defined in the TileCache  
    5050     *     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. 
    5256     */ 
    5357    initialize: function(name, url, layername, options) { 
    54         options = OpenLayers.Util.extend({maxResolution: 180/256}, options); 
    5558        this.layername = layername; 
    5659        OpenLayers.Layer.Grid.prototype.initialize.apply(this, 
  • trunk/openlayers/tests/Layer/test_TileCache.html

    r5328 r5525  
    33  <script src="../../lib/OpenLayers.js"></script> 
    44  <script type="text/javascript"> 
    5     var isMozilla = (navigator.userAgent.indexOf("compatible") == -1); 
    6     var layer;  
    75 
    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'};  
    126 
    137 
    148    function test_01_Layer_TileCache_constructor (t) { 
    159        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); 
    1817        t.ok( layer instanceof OpenLayers.Layer.TileCache, "returns OpenLayers.Layer.TileCache object" ); 
     18        layer.destroy(); 
    1919    } 
    2020 
     
    2222        t.plan(3); 
    2323 
    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); 
    2529 
    2630        var clone = layer.clone(); 
     
    2832        t.eq(layer.url, clone.url, "clone() correctly copy the 'url' property"); 
    2933        t.eq(layer.layername, clone.layername, "clone() correctly copy the 'layername' property"); 
     34        clone.destroy(); 
     35        layer.destroy(); 
    3036    } 
    3137 
    3238    function test_03_Layer_TileCache_clearTiles (t) { 
    3339        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); 
    3445        var map = new OpenLayers.Map('map'); 
    35         layer = new OpenLayers.Layer.TileCache(name, url, layername, options); 
    3646        map.addLayer(layer); 
    3747 
     
    4454 
    4555        t.ok( layer.grid != null, "layer.grid does not get nullified" ); 
     56        map.destroy(); 
    4657    } 
    4758 
     
    5061        t.plan( 1 ); 
    5162 
    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); 
    5368 
    5469        var bl = { bounds: new OpenLayers.Bounds(1,2,0,0)}; 
     
    6277         
    6378        t.ok( bounds.equals(testBounds), "getTileCacheBounds() returns correct bounds") 
    64          
    65         layer.grid = null; 
     79 
    6680    } 
    6781 
     
    6983        t.plan( 1 ); 
    7084 
     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};  
    7189        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); 
    7391        map.addLayer(layer); 
    7492 
     
    7694 
    7795        t.eq( layer.getResolution(), 0.02197265625, "getResolution() returns correct value"); 
     96        map.destroy(); 
    7897    } 
    7998 
     
    82101        var bounds, zoom; 
    83102 
     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};  
    84107        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); 
    86109        map.addLayer(layer); 
    87110 
     
    95118 
    96119        t.eq( zoom, 1, "getZoomForExtent() returns correct value"); 
     120        map.destroy(); 
    97121    }    
    98122 
    99  
    100     /** THIS WOULD BE WHERE THE TESTS WOULD GO FOR  
    101      *      
    102      *    -moveTo 
    103      *    -insertColumn 
    104      *    -insertRow 
    105      
    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      */ 
    117123    function test_10_Layer_TileCache_getURL(t) { 
    118124 
    119125        t.plan(2); 
    120126         
    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); 
    124133        map.addLayer(layer); 
    125134        map.setCenter(new OpenLayers.LonLat(0,0), 9); 
     
    130139        tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125)); 
    131140        t.eq(tileurl, "http://tilecache2/basic/09/000/000/522/000/000/384.jpeg", "Tile URL is deterministic"); 
     141        map.destroy(); 
    132142    } 
    133143 
     
    136146        t.plan(3); 
    137147         
    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); 
    140154 
    141155        t.eq(layer.tileOrigin, null, "Tile origin starts out null"); 
     
    144158        t.eq(layer.tileOrigin.lat, -90, "lat is -90"); 
    145159        t.eq(layer.tileOrigin.lon, -180, "lon is -180"); 
     160        map.destroy(); 
    146161    } 
    147162 
     
    150165        t.plan( 3 ); 
    151166 
     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};  
    152171        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); 
    154173        map.addLayer(layer); 
    155174        layer.destroy(); 
     
    168187 
    169188        t.ok( layer.grid == null, "tiles appropriately destroyed"); 
     189        map.destroy(); 
    170190    } 
    171191