Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 377:0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
flys-artifacts/trunk@1789 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 02 May 2011 12:47:10 +0000 |
parents | 3e66a5705c39 |
children | c21fb8de54f8 |
comparison
equal
deleted
inserted
replaced
376:aa0889141b15 | 377:0ccf7200fc51 |
---|---|
30 | 30 |
31 import de.intevation.flys.model.Gauge; | 31 import de.intevation.flys.model.Gauge; |
32 import de.intevation.flys.model.River; | 32 import de.intevation.flys.model.River; |
33 | 33 |
34 import de.intevation.flys.artifacts.context.FLYSContext; | 34 import de.intevation.flys.artifacts.context.FLYSContext; |
35 import de.intevation.flys.artifacts.model.DischargeTables; | |
35 import de.intevation.flys.artifacts.model.RiverFactory; | 36 import de.intevation.flys.artifacts.model.RiverFactory; |
36 import de.intevation.flys.artifacts.states.DefaultState; | 37 import de.intevation.flys.artifacts.states.DefaultState; |
37 | 38 |
38 | 39 |
39 /** | 40 /** |
531 * This method returns the Q values. | 532 * This method returns the Q values. |
532 * | 533 * |
533 * @return the selected Q values or null, if no Q values are selected. | 534 * @return the selected Q values or null, if no Q values are selected. |
534 */ | 535 */ |
535 public double[] getQs() { | 536 public double[] getQs() { |
537 StateData dMode = getData("wq_mode"); | |
538 | |
539 String mode = dMode != null ? (String) dMode.getValue() : ""; | |
540 | |
541 if (mode.equals("Q")) { | |
542 return getWQTriple(); | |
543 } | |
544 else { | |
545 logger.warn("You try to get Qs, but W has been inserted."); | |
546 return null; | |
547 } | |
548 } | |
549 | |
550 | |
551 /** | |
552 * This method returns the W values. | |
553 * | |
554 * @return the selected W values or null, if no W values are selected. | |
555 */ | |
556 public double[] getWs() { | |
557 StateData dMode = getData("wq_mode"); | |
558 | |
559 String mode = dMode != null ? (String) dMode.getValue() : ""; | |
560 | |
561 if (mode.equals("W")) { | |
562 return getWQTriple(); | |
563 } | |
564 else { | |
565 logger.warn("You try to get Qs, but W has been inserted."); | |
566 return null; | |
567 } | |
568 } | |
569 | |
570 | |
571 /** | |
572 * Returns the Qs for a number of Ws. This method makes use of | |
573 * DischargeTables.getQForW(). | |
574 * | |
575 * @param ws An array of W values. | |
576 * | |
577 * @return an array of Q values. | |
578 */ | |
579 public double[] getQsForWs(double[] ws) { | |
580 logger.debug("FLYSArtifact.getQsForWs"); | |
581 | |
582 River r = getRiver(); | |
583 Gauge g = getGauge(); | |
584 | |
585 DischargeTables dt = new DischargeTables(r.getName(), g.getName()); | |
586 Map<String, double [][]> tmp = dt.getValues(); | |
587 | |
588 double[][] values = tmp.get(g.getName()); | |
589 double[] qs = new double[ws.length]; | |
590 | |
591 for (int i = 0; i < ws.length; i++) { | |
592 qs[i] = dt.getQForW(values, ws[i]); | |
593 logger.debug("Q for " + ws[i] + " = " + qs[i]); | |
594 } | |
595 | |
596 return qs; | |
597 } | |
598 | |
599 | |
600 /** | |
601 * This method returns an array of inserted WQ triples that consist of from, | |
602 * to and the step width. | |
603 * | |
604 * @return an array of from, to and step width. | |
605 */ | |
606 protected double[] getWQTriple() { | |
536 StateData dFrom = getData("wq_from"); | 607 StateData dFrom = getData("wq_from"); |
537 StateData dTo = getData("wq_to"); | 608 StateData dTo = getData("wq_to"); |
538 | 609 |
539 if (dFrom == null || dTo == null) { | 610 if (dFrom == null || dTo == null) { |
540 logger.warn("Missing start or end value for Q range."); | 611 logger.warn("Missing start or end value for Q range."); |