Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightSoundingWidthFacet.java @ 8587:07c9ac22f611
(issue1755) Generalise BedQuality result handling
The bedquality calculation now produces a result for each time period
which has BedQualityResultValues for each specific result type.
Formally this was split up in density, porosity and diameter classes
with some bedload diameter classes mixed in for extra fun.
The intent of this commit is to allow more shared code and generic
access patterns to the BedQuality results.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 18 Mar 2015 18:42:08 +0100 |
parents | 6d8d7425a6b5 |
children | cd5e0662f75c |
rev | line source |
---|---|
7995 | 1 package org.dive4elements.river.artifacts.model.minfo; |
2 | |
3 import java.util.List; | |
4 | |
5 import org.dive4elements.artifacts.Artifact; | |
6 import org.dive4elements.artifacts.CallContext; | |
7 import org.dive4elements.river.artifacts.D4EArtifact; | |
8 import org.dive4elements.river.artifacts.access.BedHeightAccess; | |
9 import org.dive4elements.river.artifacts.model.BlackboardDataFacet; | |
10 import org.dive4elements.river.artifacts.model.FacetTypes; | |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8427
diff
changeset
|
11 import org.dive4elements.river.model.BedHeight; |
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8427
diff
changeset
|
12 import org.dive4elements.river.model.BedHeightValue; |
7995 | 13 |
14 | |
15 public class BedHeightSoundingWidthFacet | |
16 extends BlackboardDataFacet | |
17 implements FacetTypes | |
18 { | |
19 public BedHeightSoundingWidthFacet(String name, String description) { | |
20 this.name = name; | |
21 this.description = description; | |
22 this.index = 0; | |
23 this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); | |
8267
99912f51468d
A bit less chaos in i18n for bed heights.
"Tom Gottfried <tom@intevation.de>"
parents:
7995
diff
changeset
|
24 this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label"); |
7995 | 25 } |
26 | |
27 /** | |
28 * Returns the data this facet requires. | |
29 * | |
30 * @param artifact the owner artifact. | |
31 * @param context the CallContext (ignored). | |
32 * | |
33 * @return the data. | |
34 */ | |
35 @Override | |
36 public Object getData(Artifact artifact, CallContext context) { | |
37 BedHeightAccess access = new BedHeightAccess((D4EArtifact)artifact); | |
38 /* Former doc (from BedHeightAccess): | |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8427
diff
changeset
|
39 * Return a {@link List} of {@link BedHeightValue}s |
7995 | 40 * at the range of the artifact |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8427
diff
changeset
|
41 * @return List of {@link BedHeightValue}s */ |
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8427
diff
changeset
|
42 BedHeight single = BedHeight.getBedHeightById( |
7995 | 43 access.getHeightId()); |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8427
diff
changeset
|
44 List<BedHeightValue> bedheightValues = |
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8427
diff
changeset
|
45 BedHeightValue.getBedHeightValues( |
7995 | 46 single, |
47 access.getFrom(), | |
48 access.getTo()); | |
49 double[][] values = new double[2][bedheightValues.size()]; | |
50 int i = 0; | |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8427
diff
changeset
|
51 for (BedHeightValue bedheightValue : bedheightValues) { |
7995 | 52 values[0][i] = bedheightValue.getStation(); |
8427
2f640972ecf6
There might be no sounding width given at some stations of a bed height single.
Tom Gottfried <tom@intevation.de>
parents:
8267
diff
changeset
|
53 values[1][i] = bedheightValue.getSoundingWidth() != null |
2f640972ecf6
There might be no sounding width given at some stations of a bed height single.
Tom Gottfried <tom@intevation.de>
parents:
8267
diff
changeset
|
54 ? bedheightValue.getSoundingWidth() : Double.NaN; |
7995 | 55 i++; |
56 } | |
57 return values; | |
58 } | |
59 | |
60 /** | |
61 * Create a deep copy of this Facet. | |
62 * @return a deep copy. | |
63 */ | |
64 @Override | |
65 public BedHeightSoundingWidthFacet deepCopy() { | |
66 BedHeightSoundingWidthFacet copy = | |
67 new BedHeightSoundingWidthFacet(name, description); | |
68 copy.set(this); | |
69 return copy; | |
70 } | |
71 } |