comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Parameters.java @ 3056:0b5a7a2c3724

Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator flys-artifacts/trunk@4632 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Sun, 10 Jun 2012 11:12:38 +0000
parents 52aac4941d2a
children febc39e77672
comparison
equal deleted inserted replaced
3055:1fbf8462f808 3056:0b5a7a2c3724
32 for (int i = 0; i < columnNames.length; ++i) { 32 for (int i = 0; i < columnNames.length; ++i) {
33 if (columnNames[i].equals(name)) { 33 if (columnNames[i].equals(name)) {
34 return i; 34 return i;
35 } 35 }
36 } 36 }
37 log.debug("columnIndex: " + name + " not found in columnNames");
37 return -1; 38 return -1;
38 } 39 }
39 40
40 public int newRow() { 41 public int newRow() {
41 42
119 120
120 public int binarySearch(String columnName, double value) { 121 public int binarySearch(String columnName, double value) {
121 return binarySearch(columnIndex(columnName), value); 122 return binarySearch(columnIndex(columnName), value);
122 } 123 }
123 124
125 /**
126 * Performes a binary search in the column identified by its
127 * index.
128 * @return Index of found element or negative insertion point (shifted by one)
129 */
124 public int binarySearch(int columnIndex, double value) { 130 public int binarySearch(int columnIndex, double value) {
125 TDoubleArrayList column = columns[columnIndex]; 131 TDoubleArrayList column = columns[columnIndex];
126 return column.binarySearch(value); 132 return column.binarySearch(value);
127 } 133 }
128 134
129 public int binarySearch(String columnName, double value, double epsilon) { 135 public int binarySearch(String columnName, double value, double epsilon) {
130 return binarySearch(columnIndex(columnName), value, epsilon); 136 return binarySearch(columnIndex(columnName), value, epsilon);
131 } 137 }
132 138
133 public int binarySearch(int columnIndex, double value, double epsilon) { 139 public int binarySearch(int columnIndex, double value, double epsilon) {
134 if (epsilon < 0d) epsilon = -epsilon; 140 if (epsilon < 0d)
141 epsilon = -epsilon;
135 double vl = value - epsilon; 142 double vl = value - epsilon;
136 double vh = value + epsilon; 143 double vh = value + epsilon;
137 144
138 TDoubleArrayList column = columns[columnIndex]; 145 TDoubleArrayList column = columns[columnIndex];
139 int lo = 0, hi = column.size()-1; 146 int lo = 0, hi = column.size()-1;
140 while (hi >= lo) { 147 while (hi >= lo) {
141 int mid = (lo+hi) >> 1; 148 int mid = (lo + hi) >> 1;
142 double v = column.getQuick(mid); 149 double v = column.getQuick(mid);
143 if (v < vl) hi = mid - 1; 150 if (v < vl)
144 else if (v > vh) lo = mid + 1; 151 hi = mid - 1;
145 else return mid; 152 else if (v > vh)
153 lo = mid + 1;
154 else
155 return mid;
146 } 156 }
147 157
148 return -1; 158 return -1;
149 } 159 }
150 160

http://dive4elements.wald.intevation.org