view artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoad.java @ 7357:9d3e44ab25f2

Refactoring: Move functionality of BedHeightAccess into BedHeightFacet for now. Idea is that Artifact and Access are lightweight. Access access the 'data' ('parameterization') attached to artifact, not the data delivered by means of artifact and its parameterization.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 16 Oct 2013 10:42:45 +0200
parents 998a9710007e
children
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.Map;
import java.util.Set;
import java.util.TreeMap;

import org.dive4elements.river.artifacts.model.NamedObjectImpl;
import org.dive4elements.river.artifacts.model.Range;
import org.dive4elements.river.utils.EpsilonComparator;

import org.apache.log4j.Logger;


/** Gives access to Fractions (at kms). */
public class SedimentLoad
extends NamedObjectImpl
{
    /** Private logger. */
    private static final Logger logger = Logger
        .getLogger(SedimentLoad.class);

    protected String description;
    protected Date start;
    protected Date end;
    protected boolean isEpoch;
    protected String unit;

    protected Map<Double, SedimentLoadFraction> kms;

    public SedimentLoad() {
        kms = new TreeMap<Double, SedimentLoadFraction>(EpsilonComparator.CMP);
    }

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

    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) {
        SedimentLoadFraction f = kms.get(km);
        if (f == null) {
            f = new SedimentLoadFraction();
            kms.put(km, f);
        }
        return f;
    }

    public void setCoarse(double km, double coarse, Range range) {
        if (range == null) {
            logger.error("coarse/range is null!");
            return;
        }
        SedimentLoadFraction f = getFraction(km);
        f.setCoarse(coarse);
        f.setCoarseRange(range);
    }

    public void setFineMiddle(double km, double fine_middle, Range range) {
        if (range == null) {
            logger.error("finemiddle/range is null!");
            return;
        }
        SedimentLoadFraction f = getFraction(km);
        f.setFineMiddle(fine_middle);
        f.setFineMiddleRange(range);
    }


    public void setSand(double km, double sand, Range range) {
        if (range == null) {
            logger.error("sand/range is null!");
            return;
        }
        SedimentLoadFraction f = getFraction(km);
        f.setSand(sand);
        f.setSandRange(range);
    }

    public void setSuspSand(double km, double susp_sand, Range range) {
        if (range == null) {
            logger.error("suspsand/range is null!");
            return;
        }
        SedimentLoadFraction f = getFraction(km);
        f.setSuspSand(susp_sand);
        f.setSuspSandRange(range);
    }

    public void setSuspSandBed(double km, double susp_sand_bed, Range range) {
        if (range == null) {
            logger.error("suspsandbed/range is null!");
            return;
        }
        SedimentLoadFraction f = getFraction(km);
        f.setSuspSandBed(susp_sand_bed);
        f.setSuspSandBedRange(range);
    }

    public void setSuspSediment(double km, double susp_sediment, Range range) {
        if (range == null) {
            logger.error("suspsed/range is null!");
            return;
        }
        SedimentLoadFraction f = getFraction(km);
        f.setSuspSediment(susp_sediment);
        f.setSuspSedimentRange(range);
    }

    public void setLoadTotal(double km, double total) {
        setLoadTotal(km, total, null);
    }

    public void setLoadTotal(double km, double total, Range range) {
        if (range == null) {
            logger.error("loadtotal/range is null!");
            return;
        }
        SedimentLoadFraction f = getFraction(km);
        f.setLoadTotal(total);
        f.setLoadTotalRange(range);
    }

    public void setTotal(double km, double total, Range range) {
        if (range == null) {
            logger.error("total/range is null!");
            return;
        }
        SedimentLoadFraction f = getFraction(km);
        f.setTotal(total);
        f.setTotalRange(range);
    }

    public void setUnknown(double km, double unknown, Range range) {
        if (range == null) {
            logger.error("unknown/range is null!");
            return;
        }
        SedimentLoadFraction f = getFraction(km);
        f.setUnknown(unknown);
        f.setUnknownRange(range);
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    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.getFineMiddle() > 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.getSuspSand() > 0d) {
                return true;
            }
        }
        return false;
    }

    public boolean hasSuspSediment() {
        for (SedimentLoadFraction slf : kms.values()) {
            if (slf.getSuspSediment() > 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