comparison artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java @ 9448:d32b11d585cd

CSV-Export bundu.wst fehlvolumen
author gernotbelger
date Wed, 22 Aug 2018 11:51:46 +0200
parents e60584f2a531
children 7e1fb8d0cb0d
comparison
equal deleted inserted replaced
9447:3f4215ddd6b4 9448:d32b11d585cd
55 55
56 private final CallContext context; 56 private final CallContext context;
57 57
58 private final List<ResultRow> rows; 58 private final List<ResultRow> rows;
59 59
60
61 public BezugswstCalculation(final CallContext context) { 60 public BezugswstCalculation(final CallContext context) {
62 this.context = context; 61 this.context = context;
63 this.rows = new ArrayList<>(); 62 this.rows = new ArrayList<>();
64 } 63 }
65
66 64
67 /** 65 /**
68 * Calculates the result rows of a bundu bzws workflow 66 * Calculates the result rows of a bundu bzws workflow
69 */ 67 */
70 public CalculationResult calculate(final BUNDUArtifact bunduartifact) { 68 public CalculationResult calculate(final BUNDUArtifact bunduartifact) {
212 fieldDepths.add(Double.valueOf(w - h)); 210 fieldDepths.add(Double.valueOf(w - h));
213 if (h > channelHeight + 0.001) { 211 if (h > channelHeight + 0.001) {
214 missFieldCnt++; 212 missFieldCnt++;
215 fieldMissDepths.add(Double.valueOf(h - channelHeight)); 213 fieldMissDepths.add(Double.valueOf(h - channelHeight));
216 fieldMissWidths.add(Double.valueOf(channelWidth / BedHeightValueType.FIELD_LAST_INDEX)); 214 fieldMissWidths.add(Double.valueOf(channelWidth / BedHeightValueType.FIELD_LAST_INDEX));
217 } 215 } else {
218 else {
219 fieldMissDepths.add(Double.valueOf(0.0)); 216 fieldMissDepths.add(Double.valueOf(0.0));
220 fieldMissWidths.add(Double.valueOf(0.0)); 217 fieldMissWidths.add(Double.valueOf(0.0));
221 } 218 }
222 } 219 }
223 row.putValue(BunduResultType.missDepthFields, fieldMissDepths); 220 row.putValue(BunduResultType.missDepthFields, fieldMissDepths);
270 if (getFieldValue(i, BunduResultType.missDepthFields, j) > 0.0001) { 267 if (getFieldValue(i, BunduResultType.missDepthFields, j) > 0.0001) {
271 computeMissingVolume(volumes, areas, i, first, last, j); 268 computeMissingVolume(volumes, areas, i, first, last, j);
272 vTotal += volumes.get(j - 1); 269 vTotal += volumes.get(j - 1);
273 vExcav += volumes.get(j - 1) + areas.get(j - 1) * EXCAVATION_DEPTH; 270 vExcav += volumes.get(j - 1) + areas.get(j - 1) * EXCAVATION_DEPTH;
274 expenses += vExcav * EXPENSE_PER_CBM; 271 expenses += vExcav * EXPENSE_PER_CBM;
275 } 272 } else {
276 else {
277 volumes.add(Double.valueOf(0.0)); 273 volumes.add(Double.valueOf(0.0));
278 areas.add(Double.valueOf(0.0)); 274 areas.add(Double.valueOf(0.0));
279 } 275 }
280 } 276 }
281 this.rows.get(i).putValue(BunduResultType.missVolumeFields, volumes); 277 this.rows.get(i).putValue(BunduResultType.missVolumeFields, volumes);
278 // TODO: berechnete masse hier einfügen!
279 this.rows.get(i).putValue(BunduResultType.missMassFields, volumes);
282 this.rows.get(i).putValue(BunduResultType.missAreaFields, areas); 280 this.rows.get(i).putValue(BunduResultType.missAreaFields, areas);
283 this.rows.get(i).putValue(BunduResultType.missVolumeTotal, vTotal); 281 this.rows.get(i).putValue(BunduResultType.missVolumeTotal, vTotal);
284 this.rows.get(i).putValue(BunduResultType.excavationVolume, vExcav); 282 this.rows.get(i).putValue(BunduResultType.excavationVolume, vExcav);
285 this.rows.get(i).putValue(BunduResultType.excavationCosts, expenses); 283 this.rows.get(i).putValue(BunduResultType.excavationCosts, expenses);
286 i++; 284 i++;
299 final double kmPrev = missingKm(current - 1); 297 final double kmPrev = missingKm(current - 1);
300 final double kmNext = missingKm(current + 1); 298 final double kmNext = missingKm(current + 1);
301 if (Double.isNaN(kmPrev) || Double.isNaN(kmNext)) { 299 if (Double.isNaN(kmPrev) || Double.isNaN(kmNext)) {
302 volumes.add(Double.valueOf(0.0)); 300 volumes.add(Double.valueOf(0.0));
303 areas.add(Double.valueOf(0.0)); 301 areas.add(Double.valueOf(0.0));
304 } 302 } else {
305 else {
306 final double area1 = 0.5 * (areaCurr + areaPrev); 303 final double area1 = 0.5 * (areaCurr + areaPrev);
307 final double area2 = 0.5 * (areaCurr + areaNext); 304 final double area2 = 0.5 * (areaCurr + areaNext);
308 volumes.add(Double.valueOf((Math.abs(kmCurr - kmPrev) * 0.5 * area1) + (Math.abs(kmNext - kmCurr) * 0.5 * area2))); 305 volumes.add(Double.valueOf((Math.abs(kmCurr - kmPrev) * 0.5 * area1) + (Math.abs(kmNext - kmCurr) * 0.5 * area2)));
309 areas.add(Double.valueOf(area1 + area2)); 306 areas.add(Double.valueOf(area1 + area2));
310 } 307 }
313 /** 310 /**
314 * Gets the missing area of a field and a row if in range, otherwise 0.0 311 * Gets the missing area of a field and a row if in range, otherwise 0.0
315 */ 312 */
316 private double missingArea(final int rowIndex, final int first, final int last, final int fieldIndex) { 313 private double missingArea(final int rowIndex, final int first, final int last, final int fieldIndex) {
317 if ((first <= rowIndex) && (rowIndex <= last)) 314 if ((first <= rowIndex) && (rowIndex <= last))
318 return getFieldValue(rowIndex, BunduResultType.missDepthFields, fieldIndex) 315 return getFieldValue(rowIndex, BunduResultType.missDepthFields, fieldIndex) * getFieldValue(rowIndex, BunduResultType.missWidthFields, fieldIndex);
319 * getFieldValue(rowIndex, BunduResultType.missWidthFields, fieldIndex);
320 else 316 else
321 return 0.0; 317 return 0.0;
322 } 318 }
323 319
324 /** 320 /**

http://dive4elements.wald.intevation.org