view artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/BunduResultType.java @ 9444:ecadc9ed0ba0

Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
author mschaefer
date Tue, 21 Aug 2018 13:41:18 +0200
parents d194c5b24bf8
children e60584f2a531
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);
        }
    };

    /**
     * List of bed height values of the 10 fields of a cross section
     */
    public static final BunduResultType bedHeightFields = new BunduResultType(null, null) {

        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) {
            throw new UnsupportedOperationException();
        }
    };

    /**
     * List of depth values of the 10 fields of a cross section
     */
    public static final BunduResultType depthFields = new BunduResultType(I18NStrings.UNIT_NONE, null) {

        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) {
            throw new UnsupportedOperationException();
        }
    };

    /**
     * List of volume values of the 10 fields of a cross section
     */
    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);
        }
    };

    /**
     * List of mass values of the 10 fields of a cross section
     */
    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 missStationRangeFrom = new BunduResultType(I18NStrings.UNIT_KM, "bundu.export.bezugswst.csv.meta.miss.mass.km_from") {

        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.getWaterlevelKM(context);
        }
    };

    public static final BunduResultType missStationRangeTo = new BunduResultType(I18NStrings.UNIT_KM, "bundu.export.bezugswst.csv.meta.miss.mass.km_to") {

        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.getWaterlevelKM(context);
        }
    };
}

http://dive4elements.wald.intevation.org