view artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisResult.java @ 9415:9744ce3c3853

Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets. The facets also put the valid station range into their xml-metadata
author gernotbelger
date Thu, 16 Aug 2018 16:27:53 +0200
parents ddcd52d239cd
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.fixings;

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

public class FixAnalysisResult extends FixResult {

    private static final long serialVersionUID = 1L;

    private final KMIndex<AnalysisPeriod[]> analysisKmPeriods;

    private final AnalysisPeriodEventResults analysisEventResults;

    public FixAnalysisResult(final Parameters parameters, final FixResultColumns fixResultColumns, final KMIndex<AnalysisPeriod[]> analysisKmPeriods,
            final AnalysisPeriodEventResults analysisEventResults) {
        super(parameters, fixResultColumns);

        this.analysisKmPeriods = analysisKmPeriods;
        this.analysisEventResults = analysisEventResults;
    }

    public final int getUsedSectorsInAnalysisPeriods() {
        int result = 0;
        for (final KMIndex.Entry<AnalysisPeriod[]> entry : this.analysisKmPeriods) {
            for (final AnalysisPeriod period : entry.getValue()) {
                for (int i = 0; i < 4; ++i) {
                    result |= period.getQSectorAverage(i) != null ? (1 << i) : 0;
                }
                // XXX: Stop early on result == ~(~0 << 4)) ?
            }
        }
        return result;
    }

    public final KMIndex<AnalysisPeriod[]> getAnalysisPeriods() {
        return this.analysisKmPeriods;
    }

    public AnalysisPeriodEventResults getAnalysisEventResults() {
        return this.analysisEventResults;
    }
}

http://dive4elements.wald.intevation.org