Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 450:c8bb38115290
Enabled the discharge longitudinal section to be exported as WST.
flys-artifacts/trunk@1944 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 18 May 2011 10:59:38 +0000 |
parents | 9814d4808410 |
children | 73bc64c4a7b0 |
comparison
equal
deleted
inserted
replaced
449:9814d4808410 | 450:c8bb38115290 |
---|---|
493 } | 493 } |
494 | 494 |
495 double[][] dist = getSplittedDistance(); | 495 double[][] dist = getSplittedDistance(); |
496 int num = dist != null ? dist.length : 0; | 496 int num = dist != null ? dist.length : 0; |
497 | 497 |
498 WQKms[][] wqkms = new WQKms[num][]; | 498 double[][] allQs = new double[num][]; |
499 double[][] allWs = new double[num][]; | |
500 WQKms[][] wqkms = new WQKms[num][]; | |
501 | |
502 boolean qSel = true; | |
499 | 503 |
500 for (int i = 0; i < num; i++) { | 504 for (int i = 0; i < num; i++) { |
501 double[] kms = getKms(dist[i]); | 505 double[] kms = getKms(dist[i]); |
502 if (kms == null) { | 506 if (kms == null) { |
503 // XXX maybe we should cancel this operation here. | 507 // XXX maybe we should cancel this operation here. |
504 continue; | 508 continue; |
505 } | 509 } |
506 | 510 |
507 double[] qs = getQs(dist[i]); | 511 double[] qs = getQs(dist[i]); |
512 allQs[i] = qs; | |
513 | |
508 if (qs == null) { | 514 if (qs == null) { |
509 logger.debug("Determine Q values based on a set of W values."); | 515 logger.debug("Determine Q values based on a set of W values."); |
510 | 516 qSel = false; |
511 double[] ws = getWs(dist[i]); | 517 |
512 qs = getQsForWs(ws); | 518 allWs[i] = getWs(dist[i]); |
519 qs = getQsForWs(allWs[i]); | |
513 } | 520 } |
514 | 521 |
515 wqkms[i] = computeWaterlevelData(kms, qs, wst); | 522 wqkms[i] = computeWaterlevelData(kms, qs, wst); |
516 } | 523 } |
517 | 524 |
519 int numMerged = merged.length; | 526 int numMerged = merged.length; |
520 WQKms[] computed = new WQKms[numMerged]; | 527 WQKms[] computed = new WQKms[numMerged]; |
521 | 528 |
522 for (int i = 0; i < numMerged; i++) { | 529 for (int i = 0; i < numMerged; i++) { |
523 computed[i] = computeDischargeLongitudinalSectionData(merged[i]); | 530 computed[i] = computeDischargeLongitudinalSectionData(merged[i]); |
531 | |
532 setDischargeLongitudinalSectionNames( | |
533 computed[i], | |
534 qSel ? allQs : allWs, | |
535 i, | |
536 qSel ? "Q" : "W"); | |
524 } | 537 } |
525 | 538 |
526 // TODO Introduce a caching mechanism here! | 539 // TODO Introduce a caching mechanism here! |
527 | 540 |
528 return computed; | 541 return computed; |
542 } | |
543 | |
544 | |
545 /** | |
546 * Sets the name for discharge longitudinal section curves where each WQKms | |
547 * in <i>r</i> represents a column. | |
548 * | |
549 * @param wqkms A longitudinal section curve. | |
550 * @param allValues The input values of the computations. | |
551 * @param col The requested column in the table of Ws or Qs. | |
552 * @param wq The WQ mode - can be one of "W" or "Q". | |
553 */ | |
554 public static void setDischargeLongitudinalSectionNames( | |
555 WQKms wqkms, | |
556 double[][] allValues, | |
557 int col, | |
558 String wq) | |
559 { | |
560 logger.debug("WINFOArtifact.setDischargeLongitudinalSectionNames"); | |
561 | |
562 StringBuilder sb = new StringBuilder(" ("); | |
563 boolean first = true; | |
564 | |
565 int rows = allValues.length; | |
566 | |
567 for (int i = 0; i < rows; i++) { | |
568 double[] values = allValues[i]; | |
569 | |
570 if (!first) { | |
571 sb.append("; "); | |
572 } | |
573 | |
574 sb.append(Double.toString(values[col])); | |
575 | |
576 first = false; | |
577 } | |
578 | |
579 sb.append(")"); | |
580 | |
581 wqkms.setName(wq + " Benutzerdefiniert" + sb.toString()); | |
529 } | 582 } |
530 | 583 |
531 | 584 |
532 /** | 585 /** |
533 * Computes the data used for a discharge longitudinal section based on a | 586 * Computes the data used for a discharge longitudinal section based on a |