← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8854: (GIS) Interpretations + Measure distance.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 8854 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-11-04 12:27:11 +0300
message:
  (GIS) Interpretations + Measure distance.
added:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/interpretation_14.png
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/measure_24.png
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/index.html
  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/styles/style.css
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonInitialize.vm


--
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-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java	2012-10-23 13:24:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java	2012-11-03 20:54:57 +0000
@@ -40,6 +40,7 @@
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.mapping.Map;
 import org.hisp.dhis.mapping.MapView;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
@@ -60,7 +61,7 @@
 {
     private Chart chart;
 
-    private MapView mapView;
+    private Map map;
     
     private ReportTable reportTable;
     
@@ -95,9 +96,9 @@
         this.created = new Date();
     }
 
-    public Interpretation( MapView mapView, String text )
+    public Interpretation( Map map, String text )
     {
-        this.mapView = mapView;
+        this.map = map;
         this.text = text;
         this.created = new Date();
     }
@@ -133,9 +134,9 @@
         return chart != null;
     }
     
-    public boolean isMapViewInterpretation()
+    public boolean isMapInterpretation()
     {
-        return mapView != null;
+        return map != null;
     }
     
     public boolean isReportTableInterpretation()
@@ -181,14 +182,14 @@
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
-    public MapView getMapView()
+    public Map getMap()
     {
-        return mapView;
+        return map;
     }
 
-    public void setMapView( MapView mapView )
+    public void setMap( Map map )
     {
-        this.mapView = mapView;
+        this.map = map;
     }
 
     @JsonProperty

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml	2012-08-31 15:35:59 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml	2012-11-03 20:54:57 +0000
@@ -18,8 +18,8 @@
     <many-to-one name="chart" class="org.hisp.dhis.chart.Chart" column="chartid"
         foreign-key="fk_interpretation_chartid" />
 
-    <many-to-one name="mapView" class="org.hisp.dhis.mapping.MapView" column="mapviewid"
-		foreign-key="fk_interpretation_mapviewid" />
+    <many-to-one name="map" class="org.hisp.dhis.mapping.Map" column="mapid"
+		foreign-key="fk_interpretation_mapid" />
 
 	<many-to-one name="reportTable" class="org.hisp.dhis.reporttable.ReportTable" column="reporttableid"
 		foreign-key="fk_interpretation_reporttableid" />

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java	2012-10-24 08:31:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java	2012-11-03 20:54:57 +0000
@@ -42,6 +42,7 @@
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.interpretation.Interpretation;
 import org.hisp.dhis.interpretation.InterpretationService;
+import org.hisp.dhis.mapping.Map;
 import org.hisp.dhis.mapping.MapView;
 import org.hisp.dhis.mapping.MappingService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -136,18 +137,18 @@
 
     @RequestMapping( value = "/map/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
     public void shareMapInterpretation( 
-        @PathVariable( "uid" ) String mapViewUid, 
+        @PathVariable( "uid" ) String mapUid, 
         @RequestBody String text, HttpServletResponse response ) throws IOException
     {
-        MapView mapView = mappingService.getMapView( mapViewUid );
+        Map map = mappingService.getMap( mapUid );
         
-        if ( mapView == null )
+        if ( map == null )
         {
-            ContextUtils.conflictResponse( response, "Map view identifier not valid: " + mapViewUid );
+            ContextUtils.conflictResponse( response, "Map identifier not valid: " + mapUid );
             return;
         }
         
-        Interpretation interpretation = new Interpretation( mapView, text );
+        Interpretation interpretation = new Interpretation( map, text );
         
         interpretationService.saveInterpretation( interpretation );
 

=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/interpretation_14.png'
Binary files dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/interpretation_14.png	1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/interpretation_14.png	2012-11-03 20:54:57 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/measure_24.png'
Binary files dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/measure_24.png	1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/images/measure_24.png	2012-11-04 09:24:06 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/index.html'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/index.html	2012-11-03 16:00:58 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/index.html	2012-11-04 09:20:14 +0000
@@ -32,7 +32,9 @@
 		document.getElementById('slow').innerHTML = "<a href=''>SLOW CONNECTION?</a>";
 	</script>
     
+<!--
     <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false";></script>
+-->
 
     <script type="text/javascript" src="../../dhis-web-commons/javascripts/ext/ext-all.js"></script>
     <script type="text/javascript">

=== 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	2012-11-03 16:00:58 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2012-11-04 09:20:14 +0000
@@ -109,7 +109,8 @@
 	gui: {
 		window: {},
 		combo: {}
-	}
+	},
+	measure: {}
 };
 
 GIS.map;
@@ -215,6 +216,7 @@
 		document.getElementsByClassName('zoomInButton')[0].innerHTML = '<img src="images/zoomin_24.png" />';
 		document.getElementsByClassName('zoomOutButton')[0].innerHTML = '<img src="images/zoomout_24.png" />';
 		document.getElementsByClassName('zoomVisibleButton')[0].innerHTML = '<img src="images/zoomvisible_24.png" />';
+		document.getElementsByClassName('measureButton')[0].innerHTML = '<img src="images/measure_24.png" />';
 		
 		// Map events
 		GIS.map.events.register('mousemove', null, function(e) {
@@ -980,6 +982,8 @@
 			text: 'Close', //i18n
 			iconCls: 'gis-menu-item-icon-clear',
 			handler: function() {
+				GIS.cmp.interpretationButton.disable();
+				
 				base.widget.reset();
 			}
 		};
@@ -1077,7 +1081,10 @@
 				{
 					text: 'Update', //i18n
 					handler: function() {
-						base.widget.execute();
+						GIS.map.mapLoader = null;
+						GIS.cmp.interpretationButton.disable();
+						
+						base.widget.execute();						
 					}
 				}
 			],
@@ -1647,6 +1654,8 @@
 								success: function() {								
 									GIS.store.maps.loadStore();
 									
+									GIS.cmp.interpretationButton.enable();
+									
 									window.destroy();
 								}
 							});
@@ -1998,7 +2007,7 @@
 			],
 			listeners: {
 				show: function() {
-					this.setPosition(this.getPosition()[0], 40);
+					this.setPosition(115, 37);
 				}
 			}
 		});
@@ -2064,7 +2073,7 @@
 				callbackRegister.push(widget);
 				
 				if (callbackRegister.length === map.mapViews.length) {
-					GIS.map.mapLoader = null;
+					GIS.cmp.interpretationButton.enable();
 				}
 			}
 		};
@@ -2741,7 +2750,7 @@
 			},
 			listeners: {					
 				show: function() {
-					this.setPosition(this.getPosition()[0], 40);
+					this.setPosition(185, 37);
 				}
 			}
 		});
@@ -2823,6 +2832,127 @@
 		return menu;
 	};
 	
+	GIS.obj.InterpretationWindow = function() {
+		var window,
+			textarea,
+			button;
+			
+		textarea = Ext.create('Ext.form.field.TextArea', {
+			xtype: 'textarea',
+			cls: 'gis-textarea',
+			height: 170,
+			emptyText: 'Write your interpretation...' //i18n
+		});
+		
+		button = Ext.create('Ext.button.Button', {
+			text: 'Share', //i18n
+			handler: function() {
+				if (textarea.getValue() && GIS.map.mapLoader) {
+					Ext.Ajax.request({
+						url: GIS.conf.url.path_api + 'interpretations/map/' + GIS.map.mapLoader.id,
+						method: 'POST',
+						params: textarea.getValue(),
+						headers: {'Content-Type': 'text/html'},
+						success: function() {
+							window.destroy();
+							
+							alert('Interpretation was shared!');
+						}
+					});
+				}
+			}
+		});
+		
+		window = Ext.create('Ext.window.Window', {
+			title: 'Share interpretation', //i18n
+			layout: 'fit',
+			iconCls: 'gis-window-title-icon-interpretation',
+			cls: 'gis-container-default',
+			width: 450,
+			resizable: true,
+			modal: true,
+			items: textarea,
+			bbar: [
+				'->',
+				button
+			],
+			listeners: {
+				show: function() {
+					this.setPosition(325, 37);
+				}
+			}
+		});
+		
+		return window;
+	};
+	
+	GIS.obj.MeasureWindow = function() {
+		var window,
+			label,
+			handleMeasurements,
+			control,
+			styleMap;
+			
+		styleMap = new OpenLayers.StyleMap({
+			'default': new OpenLayers.Style()
+		});
+			
+		control = new OpenLayers.Control.Measure( OpenLayers.Handler.Path, {
+			persist: true,
+			immediate: true,
+			handlerOption: {
+				layerOptions: {
+					styleMap: styleMap
+				}
+			}
+		});
+		
+		handleMeasurements = function(e) {
+			if (e.measure) {				
+				label.setText(e.measure.toFixed(2) + ' ' + e.units);
+			}
+		};
+		
+		GIS.map.addControl(control);
+		
+		control.events.on({
+			measurepartial: handleMeasurements,
+			measure: handleMeasurements
+		});
+		
+		control.geodesic = true;
+		control.activate();
+		
+		label = Ext.create('Ext.form.Label', {
+			style: 'height: 20px',
+			text: '0 km'
+		});
+		
+		window = Ext.create('Ext.window.Window', {
+			title: 'Measure distance', //i18n
+			layout: 'fit',
+			cls: 'gis-container-default',
+			bodyStyle: 'text-align: center',
+			width: 130,
+			minWidth: 130,
+			resizable: false,
+			items: label,
+			listeners: {
+				show: function() {
+					var x = GIS.cmp.region.east.x - this.getWidth() - 5,
+						y = 60;
+					this.setPosition(x, y);
+				},
+				destroy: function() {
+					control.deactivate();
+					GIS.map.removeControl(control);
+				}
+			}
+		});
+		
+		return window;
+	};
+	
 	// OpenLayers map
 	
 	GIS.map = new OpenLayers.Map({
@@ -2848,6 +2978,13 @@
 	GIS.util.map.addMapControl('zoomIn', GIS.map.zoomIn);
 	GIS.util.map.addMapControl('zoomOut', GIS.map.zoomOut);
 	GIS.util.map.addMapControl('zoomVisible', GIS.util.map.zoomToVisibleExtent);
+	GIS.util.map.addMapControl('measure', function() {
+		if (GIS.cmp.measureWindow && GIS.cmp.measureWindow.destroy) {
+			GIS.cmp.measureWindow.destroy();
+		}		
+		GIS.cmp.measureWindow = new GIS.obj.MeasureWindow();
+		GIS.cmp.measureWindow.show();
+	});
     
     // Base layers
     
@@ -3086,7 +3223,20 @@
 						{
 							text: 'Share', //i18n
 							menu: {},
-							disabled: true
+							disabled: true,
+							handler: function() {
+								if (GIS.cmp.interpretationWindow && GIS.cmp.interpretationWindow.destroy) {
+									GIS.cmp.interpretationWindow.destroy();
+								}
+								
+								GIS.cmp.interpretationWindow = new GIS.obj.InterpretationWindow();
+								GIS.cmp.interpretationWindow.show();
+							},
+							listeners: {
+								added: function() {
+									GIS.cmp.interpretationButton = this;
+								}
+							}
 						},
 						'->',
 						{

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/styles/style.css	2012-11-03 11:15:24 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/styles/style.css	2012-11-04 09:20:14 +0000
@@ -11,6 +11,7 @@
  * Window
  * Grid
  * TextField
+ * TextArea
  * Checkbox
  * NumberField
  * Label
@@ -83,13 +84,17 @@
 }
 
 .olControlPanel.zoomIn {
-	right: 48px;
+	right: 72px;
 }
 .olControlPanel.zoomIn .olControlButtonItemActive {
 	border-bottom-left-radius: 2px;
 }
 
 .olControlPanel.zoomOut {
+	right: 48px;
+}
+
+.olControlPanel.zoomVisible {
 	right: 24px;
 }
 
@@ -436,6 +441,12 @@
 .gis-window-title-icon-legendset {
 	background: url('../images/legendset_14.png') no-repeat;
 }
+.gis-window-title-icon-interpretation {
+	background: url('../images/interpretation_14.png') no-repeat;
+}
+.gis-window-title-icon-measure {
+	background: url('../images/measure_14.png') no-repeat;
+}
 
 /* Grid */
 
@@ -506,6 +517,11 @@
 	border-radius: 1px;
 }
 
+/* Textarea */
+.gis-textarea .x-form-field {
+	font-size: 11px;
+}
+
 /* Checkbox */
 
 .x-form-checkbox {

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonInitialize.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonInitialize.vm	2012-11-04 08:01:42 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonInitialize.vm	2012-11-04 09:25:35 +0000
@@ -1,6 +1,6 @@
 #set( $baseLayersSize = $baseLayers.size() )
 #set( $overlaysSize = $overlays.size() )
-#set( $rootNodesSize = $roteNodes.size() )
+#set( $rootNodesSize = $rootNodes.size() )
 {
   "contextPath":"$!{contextPath}",
   "mapView": {