From 84d6ec9717c8e737dfdee0f04272a4cd955daae2 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 26 Nov 2012 16:03:31 +0000 Subject: Simplify map bound transformation (should do bounds transform as might be skewed translation), fix transforms to modify original. --- web/js/OpenLayers.Projection.CH1903.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'web/js/OpenLayers.Projection.CH1903.js') 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); -- cgit v1.2.3