Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java @ 9593:8f4e300b5f79
Punkt 7.1 Vegetationszonen Stripes + Legende ändern
author | gernotbelger |
---|---|
date | Fri, 11 Jan 2019 17:44:25 +0100 |
parents | ba0561906f81 |
children | 63bbd5e45839 |
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.CallContext; 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.WmsConfig; /** * 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 { private final EpochYearAccessHelper helper; // public static enum WmsClassification { // asIs { // @Override // public String configureAddress(final WmsConfig config) { // return config.getUrl(); // } // } // // , // // vegetationZone { // // @Override // // public String configureAddress(final String serverAddress, final String url, final String vegetationZoneId) { // // // // try { // // final String urlEncoded = URLEncoder.encode(url, "UTF-8"); // // final String vegZoneIdEncoded = URLEncoder.encode(vegetationZoneId, "UTF-8"); // // // // return String.format("%s/%s/%s/%s", serverAddress, VegetationWmsResource.BASE_PATH, vegZoneIdEncoded, urlEncoded); // // } // // catch (final UnsupportedEncodingException e) { // // /* should never happen */ // // e.printStackTrace(); // // return null; // // } // // } // // } // ; // // public abstract String configureAddress(final WmsConfig config); // } // 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 CallContext context, final String i10nKey, final WmsConfig classification) // throws IOException, TsvReaderException { // // final YearType type = isUseYear() ? YearType.jahre : YearType.mittel; // final String selectedElement = getSelectedLabel(); // // final String layerLabel = Resources.getMsg(context.getMeta(), i10nKey, new Object[] { selectedElement }); // // return createWMSLayer(context, layerLabel, type, selectedElement, classification); // } // public WmsLayer createScenarioWMSLayer(final CallContext context, final String i10nKey, final WmsConfig // classification, final String vegZoneId) // throws IOException, TsvReaderException { // // // 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(context.getMeta(), i10nKey, new Object[] { selectedElement }); // // return createWMSLayer(context, layerLabel, type, selectedElement, classification); // } public WmsLayer createWMSLayer(final CallContext context, final String layerLabel, final String selectedItem, final WmsConfig config, final boolean showLayerLink) throws IOException, TsvReaderException { // final String serverAddress = context.getDatabase().getServerAddress(); // final UedauernConfiguration config = UedauernConfiguration.getInstance(getRiverName(), type); final String layerLabelFinal = Resources.getMsg(context.getMeta(), layerLabel, new Object[] { selectedItem }); final String url = config.getUrl(); final String layer = config.getLayer(); if (url != null && layer != null) { // final String realUrl = classification.configureAddress(serverAddress, url, vegZoneId); return new WmsLayer(layerLabelFinal, url, layer, showLayerLink); } return null; } public String getSelectedLabel() { return this.getString("year_epoch_select"); } public String getSelectedSzenario() { if (getIsUseScenario()) return super.getString("inundation_scenario"); return null; } public boolean getIsUseScenario() { return super.getBoolean("use_scenario"); } }