# HG changeset patch # User Ingo Weinzierl # Date 1269255455 0 # Node ID f82e57a601242aaabb382d79e6697e7a80334a5e # Parent 93489a0c13281f758e4eb8d8d66d0ffb9334be90 Added a further column in the isolines shapefile to store a description used to be displayed as labels in a wms layer (issue209). gnv-artifacts/trunk@814 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 93489a0c1328 -r f82e57a60124 gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Mon Mar 22 09:15:05 2010 +0000 +++ b/gnv-artifacts/ChangeLog Mon Mar 22 10:57:35 2010 +0000 @@ -1,3 +1,15 @@ +2010-03-22 Ingo Weinzierl + + Issue209 + + * src/main/java/de/intevation/gnv/utils/ShapeFileWriter.java: Added a + further column in the isolines shapefile to store a description for each + line. This description column contains the double value with three maximum + fraction digits. This is a workaround to adjust the rendering of double + values which cannot be adjusted in MapServer at the moment. MapServer + would display all fraction digits contained in the shapefile causing very + long labels. + 2010-03-22 Ingo Weinzierl Issue208 (Added a cleanup mechanism to do some things before exporting an diff -r 93489a0c1328 -r f82e57a60124 gnv-artifacts/src/main/java/de/intevation/gnv/utils/ShapeFileWriter.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ShapeFileWriter.java Mon Mar 22 09:15:05 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ShapeFileWriter.java Mon Mar 22 10:57:35 2010 +0000 @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.Serializable; import java.net.MalformedURLException; +import java.text.NumberFormat; import java.util.Collection; import java.util.Date; import java.util.HashMap; @@ -43,6 +44,10 @@ private static Logger log = Logger.getLogger( ShapeFileWriter.class); + private static NumberFormat format = NumberFormat.getInstance(); + + public static final int DOUBLE_PRECISION = 3; + private ShapeFileWriter() { } @@ -96,7 +101,8 @@ "PARAMETER:Integer," + "LAYER:Integer," + "DATE:Date," + - "VALUE:Double"); + "VALUE:Double," + + "DESC:String"); } catch (SchemaException se) { log.error(se.getLocalizedMessage(), se); @@ -115,6 +121,7 @@ featureBuilder.add(layer); featureBuilder.add(date); featureBuilder.add(pair.getA()); + featureBuilder.add(value2description(asDouble(pair.getA()))); SimpleFeature feature = featureBuilder.buildFeature(null); collection.add(feature); } @@ -398,5 +405,11 @@ } return 0d; } + + private static final String value2description(Double value) { + format.setMaximumFractionDigits(DOUBLE_PRECISION); + + return format.format(value); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :