# HG changeset patch # User Tom Gottfried # Date 1409755569 -7200 # Node ID 705f8b92fd668a96dc29e88027362d38f0a4bd0f # Parent 5bab2e57e96565c677282f559accc72d771eefea Complete CSV-export and correct headers. diff -r 5bab2e57e965 -r 705f8b92fd66 artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java Wed Sep 03 10:24:39 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java Wed Sep 03 16:46:09 2014 +0200 @@ -292,6 +292,10 @@ return Resources.getMsg(context.getMeta(), key, def); } + protected String msg(String key, Object[] args) { + return Resources.getMsg(context.getMeta(), key, key, args); + } + protected String msg(String key, String def, Object[] args) { return Resources.getMsg(context.getMeta(), key, def, args); } diff -r 5bab2e57e965 -r 705f8b92fd66 artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java Wed Sep 03 10:24:39 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java Wed Sep 03 16:46:09 2014 +0200 @@ -44,34 +44,38 @@ // i18n keys. public static final String CSV_KM = - "export.sedimentload_ls.csv.header.km"; + "export.csv.header.km"; public static final String CSV_YEAR = - "export.sedimentload_ls.csv.header.year"; + "export.csv.header.year"; public static final String CSV_COARSE = - "export.sedimentload_ls.csv.header.coarse"; + "export.sedimentload.csv.header.coarse"; public static final String CSV_FINEMIDDLE = - "export.sedimentload_ls.csv.header.finemiddle"; + "export.sedimentload.csv.header.fine_middle"; public static final String CSV_SAND = - "export.sedimentload_ls.csv.header.sand"; + "export.sedimentload.csv.header.sand"; public static final String CSV_SUSP_SAND = - "export.sedimentload_ls.csv.header.suspsand"; + "export.sedimentload.csv.header.susp_sand"; public static final String CSV_SUSP_SAND_BB = - "export.sedimentload_ls.csv.header.suspsandbb"; + "export.sedimentload.csv.header.susp_sand_bed"; public static final String CSV_SUSP_SEDIMENT = - "export.sedimentload_ls.csv.header.suspsediment"; + "export.sedimentload.csv.header.suspended_sediment"; + + public static final String CSV_BED_LOAD = + "export.sedimentload.csv.header.bed_load"; + + public static final String CSV_BED_LOAD_SUSP_SAND = + "export.sedimentload.csv.header.bed_load_susp_sand"; public static final String CSV_TOTAL = - "export.sedimentload_ls.csv.header.total"; + "export.sedimentload.csv.header.total"; - /* Header is: suspended_sediment, susp_sand, susp_sand_bed, sand, - * fine_middle, coarse, total */ private static final String[] FRACTION_ORDER = { "suspended_sediment", "susp_sand", @@ -79,6 +83,8 @@ "sand", "fine_middle", "coarse", + "bed_load", + "bed_load_susp_sand", "total" }; @@ -153,14 +159,6 @@ return valf.format(val); } - /** Return space when val is NaN or zero, apply NumberFormat otherwise. */ - private String nonZeroToString(NumberFormat valf, double val) { - if (Double.isNaN(val) || val == 0d) { - return " "; - } - return valf.format(val); - } - /** Write a line. */ private void writeRecord( CSVWriter writer, @@ -168,20 +166,17 @@ String years, Double[] fractions ) { - // year, total, susp sed, susp sandbed suspsand, sand, finemiddle, coarse NumberFormat kmf = Formatter.getCalculationKm(context.getMeta()); NumberFormat valf = Formatter.getFormatter(context.getMeta(), 0, 2); - writer.writeNext(new String[] { - kmf.format(km), - years, - numberToString(valf, fractions[0]), - numberToString(valf, fractions[1]), - numberToString(valf, fractions[2]), - numberToString(valf, fractions[3]), - numberToString(valf, fractions[4]), - numberToString(valf, fractions[5]), - nonZeroToString(valf, fractions[6]) - }); + + String[] record = new String[fractions.length+2]; + record[0] = kmf.format(km); + record[1] = years; + for (int i = 0; i < fractions.length; ++i) { + record[i+2] = numberToString(valf, fractions[i]); + } + + writer.writeNext(record); } /** Writes i18ned header for csv file/stream. */ @@ -192,18 +187,23 @@ SedimentLoadAccess access = new SedimentLoadAccess((D4EArtifact) master); - String unit = " [" + msg("state.minfo." + - access.getUnit(), "translation missing") + "]"; + String unit = msg("state.minfo." + access.getUnit()); - header.add(msg(CSV_KM, "km")); - header.add(msg(CSV_YEAR, "Jahr")); - header.add(msg(CSV_SUSP_SEDIMENT, "Schwebst.") + unit); - header.add(msg(CSV_SUSP_SAND, "Susp.Sand") + unit); - header.add(msg(CSV_SUSP_SAND_BB, "Susp.Sand(BB)") + unit); - header.add(msg(CSV_SAND, "Sand") + unit); - header.add(msg(CSV_FINEMIDDLE, "Kies(f+m)") + unit); - header.add(msg(CSV_COARSE, "Kies(g)") + unit); - header.add(msg(CSV_TOTAL, "Gesamt") + unit); + header.add(msg(CSV_KM)); + header.add(msg(CSV_YEAR)); + for (String head: new String[] { + CSV_SUSP_SEDIMENT, + CSV_SUSP_SAND, + CSV_SUSP_SAND_BB, + CSV_SAND, + CSV_FINEMIDDLE, + CSV_COARSE, + CSV_BED_LOAD, + CSV_BED_LOAD_SUSP_SAND, + CSV_TOTAL + }) { + header.add(msg(head, new Object[] { unit })); + } writer.writeNext(header.toArray(new String[header.size()])); } diff -r 5bab2e57e965 -r 705f8b92fd66 artifacts/src/main/resources/messages.properties --- a/artifacts/src/main/resources/messages.properties Wed Sep 03 10:24:39 2014 +0200 +++ b/artifacts/src/main/resources/messages.properties Wed Sep 03 16:46:09 2014 +0200 @@ -356,6 +356,9 @@ chart.beddifference.yaxis.label.heights = Absolute Height [{0}] chart.subtitle.radius = Width of sample window for moving average: {0} km +export.csv.header.km = km +export.csv.header.year = year + export.waterlevel.csv.header.km = River-Km export.waterlevel.csv.header.w = W [{0}] export.waterlevel.csv.header.q = Q [m\u00b3/s] @@ -433,15 +436,17 @@ export.bedheight_middle.csv.header.location.system = Location system export.bedheight_middle.csv.header.evalby = Evaluated by export.bedheight_middle.csv.header.river.elevation = River elevation model -export.sedimentload_ls.csv.header.km = km -export.sedimentload_ls.csv.header.year = year -export.sedimentload_ls.csv.header.coarse = coarse -export.sedimentload_ls.csv.header.finemiddle = finemiddle -export.sedimentload_ls.csv.header.sand = sand -export.sedimentload_ls.csv.header.suspsand = susp. sand -export.sedimentload_ls.csv.header.suspsediment = susp. sediment -export.sedimentload_ls.csv.header.suspsandbb = susp. sand (BB) -export.sedimentload_ls.csv.header.total = total + +export.sedimentload.csv.header.coarse = Coarse gravel [{0}] +export.sedimentload.csv.header.fine_middle = Fine/Mid. gravel [{0}] +export.sedimentload.csv.header.sand = Sand [{0}] +export.sedimentload.csv.header.susp_sand = Suspended sand [{0}] +export.sedimentload.csv.header.susp_sand_bed = Bed. part suspended sand [{0}] +export.sedimentload.csv.header.suspended_sediment = Suspended sediment [{0}] +export.sedimentload.csv.header.total = Total load [{0}] +export.sedimentload.csv.header.bed_load = Bed load [{0}] +export.sedimentload.csv.header.suspended_load = Suspended load [{0}] + export.sqrelation.csv.info.coeff.a = a: coefficient of transport curve export.sqrelation.csv.info.coeff.b = b: exponent of transport curve export.sqrelation.csv.info.qmax = Q max, measured: maximum measured discharge [m\u00b3/s] diff -r 5bab2e57e965 -r 705f8b92fd66 artifacts/src/main/resources/messages_de.properties --- a/artifacts/src/main/resources/messages_de.properties Wed Sep 03 10:24:39 2014 +0200 +++ b/artifacts/src/main/resources/messages_de.properties Wed Sep 03 16:46:09 2014 +0200 @@ -357,6 +357,9 @@ chart.beddifference.yaxis.label.heights = Absolute H\u00f6he [m] chart.subtitle.radius = Fensterbreite f\u00fcr gleitenden Mittelwert: {0} km +export.csv.header.km = km +export.csv.header.year = Jahr + export.waterlevel.csv.header.km = Fluss-Km export.waterlevel.csv.header.w = W [{0}] export.waterlevel.csv.header.q = Q [m\u00b3/s] @@ -435,15 +438,17 @@ export.bedheight_middle.csv.header.range = Strecke export.bedheight_middle.csv.header.location.system = Lagesystem export.bedheight_middle.csv.header.evalby = Auswerter -export.sedimentload_ls.csv.header.km = km -export.sedimentload_ls.csv.header.year = Jahr -export.sedimentload_ls.csv.header.coarse = Kies(g) -export.sedimentload_ls.csv.header.finemiddle = Kies(f+m) -export.sedimentload_ls.csv.header.sand = Sand -export.sedimentload_ls.csv.header.suspsand = susp.Sand -export.sedimentload_ls.csv.header.suspsandbb = susp.Sand(BB) -export.sedimentload_ls.csv.header.suspsediment = Schwebst. -export.sedimentload_ls.csv.header.total = Gesamt + +export.sedimentload.csv.header.coarse = Grober Kies/Steine [{0}] +export.sedimentload.csv.header.fine_middle = Fein/Mittlerer Kies [{0}] +export.sedimentload.csv.header.sand = Sand [{0}] +export.sedimentload.csv.header.susp_sand = suspendierter Sand [{0}] +export.sedimentload.csv.header.susp_sand_bed = bettbildender Anteil suspendierter Sand [{0}] +export.sedimentload.csv.header.suspended_sediment = Schwebstoff [{0}] +export.sedimentload.csv.header.total = Gesamtfracht [{0}] +export.sedimentload.csv.header.bed_load = Geschiebefracht [{0}] +export.sedimentload.csv.header.bed_load_susp_sand = bettbildende Fracht [{0}] + export.sqrelation.csv.info.coeff.a = a: Transportkurvenkoeffizient export.sqrelation.csv.info.coeff.b = b: Transportkurvenexponent export.sqrelation.csv.info.qmax = Q max, gemessen: maximal gemessener Abfluss [m\u00b3/s] diff -r 5bab2e57e965 -r 705f8b92fd66 artifacts/src/main/resources/messages_de_DE.properties --- a/artifacts/src/main/resources/messages_de_DE.properties Wed Sep 03 10:24:39 2014 +0200 +++ b/artifacts/src/main/resources/messages_de_DE.properties Wed Sep 03 16:46:09 2014 +0200 @@ -354,6 +354,9 @@ chart.beddifference.yaxis.label.heights = Absolute H\u00f6he [{0}] chart.subtitle.radius = Fensterbreite f\u00fcr gleitenden Mittelwert: {0} km +export.csv.header.km = km +export.csv.header.year = Jahr + export.waterlevel.csv.header.km = Fluss-Km export.waterlevel.csv.header.w = W [{0}] export.waterlevel.csv.header.q = Q [m\u00b3/s] @@ -431,15 +434,17 @@ export.bedheight_middle.csv.header.location.system = Lagesystem export.bedheight_middle.csv.header.evalby = Auswerter export.bedheight_middle.csv.header.river.elevation = H\u00f6hensystem des Flusses -export.sedimentload_ls.csv.header.km = km -export.sedimentload_ls.csv.header.year = Jahr -export.sedimentload_ls.csv.header.coarse = Kies(g) -export.sedimentload_ls.csv.header.finemiddle = Kies(f+m) -export.sedimentload_ls.csv.header.sand = Sand -export.sedimentload_ls.csv.header.suspsand = susp.Sand -export.sedimentload_ls.csv.header.suspsandbb = susp.Sand(BB) -export.sedimentload_ls.csv.header.suspsediment = Schwebst. -export.sedimentload_ls.csv.header.total = Gesamt + +export.sedimentload.csv.header.coarse = Grober Kies/Steine [{0}] +export.sedimentload.csv.header.fine_middle = Fein/Mittlerer Kies [{0}] +export.sedimentload.csv.header.sand = Sand [{0}] +export.sedimentload.csv.header.susp_sand = suspendierter Sand [{0}] +export.sedimentload.csv.header.susp_sand_bed = bettbildender Anteil suspendierter Sand [{0}] +export.sedimentload.csv.header.suspended_sediment = Schwebstoff [{0}] +export.sedimentload.csv.header.total = Gesamtfracht [{0}] +export.sedimentload.csv.header.bed_load = Geschiebefracht [{0}] +export.sedimentload.csv.header.bed_load_susp_sand = bettbildende Fracht [{0}] + export.sqrelation.csv.info.coeff.a = a: Transportkurvenkoeffizient export.sqrelation.csv.info.coeff.b = b: Transportkurvenexponent export.sqrelation.csv.info.qmax = Q max, gemessen: maximal gemessener Abfluss [m\u00b3/s] diff -r 5bab2e57e965 -r 705f8b92fd66 artifacts/src/main/resources/messages_en.properties --- a/artifacts/src/main/resources/messages_en.properties Wed Sep 03 10:24:39 2014 +0200 +++ b/artifacts/src/main/resources/messages_en.properties Wed Sep 03 16:46:09 2014 +0200 @@ -359,6 +359,9 @@ chart.beddifference.yaxis.label.heights = Absolute Height [m] chart.subtitle.radius = Radius for weighted Average: {0} km +export.csv.header.km = km +export.csv.header.year = year + export.waterlevel.csv.header.km = River-Km export.waterlevel.csv.header.w = W [{0}] export.waterlevel.csv.header.q = Q [m\u00b3/s] @@ -436,15 +439,17 @@ export.bedheight_middle.csv.header.location.system = Location system export.bedheight_middle.csv.header.evalby = Evaluated by export.bedheight_middle.csv.header.river.elevation = River elevation model -export.sedimentload_ls.csv.header.km = km -export.sedimentload_ls.csv.header.year = year -export.sedimentload_ls.csv.header.coarse = coarse -export.sedimentload_ls.csv.header.finemiddle = finemiddle -export.sedimentload_ls.csv.header.sand = sand -export.sedimentload_ls.csv.header.suspsandbb = susp. sand (BB) -export.sedimentload_ls.csv.header.suspsand = susp. sand -export.sedimentload_ls.csv.header.suspsediment = susp. sediment -export.sedimentload_ls.csv.header.total = total + +export.sedimentload.csv.header.coarse = Coarse gravel [{0}] +export.sedimentload.csv.header.fine_middle = Fine/Mid. gravel [{0}] +export.sedimentload.csv.header.sand = Sand [{0}] +export.sedimentload.csv.header.susp_sand = Suspended sand [{0}] +export.sedimentload.csv.header.susp_sand_bed = Bed. part suspended sand [{0}] +export.sedimentload.csv.header.suspended_sediment = Suspended sediment [{0}] +export.sedimentload.csv.header.total = Total load [{0}] +export.sedimentload.csv.header.bed_load = Bed load [{0}] +export.sedimentload.csv.header.suspended_load = Suspended load [{0}] + export.sqrelation.csv.info.coeff.a = a: coefficient of transport curve export.sqrelation.csv.info.coeff.b = b: exponent of transport curve export.sqrelation.csv.info.qmax = Q max, measured: maximum measured discharge [m\u00b3/s]