view artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/BunduResultType.java @ 9432:d194c5b24bf8

Added bundu bzws w calculation and longitudinal sections of wspl and depth
author mschaefer
date Mon, 20 Aug 2018 09:46:02 +0200
parents c64de8cc4e97
children ecadc9ed0ba0
line wrap: on
line source
/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
 * Software engineering by
 *  Björnsen Beratende Ingenieure GmbH
 *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
 *
 * 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.bundu;

import java.text.NumberFormat;

import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.common.AbstractResultType;
import org.dive4elements.river.artifacts.common.I18NStrings;
import org.dive4elements.river.utils.Formatter;

/**
 * @author Domenico Nardi Tironi
 *
 */
public abstract class BunduResultType extends AbstractResultType {

    protected BunduResultType(final String unit, final String csvHeader, final String pdfHeader) {
        super(unit, csvHeader, pdfHeader);
    }

    protected BunduResultType(final String unit, final String csvHeader) {
        super(unit, csvHeader, csvHeader);
    }

    private static final long serialVersionUID = 1L;

    public static final BunduResultType bezugswst = new BunduResultType(I18NStrings.UNIT_NONE, "bundu.wst.export.csv.meta.header.bezugswst",
            "bundu.wst.export.pdf.meta.header.bezugswst") { // Unit dynamic

        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getFlowDepth(context); // REMARK same as SInfoResultType.waterlevel
        }
    };

    public static final BunduResultType sounding = new BunduResultType(I18NStrings.UNIT_NONE, "bundu.export.bezugswst.csv.meta.miss.sounding") {

        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            return exportStringValue(value);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            throw new UnsupportedOperationException();
        }
    };

    public static final BunduResultType channelLowerEdge = new BunduResultType(I18NStrings.UNIT_NONE, "bundu.export.bezugswst.csv.meta.miss.channel.lower_edge",
            "bundu.export.bezugswst.pdf.meta.miss.channel.lower_edge") { // Unit dynamic

        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getFlowDepth(context); // REMARK same as SInfoResultType.waterlevel
        }
    };

    public static final BunduResultType channelDepth = new BunduResultType(I18NStrings.UNIT_M, "bundu.export.bezugswst.csv.meta.miss.channel.min_depth",
            "bundu.export.bezugswst.pdf.meta.miss.channel.min_depth") {

        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getWaterlevelQ(context); // Richtiges Format? TODO check!
        }
    };

    public static final BunduResultType hasMissingDepth = new BunduResultType(I18NStrings.UNIT_NONE, "bundu.export.bezugswst.csv.meta.miss.exists",
            "bundu.export.bezugswst.pdf.meta.miss.exists") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            return exportStringValue(value);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            throw new UnsupportedOperationException();
        }
    };
    public static final BunduResultType missVolumeTotal = new BunduResultType(I18NStrings.UNIT_CUBIC_M, "bundu.export.bezugswst.csv.meta.miss.volume.total") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getIntegerFormatter(context);
        }
    };

    public static final BunduResultType missMassTotal = new BunduResultType(I18NStrings.UNIT_TON, "bundu.export.bezugswst.csv.meta.miss.mass.total",
            "bundu.export.bezugswst.csv.meta.miss.mass") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getMassFormat(context);
        }
    };

    public static final BunduResultType excavationVolume = new BunduResultType(I18NStrings.UNIT_CUBIC_M, "bundu.export.bezugswst.csv.meta.miss.excavation",
            "bundu.export.bezugswst.pdf.meta.miss.excavation") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getIntegerFormatter(context);
        }
    };

    public static final BunduResultType excavationCosts = new BunduResultType(I18NStrings.UNIT_EURO, "bundu.export.bezugswst.csv.meta.miss.costs",
            "bundu.export.bezugswst.pdf.meta.miss.costs") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getCurrencyFormat(context);
        }
    };

    public static final BunduResultType channelWidth = new BunduResultType(I18NStrings.UNIT_M, "bundu.export.bezugswst.csv.meta.miss.channel.width",
            "bundu.export.bezugswst.pdf.meta.miss.channel.width") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getChannelWidth(context);
        }
    };

    public static final BunduResultType density = new BunduResultType(I18NStrings.UNIT_M, "bundu.export.bezugswst.csv.meta.miss.density",
            "bundu.export.bezugswst.pdf.meta.miss.density") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getDensityFormat(context);
        }
    };

    public static final BunduResultType missVolumeMeanBed = new BunduResultType(I18NStrings.UNIT_NONE, "bundu.export.bezugswst.csv.meta.miss.volume.mean_bed") {

        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getIntegerFormatter(context);
        }
    };

    public static final BunduResultType missMassMeanBed = new BunduResultType(I18NStrings.UNIT_NONE, "bundu.export.bezugswst.csv.meta.miss.mass.mean_bed") {

        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getIntegerFormatter(context);
        }
    };

    // RESULT TYPE FIELDS
    public static final BunduResultType missVolumeFields = new BunduResultType(I18NStrings.UNIT_NONE, "bundu.export.bezugswst.csv.meta.miss.volume.field") {

        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getMassFormat(context);
        }
    };

    public static final BunduResultType missMassfields = new BunduResultType(I18NStrings.UNIT_NONE, "bundu.export.bezugswst.csv.meta.miss.mass.field") {

        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            return Formatter.getMassFormat(context);
        }
    };

    public static final BunduResultType missStationRange = new BunduResultType(I18NStrings.UNIT_KM, I18NStrings.CSV_KM_HEADER) {
        @Override
        public String exportValue(final CallContext context, final Object value) {
            return exportStringValue(value);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            throw new UnsupportedOperationException();
        }
    };

}

http://dive4elements.wald.intevation.org