Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthProcessor.java @ 8980:b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
Some improvements to error handling and handling of empty results.
author | gernotbelger |
---|---|
date | Thu, 05 Apr 2018 18:30:34 +0200 |
parents | ee5ce13016ed |
children | 23945061daec |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthProcessor.java Thu Apr 05 17:12:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthProcessor.java Thu Apr 05 18:30:34 2018 +0200 @@ -18,50 +18,87 @@ public final class FlowDepthProcessor extends AbstractSInfoLineProcessor<AbstractSInfoCalculationResult> { - private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label"; + private static final String AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label"; private static final String SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL = "sinfo.chart.flow_depth.yaxis.label"; /* Theme name, usually defined in 'FacetTypes', but that is soooo bad dependencies... */ // REMARK: these mustend with 'filtered' so extra handling happens in chart: point are always recalculated, because data // changes depending on zoom state + + /* flow depth */ public static final String FACET_FLOW_DEPTH_FILTERED = "sinfo_facet_flow_depth.filtered"; - private static final String I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth.filtered.description"; + private static final String FACET_FLOW_DEPTH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth.filtered.description"; + public static final String FACET_FLOW_DEPTH_RAW = "sinfo_facet_flow_depth"; + + private static final String FACET_FLOW_DEPTH_RAW_DESCRIPTION = "sinfo.facet.flow_depth.raw.description"; + + /* flow depth with tkh */ private static final String FACET_FLOW_DEPTH_TKH_FILTERED = "sinfo_facet_flow_depth_with_tkh.filtered"; - private static final String I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_with_tkh.filtered.description"; + private static final String FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_with_tkh.filtered.description"; + public static final String FACET_FLOW_DEPTH_TKH_RAW = "sinfo_facet_flow_depth_with_tkh"; + + private static final String FACET_FLOW_DEPTH_TKH_RAW_DESCRIPTION = "sinfo.facet.flow_depth_with_tkh.raw.description"; + + /* minimal flow depth */ public static final String FACET_FLOW_DEPTH_MIN_FILTERED = "sinfo_facet_flow_depth_min.filtered"; - private static final String I18N_FACET_FLOW_DEPTH_MIN_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_min.filtered.description"; + private static final String FACET_FLOW_DEPTH_MIN_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_min.filtered.description"; + public static final String FACET_FLOW_DEPTH_MIN_RAW = "sinfo_facet_flow_depth_min"; + + private static final String FACET_FLOW_DEPTH_MIN_RAW_DESCRIPTION = "sinfo.facet.flow_depth_min.raw.description"; + + /* maximal flow depth */ public static final String FACET_FLOW_DEPTH_MAX_FILTERED = "sinfo_facet_flow_depth_max.filtered"; - private static final String I18N_FACET_FLOW_DEPTH_MAX_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_max.filtered.description"; + private static final String FACET_FLOW_DEPTH_MAX_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_max.filtered.description"; + public static final String FACET_FLOW_DEPTH_MAX_RAW = "sinfo_facet_flow_depth_max"; + + private static final String FACET_FLOW_DEPTH_MAX_RAW_DESCRIPTION = "sinfo.facet.flow_depth_max.raw.description"; + + /* current flow depth */ public static final String FACET_FLOW_DEPTH_CURRENT_FILTERED = "sinfo_facet_flow_depth_current.filtered"; - private static final String I18N_FACET_FLOW_DEPTH_CURRENT_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_current.filtered.description"; + private static final String FACET_FLOW_DEPTH_CURRENT_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_current.filtered.description"; + public static final String FACET_FLOW_DEPTH_CURRENT_RAW = "sinfo_facet_flow_depth_current"; + + private static final String FACET_FLOW_DEPTH_CURRENT_RAW_DESCRIPTION = "sinfo.facet.flow_depth_current.raw.description"; + + /* historical flow depth */ public static final String FACET_FLOW_DEPTH_HISTORICAL_FILTERED = "sinfo_facet_flow_depth_historical.filtered"; - private static final String I18N_FACET_FLOW_DEPTH_HISTORICAL_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_historical.filtered.description"; + private static final String FACET_FLOW_DEPTH_HISTORICAL_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_historical.filtered.description"; + + public static final String FACET_FLOW_DEPTH_HISTORICAL_RAW = "sinfo_facet_flow_depth_historical"; + + private static final String FACET_FLOW_DEPTH_HISTORICAL_RAW_DESCRIPTION = "sinfo.facet.flow_depth_historical.raw.description"; private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); static { HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_FILTERED); + HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_RAW); HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_TKH_FILTERED); + HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_TKH_RAW); HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_MIN_FILTERED); + HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_MIN_RAW); HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_MAX_FILTERED); + HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_MAX_RAW); HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_CURRENT_FILTERED); + HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_CURRENT_RAW); HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_HISTORICAL_FILTERED); + HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_HISTORICAL_RAW); } public FlowDepthProcessor() { - super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); + super(AXIS_LABEL, HANDLED_FACET_TYPES); } @Override @@ -69,59 +106,107 @@ if (FACET_FLOW_DEPTH_FILTERED.contentEquals(facetName)) return data.getStationPoints(SInfoResultType.flowdepth); + if (FACET_FLOW_DEPTH_RAW.contentEquals(facetName)) + return data.getStationPoints(SInfoResultType.flowdepth); if (FACET_FLOW_DEPTH_TKH_FILTERED.contentEquals(facetName)) return data.getStationPoints(SInfoResultType.flowdepthtkh); + if (FACET_FLOW_DEPTH_TKH_RAW.contentEquals(facetName)) + return data.getStationPoints(SInfoResultType.flowdepthtkh); if (FACET_FLOW_DEPTH_MIN_FILTERED.contentEquals(facetName)) return data.getStationPoints(SInfoResultType.flowdepthmin); + if (FACET_FLOW_DEPTH_MIN_RAW.contentEquals(facetName)) + return data.getStationPoints(SInfoResultType.flowdepthmin); if (FACET_FLOW_DEPTH_MAX_FILTERED.contentEquals(facetName)) return data.getStationPoints(SInfoResultType.flowdepthmax); + if (FACET_FLOW_DEPTH_MAX_RAW.contentEquals(facetName)) + return data.getStationPoints(SInfoResultType.flowdepthmax); if (FACET_FLOW_DEPTH_CURRENT_FILTERED.contentEquals(facetName)) return data.getStationPoints(SInfoResultType.flowdepthCurrent); + if (FACET_FLOW_DEPTH_CURRENT_RAW.contentEquals(facetName)) + return data.getStationPoints(SInfoResultType.flowdepthCurrent); if (FACET_FLOW_DEPTH_HISTORICAL_FILTERED.contentEquals(facetName)) return data.getStationPoints(SInfoResultType.flowdepthHistorical); + if (FACET_FLOW_DEPTH_HISTORICAL_RAW.contentEquals(facetName)) + return data.getStationPoints(SInfoResultType.flowdepthHistorical); final String error = String.format("Unknown facet name: %s", facetName); throw new UnsupportedOperationException(error); } - public static Facet createFlowDepthFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult result, + public static Facet createFlowDepthFilteredFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult result, final int index) { return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_FILTERED, - I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION); - } - - public static Facet createFlowDepthTkhFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult result, - final int index) { - return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_TKH_FILTERED, - I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION); - } - - public static Facet createFlowDepthMinFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult result, - final int index) { - return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MIN_FILTERED, - I18N_FACET_FLOW_DEPTH_MIN_FILTERED_DESCRIPTION); + FACET_FLOW_DEPTH_FILTERED_DESCRIPTION); } - public static Facet createFlowDepthMaxFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult result, + public static Facet createFlowDepthRawFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult result, final int index) { - return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MAX_FILTERED, - I18N_FACET_FLOW_DEPTH_MAX_FILTERED_DESCRIPTION); + return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_RAW, + FACET_FLOW_DEPTH_RAW_DESCRIPTION); } - public static Facet createFlowDepthCurrentFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult result, - final int index) { - return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_CURRENT_FILTERED, - I18N_FACET_FLOW_DEPTH_CURRENT_FILTERED_DESCRIPTION); + public static Facet createFlowDepthTkhFilteredFacet(final CallContext context, final String hash, final String id, + final AbstractSInfoCalculationResult result, final int index) { + return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_TKH_FILTERED, + FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION); } - public static Facet createFlowDepthHistoricalFacet(final CallContext context, final String hash, final String id, + public static Facet createFlowDepthTkhRawFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult result, + final int index) { + return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_TKH_RAW, + FACET_FLOW_DEPTH_TKH_RAW_DESCRIPTION); + } + + public static Facet createFlowDepthMinFilteredFacet(final CallContext context, final String hash, final String id, + final AbstractSInfoCalculationResult result, final int index) { + return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MIN_FILTERED, + FACET_FLOW_DEPTH_MIN_FILTERED_DESCRIPTION); + } + + public static Facet createFlowDepthMinRawFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult result, + final int index) { + return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MIN_RAW, + FACET_FLOW_DEPTH_MIN_RAW_DESCRIPTION); + } + + public static Facet createFlowDepthMaxFilteredFacet(final CallContext context, final String hash, final String id, + final AbstractSInfoCalculationResult result, final int index) { + return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MAX_FILTERED, + FACET_FLOW_DEPTH_MAX_FILTERED_DESCRIPTION); + } + + public static Facet createFlowDepthMaxRawFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult result, + final int index) { + return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MAX_RAW, + FACET_FLOW_DEPTH_MAX_RAW_DESCRIPTION); + } + + public static Facet createFlowDepthCurrentFilteredFacet(final CallContext context, final String hash, final String id, + final AbstractSInfoCalculationResult result, final int index) { + return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_CURRENT_FILTERED, + FACET_FLOW_DEPTH_CURRENT_FILTERED_DESCRIPTION); + } + + public static Facet createFlowDepthCurrentRawFacet(final CallContext context, final String hash, final String id, + final AbstractSInfoCalculationResult result, final int index) { + return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_CURRENT_RAW, + FACET_FLOW_DEPTH_CURRENT_RAW_DESCRIPTION); + } + + public static Facet createFlowDepthHistoricalFilteredFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult result, final int index) { return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, - FACET_FLOW_DEPTH_HISTORICAL_FILTERED, I18N_FACET_FLOW_DEPTH_HISTORICAL_FILTERED_DESCRIPTION); + FACET_FLOW_DEPTH_HISTORICAL_FILTERED, FACET_FLOW_DEPTH_HISTORICAL_FILTERED_DESCRIPTION); + } + + public static Facet createFlowDepthHistoricalRawFacet(final CallContext context, final String hash, final String id, + final AbstractSInfoCalculationResult result, final int index) { + return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_HISTORICAL_RAW, + FACET_FLOW_DEPTH_HISTORICAL_RAW_DESCRIPTION); } } \ No newline at end of file