Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQSelect.java @ 8914:e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
author | gernotbelger |
---|---|
date | Tue, 27 Feb 2018 18:06:52 +0100 |
parents | 9483a5bf4219 |
children | f61bc0c63188 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQSelect.java Mon Feb 26 18:10:03 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQSelect.java Tue Feb 27 18:06:52 2018 +0100 @@ -30,10 +30,9 @@ import org.dive4elements.river.model.Wst; import org.dive4elements.river.artifacts.D4EArtifact; -import org.dive4elements.river.artifacts.WINFOArtifact; import org.dive4elements.river.artifacts.access.RangeAccess; - +import org.dive4elements.river.artifacts.access.ComputationRangeAccess; import org.dive4elements.river.artifacts.model.WstFactory; import org.dive4elements.river.artifacts.model.WstValueTable; import org.dive4elements.river.artifacts.model.WstValueTableFactory; @@ -104,8 +103,6 @@ Boolean isQ = flys.getDataAsBoolean(WQ_MODE); Boolean isFree = flys.getDataAsBoolean(WQ_FREE); - WINFOArtifact winfo = (WINFOArtifact) flys; - Element dataElement = creator.create("data"); creator.addAttr(dataElement, "name", name, true); creator.addAttr(dataElement, "type", type, true); @@ -116,10 +113,10 @@ String label; if (!isQ || isFree) { - label = getLabel(winfo, cc, value); + label = getLabel(flys, cc, value); } else { - label = getSpecialLabel(winfo, cc, value); + label = getSpecialLabel(flys, cc, value); } creator.addAttr(itemElement, "label", label, true); @@ -131,7 +128,7 @@ protected static String getLabel( - WINFOArtifact winfo, + D4EArtifact winfo, CallContext cc, String raw ) { @@ -167,7 +164,7 @@ protected static String getSpecialLabel( - WINFOArtifact winfo, + D4EArtifact winfo, CallContext cc, String raw ) { @@ -250,12 +247,12 @@ String name, CallContext context ){ - WINFOArtifact winfo = (WINFOArtifact) artifact; + D4EArtifact flys = (D4EArtifact) artifact; - double[] minmaxW = determineMinMaxW(winfo); - double[] minmaxWFree = determineMinMaxWFree(winfo); - double[] minmaxQ = determineMinMaxQAtGauge(winfo); - double[] minmaxQFree = determineMinMaxQ(winfo); + double[] minmaxW = determineMinMaxW(flys); + double[] minmaxWFree = determineMinMaxWFree(flys); + double[] minmaxQ = determineMinMaxQAtGauge(flys); + double[] minmaxQFree = determineMinMaxQ(flys); if (name.equals("wq_from")) { Element minW = createItem(cr, new String[] { @@ -400,7 +397,7 @@ * * @return the min and max W values for the current gauge. */ - protected double[] determineMinMaxW(WINFOArtifact winfo) { + protected double[] determineMinMaxW(D4EArtifact winfo) { log.debug("WQSelect.determineCurrentGauge"); RangeAccess rangeAccess = new RangeAccess(winfo); @@ -425,22 +422,24 @@ * * @return the min and max W values. */ - protected double[] determineMinMaxWFree(WINFOArtifact winfo) { + protected double[] determineMinMaxWFree(D4EArtifact winfo) { log.debug("WQSelect.determineMinMaxWFree"); WstValueTable valueTable = WstValueTableFactory.getTable( RiverUtils.getRiver(winfo)); + ComputationRangeAccess access = new ComputationRangeAccess(winfo); + double[] minmaxW = null; if(valueTable != null) { double[] km = null; - if(new RangeAccess(winfo).isRange()) { - km = winfo.getFromToStep(); + if(access.isRange()) { + km = access.getFromToStep(); // Use the start km to determine the min max values. minmaxW = valueTable.getMinMaxW(km[0]); } else { - km = winfo.getKms(); + km = access.getKms(); minmaxW = valueTable.getMinMaxW(km[0]); } } @@ -459,7 +458,7 @@ * * @return the min and max Q values for the current gauge. */ - protected double[] determineMinMaxQAtGauge(WINFOArtifact winfo) { + protected double[] determineMinMaxQAtGauge(D4EArtifact winfo) { log.debug("WQSelect.determineMinMaxQAtGauge"); RangeAccess rangeAccess = new RangeAccess(winfo); @@ -488,21 +487,23 @@ * * @return the min and max Q values for the current kilometer range. */ - protected double[] determineMinMaxQ(WINFOArtifact winfo) { + protected double[] determineMinMaxQ(D4EArtifact winfo) { log.debug("WQSelect.determineMinMaxQ"); WstValueTable valueTable = WstValueTableFactory.getTable( RiverUtils.getRiver(winfo)); + ComputationRangeAccess access = new ComputationRangeAccess(winfo); + double[] minmaxQ = null; if(valueTable != null) { double[] km = null; - if(new RangeAccess(winfo).isRange()) { - km = winfo.getFromToStep(); + if(access.isRange()) { + km = new ComputationRangeAccess(winfo).getFromToStep(); minmaxQ = valueTable.getMinMaxQ(km[0], km[1], km[2]); } else { - km = winfo.getKms(); + km = access.getKms(); minmaxQ = valueTable.getMinMaxQ(km[0]); for (int i = 1; i < km.length; i++) { double[] tmp = valueTable.getMinMaxQ(km[i]); @@ -527,7 +528,7 @@ { log.debug("WQSelect.validate"); - WINFOArtifact flys = (WINFOArtifact) artifact; + D4EArtifact flys = (D4EArtifact) artifact; StateData data = getData(flys, WQ_SELECTION); boolean isRange = data != null @@ -567,7 +568,7 @@ } - protected boolean validateSingle(WINFOArtifact artifact) + protected boolean validateSingle(D4EArtifact artifact) throws IllegalArgumentException { log.debug("WQSelect.validateSingle"); @@ -623,7 +624,7 @@ } - protected boolean validateRange(WINFOArtifact artifact) + protected boolean validateRange(D4EArtifact artifact) throws IllegalArgumentException { log.debug("WQSelect.validateRange"); @@ -685,7 +686,7 @@ * @return true, if everything was fine, otherwise an exception is thrown. */ protected boolean validateGaugeW( - WINFOArtifact artifact, + D4EArtifact artifact, double from, double to, double step) @@ -711,7 +712,7 @@ * @return true, if everything was fine, otherwise an exception is thrown. */ protected boolean validateGaugeQ( - WINFOArtifact artifact, + D4EArtifact artifact, double from, double to, double step) @@ -737,7 +738,7 @@ * @return true, if everything was fine, otherwise an exception is thrown. */ protected boolean validateFreeQ( - WINFOArtifact artifact, + D4EArtifact artifact, double from, double to, double step) @@ -763,7 +764,7 @@ * @return true, if everything was fine, otherwise an exception is thrown. */ protected boolean validateFreeW( - WINFOArtifact artifact, + D4EArtifact artifact, double from, double to, double step)