← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18115: GIS, projection fix.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 18115 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-01-23 17:04:30 +0100
message:
  GIS, projection fix.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/plugin.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/plugin.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/plugin.html	2014-12-24 15:40:47 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/plugin.html	2015-01-23 16:01:30 +0000
@@ -6,9 +6,6 @@
 <!--
     <link rel="stylesheet" type="text/css" href="//localhost:8080/dhis-web-commons/javascripts/ext/resources/css/ext-all-gray.css"/>
 -->
-<!--
-    <link rel="stylesheet" type="text/css" href="//localhost:8080/dhis-web-commons/javascripts/ext/resources/css/tmp.css"/>
--->
 
     <script src="//localhost:8080/dhis-web-commons/javascripts/ext/ext-all.js"></script>
     <script src="//maps.google.com/maps/api/js?sensor=false"></script>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2015-01-21 18:52:56 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2015-01-23 16:01:30 +0000
@@ -2658,8 +2658,11 @@
 				handler: function() {
 					var name = nameTextfield.getValue(),
 						layers = gis.util.map.getRenderedVectorLayers(),
+                        centerPoint = function() {
+                            var lonlat = gis.olmap.getCenter();
+                            return new OpenLayers.Geometry.Point(v.lon, v.lat).transform('EPSG:900913', 'EPSG:4326');
+                        }(),
 						layer,
-						lonlat = gis.olmap.getCenter(),
 						views = [],
 						view,
 						map;
@@ -2681,7 +2684,7 @@
 
                         view.hidden = !layer.visibility;
 
-						// Operand
+						// operand
 						if (Ext.isArray(view.columns) && view.columns.length) {
 							for (var j = 0; j < view.columns.length; j++) {
 								for (var k = 0, item; k < view.columns[j].items.length; k++) {
@@ -2702,8 +2705,8 @@
 
 					map = {
 						name: name,
-						longitude: lonlat.lon,
-						latitude: lonlat.lat,
+						longitude: centerPoint.x,
+						latitude: centerPoint.y,
 						zoom: gis.olmap.getZoom(),
 						mapViews: views,
 						user: {

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js	2015-01-21 18:52:56 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js	2015-01-23 16:01:30 +0000
@@ -1156,19 +1156,26 @@
 		};
 
 		afterLoad = function() {
+            var lon = parseFloat(gis.map.longitude) || 0,
+                lat = parseFloat(gis.map.latitude) || 20,
+                zoom = gis.map.zoom || 3;
+
 			register = [];
 
+            // validate, transform
+            if ((lon >= -180 && lon <= 180) && (lat >= -90 && lat <= 90)) {
+                var p = new OpenLayers.Geometry.Point(lon, lat).transform('EPSG:4326', 'EPSG:900913');
+
+                lon = p.x;
+                lat = p.y;
+            }
+
 			if (gis.el) {
 				gis.olmap.zoomToVisibleExtent();
 			}
 			else {
-				if (gis.map.longitude && gis.map.latitude && gis.map.zoom) {
-					gis.olmap.setCenter(new OpenLayers.LonLat(gis.map.longitude, gis.map.latitude), gis.map.zoom);
-				}
-				else {
-					gis.olmap.zoomToVisibleExtent();
-				}
-			}
+                gis.olmap.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
+            }
 
 			// interpretation button
 			if (gis.viewport.shareButton) {