# HG changeset patch # User gernotbelger # Date 1518631581 -3600 # Node ID f431aec10d2cc6a6d4a8dbcf6f7b18397c48a3aa # Parent 90b7f45ff4aeb4a905b28dd3fd1bcbc0d33f9bec Implemented access to bed measurements diff -r 90b7f45ff4ae -r f431aec10d2c artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java Wed Feb 14 18:45:42 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java Wed Feb 14 19:06:21 2018 +0100 @@ -10,8 +10,10 @@ package org.dive4elements.river.artifacts.sinfo.flowdepth; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.List; import org.apache.commons.math.FunctionEvaluationException; @@ -24,6 +26,8 @@ import org.dive4elements.river.artifacts.model.LocationProvider; import org.dive4elements.river.artifacts.model.QKms; import org.dive4elements.river.artifacts.model.WKms; +import org.dive4elements.river.artifacts.model.minfo.QualityMeasurementFactory; +import org.dive4elements.river.artifacts.model.minfo.QualityMeasurements; import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; import org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthAccess.DifferencesPair; @@ -39,6 +43,8 @@ class FlowDepthCalculation { + private static final int VALID_BED_MEASUREMENT_YEARS = 20; + private static final String CSV_NOT_IN_GAUGE_RANGE = "export.waterlevel.csv.not.in.gauge.range"; private final CallContext context; @@ -136,13 +142,17 @@ // TODO: keine Berechnung TKH } - // FIXME - // - Sohlbeschaffenheit (D50 Korndurchmesser aus Seddb) - // - Abhängig von Peiljahr - // - kein D50 vorhanden --> Fehler + final QualityMeasurements bedMeasurements = getBedMeasurements(river, from, to, sounding.getYear()); + // FIXME: prüfung ob (genug) werte vorhanden sind? was sind genau die kriterien? falls nein, problemhinzufügen und keine + // berechnung tkh + // FIXME: wie wird ggf. interpoliert? --> absprache? + // FIXME: mir direkt aufgefallen, die Beispieldatenbank liefert Werte zum gleichen km und zeitpunkt, die messwerte sind + // aber unterschiedlich....??? + // FIXME: die eigentlichen daten extrahieren, ggf. wenn esswerte zum gleichen datum voriliegen. das neueste nehmen? oder + // das näheste zum Peiljahr? - // FIXME - // - Art der Gewässersohle (starr/mobil) + // FIXME Art der Gewässersohle (starr/mobil) + // FIXME: wie wird ggf. interpoliert? prüfung ob werte vorhanden? final String bedHeightLabel = bedHeight.getDescription(); final String wstLabel = wstKms.getName(); @@ -245,6 +255,25 @@ } /** + * Sohlbeschaffenheit (D50 Korndurchmesser aus Seddb) + * Abhängig von Peiljahr + */ + private QualityMeasurements getBedMeasurements(final River river, final double from, final double to, final int soundingYear) { + + /* construct valid measurement time range */ + final Calendar cal = Calendar.getInstance(); + cal.clear(); + + cal.set(soundingYear - VALID_BED_MEASUREMENT_YEARS, 0, 1); + final Date startTime = cal.getTime(); + + cal.set(soundingYear + VALID_BED_MEASUREMENT_YEARS, 11, 31); + final Date endTime = cal.getTime(); + + return QualityMeasurementFactory.getBedMeasurements(river.getName(), from, to, startTime, endTime); + } + + /** * Checks the year difference between waterlevels and sounding, and issues a warning if too big. * * Zeitraum Zeitliche Differenz [a] diff -r 90b7f45ff4ae -r f431aec10d2c artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthFacet.java Wed Feb 14 18:45:42 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthFacet.java Wed Feb 14 19:06:21 2018 +0100 @@ -47,41 +47,13 @@ final FlowDepthCalculationResults data = (FlowDepthCalculationResults) res.getData(); - final FlowDepthCalculationResult result = data.getResults().get(this.index); - - // FIXME: variable mean computation depending on current scale - - // Double start = (Double)context.getContextValue("startkm"); - // Double end = (Double)context.getContextValue("endkm"); - // if(start != null && end != null) { - // RiverContext fc = (RiverContext)context.globalContext(); - // ZoomScale scales = (ZoomScale)fc.get("zoomscale"); - // RiverAccess access = new RiverAccess((D4EArtifact)artifact); - // String river = access.getRiverName(); - // - // double radius = scales.getRadius(river, start, end); - // FlowVelocityData oldData = data[index]; - // FlowVelocityData newData = new FlowVelocityData(); - // double[][] q = oldData.getQPoints(); - // double[][] totalV = MovingAverage.weighted(oldData.getTotalChannelPoints(), radius); - // double[][] mainV = MovingAverage.weighted(oldData.getMainChannelPoints(), radius); - // double[][] tau = MovingAverage.weighted(oldData.getTauPoints(), radius); - // for(int j = 0; j < q[0].length; j++) { - // newData.addKM(q[0][j]); - // newData.addQ(q[1][j]); - // newData.addTauMain(tau[1][j]); - // newData.addVMain(mainV[1][j]); - // newData.addVTotal(totalV[1][j]); - // } - // return newData; - // } - - return result; + return data.getResults().get(this.index); } /** Copy deeply. */ @Override public Facet deepCopy() { + // FIXME: why not simply use the full constructor instead? final FlowDepthFacet copy = new FlowDepthFacet(); // FIXME: why does DataFacet does not override set? Bad access to variables of parent! copy.set(this);