Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java @ 3204:19ce06eb56c3
FixA: Only emit analysis period / discharge sectors which really contain data.
flys-artifacts/trunk@4821 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 28 Jun 2012 13:07:27 +0000 |
parents | 1b9f791937c3 |
children | bbb488b145ce |
comparison
equal
deleted
inserted
replaced
3203:1b9f791937c3 | 3204:19ce06eb56c3 |
---|---|
23 import de.intevation.flys.artifacts.model.fixings.FixLongitudinalAnalysisFacet; | 23 import de.intevation.flys.artifacts.model.fixings.FixLongitudinalAnalysisFacet; |
24 import de.intevation.flys.artifacts.model.fixings.FixLongitudinalDeviationFacet; | 24 import de.intevation.flys.artifacts.model.fixings.FixLongitudinalDeviationFacet; |
25 import de.intevation.flys.artifacts.model.fixings.FixLongitudinalReferenceFacet; | 25 import de.intevation.flys.artifacts.model.fixings.FixLongitudinalReferenceFacet; |
26 import de.intevation.flys.artifacts.model.fixings.FixOutlierFacet; | 26 import de.intevation.flys.artifacts.model.fixings.FixOutlierFacet; |
27 import de.intevation.flys.artifacts.model.fixings.FixReferenceEventsFacet; | 27 import de.intevation.flys.artifacts.model.fixings.FixReferenceEventsFacet; |
28 import de.intevation.flys.artifacts.model.fixings.FixResult; | |
28 import de.intevation.flys.artifacts.model.fixings.FixWQCurveFacet; | 29 import de.intevation.flys.artifacts.model.fixings.FixWQCurveFacet; |
29 | 30 |
30 import de.intevation.flys.artifacts.resources.Resources; | 31 import de.intevation.flys.artifacts.resources.Resources; |
31 | 32 |
32 import de.intevation.flys.artifacts.states.DefaultState; | 33 import de.intevation.flys.artifacts.states.DefaultState; |
103 FixationArtifactAccess access = | 104 FixationArtifactAccess access = |
104 new FixationArtifactAccess(artifact); | 105 new FixationArtifactAccess(artifact); |
105 | 106 |
106 if (old instanceof CalculationResult) { | 107 if (old instanceof CalculationResult) { |
107 res = (CalculationResult)old; | 108 res = (CalculationResult)old; |
108 log.debug("---------- Using result from Cache --------"); | |
109 } | 109 } |
110 else { | 110 else { |
111 log.debug("+++++++++ Recalculating +++++++"); | 111 FixCalculation calc = new FixCalculation(access); |
112 FixCalculation calc = | |
113 new FixCalculation(access); | |
114 | |
115 res = calc.calculate(); | 112 res = calc.calculate(); |
116 } | 113 } |
117 | 114 |
118 if (facets == null) { | 115 if (facets == null) { |
119 return res; | 116 return res; |
120 } | 117 } |
121 | 118 |
122 if (res.getReport().hasProblems()) { | 119 if (res.getReport().hasProblems()) { |
123 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id)); | 120 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id)); |
124 } | 121 } |
122 | |
123 FixResult fr = (FixResult)res.getData(); | |
124 | |
125 if (fr == null) { | |
126 return res; | |
127 } | |
128 | |
125 facets.add( | 129 facets.add( |
126 new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); | 130 new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); |
127 | 131 |
128 int maxId = -100; | 132 int maxId = -100; |
129 | 133 |
130 int count = access.getAnalysisPeriods().length; | 134 int count = access.getAnalysisPeriods().length; |
135 | |
136 int sectorMask = fr.getUsedSectorsInAnalysisPeriods(); | |
131 | 137 |
132 for (int i = 0; i < count; i++) { | 138 for (int i = 0; i < count; i++) { |
133 DateRange period = access.getAnalysisPeriods()[i]; | 139 DateRange period = access.getAnalysisPeriods()[i]; |
134 DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM); | 140 DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
135 String startDate = df.format(period.getFrom()); | 141 String startDate = df.format(period.getFrom()); |
136 String endDate = df.format(period.getTo()); | 142 String endDate = df.format(period.getTo()); |
137 | 143 |
138 for (int j = access.getQSectorStart().intValue(); | 144 for (int j = access.getQSectorStart().intValue(); |
139 j <= access.getQSectorEnd().intValue(); | 145 j <= access.getQSectorEnd().intValue(); |
140 j++) { | 146 j++) { |
147 | |
148 // Only emit facet for sectors that really have data. | |
149 if ((sectorMask & (1 << j)) == 0) { | |
150 continue; | |
151 } | |
141 | 152 |
142 String sector = ""; | 153 String sector = ""; |
143 switch (j) { | 154 switch (j) { |
144 case 0: sector = "[0 - (MNQ+MQ)/2)"; break; | 155 case 0: sector = "[0 - (MNQ+MQ)/2)"; break; |
145 case 1: sector = "[(MNQ+MQ)/2 - (MQ+MHQ)/2)"; break; | 156 case 1: sector = "[(MNQ+MQ)/2 - (MQ+MHQ)/2)"; break; |
162 description)); | 173 description)); |
163 facets.add( | 174 facets.add( |
164 new FixLongitudinalAnalysisFacet(facetNdx, | 175 new FixLongitudinalAnalysisFacet(facetNdx, |
165 FIX_SECTOR_AVERAGE_LS + "_" + sectorNdx, | 176 FIX_SECTOR_AVERAGE_LS + "_" + sectorNdx, |
166 description)); | 177 description)); |
178 // TODO: i18n | |
167 String dev = "Abweichung: " + description; | 179 String dev = "Abweichung: " + description; |
168 facets.add( | 180 facets.add( |
169 new FixLongitudinalAnalysisFacet(facetNdx, | 181 new FixLongitudinalAnalysisFacet(facetNdx, |
170 FIX_SECTOR_AVERAGE_LS_DEVIATION + "_" + sectorNdx, | 182 FIX_SECTOR_AVERAGE_LS_DEVIATION + "_" + sectorNdx, |
171 dev)); | 183 dev)); |