Use proj/unproj consistently
authorJohn Firebaugh <john.firebaugh@gmail.com>
Mon, 8 Oct 2012 05:29:58 +0000 (22:29 -0700)
committerTom Hughes <tom@compton.nu>
Sat, 13 Oct 2012 11:58:18 +0000 (12:58 +0100)
app/assets/javascripts/browse.js
app/assets/javascripts/index/browse.js
app/assets/javascripts/index/export.js
app/assets/javascripts/map.js.erb

index 9858db091a65c769c7b0cd0994ecf542d3b3d3fb..1c0b1b47993287bd03378cee90c9ad9b85a610be 100644 (file)
@@ -56,7 +56,7 @@ $(document).ready(function () {
       $("#browse_map .geolink").show();
 
       if (extent) {
-        extent.transform(map.getProjectionObject(), map.displayProjection);
+        extent = unproj(extent);
 
         var centre = extent.getCenterLonLat();
 
index 891e1c9bc73f5c3da1868883e78669e9669c83a2..4f3351a76f56a3f88eeff92cbd87172c9c28b06a 100644 (file)
@@ -100,7 +100,7 @@ $(document).ready(function () {
 
     function useMap(reload) {
       var bounds = map.getExtent();
-      var projected = bounds.clone().transform(map.getProjectionObject(), epsg4326);
+      var projected = unproj(bounds);
 
       if (!browseBounds || !browseBounds.containsBounds(projected)) {
         var center = bounds.getCenterLonLat();
@@ -144,7 +144,7 @@ $(document).ready(function () {
 
     function endDrag(bbox) {
       var bounds = bbox.getBounds();
-      var projected = bounds.clone().transform(map.getProjectionObject(), epsg4326);
+      var projected = unproj(bounds);
 
       browseBoxControl.deactivate();
       browseBounds = projected;
@@ -197,7 +197,7 @@ $(document).ready(function () {
     }
 
     function getData(bounds, reload) {
-      var projected = bounds.clone().transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));
+      var projected = unproj(bounds);
       var size = projected.getWidth() * projected.getHeight();
 
       if (size > OSM.MAX_REQUEST_AREA) {
index c5813dc1c3282c1d8eea2052a0deb5a32366fc7a..8696338ab403fade93cbf53eb34100bf792f6d46 100644 (file)
@@ -15,9 +15,7 @@ $(document).ready(function () {
         box,
         transform,
         markerLayer,
-        markerControl,
-        epsg4326 = new OpenLayers.Projection("EPSG:4326"),
-        epsg900913 = new OpenLayers.Projection("EPSG:900913");
+        markerControl;
 
     vectors = new OpenLayers.Layer.Vector("Vector Layer", {
       displayInLayerSwitcher: false
@@ -83,7 +81,7 @@ $(document).ready(function () {
       var bounds = new OpenLayers.Bounds($("#minlon").val(), $("#minlat").val(),
                                          $("#maxlon").val(), $("#maxlat").val());
 
-      return bounds.transform(epsg4326, epsg900913);
+      return proj(bounds);
     }
 
     function boundsChanged() {
@@ -157,7 +155,7 @@ $(document).ready(function () {
       $("#add_marker").html(I18n.t('export.start_rjs.change_marker'));
       $("#marker_inputs").show();
 
-      var geom = event.feature.geometry.clone().transform(epsg900913, epsg4326);
+      var geom = unproj(event.feature.geometry);
 
       $("#marker_lon").val(geom.x.toFixed(5));
       $("#marker_lat").val(geom.y.toFixed(5));
@@ -186,7 +184,7 @@ $(document).ready(function () {
     function setBounds(bounds) {
       var toPrecision = zoomPrecision(map.getZoom());
 
-      bounds = bounds.clone().transform(map.getProjectionObject(), epsg4326);
+      bounds = unproj(bounds);
 
       $("#minlon").val(toPrecision(bounds.left));
       $("#minlat").val(toPrecision(bounds.bottom));
@@ -247,8 +245,7 @@ $(document).ready(function () {
       // Create "larger map" link
       var center = bounds.getCenterLonLat();
 
-      bounds.transform(epsg4326, epsg900913);
-      var zoom = map.getZoomForExtent(bounds);
+      var zoom = map.getZoomForExtent(proj(bounds));
 
       var layers = getMapLayers();
 
index 5299340480fa4a243d94fef17ba63d3034549a9d..c06c9c8eaf809cf0aecc9733da766b0458aeff2a 100644 (file)
@@ -219,7 +219,7 @@ function setMapCenter(center, zoom) {
 }
 
 function getEventPosition(event) {
-   return map.getLonLatFromViewPortPx(event.xy).clone().transform(map.getProjectionObject(), epsg4326);
+   return unproj(map.getLonLatFromViewPortPx(event.xy));
 }
 
 function getMapLayers() {