OpenLayers OpenLayers

Changeset 4037

Show
Ignore:
Timestamp:
08/24/07 19:49:06 (1 year ago)
Author:
crschmidt
Message:

TMS layer needs to round x and y in TMS url. Patch by Paul Spencer, Review by
Tim. (Closes #913.)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Layer/TMS.js

    r3984 r4037  
    9595        bounds = this.adjustBounds(bounds); 
    9696        var res = this.map.getResolution(); 
    97         var x = (bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w); 
    98         var y = (bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h); 
     97        var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); 
     98        var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); 
    9999        var z = this.map.getZoom(); 
    100100        var path = "1.0.0" + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;  
  • trunk/openlayers/tests/Layer/test_TMS.html

    r3725 r4037  
    121121        t.eq(tileurl, "http://tilecache1/1.0.0/basic/9/261/192.png", "Tile URL is deterministic"); 
    122122    } 
     123    function test_Layer_TMS_Rounding(t) { 
     124        t.plan(1); 
     125            m = new OpenLayers.Map("map", {'maxExtent':new OpenLayers.Bounds(-122.6579,37.4901,-122.0738,37.8795)}); 
     126            layer = new OpenLayers.Layer.TMS( "TMS",  
     127                    "http://labs.metacarta.com/wms-c/Basic.py/", {layername: 'basic', type:'png', resolutions:[0.000634956337608418]} ); 
     128            m.addLayer(layer); 
     129            m.zoomToMaxExtent() 
     130            t.eq(layer.getURL(layer.grid[3][3].bounds), "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/0/1/1.png", "TMS tiles around rounded properly."); 
     131    }         
     132             
    123133 
    124134    function test_11_Layer_TMS_setMap(t) {