From 4f58ff0352386861b55f728fb67c12dc65fce43f Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 18 Nov 2011 13:06:28 +0100 Subject: [PATCH] Removing getBoundsFromBaseLayer method. This method is only needed when the deprecated reproject option is set to true. --- examples/google-reproject.html | 63 --------------------------------- lib/OpenLayers/Layer/WMS.js | 11 ------ lib/OpenLayers/Tile.js | 38 -------------------- lib/deprecated.js | 43 ++++++++++++++++++++++ tests/Layer/MapServer.html | 2 +- tests/Layer/WMS.html | 40 --------------------- tests/Layer/WrapDateLine.html | 2 +- tests/Tile/Image.html | 4 +-- tests/deprecated/Layer/WMS.html | 57 +++++++++++++++++++++++++++++ tests/list-tests.html | 1 + 10 files changed, 105 insertions(+), 156 deletions(-) delete mode 100644 examples/google-reproject.html create mode 100644 tests/deprecated/Layer/WMS.html diff --git a/examples/google-reproject.html b/examples/google-reproject.html deleted file mode 100644 index 1606e6e0ef..0000000000 --- a/examples/google-reproject.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - OpenLayers Google with Overlay Example - - - - - - - - -

Google with Overlay Example

- -
- Google, overlay, mercator, reproject, cleanup -
- -

- Demonstrate a Google basemap used with boundary overlay layer. -

- -
- -
-

An overlay in a Geographic projection can be stretched to somewhat - line up with Google tiles (in a Mercator projection). Results get - worse farther from the equator. Use the "reproject" option on a - layer to get this behavior. Use the sphericalMercator option on - a Google layer to get proper overlays (with other layers in - Spherical Mercator).

-
- - diff --git a/lib/OpenLayers/Layer/WMS.js b/lib/OpenLayers/Layer/WMS.js index 5e1eaf0290..037a014560 100644 --- a/lib/OpenLayers/Layer/WMS.js +++ b/lib/OpenLayers/Layer/WMS.js @@ -31,17 +31,6 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, { format: "image/jpeg" }, - /** - * Property: reproject - * *Deprecated*. See http://trac.openlayers.org/wiki/SphericalMercator - * for information on the replacement for this functionality. - * {Boolean} Try to reproject this layer if its coordinate reference system - * is different than that of the base layer. Default is false. - * Set this in the layer options. Should be set to false in - * most cases. - */ - reproject: false, - /** * APIProperty: isBaseLayer * {Boolean} Default is true for WMS layer diff --git a/lib/OpenLayers/Tile.js b/lib/OpenLayers/Tile.js index fb8b08d931..b083015b40 100644 --- a/lib/OpenLayers/Tile.js +++ b/lib/OpenLayers/Tile.js @@ -236,43 +236,5 @@ OpenLayers.Tile = OpenLayers.Class({ // to be implemented by subclasses }, - /** - * Method: getBoundsFromBaseLayer - * Take the pixel locations of the corner of the tile, and pass them to - * the base layer and ask for the location of those pixels, so that - * displaying tiles over Google works fine. - * - * Parameters: - * position - {} - * - * Returns: - * bounds - {} - */ - getBoundsFromBaseLayer: function(position) { - var msg = OpenLayers.i18n('reprojectDeprecated', - {'layerName':this.layer.name}); - OpenLayers.Console.warn(msg); - var topLeft = this.layer.map.getLonLatFromLayerPx(position); - var bottomRightPx = position.clone(); - bottomRightPx.x += this.size.w; - bottomRightPx.y += this.size.h; - var bottomRight = this.layer.map.getLonLatFromLayerPx(bottomRightPx); - // Handle the case where the base layer wraps around the date line. - // Google does this, and it breaks WMS servers to request bounds in - // that fashion. - if (topLeft.lon > bottomRight.lon) { - if (topLeft.lon < 0) { - topLeft.lon = -180 - (topLeft.lon+180); - } else { - bottomRight.lon = 180+bottomRight.lon+180; - } - } - var bounds = new OpenLayers.Bounds(topLeft.lon, - bottomRight.lat, - bottomRight.lon, - topLeft.lat); - return bounds; - }, - CLASS_NAME: "OpenLayers.Tile" }); diff --git a/lib/deprecated.js b/lib/deprecated.js index 3a844da75d..23f0d976b8 100644 --- a/lib/deprecated.js +++ b/lib/deprecated.js @@ -1053,6 +1053,49 @@ if (window.Event) { var Event = OpenLayers.Event; } +/** + * Namespace: OpenLayers.Tile + */ +OpenLayers.Util.extend(OpenLayers.Tile.prototype, { + /** + * Method: getBoundsFromBaseLayer + * Take the pixel locations of the corner of the tile, and pass them to + * the base layer and ask for the location of those pixels, so that + * displaying tiles over Google works fine. + * + * Parameters: + * position - {} + * + * Returns: + * bounds - {} + */ + getBoundsFromBaseLayer: function(position) { + var msg = OpenLayers.i18n('reprojectDeprecated', + {'layerName':this.layer.name}); + OpenLayers.Console.warn(msg); + var topLeft = this.layer.map.getLonLatFromLayerPx(position); + var bottomRightPx = position.clone(); + bottomRightPx.x += this.size.w; + bottomRightPx.y += this.size.h; + var bottomRight = this.layer.map.getLonLatFromLayerPx(bottomRightPx); + // Handle the case where the base layer wraps around the date line. + // Google does this, and it breaks WMS servers to request bounds in + // that fashion. + if (topLeft.lon > bottomRight.lon) { + if (topLeft.lon < 0) { + topLeft.lon = -180 - (topLeft.lon+180); + } else { + bottomRight.lon = 180+bottomRight.lon+180; + } + } + var bounds = new OpenLayers.Bounds(topLeft.lon, + bottomRight.lat, + bottomRight.lon, + topLeft.lat); + return bounds; + } +}); + /** * Class: OpenLayers.Control.MouseDefaults * This class is DEPRECATED in 2.4 and will be removed by 3.0. diff --git a/tests/Layer/MapServer.html b/tests/Layer/MapServer.html index 04f73b9e18..59757d89cc 100644 --- a/tests/Layer/MapServer.html +++ b/tests/Layer/MapServer.html @@ -229,7 +229,7 @@ var map = new OpenLayers.Map('map'); var layer = new OpenLayers.Layer.Google("Google"); map.addLayer(layer); - layer = new OpenLayers.Layer.MapServer(name, url, params, {isBaseLayer: false, reproject: true, buffer: 2}); + layer = new OpenLayers.Layer.MapServer(name, url, params, {isBaseLayer: false, buffer: 2}); layer.isBaseLayer=false; map.addLayer(layer); map.setCenter(new OpenLayers.LonLat(0,0), 5); diff --git a/tests/Layer/WMS.html b/tests/Layer/WMS.html index 377925926a..3bba3c821b 100644 --- a/tests/Layer/WMS.html +++ b/tests/Layer/WMS.html @@ -296,46 +296,6 @@ map.destroy(); } - function test_Layer_WMS_Reproject (t) { - var validkey = (window.location.protocol == "file:") || - (window.location.host == "localhost") || - (window.location.host == "openlayers.org"); - if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.BROWSER_NAME == "safari") { - t.plan(1); - t.debug_print("Can't test google reprojection in Opera or Safari."); - } else if(validkey) { - t.plan(5); - - var map = new OpenLayers.Map('map'); - var layer = new OpenLayers.Layer.Google("Google"); - map.addLayer(layer); - var wmslayer = new OpenLayers.Layer.WMS(name, url, params, - {isBaseLayer: false, reproject:true, buffer: 2}); - wmslayer.isBaseLayer=false; - map.addLayer(wmslayer); - map.setCenter(new OpenLayers.LonLat(0,0), 5); - var tile = wmslayer.grid[0][0]; - t.eq( tile.bounds.left, -22.5, "left side matches" ); - t.eq( tile.bounds.right, -11.25, "right side matches" ); - t.eq( tile.bounds.bottom.toFixed(6), '11.178402', "bottom side matches" ); - t.eq( tile.bounds.top.toFixed(6), '21.943046', "top side matches" ); - map.destroy(); - } else { - t.plan(1); - t.debug_print("can't test google layer from " + - window.location.host); - } - - var map = new OpenLayers.Map('map'); - layer = new OpenLayers.Layer.WMS(name, url, params, {buffer: 2}); - map.addLayer(layer); - map.setCenter(new OpenLayers.LonLat(0,0), 5); - var tile = layer.grid[0][0]; - t.ok( tile.bounds.equals(new OpenLayers.Bounds(-33.75, 33.75, -22.5, 45)), "okay"); - - map.destroy(); - } - function test_Layer_WMS_noGutters (t) { t.plan(2); var map = new OpenLayers.Map('map'); diff --git a/tests/Layer/WrapDateLine.html b/tests/Layer/WrapDateLine.html index 010918e958..15e9d5771a 100644 --- a/tests/Layer/WrapDateLine.html +++ b/tests/Layer/WrapDateLine.html @@ -164,7 +164,7 @@ {layers: "bathymetry,land_fn,park,drain_fn,drainage," + "prov_bound,fedlimit,rail,road,popplace", transparent: "true", format: "image/png"}, - {wrapDateLine: true, reproject: false,encodeBBOX:true, buffer:2}); + {wrapDateLine: true, encodeBBOX:true, buffer:2}); var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}}); m.addLayers([baselayer,layer]); m.zoomToMaxExtent(); diff --git a/tests/Tile/Image.html b/tests/Tile/Image.html index 22aa3ab6fa..fcad0917c7 100644 --- a/tests/Tile/Image.html +++ b/tests/Tile/Image.html @@ -255,7 +255,7 @@ var size = new OpenLayers.Size(5,6); var map = new OpenLayers.Map('map'); var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", - "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}, {'reproject': true}); + "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}); map.addLayer(layer); map.zoomToMaxExtent(); tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size); @@ -263,7 +263,7 @@ tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true); t.delay_call( 1, function() { t.eq(tile.imgDiv.style.display, "none", "Tile image is invisible.") } ); var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", - "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}, {'reproject': true, 'alpha':true}); + "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}, {'alpha':true}); map.addLayer(layer); tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size); tile.draw(); diff --git a/tests/deprecated/Layer/WMS.html b/tests/deprecated/Layer/WMS.html new file mode 100644 index 0000000000..8a2a43eeae --- /dev/null +++ b/tests/deprecated/Layer/WMS.html @@ -0,0 +1,57 @@ + + + + + + + +
+ + diff --git a/tests/list-tests.html b/tests/list-tests.html index 124ef8223f..adc9580f73 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -230,6 +230,7 @@
  • deprecated/Layer/MapServer/Untiled.html
  • deprecated/Layer/MultiMap.html
  • deprecated/Layer/WFS.html
  • +
  • deprecated/Layer/WMS.html
  • deprecated/Layer/WMS/Post.html
  • deprecated/Tile/WFS.html