# HG changeset patch # User Ingo Weinzierl # Date 1308059659 0 # Node ID dda282dcc44f30445ec33b050fd5d4ed2d2d778d # Parent bcd62609c936aeb05a5db50f298cde925b311bb6 The min/max W/Q ranges in the panel for calculation4 are written into the DESCRIBE. flys-artifacts/trunk@2110 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r bcd62609c936 -r dda282dcc44f flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue Jun 14 13:53:25 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Jun 14 13:54:19 2011 +0000 @@ -6,6 +6,11 @@ 2011-06-14 Ingo Weinzierl + * src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java: + Write the min/max W/Q ranges as art:range elements into the DESCRIBE. + +2011-06-14 Ingo Weinzierl + * src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java: This state that is used to retrieve locations will now write the kilometer range of the selected river into the DESCRIBE document. diff -r bcd62609c936 -r dda282dcc44f flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java Tue Jun 14 13:53:25 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java Tue Jun 14 13:54:19 2011 +0000 @@ -121,6 +121,8 @@ FLYSArtifact flysArtifact = (FLYSArtifact) artifact; double[] dist = flysArtifact.getDistance(); + River river = flysArtifact.getRiver(); + Wst wst = WstFactory.getWst(river); List gauges = flysArtifact.getGauges(); int num = gauges != null ? gauges.size() : 0; @@ -147,8 +149,11 @@ double from = lower < rangeFrom ? rangeFrom : lower; double to = upper > rangeTo ? rangeTo : upper; + double[] mmQ = determineMinMaxQ(gauge, wst); + double[] mmW = gauge.determineMinMaxW(); + elements[idx++] = createItem( - cr, new String[] { from + ";" + to, ""}); + cr, new String[] { from + ";" + to, ""}, mmQ, mmW); } } else { @@ -173,6 +178,16 @@ protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { + return createItem(cr, obj, null, null); + } + + + protected Element createItem( + XMLUtils.ElementCreator cr, + Object obj, + double[] q, + double[] w) + { Element item = ProtocolUtils.createArtNode(cr, "item", null, null); Element label = ProtocolUtils.createArtNode(cr, "label", null, null); Element value = ProtocolUtils.createArtNode(cr, "value", null, null); @@ -185,10 +200,67 @@ item.appendChild(label); item.appendChild(value); + if (q != null) { + Element qRange = createRangeElement(cr, q, "Q"); + item.appendChild(qRange); + } + + if (w != null) { + Element wRange = createRangeElement(cr, w, "W"); + item.appendChild(wRange); + } + return item; } + protected Element createRangeElement( + XMLUtils.ElementCreator cr, + double[] mm, + String type) + { + Element range = ProtocolUtils.createArtNode( + cr, "range", + new String[] {"type"}, + new String[] {type}); + + Element min = ProtocolUtils.createArtNode(cr, "min", null, null); + min.setTextContent(String.valueOf(mm[0])); + + Element max = ProtocolUtils.createArtNode(cr, "max", null, null); + max.setTextContent(String.valueOf(mm[1])); + + range.appendChild(min); + range.appendChild(max); + + return range; + } + + + /** + * Determines the min and max Q value for the given gauge. If no min and + * max values could be determined, this method will return + * [Double.MIN_VALUE, Double.MAX_VALUE]. + * + * @param gauge + * @param wst + * + * @return the min and max Q values for the given gauge. + */ + protected double[] determineMinMaxQ(Gauge gauge, Wst wst) { + logger.debug("WQAdapted.determineMinMaxQ"); + + double[] minmaxQ = gauge != null + ? wst.determineMinMaxQ(gauge.getRange()) + : null; + + double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE; + double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE; + + return new double[] { minQ, maxQ }; + } + + @Override protected String getUIProvider() { return "wq_panel_adapted";