Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixLongitudinalAvSectorFacet.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 | e4606eae8ea5 |
children | 0a5239a1e46e |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
9 package org.dive4elements.river.artifacts.model.fixings; |
3610 | 10 |
11 import org.apache.log4j.Logger; | |
12 | |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
13 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
14 import org.dive4elements.artifacts.CallContext; |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
15 import org.dive4elements.river.artifacts.D4EArtifact; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
16 import org.dive4elements.river.artifacts.model.CalculationResult; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
17 import org.dive4elements.river.artifacts.model.DataFacet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
18 import org.dive4elements.river.artifacts.model.FacetTypes; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
19 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
20 import org.dive4elements.river.utils.KMIndex; |
3610 | 21 |
22 public class FixLongitudinalAvSectorFacet | |
23 extends DataFacet | |
24 implements FacetTypes { | |
25 | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
26 /** House log. */ |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
27 private static Logger log = |
3610 | 28 Logger.getLogger(FixLongitudinalAvSectorFacet.class); |
29 | |
30 /** Trivial Constructor. */ | |
31 public FixLongitudinalAvSectorFacet() { | |
32 } | |
33 | |
34 | |
35 public FixLongitudinalAvSectorFacet( | |
36 int ndx, | |
37 String name, | |
38 String description) | |
39 { | |
40 super( | |
41 ndx, | |
42 name, | |
43 description, | |
44 ComputeType.ADVANCE, | |
45 null, | |
46 null); | |
47 } | |
48 | |
49 | |
50 /** | |
51 * Returns the data this facet requires. | |
52 * | |
53 * @param artifact the owner artifact. | |
54 * @param context the CallContext. | |
55 * | |
56 * @return the data as KMIndex. | |
57 */ | |
58 @Override | |
59 public Object getData(Artifact artifact, CallContext context) { | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
60 log.debug("FixLongitudinalAvSectorFacet.getData"); |
3610 | 61 |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
62 if (artifact instanceof D4EArtifact) { |
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
63 D4EArtifact flys = (D4EArtifact)artifact; |
3610 | 64 |
65 CalculationResult res = | |
66 (CalculationResult) flys.compute(context, | |
67 ComputeType.ADVANCE, | |
68 false); | |
69 | |
70 FixAnalysisResult result = (FixAnalysisResult) res.getData(); | |
71 | |
72 KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods(); | |
73 if (kmPeriods == null) { | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
74 log.warn("No analysis periods found."); |
3610 | 75 return null; |
76 } | |
77 int periodNdx = index >> 2; | |
78 KMIndex<AnalysisPeriod> resPeriods = | |
79 new KMIndex<AnalysisPeriod>(); | |
80 for (KMIndex.Entry<AnalysisPeriod[]> entry: kmPeriods) { | |
81 AnalysisPeriod ap = entry.getValue()[periodNdx]; | |
82 resPeriods.add(entry.getKm(), ap); | |
83 } | |
84 | |
85 return resPeriods; | |
86 } | |
87 else { | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
88 log.warn("Artifact is no instance of D4EArtifact."); |
3610 | 89 return null; |
90 } | |
91 } | |
92 | |
93 | |
94 /** | |
95 * Create a deep copy of this Facet. | |
96 * @return a deep copy. | |
97 */ | |
98 @Override | |
99 public FixLongitudinalAvSectorFacet deepCopy() { | |
100 FixLongitudinalAvSectorFacet copy = new FixLongitudinalAvSectorFacet(); | |
101 copy.set(this); | |
102 return copy; | |
103 } | |
104 } | |
105 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |