changeset 1300:6890e1041eac

Bugfix: #289 Display measured areas in 'ha'. flys-client/trunk@2924 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 10 Oct 2011 11:07:06 +0000
parents f4f30d758550
children 2fa7ed1ac7cf
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MeasureControl.java
diffstat 2 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Oct 10 10:46:04 2011 +0000
+++ b/flys-client/ChangeLog	Mon Oct 10 11:07:06 2011 +0000
@@ -1,3 +1,10 @@
+2011-10-10  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue289 (ÜSK: Messen von Strecken und Flächen in falscher Dimension)
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/MeasureControl.java:
+	  Measured areas are now displayed in 'ha'.
+
 2011-10-10  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/RecommendationPairRecord.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MeasureControl.java	Mon Oct 10 10:46:04 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MeasureControl.java	Mon Oct 10 11:07:06 2011 +0000
@@ -25,6 +25,10 @@
 
     public static final String NUMBER_FORMAT_PATTERN = "#.##";
 
+    public static final String AREA_UNIT      = "ha";
+    public static final int    AREA_FACTOR_M  = 10000;
+    public static final int    AREA_FACTOR_KM = 100;
+
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
     protected FloodMap floodMap;
@@ -108,12 +112,12 @@
         measurePolygon.setPersist(true);
         measurePolygon.addMeasureListener(new MeasureListener() {
             public void onMeasure(MeasureEvent e) {
-                updateMeasure(e.getMeasure(), e.getUnits());
+                updateMeasureArea(e.getMeasure(), e.getUnits());
             }
         });
         measurePolygon.addMeasurePartialListener(new MeasurePartialListener() {
             public void onMeasurePartial(MeasureEvent e) {
-                updateMeasure(e.getMeasure(), e.getUnits());
+                updateMeasureArea(e.getMeasure(), e.getUnits());
             }
         });
 
@@ -155,6 +159,23 @@
     }
 
 
+    protected void updateMeasureArea(float value, String unit) {
+        float  ha      = value;
+        String ha_unit = unit;
+
+        if (unit.equals("m")) {
+            ha      = (float) value / AREA_FACTOR_M;
+            ha_unit = AREA_UNIT;
+        }
+        else if (unit.equals("km")) {
+            ha      = (float) value * AREA_FACTOR_KM;
+            ha_unit = AREA_UNIT;
+        }
+
+        label.setContents(formatter.format(ha) + " " + ha_unit);
+    }
+
+
     public void activate(boolean activate) {
         if (!activate) {
             clearMeasure();

http://dive4elements.wald.intevation.org