Mercurial > dive4elements > river
changeset 6963:aa1d681ee6eb
SedimentLoadExporter: Minor refac. Determine a displayed string
only when necessary.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 05 Sep 2013 11:48:38 +0200 |
parents | 234b1a3b527d |
children | 5a348e3df0f8 |
files | artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java Wed Sep 04 10:53:53 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java Thu Sep 05 11:48:38 2013 +0200 @@ -95,19 +95,26 @@ writeCSVHeader(writer); for (SedimentLoadResult result: results) { + String years = (toYear == 0) + ? result.getStartYear()+ " " + : result.getStartYear() + "-" + result.getEndYear(); SedimentLoad load = result.getLoad(); // Put load.getName()+load.getDescription()}); somewhere? for (double km: new TreeSet<Double>(load.getKms())) { SedimentLoadFraction fraction = load.getFraction(km); - writeRecord(writer, km, result.getStartYear(), result.getEndYear(), fraction); + writeRecord(writer, km, years, fraction); } } } /** Write a line. */ - private void writeRecord(CSVWriter writer, double km, int fromYear, int toYear, SedimentLoadFraction fraction) { + private void writeRecord( + CSVWriter writer, + double km, + String years, + SedimentLoadFraction fraction + ) { // year, total, susp sed, susp sandbed suspsand, sand, finemiddle, coarse - String years = (toYear == 0) ? fromYear+"" : fromYear + "-" + toYear; NumberFormat kmf = Formatter.getCalculationKm(context.getMeta()); NumberFormat valf = Formatter.getFormatter(context.getMeta(), 0, 2); writer.writeNext(new String[] {