comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFacet.java @ 8174:4b2b7593815c

Make sedimentload loadable as old calculation.
author Tom Gottfried <tom@intevation.de>
date Tue, 02 Sep 2014 14:46:20 +0200
parents f2bbe09e516e
children e4606eae8ea5
comparison
equal deleted inserted replaced
8173:16be0ceee25b 8174:4b2b7593815c
90 metaData.put("Y", ""); 90 metaData.put("Y", "");
91 } 91 }
92 92
93 @Override 93 @Override
94 public Object getData(Artifact artifact, CallContext context) { 94 public Object getData(Artifact artifact, CallContext context) {
95 logger.debug("Get data for sediment load with fraction: " + fraction);
96 95
97 D4EArtifact flys = (D4EArtifact) artifact; 96 D4EArtifact flys = (D4EArtifact) artifact;
98 97
99 CalculationResult res = (CalculationResult) flys.compute(context, hash, stateId, type, false); 98 CalculationResult res = (CalculationResult) flys.compute(context, hash, stateId, type, false);
100 Object payload = res.getData(); 99 Object payload = res.getData();
103 logger.error("Invalid result!"); 102 logger.error("Invalid result!");
104 } 103 }
105 104
106 SedimentLoadDataResult sdResult = (SedimentLoadDataResult) payload; 105 SedimentLoadDataResult sdResult = (SedimentLoadDataResult) payload;
107 106
108 List<Fraction> fractions = sdResult.getFractionsByNameAndPeriod( 107 List<Fraction> fractions = sdResult.getFractions();
109 fraction, period 108
110 ); 109 if (fractions.size() < index + 1) {
111 if (fractions == null) { 110 logger.error("No result for fraction '" + fraction +
112 logger.warn("No result for fraction '" + fraction +
113 "' and period '" + period + "'"); 111 "' and period '" + period + "'");
114 return null; 112 return null;
115 } 113 }
116 114
117 if (fractions.size() > 1) { 115 return fractions.get(index).getData();
118 logger.error("Multiple results for fraction '" + fraction +
119 "' and period '" + period + "'");
120 }
121
122 return fractions.get(0).getData();
123 116
124 /* Are gaps neccessary now? 117 /* Are gaps neccessary now?
125 for (int x = 0; x < values[0].length-1; x++) { 118 for (int x = 0; x < values[0].length-1; x++) {
126 // Introduce gaps where no data in measurement station. 119 // Introduce gaps where no data in measurement station.
127 if (Math.abs(values[0][x+1] - values[0][x]) > 3*EPSILON 120 if (Math.abs(values[0][x+1] - values[0][x]) > 3*EPSILON

http://dive4elements.wald.intevation.org