Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java @ 8714:4e8c80ff07e3
(issue1602) We don't distinguish between types since sometime but we want to have metadata at the facet.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 24 Apr 2015 18:01:18 +0200 |
parents | cd5e0662f75c |
children | 8dbb969091c5 |
comparison
equal
deleted
inserted
replaced
8713:6b68777aaeab | 8714:4e8c80ff07e3 |
---|---|
14 | 14 |
15 import org.apache.log4j.Logger; | 15 import org.apache.log4j.Logger; |
16 import org.dive4elements.artifacts.Artifact; | 16 import org.dive4elements.artifacts.Artifact; |
17 import org.dive4elements.artifacts.CallContext; | 17 import org.dive4elements.artifacts.CallContext; |
18 import org.dive4elements.river.artifacts.D4EArtifact; | 18 import org.dive4elements.river.artifacts.D4EArtifact; |
19 import org.dive4elements.river.artifacts.resources.Resources; | |
19 import org.dive4elements.river.artifacts.access.BedHeightAccess; | 20 import org.dive4elements.river.artifacts.access.BedHeightAccess; |
20 import org.dive4elements.river.artifacts.model.BlackboardDataFacet; | 21 import org.dive4elements.river.artifacts.model.BlackboardDataFacet; |
21 import org.dive4elements.river.artifacts.model.FacetTypes; | 22 import org.dive4elements.river.artifacts.model.FacetTypes; |
22 import org.dive4elements.river.model.BedHeight; | 23 import org.dive4elements.river.model.BedHeight; |
23 import org.dive4elements.river.model.BedHeightValue; | 24 import org.dive4elements.river.model.BedHeightValue; |
26 extends BlackboardDataFacet | 27 extends BlackboardDataFacet |
27 implements FacetTypes { | 28 implements FacetTypes { |
28 | 29 |
29 private static final Logger log = Logger.getLogger(BedHeightFacet.class); | 30 private static final Logger log = Logger.getLogger(BedHeightFacet.class); |
30 | 31 |
31 private String type; | 32 public BedHeightFacet(String name, String description) { |
32 | |
33 public BedHeightFacet(String name, String description, String type) { | |
34 this.name = name; | 33 this.name = name; |
35 this.description = description; | 34 this.description = description; |
36 this.type = type; | |
37 this.index = 0; | 35 this.index = 0; |
38 this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); | 36 this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); |
39 this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label"); | 37 this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label"); |
40 } | 38 } |
41 | 39 |
48 * @return the data. | 46 * @return the data. |
49 */ | 47 */ |
50 @Override | 48 @Override |
51 public Object getData(Artifact artifact, CallContext context) { | 49 public Object getData(Artifact artifact, CallContext context) { |
52 BedHeightAccess access = new BedHeightAccess((D4EArtifact)artifact); | 50 BedHeightAccess access = new BedHeightAccess((D4EArtifact)artifact); |
53 if (type.equals("singlevalues")) { | 51 BedHeight single = BedHeight.getBedHeightById(access.getHeightId()); |
54 /* Former doc (from BedHeightAccess): | 52 List<BedHeightValue> bedheightValues = |
55 * Return a {@link List} of {@link BedHeightValue}s | 53 BedHeightValue.getBedHeightValues( |
56 * at the range of the artifact | 54 single, |
57 * @return List of {@link BedHeightValue}s */ | 55 access.getFrom(true), |
58 BedHeight single = BedHeight.getBedHeightById( | 56 access.getTo(true)); |
59 access.getHeightId()); | 57 double[][] values = new double[2][bedheightValues.size()]; |
60 List<BedHeightValue> bedheightValues = | 58 int i = 0; |
61 BedHeightValue.getBedHeightValues( | 59 for (BedHeightValue bedheightValue : bedheightValues) { |
62 single, | 60 values[0][i] = bedheightValue.getStation(); |
63 access.getFrom(true), | 61 values[1][i] = bedheightValue.getHeight(); |
64 access.getTo(true)); | 62 i++; |
65 double[][] values = new double[2][bedheightValues.size()]; | |
66 int i = 0; | |
67 for (BedHeightValue bedheightValue : bedheightValues) { | |
68 values[0][i] = bedheightValue.getStation(); | |
69 values[1][i] = bedheightValue.getHeight(); | |
70 i++; | |
71 } | |
72 return values; | |
73 } | 63 } |
74 else { | 64 |
75 /* Former doc (from BedHeightAccess): | 65 this.addMetaData(Resources.getMsg( |
76 * Return the {@link BedHeight} at the height_id and time of the artifact | 66 context.getMeta(), |
77 * @return {@link BedHeight} */ | 67 "meta.bedheight.cur.elevation"), |
78 BedHeightData data = BedHeightFactory.getHeight( | 68 single.getCurElevationModel().getName()); |
79 access.getType(), | 69 if (single.getOldElevationModel() != null) { |
80 access.getHeightId()); | 70 this.addMetaData(Resources.getMsg( |
81 //data.removeNaNs(); | 71 context.getMeta(), |
82 TDoubleArrayList stations= data.getStations(); | 72 "meta.bedheight.old.elevation"), |
83 double[][] values = new double[2][stations.size()]; | 73 single.getOldElevationModel().getName()); |
84 for (int i = 0; i < stations.size(); i++) { | |
85 values[0][i] = stations.get(i); | |
86 values[1][i] = data.getHeight(i); | |
87 } | |
88 return values; | |
89 } | 74 } |
75 this.addMetaData(Resources.getMsg( | |
76 context.getMeta(), | |
77 "meta.bedheight.river.elevation"), | |
78 access.getRiver().getWstUnit().getName()); | |
79 | |
80 return values; | |
90 } | 81 } |
91 | 82 |
92 /** | 83 /** |
93 * Create a deep copy of this Facet. | 84 * Create a deep copy of this Facet. |
94 * @return a deep copy. | 85 * @return a deep copy. |
95 */ | 86 */ |
96 @Override | 87 @Override |
97 public BedHeightFacet deepCopy() { | 88 public BedHeightFacet deepCopy() { |
98 BedHeightFacet copy = new BedHeightFacet(name, description, type); | 89 BedHeightFacet copy = new BedHeightFacet(name, description); |
99 copy.set(this); | 90 copy.set(this); |
100 return copy; | 91 return copy; |
101 } | 92 } |
102 } | 93 } |
103 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 94 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |