view artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixResult.java @ 9360:ddcd52d239cd

Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle). Removed old outliers theme. Also consider showpoints property. Also consider pointsize property.
author gernotbelger
date Wed, 01 Aug 2018 17:13:52 +0200
parents a3f318347707
children 9744ce3c3853
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.fixings;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

import org.dive4elements.river.artifacts.model.Parameters;
import org.dive4elements.river.utils.KMIndex;

public class FixResult implements Serializable
{
    private static final long serialVersionUID = 1L;

    protected Parameters      parameters;
    protected KMIndex<QWD []> fixings;

    public FixResult() {
    }

    public FixResult( final Parameters parameters, final KMIndex<QWD []> fixings ) {
        this.parameters = parameters;
        this.fixings = fixings;
    }

    public KMIndex<QWD []> getFixings() {
        return fixings;
    }

    public void makeEventsDatesUnique() {
        final DateUniqueMaker dum = new DateUniqueMaker();
        
        for (KMIndex.Entry<QWD []> entry: fixings) {
            for (QWD ref: entry.getValue())
                dum.makeUnique(ref);
        }
    }

    private Collection<Integer> getEventsIndices() {
        final TreeMap<Date, Integer> dates = new TreeMap<>();
        
        for (KMIndex.Entry<QWD []> entry: fixings) {
            for (QWD value: entry.getValue())
                dates.put(value.date, value.index);
        }
        
        return dates.values();
    }

    public void remapEventIndicesToRank() {
        final RankRemapper remapper = new RankRemapper();
        for (Integer idx: getEventsIndices())
            remapper.toMap(idx);

        for (KMIndex.Entry<QWD []> entry: fixings) {
            for (QWD value: entry.getValue())
                remapper.remap(value);
        }
    }

    public Collection<Date> getReferenceEventsDates() {
        
        final Set<Date> dates = new TreeSet<>();
        
        for (final KMIndex.Entry<QWD []> entry: fixings) {
            for (final QWD qwd: entry.getValue())
                dates.add(qwd.date);
        }
        
        return dates;
    }

    public Parameters getParameters() {
        return parameters;
    }
}

http://dive4elements.wald.intevation.org