Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java @ 9481:787fc085459b
TSV introduced; uinfo.inundationWMS-Config
author | gernotbelger |
---|---|
date | Wed, 12 Sep 2018 10:55:09 +0200 |
parents | 0633f963c5be |
children | bf6b63208f34 |
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.inundationduration; import java.io.IOException; import org.dive4elements.artifacts.CallMeta; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.artifacts.sinfo.tkhstate.TsvHelper.TsvReaderException; import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; import org.dive4elements.river.artifacts.uinfo.inundationduration.InundationDurationCalculationResult.WmsLayer; import org.dive4elements.river.artifacts.uinfo.inundationduration.UedauernConfiguration.YearType; /** * 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 InundationDurationAccess extends RangeAccess { // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; private final EpochYearAccessHelper helper; // Fields from state: // // calculation_mode (String) // ld_from, ld_to // ye_select (String; state.uinfo.totalepoch oder state.uinfo.year) // year_epoch_select // totalepoch (String; TODO: minmax totalEpoch herausfinden und setzen (nicht hier.. aber trotzdem die Erinnerung hier)) // use_scenario boolean (danach kommt kein radioBtn, sondern sedimentheight-Eingabe) // sedimentheight String // // vegzones (String) TODO: MIT VegetationzonesAccess zusammenlegen public InundationDurationAccess(final UINFOArtifact uinfo) { super(uinfo); /* assert calculation mode */ final UinfoCalcMode calculationMode = uinfo.getCalculationMode(); this.helper = new EpochYearAccessHelper(uinfo); assert (calculationMode == UinfoCalcMode.uinfo_inundation_duration); } public boolean isUseYear() { if (this.helper.getYearEpoch().equals("state.uinfo.year")) return true; return false; } public WmsLayer createWMSLayer(final CallMeta meta, final String i10nKey) { final YearType type = isUseYear() ? YearType.jahre : YearType.mittel; final String selectedElement = getSelectedLabel(); final String layerLabel = Resources.getMsg(meta, i10nKey, new Object[] { selectedElement }); try { final UedauernConfiguration helper = UedauernConfiguration.getInstance(getRiverName(), type); final String url = helper.getUrl(selectedElement); final String layer = helper.getLayer(selectedElement); return new WmsLayer(layerLabel, url, layer, true); } catch (final IOException | TsvReaderException e) { e.printStackTrace(); } return null; } public WmsLayer createScenarioWMSLayer(final CallMeta meta, final String i10nKey) { // FIXME: use scenario-cm as label, and scenario-type final YearType type = YearType.jahre; final String selectedElement = Integer.toString(getDwspl()); final String layerLabel = Resources.getMsg(meta, i10nKey, new Object[] { selectedElement }); try { final UedauernConfiguration helper = UedauernConfiguration.getInstance(getRiverName(), type); final String url = helper.getUrl(selectedElement); final String layer = helper.getLayer(selectedElement); return new WmsLayer(layerLabel, url, layer, false); } catch (final IOException | TsvReaderException e) { e.printStackTrace(); } return null; } private String getSelectedLabel() { return this.getString("year_epoch_select"); } private Integer getDwspl() { if (getIsUseScenario()) return super.getInteger("sedimentheight"); return null; } public String getVegZones() { // mit VegetationzonesAccess zusammenlegen (eine Zeile sparen...) return super.getString("vegzones"); } public boolean getIsUseScenario() { return super.getBoolean("use_scenario"); } }