← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13454: GIS, point admin option: swap lon/lat

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 13454 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-12-27 19:46:10 +0100
message:
  GIS, point admin option: swap lon/lat
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/relocate_14.png
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/relocate_16.png
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/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-mapping/src/main/webapp/dhis-web-mapping/app/images/relocate_14.png'
Binary files dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/relocate_14.png	2012-10-02 11:24:35 +0000 and dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/relocate_14.png	2013-12-27 18:20:40 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/relocate_16.png'
Binary files dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/relocate_16.png	2012-10-02 09:45:46 +0000 and dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/relocate_16.png	2013-12-27 18:20:40 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2013-12-27 13:44:39 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2013-12-27 18:04:31 +0000
@@ -8433,7 +8433,6 @@
                                 success: function(r) {
                                     gis.olmap.relocate.active = false;
                                     gis.olmap.relocate.window.destroy();
-
                                     gis.olmap.relocate.feature.move({x: parseFloat(e.clientX - center.x), y: parseFloat(e.clientY - 28)});
                                     gis.olmap.getViewport().style.cursor = 'auto';
 

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2013-12-24 15:22:04 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2013-12-27 18:43:30 +0000
@@ -486,6 +486,46 @@
 				}));
 
 				menuItems.push( Ext.create('Ext.menu.Item', {
+                    text: 'Swap lon/lat',
+					iconCls: 'gis-menu-item-icon-relocate',
+					disabled: !gis.init.user.isAdmin,
+					handler: function(item) {
+                        var id = feature.attributes.id,
+                            geo = Ext.clone(feature.geometry).transform('EPSG:900913', 'EPSG:4326');
+
+                        if (Ext.isNumber(geo.x) && Ext.isNumber(geo.y) && gis.init.user.isAdmin) {
+                            Ext.Ajax.request({
+                                url: gis.init.contextPath + '/api/organisationUnits/' + id + '.json?links=false',
+                                success: function(r) {
+                                    var orgUnit = Ext.decode(r.responseText);
+
+                                    orgUnit.coordinates = '[' + geo.y.toFixed(5) + ',' + geo.x.toFixed(5) + ']';
+
+                                    Ext.Ajax.request({
+                                        url: gis.init.contextPath + '/api/metaData?preheatCache=false',
+                                        method: 'POST',
+                                        headers: {'Content-Type': 'application/json'},
+                                        params: Ext.encode({organisationUnits: [orgUnit]}),
+                                        success: function(r) {
+                                            var x = feature.geometry.x,
+                                                y = feature.geometry.y;
+
+                                            delete feature.geometry.bounds;
+                                            feature.geometry.x = y;
+                                            feature.geometry.y = x;
+
+                                            layer.redraw();
+
+                                            console.log(feature.attributes.name + ' relocated to ' + orgUnit.coordinates);
+                                        }
+                                    });
+                                }
+                            });
+                        }
+					}
+				}));
+
+				menuItems.push( Ext.create('Ext.menu.Item', {
 					text: GIS.i18n.show_information_sheet,
 					iconCls: 'gis-menu-item-icon-information',
 					handler: function(item) {