Mercurial > dive4elements > river
changeset 7791:8b95f9c4f341 minfo-opt
Added new facet for filtered winfo differences.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 06 Mar 2014 14:04:46 +0100 |
parents | 6ed8bc0c461c |
children | 6451970e0562 |
files | artifacts/doc/conf/artifacts/minfo.xml artifacts/doc/conf/artifacts/winfo.xml artifacts/src/main/java/org/dive4elements/river/artifacts/model/DifferenceCurveFilterFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java |
diffstat | 4 files changed, 89 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/minfo.xml Thu Mar 06 14:03:10 2014 +0100 +++ b/artifacts/doc/conf/artifacts/minfo.xml Thu Mar 06 14:04:46 2014 +0100 @@ -246,6 +246,7 @@ <facet name="longitudinal_section.w"/> <facet name="longitudinal_section.q"/> <facet name="w_differences" description="facet.w_differences"/> + <facet name="w_differences.filtered" description="facet.w_differences"/> <facet name="other.wkms.interpol" description="Height over km, like flood protections."/> <facet name="morph-width" description="morphologic width, not sounding width!"/> </facets> @@ -273,6 +274,7 @@ <facet name="longitudinal_section.w"/> <facet name="longitudinal_section.q"/> <facet name="w_differences" description="facet.w_differences"/> + <facet name="w_differences.filtered" description="facet.w_differences"/> <facet name="other.wkms.interpol" description="Height over km, like flood protections."/> <facet name="morph-width" description="morphologic width, not sounding width!"/> </facets> @@ -530,6 +532,7 @@ <facet name="bedheight_difference.year.filtered" description="A facet for bed height differences"/> <facet name="bedheight_difference.epoch" description="A facet for bed height differences"/> <facet name="w_differences" description="facet.w_differences"/> + <facet name="w_differences.filtered" description="facet.w_differences"/> <facet name="longitudinal_section.annotations" description="facet.longitudinal_section.annotations"/> </facets> </outputmode>
--- a/artifacts/doc/conf/artifacts/winfo.xml Thu Mar 06 14:03:10 2014 +0100 +++ b/artifacts/doc/conf/artifacts/winfo.xml Thu Mar 06 14:04:46 2014 +0100 @@ -264,6 +264,7 @@ <facet name="longitudinal_section.q" description="facet.longitudinal_section.q"/> <facet name="longitudinal_section.w" description="facet.longitudinal_section.w"/> <facet name="w_differences" description="facet.w_differences"/> + <facet name="w_differences.filtered" description="facet.w_differences"/> <facet name="other.wkms" description="facet.other.wkms"/> <facet name="other.wqkms" description="facet.other.wqkms"/> <facet name="other.wqkms.w" description="W-Type of data" /> @@ -371,6 +372,7 @@ <facet name="longitudinal_section.w" description="facet.longitudinal_section.w"/> <facet name="longitudinal_section.q" description="facet.longitudinal_section.q"/> <facet name="w_differences" description="facet.w_differences"/> + <facet name="w_differences.filtered" description="facet.w_differences"/> <facet name="other.wqkms.w" description="W-Type of data" /> <facet name="other.wq" description="WQ-Type of data" /> <facet name="other.wqkms.q" description="Q-Type of data" /> @@ -693,6 +695,7 @@ <facet name="longitudinal_section.w" description="facet.longitudinal_section.w"/> <facet name="longitudinal_section.q" description="facet.longitudinal_section.q"/> <facet name="w_differences" description="facet.w_differences"/> + <facet name="w_differences.filtered" description="facet.w_differences"/> <facet name="other.wqkms.w" description="W-Type of data" /> <facet name="other.wq" description="WQ-Type of data" /> <facet name="other.wqkms.q" description="Q-Type of data" />
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/DifferenceCurveFilterFacet.java Thu Mar 06 14:04:46 2014 +0100 @@ -0,0 +1,82 @@ +package org.dive4elements.river.artifacts.model; + +import org.apache.log4j.Logger; +import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.WINFOArtifact; +import org.dive4elements.river.artifacts.access.RiverAccess; +import org.dive4elements.river.artifacts.context.RiverContext; +import org.dive4elements.river.artifacts.math.MovingAverage; +import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; + + +public class DifferenceCurveFilterFacet +extends DifferenceCurveFacet +{ + private static Logger logger = Logger.getLogger(DifferenceCurveFacet.class); + + + public DifferenceCurveFilterFacet() { + } + + public DifferenceCurveFilterFacet( + int index, + String name, + String description, + ComputeType type, + String stateID, + String hash + + ) { + super(index, name, description, type, stateID, hash); + } + + /** + * Get difference curve data. + * @return a WKms at given index. + */ + @Override + public Object getData(Artifact artifact, CallContext context) { + WKms result = (WKms)super.getData(artifact, context); + + Double start = (Double)context.getContextValue("startkm"); + Double end = (Double)context.getContextValue("endkm"); + if(start != null && end != null) { + RiverContext fc = (RiverContext)context.globalContext(); + // Adaptive smoothing, based on zoom factor/diagram extents. + ZoomScale scales = (ZoomScale)fc.get("zoomscale"); + RiverAccess access = new RiverAccess((D4EArtifact)artifact); + String river = access.getRiverName(); + + double radius = scales.getRadius(river, start, end); + + double[][] oldData = new double[2][result.size()]; + for (int i = 0; i < result.size(); i++) { + oldData[0][i] = result.getKm(i); + oldData[1][i] = result.getW(i); + } + + double[][] diffs = MovingAverage.weighted(oldData, radius); + WKmsImpl newData = new WKmsImpl(); + for(int j = 0; j < diffs[0].length; j++) { + newData.add(diffs[0][j], diffs[1][j]); + } + return newData; + } + return result; + } + + + /** Copy deeply. */ + @Override + public Facet deepCopy() { + WaterlevelFacet copy = new DifferenceCurveFilterFacet(); + copy.set(this); + copy.type = type; + copy.stateId = stateId; + copy.hash = hash; + return copy; + } +}
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java Thu Mar 06 14:03:10 2014 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java Thu Mar 06 14:04:46 2014 +0100 @@ -245,6 +245,7 @@ String LONGITUDINAL_MANUALPOINTS = "longitudinal_section.manualpoints"; String W_DIFFERENCES = "w_differences"; + String W_DIFFERENCES_FILTERED = "w_differences.filtered"; String COMPUTED_DISCHARGE_Q = "computed_discharge_curve.q"; String COMPUTED_DISCHARGE_MAINVALUES_Q = "computed_discharge_curve.mainvalues.q";