aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/OpenLayers.Projection.CH1903.js
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-11-26 16:03:31 +0000
committerMatthew Somerville <matthew@mysociety.org>2012-11-26 16:27:20 +0000
commit84d6ec9717c8e737dfdee0f04272a4cd955daae2 (patch)
tree70f9fccc296b770a9458b8f51f3b6242dc843a27 /web/js/OpenLayers.Projection.CH1903.js
parenta6a42abed9dd134169d2db3d55de555951ca319f (diff)
Simplify map bound transformation (should do bounds transform as might be skewed translation), fix transforms to modify original.
Diffstat (limited to 'web/js/OpenLayers.Projection.CH1903.js')
-rw-r--r--web/js/OpenLayers.Projection.CH1903.js20
1 files changed, 11 insertions, 9 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);