OpenLayers OpenLayers

Ticket #1023: tms_serviceVersion.patch

File tms_serviceVersion.patch, 2.2 kB (added by sderle, 1 year ago)

patch to add serviceVersion to TMS

  • tests/Layer/test_TMS.html

    old new  
    119119     */ 
    120120    function test_10_Layer_TMS_getURL(t) { 
    121121 
    122         t.plan(2); 
     122        t.plan(3); 
    123123         
    124124        var map = new OpenLayers.Map('map', options); 
    125125        var options = {'layername':'basic', 'type':'png'};  
     
    128128        map.setCenter(new OpenLayers.LonLat(0,0), 9); 
    129129        var tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125)); 
    130130        t.eq(tileurl, "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/9/261/192.png", "Tile URL is correct"); 
     131     
     132        var layer2 = layer.clone(); 
     133        layer2.serviceVersion = "1.2.3"; 
     134        map.addLayer(layer2); 
     135        tileurl = layer2.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125)); 
     136        t.eq(tileurl, "http://labs.metacarta.com/wms-c/Basic.py/1.2.3/basic/9/261/192.png", "TMS serviceVersion is correct"); 
    131137 
    132138        layer.url = ["http://tilecache1/", "http://tilecache2/", "http://tilecache3/"]; 
    133139        tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125)); 
  • lib/OpenLayers/Layer/TMS.js

    old new  
    1414OpenLayers.Layer.TMS = OpenLayers.Class(OpenLayers.Layer.Grid, { 
    1515 
    1616    /** 
     17     * APIProperty: serviceVersion 
     18     * {String} 
     19     */ 
     20    serviceVersion: "1.0.0", 
     21 
     22    /** 
    1723     * APIProperty: isBaseLayer 
    1824     * {Boolean} 
    1925     */ 
     
    9197        var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); 
    9298        var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); 
    9399        var z = this.map.getZoom(); 
    94         var path = "1.0.0" + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;  
     100        var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;  
    95101        var url = this.url; 
    96102        if (url instanceof Array) { 
    97103            url = this.selectUrl(path, url);