Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java @ 2166:2898b1ff6013
I18N for WINFO calculation result messages.
flys-artifacts/trunk@3758 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 24 Jan 2012 22:59:44 +0000 |
parents | 2730d17df021 |
children | ec2574eb2d32 |
comparison
equal
deleted
inserted
replaced
2165:637dd38d0e2f | 2166:2898b1ff6013 |
---|---|
128 outWs[i] = spline.value(outQs[i] = q); | 128 outWs[i] = spline.value(outQs[i] = q); |
129 } | 129 } |
130 } | 130 } |
131 catch (ArgumentOutsideDomainException aode) { | 131 catch (ArgumentOutsideDomainException aode) { |
132 if (errors != null) { | 132 if (errors != null) { |
133 // TODO: I18N | 133 errors.addProblem(km, "spline.interpolation.failed"); |
134 errors.addProblem(km, "spline interpolation failed"); | |
135 } | 134 } |
136 log.error("spline interpolation failed.", aode); | 135 log.error("spline interpolation failed.", aode); |
137 } | 136 } |
138 | 137 |
139 return new double [][] { outWs, outQs }; | 138 return new double [][] { outWs, outQs }; |
220 if (table.getQPosition(km, iqs[i], qPosition) != null) { | 219 if (table.getQPosition(km, iqs[i], qPosition) != null) { |
221 double wt = getW(qPosition); | 220 double wt = getW(qPosition); |
222 double wo = other.getW(qPosition); | 221 double wo = other.getW(qPosition); |
223 if (Double.isNaN(wt) || Double.isNaN(wo)) { | 222 if (Double.isNaN(wt) || Double.isNaN(wo)) { |
224 if (errors != null) { | 223 if (errors != null) { |
225 // TODO: I18N | |
226 errors.addProblem( | 224 errors.addProblem( |
227 km, "cannot find w for q = " + iqs[i]); | 225 km, "cannot.find.w.for.q", iqs[i]); |
228 } | 226 } |
229 ows[i] = Double.NaN; | 227 ows[i] = Double.NaN; |
230 } | 228 } |
231 else { | 229 else { |
232 ows[i] = Linear.weight(kmWeight, wt, wo); | 230 ows[i] = Linear.weight(kmWeight, wt, wo); |
233 } | 231 } |
234 } | 232 } |
235 else { | 233 else { |
236 if (errors != null) { | 234 if (errors != null) { |
237 // TODO: I18N | 235 errors.addProblem(km, "cannot.find.q", iqs[i]); |
238 errors.addProblem(km, "cannot find q = " + iqs[i]); | |
239 } | 236 } |
240 ows[i] = Double.NaN; | 237 ows[i] = Double.NaN; |
241 } | 238 } |
242 } | 239 } |
243 } | 240 } |
249 ) { | 246 ) { |
250 int W = ws.length; | 247 int W = ws.length; |
251 | 248 |
252 if (W < 1) { | 249 if (W < 1) { |
253 if (errors != null) { | 250 if (errors != null) { |
254 // TODO: I18N | 251 errors.addProblem(km, "no.ws.found"); |
255 errors.addProblem(km, "no ws found"); | |
256 } | 252 } |
257 return null; | 253 return null; |
258 } | 254 } |
259 | 255 |
260 double [] splineQs = new double[W]; | 256 double [] splineQs = new double[W]; |
261 | 257 |
262 for (int i = 0; i < W; ++i) { | 258 for (int i = 0; i < W; ++i) { |
263 double sq = table.getQIndex(i, km); | 259 double sq = table.getQIndex(i, km); |
264 if (Double.isNaN(sq) && errors != null) { | 260 if (Double.isNaN(sq) && errors != null) { |
265 // TODO: I18N | |
266 errors.addProblem( | 261 errors.addProblem( |
267 km, "no q found in " + (i+1) + " column"); | 262 km, "no.q.found.in.column", (i+1)); |
268 } | 263 } |
269 splineQs[i] = sq; | 264 splineQs[i] = sq; |
270 } | 265 } |
271 | 266 |
272 try { | 267 try { |
276 | 271 |
277 return new SplineFunction(spline, splineQs, ws); | 272 return new SplineFunction(spline, splineQs, ws); |
278 } | 273 } |
279 catch (MathIllegalArgumentException miae) { | 274 catch (MathIllegalArgumentException miae) { |
280 if (errors != null) { | 275 if (errors != null) { |
281 // TODO: I18N | 276 errors.addProblem(km, "spline.creation.failed"); |
282 errors.addProblem(km, "spline creation failed"); | |
283 } | 277 } |
284 log.error("spline creation failed", miae); | 278 log.error("spline creation failed", miae); |
285 } | 279 } |
286 return null; | 280 return null; |
287 } | 281 } |
294 ) { | 288 ) { |
295 int W = Math.min(ws.length, other.ws.length); | 289 int W = Math.min(ws.length, other.ws.length); |
296 | 290 |
297 if (W < 1) { | 291 if (W < 1) { |
298 if (errors != null) { | 292 if (errors != null) { |
299 // TODO: I18N | 293 errors.addProblem("no.ws.found"); |
300 errors.addProblem("no ws found"); | |
301 } | 294 } |
302 return null; | 295 return null; |
303 } | 296 } |
304 | 297 |
305 double factor = Linear.factor(km, this.km, other.km); | 298 double factor = Linear.factor(km, this.km, other.km); |
314 table.getQIndex(i, km), | 307 table.getQIndex(i, km), |
315 table.getQIndex(i, other.km)); | 308 table.getQIndex(i, other.km)); |
316 | 309 |
317 if (Double.isNaN(wws) || Double.isNaN(wqs)) { | 310 if (Double.isNaN(wws) || Double.isNaN(wqs)) { |
318 if (errors != null) { | 311 if (errors != null) { |
319 // TODO: I18N | 312 errors.addProblem(km, "cannot.find.w.or.q"); |
320 errors.addProblem(km, "cannot find w or q"); | |
321 } | 313 } |
322 } | 314 } |
323 | 315 |
324 splineWs[i] = wws; | 316 splineWs[i] = wws; |
325 splineQs[i] = wqs; | 317 splineQs[i] = wqs; |
333 | 325 |
334 return new SplineFunction(spline, splineQs, splineWs); | 326 return new SplineFunction(spline, splineQs, splineWs); |
335 } | 327 } |
336 catch (MathIllegalArgumentException miae) { | 328 catch (MathIllegalArgumentException miae) { |
337 if (errors != null) { | 329 if (errors != null) { |
338 // TODO: I18N | 330 errors.addProblem(km, "spline.creation.failed"); |
339 errors.addProblem(km, "spline creation failed"); | |
340 } | 331 } |
341 log.error("spline creation failed", miae); | 332 log.error("spline creation failed", miae); |
342 } | 333 } |
343 | 334 |
344 return null; | 335 return null; |
557 if (rowIndex >= 0) { // direct row match | 548 if (rowIndex >= 0) { // direct row match |
558 Row row = rows.get(rowIndex); | 549 Row row = rows.get(rowIndex); |
559 for (int i = 0; i < qs.length; ++i) { | 550 for (int i = 0; i < qs.length; ++i) { |
560 if (getQPosition(km, qs[i], qPosition) == null) { | 551 if (getQPosition(km, qs[i], qPosition) == null) { |
561 if (errors != null) { | 552 if (errors != null) { |
562 // TODO: I18N | 553 errors.addProblem(km, "cannot.find.q", qs[i]); |
563 errors.addProblem(km, "cannot find q = " + qs[i]); | |
564 } | 554 } |
565 ws[i] = Double.NaN; | 555 ws[i] = Double.NaN; |
566 } | 556 } |
567 else { | 557 else { |
568 if (Double.isNaN(ws[i] = row.getW(qPosition)) | 558 if (Double.isNaN(ws[i] = row.getW(qPosition)) |
569 && errors != null) { | 559 && errors != null) { |
570 // TODO: I18N | |
571 errors.addProblem( | 560 errors.addProblem( |
572 km, "cannot find w for q = " + qs[i]); | 561 km, "cannot.find.w.for.q", qs[i]); |
573 } | 562 } |
574 } | 563 } |
575 } | 564 } |
576 } | 565 } |
577 else { // needs bilinear interpolation | 566 else { // needs bilinear interpolation |
579 | 568 |
580 if (rowIndex < 1 || rowIndex >= rows.size()) { | 569 if (rowIndex < 1 || rowIndex >= rows.size()) { |
581 // do not extrapolate | 570 // do not extrapolate |
582 Arrays.fill(ws, Double.NaN); | 571 Arrays.fill(ws, Double.NaN); |
583 if (errors != null) { | 572 if (errors != null) { |
584 // TODO: I18N | 573 errors.addProblem(km, "km.not.found"); |
585 errors.addProblem(km, "km not found"); | |
586 } | 574 } |
587 } | 575 } |
588 else { | 576 else { |
589 Row r1 = rows.get(rowIndex-1); | 577 Row r1 = rows.get(rowIndex-1); |
590 Row r2 = rows.get(rowIndex); | 578 Row r2 = rows.get(rowIndex); |
624 rowIndex = -rowIndex -1; | 612 rowIndex = -rowIndex -1; |
625 | 613 |
626 if (rowIndex < 1 || rowIndex >= rows.size()) { | 614 if (rowIndex < 1 || rowIndex >= rows.size()) { |
627 // do not extrapolate | 615 // do not extrapolate |
628 if (errors != null) { | 616 if (errors != null) { |
629 // TODO: I18N | 617 errors.addProblem(km, "km.not.found"); |
630 errors.addProblem(km, "km not found"); | |
631 } | 618 } |
632 return new double[2][0]; | 619 return new double[2][0]; |
633 } | 620 } |
634 | 621 |
635 Row r1 = rows.get(rowIndex-1); | 622 Row r1 = rows.get(rowIndex-1); |
717 if (qPosition == null) { | 704 if (qPosition == null) { |
718 // we cannot locate q at km | 705 // we cannot locate q at km |
719 Arrays.fill(ws, Double.NaN); | 706 Arrays.fill(ws, Double.NaN); |
720 Arrays.fill(qs, Double.NaN); | 707 Arrays.fill(qs, Double.NaN); |
721 if (errors != null) { | 708 if (errors != null) { |
722 errors.addProblem(referenceKm, "cannot find q"); | 709 errors.addProblem(referenceKm, "cannot.find.q", q); |
723 } | 710 } |
724 return null; | 711 return null; |
725 } | 712 } |
726 | 713 |
727 Row kmKey = new Row(); | 714 Row kmKey = new Row(); |
730 | 717 |
731 for (int i = startIndex, end = startIndex+length; i < end; ++i) { | 718 for (int i = startIndex, end = startIndex+length; i < end; ++i) { |
732 | 719 |
733 if (Double.isNaN(qs[i] = getQ(qPosition, kms[i]))) { | 720 if (Double.isNaN(qs[i] = getQ(qPosition, kms[i]))) { |
734 if (errors != null) { | 721 if (errors != null) { |
735 errors.addProblem(kms[i], "cannot find q"); | 722 errors.addProblem(kms[i], "cannot.find.q", q); |
736 } | 723 } |
737 ws[i] = Double.NaN; | 724 ws[i] = Double.NaN; |
738 continue; | 725 continue; |
739 } | 726 } |
740 | 727 |
743 | 730 |
744 if (rowIndex >= 0) { | 731 if (rowIndex >= 0) { |
745 // direct row match | 732 // direct row match |
746 if (Double.isNaN(ws[i] = rows.get(rowIndex).getW(qPosition)) | 733 if (Double.isNaN(ws[i] = rows.get(rowIndex).getW(qPosition)) |
747 && errors != null) { | 734 && errors != null) { |
748 errors.addProblem(kms[i], "cannot find w"); | 735 errors.addProblem(kms[i], "cannot.find.w.for.q", q); |
749 } | 736 } |
750 continue; | 737 continue; |
751 } | 738 } |
752 | 739 |
753 rowIndex = -rowIndex -1; | 740 rowIndex = -rowIndex -1; |
754 | 741 |
755 if (rowIndex < 1 || rowIndex > R1) { | 742 if (rowIndex < 1 || rowIndex > R1) { |
756 // do not extrapolate | 743 // do not extrapolate |
757 if (errors != null) { | 744 if (errors != null) { |
758 errors.addProblem(kms[i], "cannot find km"); | 745 errors.addProblem(kms[i], "km.not.found"); |
759 } | 746 } |
760 ws[i] = Double.NaN; | 747 ws[i] = Double.NaN; |
761 continue; | 748 continue; |
762 } | 749 } |
763 Row r1 = rows.get(rowIndex-1); | 750 Row r1 = rows.get(rowIndex-1); |
764 Row r2 = rows.get(rowIndex); | 751 Row r2 = rows.get(rowIndex); |
765 | 752 |
766 if (Double.isNaN(ws[i] = r1.getW(r2, kms[i], qPosition)) | 753 if (Double.isNaN(ws[i] = r1.getW(r2, kms[i], qPosition)) |
767 && errors != null) { | 754 && errors != null) { |
768 errors.addProblem(kms[i], "cannot find w"); | 755 errors.addProblem(kms[i], "cannot.find.w.for.q", q); |
769 } | 756 } |
770 } | 757 } |
771 | 758 |
772 return qPosition; | 759 return qPosition; |
773 } | 760 } |
872 int rowIndex = Collections.binarySearch(rows, new Row(km)); | 859 int rowIndex = Collections.binarySearch(rows, new Row(km)); |
873 | 860 |
874 if (rowIndex >= 0) { | 861 if (rowIndex >= 0) { |
875 SplineFunction sf = rows.get(rowIndex).createSpline(this, errors); | 862 SplineFunction sf = rows.get(rowIndex).createSpline(this, errors); |
876 if (sf == null && errors != null) { | 863 if (sf == null && errors != null) { |
877 // TODO: I18N | 864 errors.addProblem(km, "cannot.create.wq.relation"); |
878 errors.addProblem(km, "cannot create w/q relation"); | |
879 } | 865 } |
880 return sf; | 866 return sf; |
881 } | 867 } |
882 | 868 |
883 rowIndex = -rowIndex - 1; | 869 rowIndex = -rowIndex - 1; |
884 | 870 |
885 if (rowIndex < 1 || rowIndex >= rows.size()) { | 871 if (rowIndex < 1 || rowIndex >= rows.size()) { |
886 // Do not extrapolate. | 872 // Do not extrapolate. |
887 if (errors != null) { | 873 if (errors != null) { |
888 // TODO: I18N | 874 errors.addProblem(km, "km.not.found"); |
889 errors.addProblem(km, "km not found"); | |
890 } | 875 } |
891 return null; | 876 return null; |
892 } | 877 } |
893 | 878 |
894 // Needs bilinear interpolation. | 879 // Needs bilinear interpolation. |
895 Row r1 = rows.get(rowIndex-1); | 880 Row r1 = rows.get(rowIndex-1); |
896 Row r2 = rows.get(rowIndex); | 881 Row r2 = rows.get(rowIndex); |
897 | 882 |
898 SplineFunction sf = r1.createSpline(r2, km, this, errors); | 883 SplineFunction sf = r1.createSpline(r2, km, this, errors); |
899 if (sf == null && errors != null) { | 884 if (sf == null && errors != null) { |
900 // TODO: I18N | 885 errors.addProblem(km, "cannot.create.wq.relation"); |
901 errors.addProblem(km, "cannot create w/q relation"); | |
902 } | 886 } |
903 | 887 |
904 return sf; | 888 return sf; |
905 } | 889 } |
906 | 890 |
922 } | 906 } |
923 | 907 |
924 PolynomialSplineFunction iQ1 = sf1.createIndexQRelation(); | 908 PolynomialSplineFunction iQ1 = sf1.createIndexQRelation(); |
925 if (iQ1 == null) { | 909 if (iQ1 == null) { |
926 if (errors != null) { | 910 if (errors != null) { |
927 // TODO: I18N | 911 errors.addProblem(km1, "cannot.create.index.q.relation"); |
928 errors.addProblem(km1, "cannot create index/q relation"); | |
929 } | 912 } |
930 return new double[2][0]; | 913 return new double[2][0]; |
931 } | 914 } |
932 | 915 |
933 PolynomialSplineFunction iQ2 = sf1.createIndexQRelation(); | 916 PolynomialSplineFunction iQ2 = sf1.createIndexQRelation(); |
934 if (iQ2 == null) { | 917 if (iQ2 == null) { |
935 if (errors != null) { | 918 if (errors != null) { |
936 // TODO: I18N | 919 errors.addProblem(km2, "cannot.create.index.q.relation"); |
937 errors.addProblem(km2, "cannot create index/q relation"); | |
938 } | 920 } |
939 return new double[2][0]; | 921 return new double[2][0]; |
940 } | 922 } |
941 | 923 |
942 int N = sf1.splineQs.length; | 924 int N = sf1.splineQs.length; |
967 if (!hadErrors) { | 949 if (!hadErrors) { |
968 // XXX: I'm not sure if this really can happen | 950 // XXX: I'm not sure if this really can happen |
969 // and if we should report this more than once. | 951 // and if we should report this more than once. |
970 hadErrors = true; | 952 hadErrors = true; |
971 if (errors != null) { | 953 if (errors != null) { |
972 // TODO: I18N | 954 errors.addProblem("relating.w.w.failed"); |
973 log.debug("W~W failed", aode); | 955 log.debug("W~W failed", aode); |
974 errors.addProblem("W~W failed"); | |
975 } | 956 } |
976 } | 957 } |
977 } | 958 } |
978 } | 959 } |
979 | 960 |