Ticket #785: gutters.patch
| File gutters.patch, 9.3 kB (added by euzuro, 1 year ago) |
|---|
-
tests/Tile/test_Image.html
old new 188 188 map.setCenter(new OpenLayers.LonLat(0,0), 5); 189 189 190 190 var tile = layer.grid[0][0]; 191 t.ok(tile.layer.imageSize .equals(tile.size),192 "zero size gutter doesn't changeimage size");191 t.ok(tile.layer.imageSize == null, 192 "zero size gutter doesn't set image size"); 193 193 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"); 196 196 197 197 var zero_gutter_bounds = tile.bounds; 198 198 -
tests/Layer/test_Image.html
old new 39 39 } 40 40 41 41 function test_50_Layer_Image_tileTests (t) { 42 t.plan( 9);42 t.plan(6); 43 43 var map = new OpenLayers.Map('map'); 44 44 45 45 layer = new OpenLayers.Layer.Image('Test Layer', … … 49 49 50 50 map.addLayer(layer); 51 51 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");55 52 56 53 // no resolution info was sent, so maxResolution should be calculated 57 54 // by aspectRatio*extent/size (this is the pixel aspect ratio) -
lib/OpenLayers/Layer.js
old new 306 306 } 307 307 }, 308 308 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 309 317 /** 310 318 * Set the tile size based on the map size. This also sets layer.imageSize 311 319 * and layer.imageOffset for use by Tile.Image. … … 327 335 this.imageOffset = new OpenLayers.Pixel(-this.gutter, -this.gutter); 328 336 this.imageSize = new OpenLayers.Size(tileSize.w + (2 * this.gutter), 329 337 tileSize.h + (2 * this.gutter)); 330 } else {331 // layers without gutters may have null tile size - as long332 // as they don't rely on Tile.Image333 this.imageSize = tileSize;334 this.imageOffset = new OpenLayers.Pixel(0, 0);335 338 } 336 339 }, 337 340 -
lib/OpenLayers/Tile/Image.js
old new 87 87 OpenLayers.Util.modifyDOMElement(this.frame, 88 88 null, this.position, this.size); 89 89 90 var imageSize = this.layer.getImageSize(); 90 91 if (this.layer.alpha) { 91 92 OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv, 92 null, null, this.layer.imageSize, this.url);93 null, null, imageSize, this.url); 93 94 } else { 94 95 this.imgDiv.src = this.url; 95 96 OpenLayers.Util.modifyDOMElement(this.imgDiv, 96 null, null, this.layer.imageSize) ;97 null, null, imageSize) ; 97 98 } 98 99 this.drawn = true; 99 100 return true; … … 126 127 * 127 128 */ 128 129 initImgDiv: function() { 130 131 var offset = this.layer.imageOffset; 132 var size = this.layer.getImageSize(); 133 129 134 if (this.layer.alpha) { 130 135 this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null, 131 this.layer.imageOffset,132 this.layer.imageSize,136 offset, 137 size, 133 138 null, 134 139 "relative", 135 140 null, … … 138 143 true); 139 144 } else { 140 145 this.imgDiv = OpenLayers.Util.createImage(null, 141 this.layer.imageOffset,142 this.layer.imageSize,146 offset, 147 size, 143 148 null, 144 149 "relative", 145 150 null, -
lib/OpenLayers/Layer/MapServer.js
old new 91 91 // Make a list, so that getFullRequestString uses literal "," 92 92 var extent = [bounds.left, bounds. bottom, bounds.right, bounds.top]; 93 93 94 var imageSize = this.getImageSize(); 95 94 96 // make lists, so that literal ','s are used 95 97 var url = this.getFullRequestString( 96 98 {mapext: extent, 97 99 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] 102 104 }); 103 105 104 106 return url; -
lib/OpenLayers/Layer/WMS.js
old new 95 95 */ 96 96 getURL: function (bounds) { 97 97 bounds = this.adjustBounds(bounds); 98 99 var imageSize = this.getImageSize(); 98 100 return this.getFullRequestString( 99 101 {BBOX:bounds.toBBOX(), 100 WIDTH: this.imageSize.w,101 HEIGHT: this.imageSize.h});102 WIDTH:imageSize.w, 103 HEIGHT:imageSize.h}); 102 104 }, 103 105 104 106 /** -
lib/OpenLayers/Layer/Image.js
old new 151 151 }, 152 152 153 153 /** 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. 156 155 */ 157 156 setTileSize: function() { 158 157 var tileWidth = this.extent.getWidth() / this.map.getResolution(); 159 158 var tileHeight = this.extent.getHeight() / this.map.getResolution(); 160 159 this.tileSize = new OpenLayers.Size(tileWidth, tileHeight); 161 this.imageSize = this.tileSize;162 this.imageOffset = new OpenLayers.Pixel(0, 0);163 160 }, 164 161 165 162 /** -
lib/OpenLayers/Layer/MapServer/Untiled.js
old new 103 103 }, 104 104 105 105 /** 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. 108 107 */ 109 108 setTileSize: function() { 110 109 var tileSize = this.map.getSize(); 111 110 tileSize.w = tileSize.w * this.ratio; 112 111 tileSize.h = tileSize.h * this.ratio; 113 112 this.tileSize = tileSize; 114 this.imageSize = tileSize;115 this.imageOffset = new OpenLayers.Pixel(0, 0);116 113 }, 117 114 118 115 /** When it is not a dragging move (ie when done dragging) -
lib/OpenLayers/Layer/WMS/Untiled.js
old new 109 109 }, 110 110 111 111 /** 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. 114 113 */ 115 114 setTileSize: function() { 116 115 var tileSize = this.map.getSize(); 117 116 tileSize.w = tileSize.w * this.ratio; 118 117 tileSize.h = tileSize.h * this.ratio; 119 118 this.tileSize = tileSize; 120 this.imageSize = tileSize;121 this.imageOffset = new OpenLayers.Pixel(0, 0);122 119 }, 123 120 124 121 /** When it is not a dragging move (ie when done dragging)
