Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Calculation4Access.java @ 4812:65bfb6faa538
Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 18 Jan 2013 19:33:26 +0100 |
parents | |
children | 61ebb6fb2ac4 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Calculation4Access.java Fri Jan 18 19:33:26 2013 +0100 @@ -0,0 +1,90 @@ +package de.intevation.flys.artifacts.access; + +import de.intevation.flys.artifacts.FLYSArtifact; + +import de.intevation.flys.artifacts.model.Segment; + +import java.util.Collections; +import java.util.List; + +import org.apache.log4j.Logger; + +import de.intevation.flys.utils.DoubleUtil; +import de.intevation.flys.utils.FLYSUtils; + +public class Calculation4Access +extends RiverAccess +{ + private static Logger log = Logger.getLogger(Calculation4Access.class); + + protected List<Segment> segments; + + protected double [] fromToStep; + + protected Boolean isQ; + + protected Boolean isRange; + + public Calculation4Access() { + } + + public Calculation4Access(FLYSArtifact artifact) { + super(artifact); + } + + public List<Segment> getSegments() { + if (segments == null) { + String input = getString("wq_values"); + if (input == null || (input = input.trim()).length() == 0) { + log.warn("no wq_values given"); + segments = Collections.<Segment>emptyList(); + } + } + return segments; + } + + public boolean isQ() { + if (isQ == null) { + Boolean value = getBoolean("wq_isq"); + isQ = value != null && value; + } + return isQ; + } + + public boolean isRange() { + if (isRange == null) { + String mode = getString("ld_mode"); + isRange = mode == null || mode.equals("distance"); + } + return isRange; + } + + public double [] getFromToStep() { + if (fromToStep == null) { + // XXX: Is this really needed in this calculation? + if (!isRange()) { + return null; + } + + // XXX: FLYSArtifact sucks! + double [] fromTo = FLYSUtils.getKmRange(artifact); + + if (fromTo == null) { + return null; + } + + Double dStep = getDouble("ld_step"); + if (dStep == null) { + return null; + } + + fromToStep = new double [] { + fromTo[0], + fromTo[1], + DoubleUtil.round(dStep / 1000d) + }; + } + return fromToStep; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :