Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveGenerator.java @ 6332:f5bb53106ae8
Remove createBarriersLayer and createBarriers
The generated mapfiles did not work and were just confusing. This
looks like historical cruft that was never deleted. The real barrier
mapfiles are created in the Floodmap state
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 13 Jun 2013 17:24:56 +0200 |
parents | af13ceeba52a |
children | 2d538e01da7c |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 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; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.StaticWKmsArtifact; import org.dive4elements.river.artifacts.WINFOArtifact; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.WKms; import org.dive4elements.river.artifacts.model.WQKms; import org.dive4elements.river.jfree.RiverAnnotation; import org.dive4elements.river.jfree.StickyAxisAnnotation; import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.utils.RiverUtils; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import org.jfree.data.xy.XYSeries; import org.w3c.dom.Document; /** * An OutGenerator that generates discharge curves. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class ComputedDischargeCurveGenerator extends DischargeCurveGenerator implements FacetTypes { /** The logger used in this generator. */ private static Logger logger = Logger.getLogger(ComputedDischargeCurveGenerator.class); public static final String I18N_CHART_TITLE = "chart.computed.discharge.curve.title"; public static final String I18N_CHART_SUBTITLE = "chart.computed.discharge.curve.subtitle"; public static final String I18N_YAXIS_LABEL = "chart.computed.discharge.curve.yaxis.label"; public static final String I18N_CHART_TITLE_DEFAULT = "Abflusskurve"; public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]"; public static final String I18N_MAINVALUES_Q_LABEL = "Q (Haupt- und Extremwerte)"; public static final String I18N_MAINVALUES_W_LABEL = "W (Haupt- und Extremwerte)"; /** Trivial Constructor. */ public ComputedDischargeCurveGenerator () { super(); } @Override protected String getDefaultChartTitle() { return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); } @Override protected String getDefaultChartSubtitle() { double[] dist = getRange(); Object[] args = new Object[] { getRiverName(), dist[0] }; return msg(I18N_CHART_SUBTITLE, "", args); } @Override protected String getDefaultYAxisLabel(int pos) { D4EArtifact flys = (D4EArtifact) master; String unit = RiverUtils.getRiver(flys).getWstUnit().getName(); return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT, new Object[] { unit }); } /** * Process data, build up plot. */ @Override public void doOut( ArtifactAndFacet artifactFacet, Document attr, boolean visible ) { String name = artifactFacet.getFacetName(); logger.debug("ComputedDischargeCurveGenerator.doOut: " + name); if (name == null) { logger.warn("Broken facet in computed discharge out generation."); return; } //XXX DEAD CODE // Facet facet = artifactFacet.getFacet(); if (name.equals(COMPUTED_DISCHARGE_Q)) { doQOut((WQKms) artifactFacet.getData(context), artifactFacet, attr, visible); } else if (name.equals(STATIC_WQ)) { doWQOut(artifactFacet.getData(context), artifactFacet, attr, visible); } else if (name.equals(STATIC_WQ_ANNOTATIONS)) { doWQAnnotations( artifactFacet.getData(context), artifactFacet, attr, visible); } else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_Q) || name.equals(MAINVALUES_Q) || name.equals(COMPUTED_DISCHARGE_MAINVALUES_W) || name.equals(MAINVALUES_W) ) { doAnnotations((RiverAnnotation) artifactFacet.getData(context), artifactFacet, attr, visible); } else if (name.equals(STATIC_WKMS_INTERPOL) || name.equals(HEIGHTMARKS_POINTS)) { doWAnnotations( artifactFacet.getData(context), artifactFacet, attr, visible); } else if (name.equals(STATIC_WKMS)) { doWAnnotations( artifactFacet.getData(context), artifactFacet, attr, visible); } else if (FacetTypes.IS.MANUALPOINTS(name)) { doPoints(artifactFacet.getData(context), artifactFacet, attr, visible, YAXIS.W.idx); } else if (name.equals(DISCHARGE_CURVE)) { doDischargeOut( (WINFOArtifact) artifactFacet.getArtifact(), artifactFacet.getData(context), artifactFacet.getFacetDescription(), attr, visible); } else { logger.warn("Unknown facet type for computed discharge: " + name); return; } } /** * Add WQ Data to plot. * @param wqkms data as double[][] */ protected void doWQOut( Object wqkms, ArtifactAndFacet aaf, Document theme, boolean visible ) { logger.debug("ComputedDischargeCurveGenerator: doWQOut"); double [][] data = (double [][]) wqkms; XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); StyledSeriesBuilder.addPoints(series, data, true); addAxisSeries(series, YAXIS.W.idx, visible); } /** * Add Q-Series to plot. * @param wqkms actual data * @param theme theme to use. */ protected void doQOut( WQKms wqkms, ArtifactAndFacet aaf, Document theme, boolean visible ) { logger.debug("ComputedDischargeCurveGenerator: doWQOut"); XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); StyledSeriesBuilder.addPointsQW(series, wqkms); addAxisSeries(series, YAXIS.W.idx, visible); } /** * Add WQ-Annotations to plot. * @param wqkms actual data * @param theme theme to use. */ protected void doWQAnnotations( Object wqkms, ArtifactAndFacet aandf, Document theme, boolean visible ) { List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); double [][] data = (double [][]) wqkms; for (int i = 0; i< data[0].length; i++) { // TODO we need linear interpolation? xy.add(new StickyAxisAnnotation(aandf.getFacetDescription(), (float) data[0][i], StickyAxisAnnotation.SimpleAxis.X_AXIS)); xy.add(new StickyAxisAnnotation(aandf.getFacetDescription(), (float) data[1][i], StickyAxisAnnotation.SimpleAxis.Y_AXIS)); } doAnnotations(new RiverAnnotation(aandf.getFacetDescription(), xy), aandf, theme, visible); } /** * Add W-Annotations to plot. * @param wqkms actual data (double[][]). * @param theme theme to use. */ protected void doWAnnotations( Object wqkms, ArtifactAndFacet aandf, Document theme, boolean visible ) { Facet facet = aandf.getFacet(); List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); // Try to find them as WKms as well... if (wqkms instanceof double[][]) { logger.debug("its double[][] time, baby"); double [][] data = (double [][]) wqkms; // TODO Do we need interpolation? for (int i = 0; i< data[0].length; i++) { xy.add(new StickyAxisAnnotation(aandf.getFacetDescription(), (float) data[1][i], StickyAxisAnnotation.SimpleAxis.Y_AXIS)); } doAnnotations(new RiverAnnotation(facet.getDescription(), xy), aandf, theme, visible); } else { logger.debug("its wkms time, baby"); WKms data = (WKms) wqkms; // Assume its WKms. // XXX DEAD CODE // double location = getRange()[0]; double w = StaticWKmsArtifact.getWAtKmLin(data, getRange()[0]); xy.add(new StickyAxisAnnotation(aandf.getFacetDescription(), (float) w, StickyAxisAnnotation.SimpleAxis.Y_AXIS)); doAnnotations(new RiverAnnotation(facet.getDescription(), xy), aandf, theme, visible); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :