comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java @ 8879:64ca63f79f6f

Further work on SINFO-FlowDepth
author gernotbelger
date Fri, 09 Feb 2018 13:27:10 +0100
parents 9f7a285b0ee3
children 7a8c12706834
comparison
equal deleted inserted replaced
8878:ddd6523e0868 8879:64ca63f79f6f
43 return "continue"; 43 return "continue";
44 } 44 }
45 45
46 @Override 46 @Override
47 public Object computeFeed( 47 public Object computeFeed(
48 final D4EArtifact artifact, 48 final D4EArtifact artifact,
49 final String hash, 49 final String hash,
50 final CallContext context, 50 final CallContext context,
51 final List<Facet> facets, 51 final List<Facet> facets,
52 final Object old 52 final Object old
53 ) { 53 ) {
54 // FIXME: why is this necessary? 54 // FIXME: why is this necessary?
55 if (artifact instanceof ChartArtifact) {
56 facets.add(new EmptyFacet());
57 return null;
58 }
59
60 return compute((SINFOArtifact) artifact, context, hash, facets, old);
61 }
62
63 @Override
64 public Object computeAdvance(
65 final D4EArtifact artifact,
66 final String hash,
67 final CallContext context,
68 final List<Facet> facets,
69 final Object old
70 ) {
55 if (artifact instanceof ChartArtifact) { 71 if (artifact instanceof ChartArtifact) {
56 facets.add(new EmptyFacet()); 72 facets.add(new EmptyFacet());
57 return null; 73 return null;
58 } 74 }
59 return compute((SINFOArtifact) artifact, context, hash, facets, old); 75 return compute((SINFOArtifact) artifact, context, hash, facets, old);
60 } 76 }
61 77
62 @Override
63 public Object computeAdvance(
64 final D4EArtifact artifact,
65 final String hash,
66 final CallContext context,
67 final List<Facet> facets,
68 final Object old
69 ) {
70 if (artifact instanceof ChartArtifact) {
71 facets.add(new EmptyFacet());
72 return null;
73 }
74 return compute((SINFOArtifact) artifact, context, hash, facets, old);
75 }
76
77 /** 78 /**
78 * Compute result or returned object from cache, create facets. 79 * Compute result or returned object from cache, create facets.
79 * @param old Object that was cached. 80 * @param old Object that was cached.
80 */ 81 */
81 private Object compute( 82 private Object compute(
82 final SINFOArtifact sinfo, 83 final SINFOArtifact sinfo,
83 final CallContext context, 84 final CallContext context,
84 final String hash, 85 final String hash,
85 final List<Facet> facets, 86 final List<Facet> facets,
86 final Object old 87 final Object old
87 ) { 88 ) {
89
88 final CalculationResult res; 90 final CalculationResult res;
89 if (old instanceof CalculationResult) 91 if (old instanceof CalculationResult)
90 res = (CalculationResult) old; 92 res = (CalculationResult) old;
91 else 93 else
92 res = new FlowDepthCalculation(context).calculate(sinfo); 94 res = new FlowDepthCalculation(context).calculate(sinfo);
93 95
94 if (facets == null) { 96 if (facets == null) {
95 return res; 97 return res;
96 } 98 }
97 99
99 101
100 /* add themes for chart, for each result */ 102 /* add themes for chart, for each result */
101 final List<FlowDepthCalculationResult> resultList = results.getResults(); 103 final List<FlowDepthCalculationResult> resultList = results.getResults();
102 for (int index = 0; index < resultList.size(); index++) { 104 for (int index = 0; index < resultList.size(); index++) {
103 105
104 final FlowDepthCalculationResult result = resultList.get(index); 106 final FlowDepthCalculationResult result = resultList.get(index);
105 107
106 /* filtered (zoom dependent mean) flow depth */ 108 /* filtered (zoom dependent mean) flow depth */
107 final String facetFlowDepthFilteredDescription = Resources.getMsg( context.getMeta(), I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, result.getLabel() ); 109 final String facetFlowDepthFilteredDescription = Resources.getMsg( context.getMeta(), I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, result.getLabel() );
108 facets.add(new FlowDepthFilterFacet( 110 facets.add(new FlowDepthFilterFacet(
109 index, 111 index,
110 FlowDepthProcessor.FACET_FLOW_DEPTH_FILTERED, 112 FlowDepthProcessor.FACET_FLOW_DEPTH_FILTERED,
111 facetFlowDepthFilteredDescription, 113 facetFlowDepthFilteredDescription,
112 ComputeType.ADVANCE, 114 ComputeType.ADVANCE,
113 id, 115 this.id,
114 hash 116 hash
115 )); 117 ));
116 118
117 // FIXME: add other themes 119 // FIXME: add other themes
118 } 120 }
119 121
120 if (!resultList.isEmpty() ) { 122 if (!resultList.isEmpty() ) {
121 Facet csv = new DataFacet( 123 final Facet csv = new DataFacet(
122 FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, id); 124 FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id);
123 Facet pdf = new DataFacet( 125 final Facet pdf = new DataFacet(
124 FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, id); 126 FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id);
125 127
126 facets.add(csv); 128 facets.add(csv);
127 facets.add(pdf); 129 facets.add(pdf);
128 } 130 }
129 131
130 final Calculation report = res.getReport(); 132 final Calculation report = res.getReport();
131 133
132 if (report.hasProblems()) { 134 if (report.hasProblems()) {
133 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id)); 135 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id));
134 } 136 }
135 137
136 return res; 138 return res;
137 } 139 }
138 } 140 }

http://dive4elements.wald.intevation.org