Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityInterpolFacet.java @ 8592:36faef4f8acb
(issue1755) Add interpolated facets and update themes accordingly
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 19 Mar 2015 13:36:38 +0100 |
parents | artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityDataFacet.java@07c9ac22f611 |
children | 4b00ee858964 |
comparison
equal
deleted
inserted
replaced
8591:9fa5c66073e7 | 8592:36faef4f8acb |
---|---|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.artifacts.model.minfo; | |
10 | |
11 import org.apache.log4j.Logger; | |
12 | |
13 import org.dive4elements.artifactdatabase.state.Facet; | |
14 import org.dive4elements.artifacts.Artifact; | |
15 import org.dive4elements.artifacts.CallContext; | |
16 import org.dive4elements.river.artifacts.D4EArtifact; | |
17 import org.dive4elements.river.artifacts.model.CalculationResult; | |
18 import org.dive4elements.river.artifacts.model.DataFacet; | |
19 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | |
20 import org.dive4elements.river.artifacts.access.RangeAccess; | |
21 | |
22 | |
23 /** | |
24 * Facet for serving interpolated BedQualityResults | |
25 */ | |
26 public class BedQualityInterpolFacet extends DataFacet { | |
27 | |
28 private static final long serialVersionUID = 1L; | |
29 | |
30 private static Logger log = Logger.getLogger(BedQualityInterpolFacet.class); | |
31 | |
32 private String valueName; /* Name of the ResultValue underlying this facet */ | |
33 private String valueType; /* Type of the ResultValue underlying this facet */ | |
34 | |
35 public BedQualityInterpolFacet() { | |
36 // required for clone operation deepCopy() | |
37 } | |
38 | |
39 public BedQualityInterpolFacet(int idx, String name, String description, | |
40 ComputeType type, String stateId, String hash, String valueName, String valueType) { | |
41 super(idx, name, description, type, hash, stateId); | |
42 this.valueName = valueName; | |
43 this.valueType = valueType; | |
44 this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); | |
45 this.metaData.put("Y", ""); /* check if those <^ be removed? */ | |
46 } | |
47 | |
48 @Override | |
49 public Object getData(Artifact artifact, CallContext context) { | |
50 log.debug("Get bedquality data: " + valueName + " - " + valueType); | |
51 | |
52 D4EArtifact flys = (D4EArtifact) artifact; | |
53 double[] kms = new RangeAccess(flys).getKmSteps(); | |
54 | |
55 CalculationResult res = (CalculationResult) flys.compute(context, hash, | |
56 stateId, type, false); | |
57 | |
58 int ndx = index >> 8; | |
59 | |
60 BedQualityResultValue value = | |
61 ((BedQualityResult[]) res.getData())[ndx].getValue(valueName, valueType); | |
62 | |
63 if (value == null) { | |
64 /* Other facets check this so we do too */ | |
65 return null; | |
66 } | |
67 return value.getDataInterpolated(kms); | |
68 } | |
69 | |
70 /** Copy deeply. */ | |
71 @Override | |
72 public Facet deepCopy() { | |
73 BedQualityInterpolFacet copy = new BedQualityInterpolFacet(); | |
74 copy.set(this); | |
75 copy.type = type; | |
76 copy.hash = hash; | |
77 copy.stateId = stateId; | |
78 copy.valueName = valueName; | |
79 copy.valueType = valueType; | |
80 return copy; | |
81 } | |
82 } |