Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java @ 9421:53e26734e4d2
Fixed NaN handling in salix historical scenarion calculation, added problem report
author | mschaefer |
---|---|
date | Fri, 17 Aug 2018 11:13:31 +0200 |
parents | 439699ff9b2d |
children | 8b7bf26b8782 |
line wrap: on
line source
/* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde * Software engineering by * Björnsen Beratende Ingenieure GmbH * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt * * 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.uinfo.salix; import org.dive4elements.river.artifacts.access.BedHeightAccess; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; import org.dive4elements.river.model.BedHeight; /** * Access to the flow depth calculation type specific SInfo artifact data. * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent * reference to the artifact instance. * Hence we do NOT cache any data. * * @author Gernot Belger */ final class SalixLineAccess extends RangeAccess { /** * Type of a salix line scenario with key property used by the client */ public enum ScenarioType { NONE(""), // REGIONAL("scenarioType.option1"), // SUPRAREGIONAL("scenarioType.option2"), // HISTORICAL("scenarioType.option3"); private String key; private ScenarioType(final String key) { this.key = key; } public static ScenarioType forKey(final String key) { for (final ScenarioType st : ScenarioType.values()) { if (st.getKey().equals(key)) return st; } return NONE; } public String getKey() { return this.key; } } public SalixLineAccess(final UINFOArtifact artifact) { super(artifact); /* assert calculation mode */ final UinfoCalcMode calculationMode = artifact.getCalculationMode(); assert (calculationMode == UinfoCalcMode.uinfo_salix_line); } private boolean getUseScenario() { return super.getBoolean("use_scenario"); } public ScenarioType getScenario() { if (getUseScenario()) return ScenarioType.forKey(getString("scenario_selection")); return ScenarioType.NONE; } public Double getFromPart() { return getDouble("ld_from_part"); } public Double getToPart() { return getDouble("ld_to_part"); } public int[] getRegionalScenarioIntegers() { // super.getIntArray("sedimentheight"); DOES NOT WORK! final String ints = super.getString("sedimentheight"); if (ints != null) { final String[] intsSplit = ints.split(" "); final int[] values = new int[intsSplit.length]; for (int i = 0; i < intsSplit.length; i++) { values[i] = Integer.valueOf(intsSplit[i]); } return values; } return null; } public String getSupraRegionalString() { return super.getString("supraregional_table"); } /** * Database id of the selected sounding, or 0 */ public int getBedHeightId() { final BedHeightAccess access = new BedHeightAccess(this.artifact); final int[] ids = access.getBedHeightIDs(); if ((ids != null) && (ids.length > 0)) { return ids[0]; } return 0; } public BedHeight getBedHeight() { // TODO: make lazy? Aber achtung, falls der user zurückgeht und ne andere Peilung auswählt... final BedHeightAccess access = new BedHeightAccess(this.artifact); final int[] ids = access.getBedHeightIDs(); if (ids != null && ids.length > 0) { return BedHeight.getBedHeightById(ids[0]); // es nur eine bedheight ausgewählt werden; ist aber noch nicht implementiert... } return null; } public Integer getYearEpoch() { // TODO: make lazy? final BedHeight bh = this.getBedHeight(); if (bh != null) { return bh.getYear(); } return null; } }