[PATCH] Sediment load: Cached sediment values dont depend on year. The cached object is an index over year so there is not need to ask the factory for this
Wald Commits
scm-commit at wald.intevation.org
Wed Jul 30 19:06:39 CEST 2014
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1406739995 -7200
# Node ID fdb26fe898dc6f09c204b129902d96f78eef6221
# Parent 50102c41151e7e19df0d808cd0c9ed1d04a09396
Sediment load: Cached sediment values dont depend on year. The cached object is an index over year so there is not need to ask the factory for this.
diff -r 50102c41151e -r fdb26fe898dc artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java Wed Jul 30 18:54:14 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java Wed Jul 30 19:06:35 2014 +0200
@@ -12,7 +12,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -83,7 +82,9 @@
public void addDensity(double km, double density, int year) {
- logger.debug("adding " + year);
+ if (logger.isDebugEnabled()) {
+ logger.debug("adding " + year);
+ }
Integer key = Integer.valueOf(year);
@@ -142,6 +143,7 @@
return getDensityAtKm(current.getValue(), km);
}
}
+
return SEDIMNET_DENSITY_FACTOR;
}
diff -r 50102c41151e -r fdb26fe898dc artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensityFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensityFactory.java Wed Jul 30 18:54:14 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensityFactory.java Wed Jul 30 19:06:35 2014 +0200
@@ -67,15 +67,14 @@
public static SedimentDensity getSedimentDensity(
String river,
double startKm,
- double endKm,
- int year
+ double endKm
) {
log.debug("getSedimentDensity");
Cache cache = CacheFactory.getCache(DENSITY_CACHE_NAME);
if (cache == null) {
log.debug("Cache not configured.");
- return getSedimentDensityUncached(river, startKm, endKm, year);
+ return getSedimentDensityUncached(river, startKm, endKm);
}
String key = river + startKm + endKm;
@@ -85,7 +84,7 @@
return (SedimentDensity)element.getValue();
}
SedimentDensity value =
- getSedimentDensityUncached(river, startKm, endKm, year);
+ getSedimentDensityUncached(river, startKm, endKm);
if (value != null && key != null) {
log.debug("Store sediment density values in cache.");
@@ -98,8 +97,7 @@
private static SedimentDensity getSedimentDensityUncached(
String river,
double startKm,
- double endKm,
- int year
+ double endKm
) {
log.debug("getSedimentDensityUncached");
Session session = SessionHolder.HOLDER.get();
diff -r 50102c41151e -r fdb26fe898dc artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java Wed Jul 30 18:54:14 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java Wed Jul 30 19:06:35 2014 +0200
@@ -523,7 +523,7 @@
*/
private SedimentLoadLSData calculateUnit(SedimentLoadLSData load, int year) {
SedimentDensity density =
- SedimentDensityFactory.getSedimentDensity(river, kmLow, kmUp, year);
+ SedimentDensityFactory.getSedimentDensity(river, kmLow, kmUp);
for (double km: load.getKms()) {
double dens = 1d/density.getDensity(km, year);
More information about the Dive4Elements-commits
mailing list