Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java @ 9465:be9bd06a1e3f
bezugswst sounding select for miss'vol only (calc crashes)
author | gernotbelger |
---|---|
date | Thu, 30 Aug 2018 10:54:40 +0200 |
parents | e60584f2a531 |
children | bb278c927b66 |
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.artifacts.bundu.bezugswst; import org.apache.log4j.Logger; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.FixAnalysisAccess; import org.dive4elements.river.artifacts.states.SoundingsSelect; public class BunduAccess extends FixAnalysisAccess { private static Logger log = Logger.getLogger(BunduAccess.class); // Alles, was in super steht, auskommentiert. TODO: endgültig löschen, nachdem ich es etwas verstanden habe // protected DateRange referencePeriod; // protected DateRange[] analysisPeriods; // // protected double[] qs; public BunduAccess(final D4EArtifact artifact) { super(artifact); } public boolean isAutoSelect() { final String fixChoice = this.artifact.getDataAsString("fix_choice"); if (fixChoice != null && fixChoice.equals("state.bundu.wst.fix.auto")) { return true; } return false; } public Integer getBezugsJahr() { return this.artifact.getDataAsInteger("singleyear"); } public int[] getEventsTemp() { return getIntArray("events_temp"); } public int getQSeriesLength() { return this.artifact.getDataAsInteger("year_input_q_series"); } public int getStartYear() { return this.getBezugsJahr() - this.getQSeriesLength() + 1; } public Integer getUd() { if (getUd_Q_mode().equals("UD")) return getInteger("bundu.wst.ud_value"); else return null; } @Override public double[] getQs() { if (getUd_Q_mode().equals("Q")) return super.getQs(); else return null; } private String getUd_Q_mode() { return getString("bundu.wst.mode"); } public Double getMissingVolFrom() { if (isCalculateMissingValue()) return getDouble("ld_from_part"); else return null; } public Double getMissingVolTo() { if (isCalculateMissingValue()) return getDouble("ld_to_part"); else return null; } public boolean isCalculateMissingValue() { return getBoolean("missing_volume"); } public Integer getBedHeightID() { final String data = getString("soundings"); if (data == null || !isCalculateMissingValue()) { log.warn("No 'soundings' parameter specified!"); return null; } else { log.debug("getBedHeightIDs(): data=" + data); } final String[] parts = data.split(";"); int singleID = 0; if (data.indexOf(SoundingsSelect.PREFIX_SINGLE) >= 0) { final String tmp = data.replace(SoundingsSelect.PREFIX_SINGLE, ""); try { singleID = Integer.parseInt(tmp); } catch (final NumberFormatException nfe) { log.warn("Cannot parse int from string: '" + tmp + "'"); } } return singleID; } // /** Access the reference date period, return null in case of 'errors'. */ // public DateRange getReferencePeriod() { // if (this.referencePeriod == null) { // final StateData refStart = artifact.getData("ref_start"); // final StateData refEnd = artifact.getData("ref_end"); // // if (refStart == null || refEnd == null) { // log.warn("missing 'ref_start' or 'ref_start' value"); // return null; // } // // try { // long rs = Long.parseLong((String) refStart.getValue()); // long re = Long.parseLong((String) refEnd.getValue()); // // if (rs > re) { // final long t = rs; // rs = re; // re = t; // } // // final Date from = new Date(rs); // final Date to = new Date(re); // this.referencePeriod = new DateRange(from, to); // } // catch (final NumberFormatException nfe) { // log.warn("ref_start or ref_end is not an integer."); // } // } // // return this.referencePeriod; // } // @Override // public DateRange[] getAnalysisPeriods() { // if (this.analysisPeriods == null) { // this.analysisPeriods = getDateRange("ana_data"); // } // // return this.analysisPeriods; // } // /** // * @return DateRange object ranging from eldest to youngest date // * of analysis and reference periods. // */ // @Override // public DateRange getDateRange() { // final DateRange refP = getReferencePeriod(); // // if (refP == null) { // return null; // } // // Date from = refP.getFrom(); // Date to = refP.getTo(); // // final DateRange[] rs = getAnalysisPeriods(); // for (final DateRange r : rs) { // if (r.getFrom().before(from)) { // from = r.getFrom(); // } // if (r.getTo().after(to)) { // to = r.getTo(); // } // } // // return new DateRange(from, to); // } // @Override // public double[] getQs() { // if (this.qs == null) { // this.qs = getDoubleArray("qs"); // } // // if (log.isDebugEnabled() && this.qs != null) { // log.debug("qs: " + Arrays.toString(this.qs)); // } // return this.qs; // } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :