# HG changeset patch # User Felix Wolfsteller # Date 1345110561 0 # Node ID 6aea625190daa3a890dc48800d060817f9a8b3f9 # Parent 3837a4e6db461b5ff035f8d6bee4a0295b48176b Handle former W calculations in fixA W/Q out. flys-artifacts/trunk@5218 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3837a4e6db46 -r 6aea625190da flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Aug 16 09:41:53 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu Aug 16 09:49:21 2012 +0000 @@ -1,3 +1,11 @@ +2012-08-16 Felix Wolfsteller + + * src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java: + Interpolate and reduce WQKms if currentKm found in context. + + * src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java: + Handle WQKms in WQOuts. + 2012-08-16 Felix Wolfsteller * doc/conf/artifacts/fixanalysis.xml: Add longitudinal section diff -r 3837a4e6db46 -r 6aea625190da flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java Thu Aug 16 09:41:53 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java Thu Aug 16 09:49:21 2012 +0000 @@ -8,6 +8,7 @@ import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.states.DefaultState.ComputeType; +import de.intevation.flys.artifacts.math.Linear; import org.apache.log4j.Logger; @@ -67,6 +68,38 @@ } WQKms [] wqkms = getWQKms(res); + if (context.getContextValue("currentKm") != null) { + logger.debug("interpolate at given km"); + // TODO handle exact match. + + WQKms wqkmsI = wqkms[index]; + double km = ((Double)context.getContextValue("currentKm")).doubleValue(); + + // TODO employ DataUtils interface to TDoubleArraList + int size = wqkmsI.size(); + boolean kmIncreasing = (wqkmsI.getKm(0) < wqkmsI.getKm(wqkmsI.size()-1)) + ? true : false; + int mod = kmIncreasing ? +1 : -1; + int idx = 0; + if (!kmIncreasing) { + while (idx < size && wqkmsI.getKm(idx) < km) { + idx++; + } + } + else { + idx = size-1; + while (idx > 0 && wqkmsI.getKm(idx) > km) { + idx--; + } + } + WQKms resultWQKms = new WQKms(); + if (idx != -1 && idx < size) { + double inW = Linear.linear(km, wqkmsI.getKm(idx), wqkmsI.getKm(idx-mod), wqkmsI.getW(idx), wqkmsI.getW(idx-mod)); + double inQ = Linear.linear(km, wqkmsI.getKm(idx),wqkmsI.getKm(idx-mod), wqkmsI.getQ(idx), wqkmsI.getQ(idx-mod)); + resultWQKms.add(inW, inQ, km); + } + return resultWQKms; + } return wqkms != null ? wqkms[index] : null; } diff -r 3837a4e6db46 -r 6aea625190da flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Thu Aug 16 09:41:53 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Thu Aug 16 09:49:21 2012 +0000 @@ -132,7 +132,7 @@ doc, visible); } - else if(STATIC_WQ.equals(name)) { + if (LONGITUDINAL_W.equals(name) || STATIC_WQ.equals(name)) { doWQOut(aaf.getData(context), aaf, doc, visible); } else if (name.equals(DISCHARGE_CURVE)) { @@ -274,7 +274,8 @@ } } - /** + + /** * Add W-Annotations to plot. * @param wqkms actual data (double[][]). * @param theme theme to use. @@ -303,7 +304,8 @@ // Assume its WKms. logger.debug("Got WKms"); WKms data = (WKms) wqkms; - Double ckm = (Double) context.getContextValue("currentKm"); + + Double ckm = (Double) context.getContextValue(CURRENT_KM); double location = (ckm != null) ? ckm.doubleValue() : getRange()[0]; @@ -353,6 +355,7 @@ addAxisSeries(series, YAXIS.W.idx, visible); } + /** * Add WQ Data to plot. * @param wqkms data as double[][] @@ -364,14 +367,27 @@ boolean visible ) { logger.debug("FixWQCurveGenerator: doWQOut"); - double [][] data = (double [][]) wqkms; + if (wqkms instanceof WQKms) { + WQKms data = (WQKms) wqkms; - XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); - StyledSeriesBuilder.addPoints(series, data, true); + XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); + Double ckm = (Double) context.getContextValue(CURRENT_KM); - addAxisSeries(series, YAXIS.W.idx, visible); + StyledSeriesBuilder.addPointsQW(series, data); + + addAxisSeries(series, YAXIS.W.idx, visible); + } + else { + double [][] data = (double [][]) wqkms; + + XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); + StyledSeriesBuilder.addPoints(series, data, true); + + addAxisSeries(series, YAXIS.W.idx, visible); + } } + protected void addQWSeries(QW[] qws, ArtifactAndFacet aaf, Document theme, boolean visible) { if(qws != null) { XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);