# HG changeset patch # User Tom Gottfried # Date 1409921638 -7200 # Node ID c657ddcf1fa65cde2696982f56a05f565a5e4052 # Parent 238fc722f87a80fcb4eba12d932f5653e01361fd Sediment loads at measurement stations and longitudinal sections need different processing and styling for diagrams. diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml --- a/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Fri Sep 05 13:19:22 2014 +0200 +++ b/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Fri Sep 05 14:53:58 2014 +0200 @@ -36,6 +36,8 @@ + + diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/doc/conf/themes.xml --- a/artifacts/doc/conf/themes.xml Fri Sep 05 13:19:22 2014 +0200 +++ b/artifacts/doc/conf/themes.xml Fri Sep 05 14:53:58 2014 +0200 @@ -310,6 +310,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -319,7 +343,8 @@ - + + @@ -329,16 +354,7 @@ - - - - - - - - - - + diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/doc/conf/themes/default.xml --- a/artifacts/doc/conf/themes/default.xml Fri Sep 05 13:19:22 2014 +0200 +++ b/artifacts/doc/conf/themes/default.xml Fri Sep 05 14:53:58 2014 +0200 @@ -1101,9 +1101,320 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1116,6 +1427,7 @@ + @@ -1125,6 +1437,7 @@ + @@ -1134,6 +1447,7 @@ + @@ -1143,6 +1457,7 @@ + @@ -1152,6 +1467,7 @@ + @@ -1161,19 +1477,7 @@ - - - - - - - - - - - + @@ -1183,19 +1487,7 @@ - - - - - - - - - - - + @@ -1205,6 +1497,17 @@ + + + + + + + + + + + @@ -1214,215 +1517,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/doc/conf/themes/second.xml --- a/artifacts/doc/conf/themes/second.xml Fri Sep 05 13:19:22 2014 +0200 +++ b/artifacts/doc/conf/themes/second.xml Fri Sep 05 14:53:58 2014 +0200 @@ -1101,9 +1101,320 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1116,6 +1427,7 @@ + @@ -1125,6 +1437,7 @@ + @@ -1134,6 +1447,7 @@ + @@ -1143,6 +1457,7 @@ + @@ -1152,6 +1467,7 @@ + @@ -1161,19 +1477,7 @@ - - - - - - - - - - - + @@ -1183,19 +1487,7 @@ - - - - - - - - - - - + @@ -1205,6 +1497,17 @@ + + + + + + + + + + + @@ -1214,215 +1517,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFacet.java Fri Sep 05 13:19:22 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFacet.java Fri Sep 05 14:53:58 2014 +0200 @@ -114,17 +114,6 @@ return fractions.get(index).getData(); - /* Are gaps neccessary now? - for (int x = 0; x < values[0].length-1; x++) { - // Introduce gaps where no data in measurement station. - if (Math.abs(values[0][x+1] - values[0][x]) > 3*EPSILON - && values[1][x+1] != values[1][x]) { - values[0][x] = Double.NaN; - values[1][x] = Double.NaN; - } - } - - return values; */ } /** Copy deeply. */ diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java Fri Sep 05 13:19:22 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java Fri Sep 05 14:53:58 2014 +0200 @@ -37,7 +37,7 @@ { private static Logger log = Logger.getLogger(SedimentLoadFacet.class); - private static final String NAME = "sedimentload"; + private static final String NAME = "sedimentload.ta"; public SedimentLoadFacet() { } @@ -88,7 +88,7 @@ String fraction = split.length >= 2 ? split[1] : ""; String years = split.length >= 3 ? split[2] : ""; - // Name has the pattern sedimentload. + // Name has the pattern sedimentload.ta. name = NAME + "." + fraction; log.debug("Created facet: " + name); diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSFacet.java Fri Sep 05 13:19:22 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSFacet.java Fri Sep 05 14:53:58 2014 +0200 @@ -47,7 +47,7 @@ /* Aheinecke we probably need to get the kind and split this up here * in some way */ - private static final String NAME = "sedimentload"; + private static final String NAME = "sedimentload.ls"; public SedimentLoadLSFacet() { } @@ -111,9 +111,7 @@ log.debug("Kind: " + theLoad.getKind()); log.debug("Unit: " + theLoad.getUnit().getName()); - /* Name has the pattern sedimentload.. - * this is partly done for backwards compatibility and theming. - * See issue 1681 for details. */ + // Name has the pattern sedimentload.ls.. name = NAME; String i18nUnit = ""; diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadLSM3AProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadLSM3AProcessor.java Fri Sep 05 14:53:58 2014 +0200 @@ -0,0 +1,32 @@ +/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ +package org.dive4elements.river.exports.process; + +import org.apache.log4j.Logger; + +import org.dive4elements.river.exports.DiagramGenerator; + +public class SedimentLoadLSM3AProcessor extends SedimentLoadLSProcessor { + + private final static Logger logger = + Logger.getLogger(SedimentLoadM3AProcessor.class); + + public static final String I18N_YAXIS_LABEL = + "chart.sedimentload.ls.yaxis.label.m3pera"; + public static final String I18N_YAXIS_LABEL_DEFAULT = "[m\u00b3/a]"; + + @Override + public boolean canHandle(String facettype) { + return facettype.startsWith("sedimentload.ls.m3a"); + } + + @Override + public String getAxisLabel(DiagramGenerator generator) { + return generator.msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); + } +} diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadLSProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadLSProcessor.java Fri Sep 05 14:53:58 2014 +0200 @@ -0,0 +1,55 @@ +/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.exports.process; + +import org.apache.log4j.Logger; +import org.jfree.data.xy.XYSeries; + +import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.exports.DiagramGenerator; +import org.dive4elements.river.exports.StyledSeriesBuilder; +import org.dive4elements.river.jfree.StyledXYSeries; +import org.dive4elements.river.themes.ThemeDocument; + +// Base class for SedimantLoad$UNITProcessors +public class SedimentLoadLSProcessor extends DefaultProcessor +{ + private final static Logger log = + Logger.getLogger(SedimentLoadProcessor.class); + + @Override + public void doOut( + DiagramGenerator generator, + ArtifactAndFacet bundle, + ThemeDocument theme, + boolean visible) { + log.debug("doOut " + bundle.getFacetName()); + CallContext context = generator.getCallContext(); + XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), + false, // Handle NaN + theme); + Object data = bundle.getData(context); + String facetName = bundle.getFacetName(); + double [][] points; + + log.debug("Do out for: " + facetName); + if (facetName.startsWith("sedimentload.")) { + points = (double[][]) data; + } else { + log.error("Unknown facet name: " + facetName); + return; + } + + StyledSeriesBuilder.addPoints(series, points, false); // Keep NaN + + generator.addAxisSeries(series, axisName, visible); + } +} + diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadLSTAProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadLSTAProcessor.java Fri Sep 05 14:53:58 2014 +0200 @@ -0,0 +1,33 @@ +/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.exports.process; + +import org.apache.log4j.Logger; + +import org.dive4elements.river.exports.DiagramGenerator; + +public class SedimentLoadLSTAProcessor extends SedimentLoadLSProcessor{ + + private final static Logger logger = + Logger.getLogger(SedimentLoadTAProcessor.class); + + public static final String I18N_YAXIS_LABEL = + "chart.sedimentload.ls.yaxis.label.tpera"; + public static final String I18N_YAXIS_LABEL_DEFAULT = "[t/a]"; + + @Override + public boolean canHandle(String facettype) { + return facettype.startsWith("sedimentload.ls.ta"); + } + + @Override + public String getAxisLabel(DiagramGenerator generator) { + return generator.msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); + } +} diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java Fri Sep 05 13:19:22 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java Fri Sep 05 14:53:58 2014 +0200 @@ -11,6 +11,8 @@ import org.apache.log4j.Logger; import org.jfree.data.xy.XYSeries; +import gnu.trove.TDoubleArrayList; + import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.exports.DiagramGenerator; @@ -18,12 +20,20 @@ import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.themes.ThemeDocument; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RiverAccess; +import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData; +import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Station; +import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataFactory; + // Base class for SedimantLoad$UNITProcessors public class SedimentLoadProcessor extends DefaultProcessor { private final static Logger log = Logger.getLogger(SedimentLoadProcessor.class); + private static final double EPS = 1e-4; + @Override public void doOut( DiagramGenerator generator, @@ -37,19 +47,49 @@ theme); Object data = bundle.getData(context); String facetName = bundle.getFacetName(); - double [][] points; log.debug("Do out for: " + facetName); if (facetName.startsWith("sedimentload.")) { - points = (double[][]) data; + /* Remove stations (with NaN-values) at stations of + different type than appropriate for current fraction.*/ + String [] facetNameParts = facetName.split("\\."); + int gfSType = SedimentLoadData.measurementStationType( + SedimentLoadData.grainFractionIndex( + facetNameParts[facetNameParts.length-1])); + + RiverAccess access = + new RiverAccess((D4EArtifact)bundle.getArtifact()); + String river = access.getRiverName(); + SedimentLoadData sld = + SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river); + + double [][] allData = (double[][]) data; + TDoubleArrayList cleanedKms = + new TDoubleArrayList(allData[0].length); + TDoubleArrayList cleanedValues = + new TDoubleArrayList(allData[0].length); + + for (int i = 0; i < allData[0].length; ++i) { + double km = allData[0][i]; + Station station = sld.findStations(km-EPS, km+EPS).get(0); + if (station.isType(gfSType)) { + cleanedKms.add(km); + cleanedValues.add(allData[1][i]); + } + } + + double [][] points = new double[2][cleanedKms.size()]; + points[0] = cleanedKms.toNativeArray(); + points[1] = cleanedValues.toNativeArray(); + + StyledSeriesBuilder.addPoints(series, points, false); // Keep NaN + + generator.addAxisSeries(series, axisName, visible); + } else { log.error("Unknown facet name: " + facetName); return; } - - StyledSeriesBuilder.addPoints(series, points, false); // Keep NaN - - generator.addAxisSeries(series, axisName, visible); } } diff -r 238fc722f87a -r c657ddcf1fa6 artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadTAProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadTAProcessor.java Fri Sep 05 13:19:22 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadTAProcessor.java Fri Sep 05 14:53:58 2014 +0200 @@ -23,8 +23,7 @@ @Override public boolean canHandle(String facettype) { - return facettype.startsWith("sedimentload") && - !facettype.startsWith("sedimentload.m3a"); + return facettype.startsWith("sedimentload.ta"); } @Override