#529 give tiles gutters - all layers that use Tile.Image must now look after layer.imageSize and layer.imageOffset - this is handled by layer.setTileSize - for untiled layers, setTileSize must be defined by the subclass - gutters are currently supported in Layer.Mapserver and Layer.WMS
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2979 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -54,10 +54,10 @@
|
||||
t.eq( img.src,
|
||||
url + "?" + OpenLayers.Util.getParameterString(tParams).replace(/,/g, "+"),
|
||||
"image src is created correctly via addtile" );
|
||||
t.eq( tile.imgDiv.style.top, "6px", "image top is set correctly via addtile" );
|
||||
t.eq( tile.imgDiv.style.left, "5px", "image top is set correctly via addtile" );
|
||||
t.eq( tile.frame.style.top, "6px", "image top is set correctly via addtile" );
|
||||
t.eq( tile.frame.style.left, "5px", "image top is set correctly via addtile" );
|
||||
|
||||
var firstChild = layer.div.firstChild;
|
||||
var firstChild = layer.div.firstChild.firstChild;
|
||||
if (!isMozilla)
|
||||
t.ok( true, "skipping element test outside of Mozilla");
|
||||
else
|
||||
@@ -186,10 +186,10 @@
|
||||
map.addLayer(tLayer);
|
||||
map.zoomToMaxExtent();
|
||||
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
|
||||
tLayer.setOpacity("0.6");
|
||||
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
|
||||
var pixel = new OpenLayers.Pixel(5,6);
|
||||
var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
|
||||
tile.draw();
|
||||
|
||||
@@ -127,10 +127,10 @@
|
||||
map.addLayer(tLayer);
|
||||
map.zoomToMaxExtent();
|
||||
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
|
||||
tLayer.setOpacity("0.6");
|
||||
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@
|
||||
t.eq( img.src,
|
||||
url + "?" + OpenLayers.Util.getParameterString(tParams),
|
||||
"image src is created correctly via addtile" );
|
||||
t.eq( tile.imgDiv.style.top, "6px", "image top is set correctly via addtile" );
|
||||
t.eq( tile.imgDiv.style.left, "5px", "image top is set correctly via addtile" );
|
||||
t.eq( tile.frame.style.top, "6px", "image top is set correctly via addtile" );
|
||||
t.eq( tile.frame.style.left, "5px", "image top is set correctly via addtile" );
|
||||
|
||||
var firstChild = layer.div.firstChild;
|
||||
var firstChild = layer.div.firstChild.firstChild;
|
||||
if (!isMozilla)
|
||||
t.ok( true, "skipping element test outside of Mozilla");
|
||||
else
|
||||
@@ -191,10 +191,10 @@
|
||||
map.addLayer(tLayer);
|
||||
map.zoomToMaxExtent();
|
||||
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
|
||||
tLayer.setOpacity("0.6");
|
||||
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
|
||||
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
|
||||
var pixel = new OpenLayers.Pixel(5,6);
|
||||
var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
|
||||
tile.draw();
|
||||
@@ -231,6 +231,48 @@
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_21_Layer_WMS_noGutters (t) {
|
||||
t.plan(2);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS("no gutter layer", url, params, {gutter: 0});
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = layer.grid[0][0];
|
||||
var request = layer.getURL(tile.bounds);
|
||||
var args = OpenLayers.Util.getArgs(request);
|
||||
t.eq(parseInt(args['WIDTH']),
|
||||
tile.size.w,
|
||||
"layer without gutter requests images that are as wide as the tile");
|
||||
t.eq(parseInt(args['HEIGHT']),
|
||||
tile.size.h,
|
||||
"layer without gutter requests images that are as tall as the tile");
|
||||
|
||||
layer.destroy();
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_22_Layer_WMS_gutters (t) {
|
||||
t.plan(2);
|
||||
var gutter = 15;
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS("gutter layer", url, params, {gutter: gutter});
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = layer.grid[0][0];
|
||||
var request = layer.getURL(tile.bounds);
|
||||
var args = OpenLayers.Util.getArgs(request);
|
||||
t.eq(parseInt(args['WIDTH']),
|
||||
tile.size.w + (2 * gutter),
|
||||
"layer with gutter requests images that are wider by twice the gutter");
|
||||
t.eq(parseInt(args['HEIGHT']),
|
||||
tile.size.h + (2 * gutter),
|
||||
"layer with gutter requests images that are taller by twice the gutter");
|
||||
|
||||
layer.destroy();
|
||||
map.destroy();
|
||||
|
||||
}
|
||||
|
||||
function test_99_Layer_WMS_destroy (t) {
|
||||
|
||||
t.plan( 1 );
|
||||
|
||||
@@ -29,12 +29,15 @@
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
|
||||
layer = new OpenLayers.Layer.WMS("Name", "http://labs.metacarta.com/TESTURL");
|
||||
var size = new OpenLayers.Size(5,6);
|
||||
layer = new OpenLayers.Layer.WMS("Name",
|
||||
"http://labs.metacarta.com/TESTURL",
|
||||
null,
|
||||
{tileSize: size});
|
||||
map.addLayer(layer);
|
||||
var position = new OpenLayers.Pixel(20,30);
|
||||
var bounds = new OpenLayers.Bounds(1,2,3,4);
|
||||
var url = "http://www.openlayers.org/dev/tests/tileimage";
|
||||
var size = new OpenLayers.Size(5,6);
|
||||
tile = new OpenLayers.Tile.Image(layer, position, bounds, url, size);
|
||||
|
||||
tile.draw();
|
||||
@@ -53,7 +56,7 @@
|
||||
REQUEST: "GetMap", STYLES: "",
|
||||
EXCEPTIONS: "application/vnd.ogc.se_inimage", FORMAT: "image/jpeg",
|
||||
SRS: "EPSG:4326", BBOX: "1,2,3,4",
|
||||
WIDTH: "256", HEIGHT: "256"
|
||||
WIDTH: String(size.w), HEIGHT: String(size.h)
|
||||
};
|
||||
t.eq( img.src,
|
||||
"http://labs.metacarta.com/TESTURL?" + OpenLayers.Util.getParameterString(tParams),
|
||||
@@ -167,11 +170,57 @@
|
||||
t.delay_call( 1, function() { t.eq(tile.imgDiv, null, "Alpha tile imgDiv is null.") } );
|
||||
|
||||
}
|
||||
|
||||
function test_05_Tile_Image_gutters(t) {
|
||||
t.plan(5);
|
||||
|
||||
var gutter = 0;
|
||||
var name = 'Test Layer';
|
||||
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||
var params = { map: '/mapdata/vmap_wms.map',
|
||||
layers: 'basic',
|
||||
format: 'image/png'};
|
||||
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS(name, url, params, {gutter: gutter});
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
|
||||
var tile = layer.grid[0][0];
|
||||
|
||||
t.ok(tile.layer.imageSize.equals(tile.size),
|
||||
"zero size gutter doesn't change image size");
|
||||
|
||||
t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(0, 0)),
|
||||
"zero size gutter doesn't affect image offset");
|
||||
|
||||
map.destroy();
|
||||
|
||||
var gutter = 15;
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS(name, url, params, {gutter: gutter});
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = layer.grid[0][0];
|
||||
t.ok(tile.layer.imageSize.equals(new OpenLayers.Size(tile.size.w + (2 * gutter),
|
||||
tile.size.h + (2 * gutter))),
|
||||
"gutter properly changes image size");
|
||||
|
||||
t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(-gutter, -gutter)),
|
||||
"gutter properly sets image offset");
|
||||
|
||||
t.ok(tile.bounds.equals(new OpenLayers.Bounds(-33.75, 33.75, -22.5, 45)),
|
||||
"gutter doesn't affect tile bounds");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="height:500px;width:500px"></div>
|
||||
<div id="map" style="height:550px;width:500px"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user