diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-11-26 16:03:31 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-11-26 16:27:20 +0000 |
commit | 84d6ec9717c8e737dfdee0f04272a4cd955daae2 (patch) | |
tree | 70f9fccc296b770a9458b8f51f3b6242dc843a27 /web/js | |
parent | a6a42abed9dd134169d2db3d55de555951ca319f (diff) |
Simplify map bound transformation (should do bounds transform as might be skewed translation), fix transforms to modify original.
Diffstat (limited to 'web/js')
-rw-r--r-- | web/js/OpenLayers.Projection.CH1903.js | 20 | ||||
-rw-r--r-- | web/js/map-wmts-zurich.js | 15 |
2 files changed, 15 insertions, 20 deletions
diff --git a/web/js/OpenLayers.Projection.CH1903.js b/web/js/OpenLayers.Projection.CH1903.js index f050441e6..cb62a0168 100644 --- a/web/js/OpenLayers.Projection.CH1903.js +++ b/web/js/OpenLayers.Projection.CH1903.js @@ -148,18 +148,20 @@ OpenLayers.Projection.CH1903 = { // Function to convert a WGS84 coordinate to a Swiss coordinate. projectForwardSwiss: function(point) { - var newPoint = {}; - newPoint.x = OpenLayers.Projection.CH1903.WGStoCHx(point.x, point.y); - newPoint.y = OpenLayers.Projection.CH1903.WGStoCHy(point.x, point.y); - return newPoint; + var x = OpenLayers.Projection.CH1903.WGStoCHx(point.y, point.x), + y = OpenLayers.Projection.CH1903.WGStoCHy(point.y, point.x); + point.x = y; // x/y are geometrically swapped by the conversion functions + point.y = x; + return point; }, // Function to convert a Swiss coordinate to a WGS84 coordinate. projectInverseSwiss: function(point) { - var newPoint = {}; - newPoint.x = OpenLayers.Projection.CH1903.chToWGSlng(point.y, point.x); - newPoint.y = OpenLayers.Projection.CH1903.chToWGSlat(point.y, point.x); - return newPoint; + var lon = OpenLayers.Projection.CH1903.chToWGSlng(point.x, point.y); + var lat = OpenLayers.Projection.CH1903.chToWGSlat(point.x, point.y); + point.x = lon; + point.y = lat; + return point; } }; @@ -170,4 +172,4 @@ OpenLayers.Projection.CH1903 = { OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:21781", OpenLayers.Projection.CH1903.projectForwardSwiss); OpenLayers.Projection.addTransform("EPSG:21781", "EPSG:4326", - OpenLayers.Projection.CH1903.projectInverseSwiss);
\ No newline at end of file + OpenLayers.Projection.CH1903.projectInverseSwiss); diff --git a/web/js/map-wmts-zurich.js b/web/js/map-wmts-zurich.js index 8723d557c..55f6f9dd2 100644 --- a/web/js/map-wmts-zurich.js +++ b/web/js/map-wmts-zurich.js @@ -10,7 +10,7 @@ function init_zurich_map(after) { fixmystreet.map = new OpenLayers.Map('map', { projection: new OpenLayers.Projection("EPSG:21781"), - displayProjection: new OpenLayers.Projection("EPSG:21781"), + displayProjection: new OpenLayers.Projection("EPSG:4326"), maxExtent: new OpenLayers.Bounds(676000,241000,690000,255000), units: 'm', scales: [ '250000', '125000', '64000', '32000', '16000', '8000', '4000', '2000', '1000', '500'], @@ -109,16 +109,9 @@ OpenLayers.Strategy.ZurichBBOX = OpenLayers.Class(OpenLayers.Strategy.BBOX, { } var swissBounds = this.layer.map.getExtent(); - - // Transform bound corners into WGS84 - note x/y arrangement of - // values from the current bounding box, it seems wrong but is not. - var topLeft = OpenLayers.Projection.CH1903.projectInverseSwiss( - {y: swissBounds.left, x: swissBounds.top} - ); - var bottomRight = OpenLayers.Projection.CH1903.projectInverseSwiss( - {y: swissBounds.right, x: swissBounds.bottom} - ); - return new OpenLayers.Bounds(topLeft.x, bottomRight.y, bottomRight.x, topLeft.y); + // Transform bound corners into WGS84 + swissBounds.transform( new OpenLayers.Projection("EPSG:21781"), new OpenLayers.Projection("EPSG:4326") ); + return swissBounds; }, CLASS_NAME: "OpenLayers.Strategy.ZurichBBOX" |