Mercurial > dive4elements > river
changeset 8421:0fa963038c61
Only draw discharge curve if on same station as navigation.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 17 Oct 2014 13:17:12 +0200 (2014-10-17) |
parents | 8a14605fb64a |
children | 96bf5135cd0e |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java artifacts/src/main/java/org/dive4elements/river/exports/process/ComputedDischargeProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java |
diffstat | 3 files changed, 36 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java Fri Oct 17 12:50:35 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java Fri Oct 17 13:17:12 2014 +0200 @@ -162,6 +162,21 @@ return new double[] {getKm(0), getKm(size()-1)}; } + private static final double EPS = 1e-5; + + public Double sameKm() { + int s = size(); + if (s < 1) return null; + if (s == 1) return getKm(0); + double a = getKm(0); + double b = getKm(s-1); + double c = getKm(s/2); + + return Math.abs(a-b) > EPS || Math.abs(a-c) > EPS || Math.abs(b-c) > EPS + ? null + : a; + } + @Override public boolean guessRTLData() { return DataUtil.guessSameDirectionData(ws, allKms());
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/ComputedDischargeProcessor.java Fri Oct 17 12:50:35 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/ComputedDischargeProcessor.java Fri Oct 17 13:17:12 2014 +0200 @@ -77,16 +77,30 @@ boolean visible ) { CallContext context = generator.getCallContext(); + + Object data = bundle.getData(context); + WQKms wqkms = (WQKms) data; + + Object currentKm = context.getContextValue("currentkm"); + if (currentKm instanceof Number) { + double ckm = ((Number)currentKm).doubleValue(); + Double skm = wqkms.sameKm(); + if (skm != null && Math.abs(skm-ckm) > 0.00001) { + return; + } + } + Map<String, String> metaData = bundle.getFacet().getMetaData( bundle.getArtifact(), context); + StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); - Object data = bundle.getData(context); series.putMetaData(metaData, bundle.getArtifact(), context); yAxisLabel = metaData.get("Y"); - WQKms wqkms = (WQKms) data; + + double[][] wqData = new double[2][wqkms.size()]; for (int i = 0; i < wqkms.size(); i++) { wqData[0][i] = wqkms.getQ(i);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java Fri Oct 17 12:50:35 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java Fri Oct 17 13:17:12 2014 +0200 @@ -110,9 +110,13 @@ Map<String, String> metaData = bundle.getFacet().getMetaData( bundle.getArtifact(), context); WQKms data = (WQKms)bundle.getData(context); + Double skm = data.sameKm(); + if (skm != null && Math.abs(skm-km) > 0.00001) { + return; + } StyledXYSeries series = new StyledXYSeries(name, theme); double[][] wqData = new double[2][data.size()]; - for (int i = 0; i < data.size(); i++) { + for (int i = 0, n = data.size(); i < n; i++) { wqData[0][i] = data.getQ(i); wqData[1][i] = data.getW(i); }