# HG changeset patch # User Ingo Weinzierl # Date 1318244826 0 # Node ID 6890e1041eac2d8a4e6aabca8da742ff596cf1a4 # Parent f4f30d758550797f99a140e355569c002a731405 Bugfix: #289 Display measured areas in 'ha'. flys-client/trunk@2924 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f4f30d758550 -r 6890e1041eac flys-client/ChangeLog --- 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 + + 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 * src/main/java/de/intevation/flys/client/client/ui/RecommendationPairRecord.java: diff -r f4f30d758550 -r 6890e1041eac flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MeasureControl.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();