view artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoad.java @ 6152:0587819960c3

Waterlevel differences & bed height differences: Add new model LinearInterpolated intented to unify the two very similiar calculations. The focus of the current implementation is correctness and not speed! The fact that the data sets more mostly sorted by station is not exploited. Doing so would improve performance significantly.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 02 Jun 2013 17:52:53 +0200
parents af13ceeba52a
children 48e92ff57f23
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
 * Software engineering by Intevation GmbH
 *
 * 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.model.minfo;

import java.util.Date;
import java.util.HashMap;
import java.util.Set;

import org.dive4elements.river.artifacts.model.NamedObjectImpl;

/** Gives access to Fractions (at kms). */
public class SedimentLoad
extends NamedObjectImpl
{
    protected String description;
    protected Date start;
    protected Date end;
    protected boolean isEpoch;

    protected HashMap<Double, SedimentLoadFraction> kms;

    public SedimentLoad() {
        kms = new HashMap<Double, SedimentLoadFraction>();
    }

    public SedimentLoad(
        String description,
        Date start,
        Date end,
        boolean isEpoch
    ) {
        this();
        this.description = description;
        this.start = start;
        this.end = end;
        this.isEpoch = isEpoch;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getStart() {
        return start;
    }

    public void setStart(Date start) {
        this.start = start;
    }

    public Date getEnd() {
        return end;
    }

    public void setEnd(Date end) {
        this.end = end;
    }

    public boolean isEpoch() {
        return isEpoch;
    }

    public void setEpoch(boolean isEpoch) {
        this.isEpoch = isEpoch;
    }

    public Set<Double> getKms() {
        return kms.keySet();
    }

    public void addKm(double km, SedimentLoadFraction fraction) {
        kms.put(km, fraction);
    }

    public SedimentLoadFraction getFraction(double km) {
        if (kms.get(km) == null) {
            return new SedimentLoadFraction();
        }
        return kms.get(km);
    }

    public void setCoarse(double km, double coarse) {
        if (kms.containsKey(km)) {
            kms.get(km).setCoarse(coarse);
        }
        else {
            SedimentLoadFraction f = new SedimentLoadFraction();
            f.setCoarse(coarse);
            kms.put(km, f);
        }
    }

    public void setFineMiddle(double km, double fine_middle) {
        if (kms.containsKey(km)) {
            kms.get(km).setFine_middle(fine_middle);
        }
        else {
            SedimentLoadFraction f = new SedimentLoadFraction();
            f.setFine_middle(fine_middle);
            kms.put(km, f);
        }
    }

    public void setSand(double km, double sand) {
        if (kms.containsKey(km)) {
            kms.get(km).setSand(sand);
        }
        else {
            SedimentLoadFraction f = new SedimentLoadFraction();
            f.setSand(sand);
            kms.put(km, f);
        }
    }

    public void setSuspSand(double km, double susp_sand) {
        if (kms.containsKey(km)) {
            kms.get(km).setSusp_sand(susp_sand);
        }
        else {
            SedimentLoadFraction f = new SedimentLoadFraction();
            f.setSusp_sand(susp_sand);
            kms.put(km, f);
        }
    }

    public void setSuspSandBed(double km, double susp_sand_bed) {
        if (kms.containsKey(km)) {
            kms.get(km).setSusp_sand_bed(susp_sand_bed);
        }
        else {
            SedimentLoadFraction f = new SedimentLoadFraction();
            f.setSusp_sand_bed(susp_sand_bed);
            kms.put(km, f);
        }
    }

    public void setSuspSediment(double km, double susp_sediment) {
        if (kms.containsKey(km)) {
            kms.get(km).setSusp_sediment(susp_sediment);
        }
        else {
            SedimentLoadFraction f = new SedimentLoadFraction();
            f.setSusp_sediment(susp_sediment);
            kms.put(km, f);
        }
    }

    public void setLoadTotal(double km, double total) {
        if (kms.containsKey(km)) {
            kms.get(km).setLoadTotal(total);
        }
        else {
            SedimentLoadFraction f = new SedimentLoadFraction();
            f.setLoadTotal(total);
            kms.put(km, f);
        }
    }

    public void setTotal(double km, double total) {
        if (kms.containsKey(km)) {
            kms.get(km).setTotal(total);
        }
        else {
            SedimentLoadFraction f = new SedimentLoadFraction();
            f.setTotal(total);
            kms.put(km, f);
        }
    }

    public boolean hasCoarse() {
        for (SedimentLoadFraction slf : kms.values()) {
            if (slf.getCoarse() > 0d) {
                return true;
            }
        }
        return false;
    }

    public boolean hasFineMiddle() {
        for (SedimentLoadFraction slf : kms.values()) {
            if (slf.getFine_middle() > 0d) {
                return true;
            }
        }
        return false;
    }

    public boolean hasSand() {
        for (SedimentLoadFraction slf : kms.values()) {
            if (slf.getSand() > 0d) {
                return true;
            }
        }
        return false;
    }

    public boolean hasSuspSand() {
        for (SedimentLoadFraction slf : kms.values()) {
            if (slf.getSusp_sand() > 0d) {
                return true;
            }
        }
        return false;
    }

    public boolean hasSuspSediment() {
        for (SedimentLoadFraction slf : kms.values()) {
            if (slf.getSusp_sediment() > 0d) {
                return true;
            }
        }
        return false;
    }

    public boolean hasTotalLoad() {
        for (SedimentLoadFraction slf : kms.values()) {
            if (slf.getLoadTotal() > 0d) {
                return true;
            }
        }
        return false;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org