comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java @ 1919:9bec7d2f8c35

Prevent ArrayIndexOutOfBounds, log method entry. flys-artifacts/trunk@3279 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 17 Nov 2011 09:14:42 +0000
parents 6c7fdfd262ac
children f07d64d5cbe1
comparison
equal deleted inserted replaced
1918:5afdf7ed0937 1919:9bec7d2f8c35
656 * of other columns). 656 * of other columns).
657 * @param km position (km) at which to interpolate/lookup. 657 * @param km position (km) at which to interpolate/lookup.
658 * @return [[q0, q1, .. qx] , [w0, w1, .. wx]] (can contain NaNs) 658 * @return [[q0, q1, .. qx] , [w0, w1, .. wx]] (can contain NaNs)
659 */ 659 */
660 public double [][] interpolateWQColumnwise(double km) { 660 public double [][] interpolateWQColumnwise(double km) {
661 log.debug("WstValueTable.interpolateWQColumnwise");
661 double [] qs = new double[columns.length]; 662 double [] qs = new double[columns.length];
662 double [] ws = new double[columns.length]; 663 double [] ws = new double[columns.length];
663 664
664 // Find out row from where we will start searching. 665 // Find out row from where we will start searching.
665 int rowIndex = Collections.binarySearch(rows, new Row(km)); 666 int rowIndex = Collections.binarySearch(rows, new Row(km));
666 667
667 if (rowIndex < 0) { 668 if (rowIndex < 0) {
668 rowIndex = -rowIndex -1; 669 rowIndex = -rowIndex -1;
669 } 670 }
671 if (rowIndex >= rows.size())
672 rowIndex = rows.size() -1;
670 673
671 Row startRow = rows.get(rowIndex); 674 Row startRow = rows.get(rowIndex);
672 675
673 for (int col = 0; col < columns.length; col++) { 676 for (int col = 0; col < columns.length; col++) {
674 qs[col] = columns[col].getQRangeTree().findQ(km); 677 qs[col] = columns[col].getQRangeTree().findQ(km);

http://dive4elements.wald.intevation.org