OpenLayers OpenLayers

Ticket #785: gutters.patch

File gutters.patch, 9.3 kB (added by euzuro, 1 year ago)

the two gutters params, imageSize and imageOffset dont both need to be set in all cases -- we should only set those when we *are* guttering

  • tests/Tile/test_Image.html

    old new  
    188188        map.setCenter(new OpenLayers.LonLat(0,0), 5); 
    189189         
    190190        var tile = layer.grid[0][0]; 
    191         t.ok(tile.layer.imageSize.equals(tile.size)
    192              "zero size gutter doesn't change image size");  
     191        t.ok(tile.layer.imageSize == null
     192             "zero size gutter doesn't set image size");  
    193193 
    194         t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(0, 0))
    195              "zero size gutter doesn't affect image offset"); 
     194        t.ok(tile.layer.imageOffset == null
     195             "zero size gutter doesn't set image offset"); 
    196196         
    197197        var zero_gutter_bounds = tile.bounds; 
    198198         
  • tests/Layer/test_Image.html

    old new  
    3939    } 
    4040 
    4141    function test_50_Layer_Image_tileTests (t) { 
    42         t.plan(9); 
     42        t.plan(6); 
    4343        var map = new OpenLayers.Map('map'); 
    4444         
    4545        layer = new OpenLayers.Layer.Image('Test Layer',  
     
    4949 
    5050        map.addLayer(layer); 
    5151        map.zoomToMaxExtent(); 
    52         t.ok(layer.imageSize, "layer.imageSize is set"); 
    53         t.ok(layer.tileSize, "layer.tileSize is set"); 
    54         t.ok(layer.tileSize.equals(layer.imageSize), "tileSize equals imageSize"); 
    5552 
    5653        // no resolution info was sent, so maxResolution should be calculated 
    5754        // by aspectRatio*extent/size (this is the pixel aspect ratio) 
  • lib/OpenLayers/Layer.js

    old new  
    306306        } 
    307307    }, 
    308308   
     309    /**  
     310     * @returns The size that the image should be, taking into account gutters 
     311     * @tile OpenLayers.Size 
     312     */ 
     313    getImageSize: function() { 
     314        return (this.imageSize || this.tileSize); 
     315    }, 
     316 
    309317    /** 
    310318     * Set the tile size based on the map size.  This also sets layer.imageSize 
    311319     * and layer.imageOffset for use by Tile.Image. 
     
    327335            this.imageOffset = new OpenLayers.Pixel(-this.gutter, -this.gutter);  
    328336            this.imageSize = new OpenLayers.Size(tileSize.w + (2 * this.gutter),  
    329337                                                 tileSize.h + (2 * this.gutter));  
    330         } else { 
    331             // layers without gutters may have null tile size - as long 
    332             // as they don't rely on Tile.Image 
    333             this.imageSize = tileSize; 
    334             this.imageOffset = new OpenLayers.Pixel(0, 0); 
    335338        } 
    336339    }, 
    337340 
  • lib/OpenLayers/Tile/Image.js

    old new  
    8787        OpenLayers.Util.modifyDOMElement(this.frame,  
    8888                                         null, this.position, this.size);    
    8989 
     90        var imageSize = this.layer.getImageSize(); 
    9091        if (this.layer.alpha) { 
    9192            OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv, 
    92                     null, null, this.layer.imageSize, this.url); 
     93                    null, null, imageSize, this.url); 
    9394        } else { 
    9495            this.imgDiv.src = this.url; 
    9596            OpenLayers.Util.modifyDOMElement(this.imgDiv, 
    96                     null, null, this.layer.imageSize) ; 
     97                    null, null, imageSize) ; 
    9798        } 
    9899        this.drawn = true; 
    99100        return true; 
     
    126127     *  
    127128     */ 
    128129    initImgDiv: function() { 
     130         
     131        var offset = this.layer.imageOffset; 
     132        var size = this.layer.getImageSize(); 
     133         
    129134        if (this.layer.alpha) { 
    130135            this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null, 
    131                                                            this.layer.imageOffset, 
    132                                                            this.layer.imageSize, 
     136                                                           offset, 
     137                                                           size, 
    133138                                                           null, 
    134139                                                           "relative", 
    135140                                                           null, 
     
    138143                                                           true); 
    139144        } else { 
    140145            this.imgDiv = OpenLayers.Util.createImage(null, 
    141                                                       this.layer.imageOffset, 
    142                                                       this.layer.imageSize, 
     146                                                      offset, 
     147                                                      size, 
    143148                                                      null, 
    144149                                                      "relative", 
    145150                                                      null, 
  • lib/OpenLayers/Layer/MapServer.js

    old new  
    9191        // Make a list, so that getFullRequestString uses literal ","  
    9292        var extent = [bounds.left, bounds. bottom, bounds.right, bounds.top]; 
    9393         
     94        var imageSize = this.getImageSize(); 
     95         
    9496        // make lists, so that literal ','s are used  
    9597        var url = this.getFullRequestString( 
    9698                     {mapext:   extent, 
    9799                      imgext:   extent, 
    98                       map_size: [this.imageSize.w, this.imageSize.h], 
    99                       imgx:     this.imageSize.w / 2, 
    100                       imgy:     this.imageSize.h / 2, 
    101                       imgxy:    [this.imageSize.w, this.imageSize.h] 
     100                      map_size: [imageSize.w, imageSize.h], 
     101                      imgx:     imageSize.w / 2, 
     102                      imgy:     imageSize.h / 2, 
     103                      imgxy:    [imageSize.w, imageSize.h] 
    102104                      }); 
    103105         
    104106        return url; 
  • lib/OpenLayers/Layer/WMS.js

    old new  
    9595     */ 
    9696    getURL: function (bounds) { 
    9797        bounds = this.adjustBounds(bounds); 
     98         
     99        var imageSize = this.getImageSize(); 
    98100        return this.getFullRequestString( 
    99101                     {BBOX:bounds.toBBOX(), 
    100                       WIDTH:this.imageSize.w, 
    101                       HEIGHT:this.imageSize.h}); 
     102                      WIDTH:imageSize.w, 
     103                      HEIGHT:imageSize.h}); 
    102104    }, 
    103105 
    104106    /** 
  • lib/OpenLayers/Layer/Image.js

    old new  
    151151    },  
    152152 
    153153    /** 
    154      * Set the tile size based on the map size.  This also sets layer.imageSize 
    155      * and layer.imageOffset for use by Tile.Image. 
     154     * Set the tile size based on the map size. 
    156155     */ 
    157156    setTileSize: function() { 
    158157        var tileWidth = this.extent.getWidth() / this.map.getResolution(); 
    159158        var tileHeight = this.extent.getHeight() / this.map.getResolution(); 
    160159        this.tileSize = new OpenLayers.Size(tileWidth, tileHeight); 
    161         this.imageSize = this.tileSize; 
    162         this.imageOffset = new OpenLayers.Pixel(0, 0); 
    163160    }, 
    164161 
    165162    /** 
  • lib/OpenLayers/Layer/MapServer/Untiled.js

    old new  
    103103    }, 
    104104     
    105105    /** 
    106      * Set the tile size based on the map size.  This also sets layer.imageSize 
    107      * and layer.imageOffset for use by Tile.Image. 
     106     * Set the tile size based on the map size. 
    108107     */ 
    109108    setTileSize: function() { 
    110109        var tileSize = this.map.getSize(); 
    111110        tileSize.w = tileSize.w * this.ratio; 
    112111        tileSize.h = tileSize.h * this.ratio; 
    113112        this.tileSize = tileSize; 
    114         this.imageSize = tileSize; 
    115         this.imageOffset = new OpenLayers.Pixel(0, 0); 
    116113    }, 
    117114 
    118115    /** When it is not a dragging move (ie when done dragging) 
  • lib/OpenLayers/Layer/WMS/Untiled.js

    old new  
    109109    }, 
    110110 
    111111    /** 
    112      * Set the tile size based on the map size.  This also sets layer.imageSize 
    113      * and layer.imageOffset for use by Tile.Image. 
     112     * Set the tile size based on the map size. 
    114113     */ 
    115114    setTileSize: function() { 
    116115        var tileSize = this.map.getSize(); 
    117116        tileSize.w = tileSize.w * this.ratio; 
    118117        tileSize.h = tileSize.h * this.ratio; 
    119118        this.tileSize = tileSize; 
    120         this.imageSize = tileSize; 
    121         this.imageOffset = new OpenLayers.Pixel(0, 0); 
    122119    }, 
    123120 
    124121    /** When it is not a dragging move (ie when done dragging)