Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java @ 9661:9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
localized vegetation type names by querying the database instead of translating by resource property,
detecting and cancelling the import of a second vegetation zone file for a river,
detecting, logging, cancelling in case of wrong column titles,
detecting, logging and ignoring lines with missing (color) values,
comparing vegetation zone name and class with the database and logging+ignoring in case of inconsistencies,
starting the most elevated zone with 0 instead of -1 overflow days
author | mschaefer |
---|---|
date | Mon, 23 Mar 2020 16:38:12 +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); } }