Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixRealizingCalculationExtended.java @ 9415:9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
The facets also put the valid station range into their xml-metadata
author | gernotbelger |
---|---|
date | Thu, 16 Aug 2018 16:27:53 +0200 |
parents | 7565d7dce850 |
children |
rev | line source |
---|---|
8883 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.model.fixings; | |
11 | |
8957
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
12 import java.util.Calendar; |
8883 | 13 import java.util.Date; |
14 import java.util.List; | |
8957
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
15 import java.util.SortedSet; |
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
16 import java.util.TreeSet; |
8883 | 17 |
18 import org.dive4elements.river.artifacts.access.FixRealizingAccess; | |
19 | |
20 /** | |
21 * REMARK: this inheritance is only needed, beause changing the orignal calculation will probably break the | |
22 * serialization of the artifact.... | |
23 * | |
24 * @author Gernot Belger | |
25 */ | |
26 public class FixRealizingCalculationExtended extends FixRealizingCalculation { | |
27 private static final long serialVersionUID = 1L; | |
28 | |
29 public FixRealizingCalculationExtended(final FixRealizingAccess fixAccess) { | |
30 super(fixAccess); | |
31 } | |
32 | |
33 public int determineMeanYear() { | |
34 final FixingsOverview overview = FixingsOverviewFactory.getOverview(this.river); | |
35 final ColumnCache cc = new ColumnCache(); | |
36 | |
8957
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
37 final SortedSet<Integer> years = new TreeSet<>(); |
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
38 |
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
39 final Calendar cal = Calendar.getInstance(); |
8904 | 40 |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8957
diff
changeset
|
41 final List<FixingColumnWithData> columns = getEventColumns(overview, cc); |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8957
diff
changeset
|
42 for (final FixingColumnWithData column : columns) { |
8883 | 43 final Date date = column.getDate(); |
8957
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
44 cal.setTime(date); |
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
45 |
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
46 final int year = cal.get(Calendar.YEAR); |
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
47 years.add(year); |
8883 | 48 } |
49 | |
8957
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
50 final Integer first = years.first(); |
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
51 final Integer last = years.last(); |
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
52 if (first == null || last == null) |
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
53 return -1; |
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
54 |
7565d7dce850
Implemented calculation of 'year' for fixations
gernotbelger
parents:
8906
diff
changeset
|
55 return (first + last) / 2; |
8883 | 56 } |
57 } |