comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 1138:d90f5bfa3ddf

Fix profile loading of cross section diagram. flys-artifacts/trunk@2659 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 07 Sep 2011 07:48:03 +0000
parents 073c36bb94ed
children 6d9b08b958e2
comparison
equal deleted inserted replaced
1137:073c36bb94ed 1138:d90f5bfa3ddf
653 * 653 *
654 * @return an array holding coordinates of points of profile ( 654 * @return an array holding coordinates of points of profile (
655 * in the form {{x1, x2} {y1, y2}} ). 655 * in the form {{x1, x2} {y1, y2}} ).
656 */ 656 */
657 public double [][] getCrossSectionData() { 657 public double [][] getCrossSectionData() {
658 return getCrossSectionProfile(getCrossSections().get(0).getLines().get(0)); 658 logger.info("getCrossSectionData(), also cross_section.km " + getDataAsString("cross_section.km"));
659 double wishKM = 0.0f;
660 try {
661 wishKM = Double.parseDouble(getDataAsString("cross_section.km"));
662 }
663 catch (Exception e) {
664 ;
665 }
666
667 // Get the cross section closest to requested km.
668 //
669 // Naive, linear approach.
670 List<CrossSectionLine> crossSectionLines =
671 getCrossSections().get(0).getLines();
672 CrossSectionLine oldLine = crossSectionLines.get(0);
673 double oldDiff = Math.abs(wishKM - oldLine.getKm().doubleValue());
674 for (CrossSectionLine line: crossSectionLines) {
675 double diff = Math.abs(wishKM - line.getKm().doubleValue());
676 if (diff > oldDiff) {
677 break;
678 }
679 oldDiff = diff;
680 oldLine = line;
681 }
682 return getCrossSectionProfile(oldLine);
659 } 683 }
660 684
661 685
662 /** 686 /**
663 * Get points of line describing the surface of water at cross section. 687 * Get points of line describing the surface of water at cross section.

http://dive4elements.wald.intevation.org