Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java @ 9593:8f4e300b5f79
Punkt 7.1 Vegetationszonen Stripes + Legende ändern
author | gernotbelger |
---|---|
date | Fri, 11 Jan 2019 17:44:25 +0100 |
parents | 8b7bf26b8782 |
children |
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.vegetationzones; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.model.Calculation; import org.dive4elements.river.artifacts.model.CalculationResult; import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; import org.dive4elements.river.artifacts.uinfo.common.UInfoResultType; import org.dive4elements.river.model.River; /** * @author Domenico Nardi Tironi * */ final class VegetationZonesCalculation { private final CallContext context; public VegetationZonesCalculation(final CallContext context) { this.context = context; } public CalculationResult calculate(final UINFOArtifact uinfo) { final Calculation problems = new Calculation(); final String calcModeLabel = Resources.getMsg(this.context.getMeta(), uinfo.getCalculationMode().name()); final String user = CalculationUtils.findArtifactUser(this.context, uinfo); final VegetationzonesAccess vAccess = new VegetationzonesAccess(uinfo); final River river = vAccess.getRiver(); final DoubleRange calcRange = vAccess.getRange(); final RiverInfo riverInfo = new RiverInfo(river); final String zonesRaw = vAccess.getVegZones(); final List<VegetationZoneServerClientXChange> helpers = VegetationZoneServerClientXChange.parse(zonesRaw); final VegetationZonesCalculationResults results = new VegetationZonesCalculationResults(calcModeLabel, user, riverInfo, calcRange); final Collection<ResultRow> rows = new ArrayList<>(); for (final VegetationZoneServerClientXChange zone : helpers) { final ResultRow row2 = ResultRow.create().// putValue(UInfoResultType.vegname, zone.getZoneName()).// putValue(UInfoResultType.vegdauervon, zone.getMin_day_overflow()).// putValue(UInfoResultType.vegdauerbis, zone.getMax_day_overflow()).// putValue(UInfoResultType.vegzone_color, zone.getHexColor()); rows.add(row2); } final String label = String.format("%.3f - %.3f", calcRange.getMinimumDouble(), calcRange.getMaximumDouble()); final VegetationZonesCalculationResult result = new VegetationZonesCalculationResult(label, rows); results.addResult(result, problems); return new CalculationResult(results, problems); } }