comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java @ 6665:b7945db8a43b

issue1413: Only show unknown sediment loads of selected unit type. Therefore, adjusted the factory to take the units name. Unfortunately, names in db do not match values of data items. Thus do manual replacing. In Facet and Calculate, take the chosen unit via access and to the string replacement. In Facet, do not transform data (we assume it comes in unit as labeled in the db), and removed the possibility of m3/a-data of unknown yields in a t/a diagram and vice versa.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 25 Jul 2013 15:08:13 +0200
parents 4ae1fbaaacdd
children 91c43293e538
comparison
equal deleted inserted replaced
6664:4ae1fbaaacdd 6665:b7945db8a43b
22 public SedimentLoadUnknownFacet(int idx, String name, String description, 22 public SedimentLoadUnknownFacet(int idx, String name, String description,
23 ComputeType type, String stateId, String hash) { 23 ComputeType type, String stateId, String hash) {
24 super(idx, name, description, type, hash, stateId); 24 super(idx, name, description, type, hash, stateId);
25 } 25 }
26 26
27 /** Get data from SedimentLoad with unknown type, from factory. */
27 @Override 28 @Override
28 public Object getData(Artifact artifact, CallContext context) { 29 public Object getData(Artifact artifact, CallContext context) {
29 logger.debug("Get data for sediment load at index: " + index); 30 logger.debug("Get data for sediment load at index: " + index);
30 31
31 D4EArtifact flys = (D4EArtifact) artifact; 32 D4EArtifact flys = (D4EArtifact) artifact;
32 33
33 SedimentLoadAccess access = new SedimentLoadAccess(flys); 34 SedimentLoadAccess access = new SedimentLoadAccess(flys);
34 String river = access.getRiver(); 35 String river = access.getRiver();
36 String unit = access.getUnit();
35 SedimentLoad[] unknown = 37 SedimentLoad[] unknown =
36 SedimentLoadFactory.getSedimentLoadUnknown(river); 38 SedimentLoadFactory.getSedimentLoadUnknown(river, unit.replace("_per_","/"));
37 39
38 SedimentLoad load = SedimentLoadFactory.getLoadUnknown( 40 SedimentLoad load = SedimentLoadFactory.getLoadUnknown(
39 river, unknown[index].getDescription()); 41 river, unknown[index].getDescription());
40 if (access.getUnit().equals("t/a") && load.getUnit().equals("m3/a")) {
41 for (Double km: load.getKms()) {
42 SedimentLoadFraction fraction = load.getFraction(km);
43 fraction.setUnknown(fraction.getUnknown() / 1.8);
44 load.addKm(km, fraction);
45 }
46 }
47 else if (access.getUnit().equals("m3/a") && load.getUnit().equals("t/a")) {
48 for (Double km: load.getKms()) {
49 SedimentLoadFraction fraction = load.getFraction(km);
50 fraction.setUnknown(fraction.getUnknown() * 1.8);
51 load.addKm(km, fraction);
52 }
53 }
54 return load; 42 return load;
55 } 43 }
56 44
57 /** Copy deeply. */ 45 /** Copy deeply. */
58 @Override 46 @Override

http://dive4elements.wald.intevation.org