Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java @ 6970:7be97faf5848
flys/issue1235: Same kicks against a few inconsistencies and bugs in the calculation of sediment loads. I believe it _do_not_ delivers the right results.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 05 Sep 2013 17:15:04 +0200 |
parents | c137f5028591 |
children | 77f48c104d23 |
comparison
equal
deleted
inserted
replaced
6969:c137f5028591 | 6970:7be97faf5848 |
---|---|
11 import gnu.trove.TDoubleArrayList; | 11 import gnu.trove.TDoubleArrayList; |
12 | 12 |
13 import java.util.Calendar; | 13 import java.util.Calendar; |
14 import java.util.Date; | 14 import java.util.Date; |
15 import java.util.List; | 15 import java.util.List; |
16 import java.util.Map; | |
16 import java.util.TreeMap; | 17 import java.util.TreeMap; |
17 | 18 |
18 import net.sf.ehcache.Cache; | 19 import net.sf.ehcache.Cache; |
19 import net.sf.ehcache.Element; | 20 import net.sf.ehcache.Element; |
20 | 21 |
506 */ | 507 */ |
507 protected static Range findMeasurementStationRange( | 508 protected static Range findMeasurementStationRange( |
508 TreeMap<Double, MeasurementStation> stations, | 509 TreeMap<Double, MeasurementStation> stations, |
509 double km | 510 double km |
510 ) { | 511 ) { |
511 MeasurementStation station = stations.floorEntry(km).getValue(); | 512 Map.Entry<Double, MeasurementStation> entry = stations.floorEntry(km); |
512 if (station == null || !station.getRange().contains(km)) { | 513 if (entry == null) { |
513 return null; | 514 return null; |
514 } | 515 } |
516 MeasurementStation station = entry.getValue(); | |
517 if (station == null | |
518 || station.getRange() == null | |
519 || !station.getRange().contains(km)) { | |
520 return null; | |
521 } | |
515 | 522 |
516 double endKm; | 523 double endKm; |
517 | 524 |
518 if (stations.ceilingEntry(km + 0.1d) != null) { | 525 Map.Entry<Double, MeasurementStation> ceilingEntry = |
519 MeasurementStation nextStation = stations.ceilingEntry(km + 0.1d).getValue(); | 526 stations.ceilingEntry(km + 0.1d); |
527 | |
528 if (ceilingEntry != null) { | |
529 MeasurementStation nextStation = ceilingEntry.getValue(); | |
520 endKm = nextStation.getRange().getA().doubleValue(); | 530 endKm = nextStation.getRange().getA().doubleValue(); |
521 } | 531 } |
522 else { | 532 else { |
523 // TODO end-of-river instead of B. | 533 // TODO end-of-river instead of B. |
524 endKm = station.getRange().getB().doubleValue(); | 534 endKm = station.getRange().getB().doubleValue(); |