Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java @ 3051:49727e9dcfde
Polished Gauge Discharges in computed discharge curves.
flys-artifacts/trunk@4625 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 07 Jun 2012 20:47:17 +0000 |
parents | 6e4ad35bcb11 |
children | 5642a83420f2 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java Thu Jun 07 13:13:13 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java Thu Jun 07 20:47:17 2012 +0000 @@ -69,9 +69,10 @@ Document data) { logger.debug("GaugeDischargeArtifact.setup"); + String ids = StaticFLYSArtifact.getDatacageIDValue(data); + addStringData("ids", ids); + logger.debug("id for gaugedischarge: " + ids); super.setup(identifier, factory, context, callMeta, data); - String ids = StaticFLYSArtifact.getDatacageIDValue(data); - logger.debug("id for gaugedischarge: " + ids); } @@ -81,12 +82,6 @@ } - /** Access state data storing the jsonstring with points. - public String getPointsData(String facetName) { - return getDataAsString(facetName + ".data"); - }*/ - - /** * Setup state and facet, copy from master artifact. */ @@ -98,10 +93,7 @@ importData(artifact, "river"); // Get the location(s) - //importData(artifact, "ld_mode"); - //importData(artifact, "ld_from"); - //importData(artifact, "ld_to"); - //importData(artifact, "ld_locations"); + //importData(artifact, "ld_mode", ld_from, ld_to, ld_locations addStringData("ld_from", "0"); addStringData("ld_to", "1000"); addStringData("ld_mode", "distance"); @@ -120,28 +112,22 @@ } - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). This will be checked one time - * when the facet enters a collections describe document. - * - * @param facetName name of the facet. - * @param index index of the facet. - * @return 0 if not active - */ - @Override - public int getInitialFacetActivity( - String outputName, - String facetName, - int index) - { - return 1; + /** Get the Gauges name which came with datacage data-document. */ + public String getGaugeName() { + return this.getDataAsString("ids"); + } + + + /** Get the Gauges which came with datacage data-document. */ + public Gauge getGauge() { + River river = FLYSUtils.getRiver(this); + return river.determineGaugeByName(getGaugeName()); } /** * Returns the data that is used to create discharge curves. - * + * @return CalculationResult with WQKms. */ public CalculationResult getDischargeCurveData() { @@ -149,7 +135,8 @@ if (river == null) { return error(new WQKms[0], "no.river.selected"); } - + /* + // This one would allow to automatically pick the right Gauge. double [] distance = FLYSUtils.getKmRange(this); logger.debug("getDischargeCurveData: get range"); @@ -158,7 +145,7 @@ } List<Gauge> gauges = river.determineGauges(distance[0], distance[1]); - logger.debug("getDischargeCurveData: get gauges"); + logger.debug("getDischargeCurveData: got " + gauges.size() + " gauges"); if (gauges.isEmpty()) { return error(new WQKms[0], "no.gauge.selected"); @@ -170,29 +157,50 @@ names[i] = gauges.get(i).getName(); logger.debug("getDischargeCurveData: name " + names[i]); } + */ - DischargeTables dt = new DischargeTables(river.getName(), names); + DischargeTables dt = new DischargeTables(river.getName(), getDataAsString("ids")); - Map<String, double [][]> map = dt.getValues(100d); + Map<String, double [][]> map = dt.getValues(100); ArrayList<WQKms> res = new ArrayList<WQKms>(); - for (Gauge gauge: gauges) { - String name = gauge.getName(); - double [][] values = map.get(name); - if (values == null) { - continue; - } - double [] kms = new double[values[0].length]; - Arrays.fill(kms, gauge.getStation().doubleValue()); - res.add(new WQKms(kms, values[0], values[1], name)); - logger.debug("getDischargeCurveData: add one res gauge"); + Gauge gauge = river.determineGaugeByName(this.getDataAsString("ids")); + + String name = getGaugeName(); + double [][] values = map.get(name); + if (values == null) { + logger.error("No values for this gauge / discharge found."); } + for (int i = 0 ; i < values[0].length; i++) { + values[0][i] += gauge.getDatum().doubleValue(); + } + double [] kms = new double[values[0].length]; + Arrays.fill(kms, gauge.getStation().doubleValue()); + res.add(new WQKms(kms, values[0], values[1], name)); return new CalculationResult( res.toArray(new WQKms[res.size()]), new Calculation()); } + + /** + * Determines Facets initial disposition regarding activity (think of + * selection in Client ThemeList GUI). This will be checked one time + * when the facet enters a collections describe document. + * + * @param facetName name of the facet. + * @param index index of the facet. + * @return 1 - all Facets enter activated. + */ + @Override + public int getInitialFacetActivity( + String outputName, + String facetName, + int index) + { + return 1; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :