Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java @ 446:f5a041000357
Connected vertical cross section with chart generation.
gnv-artifacts/trunk@494 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 01 Jan 2010 12:08:05 +0000 |
parents | f42ed4f10b79 |
children | 92b7ccbf6163 |
comparison
equal
deleted
inserted
replaced
445:f42ed4f10b79 | 446:f5a041000357 |
---|---|
37 import de.intevation.gnv.artifacts.cache.CacheFactory; | 37 import de.intevation.gnv.artifacts.cache.CacheFactory; |
38 | 38 |
39 import de.intevation.gnv.chart.Chart; | 39 import de.intevation.gnv.chart.Chart; |
40 import de.intevation.gnv.chart.ChartLabels; | 40 import de.intevation.gnv.chart.ChartLabels; |
41 import de.intevation.gnv.chart.ChartStyle; | 41 import de.intevation.gnv.chart.ChartStyle; |
42 import de.intevation.gnv.chart.VerticalCrossSectionChart; | |
42 | 43 |
43 import de.intevation.gnv.chart.exception.TechnicalChartException; | 44 import de.intevation.gnv.chart.exception.TechnicalChartException; |
44 | 45 |
45 import de.intevation.gnv.geobackend.base.Result; | 46 import de.intevation.gnv.geobackend.base.Result; |
46 import de.intevation.gnv.geobackend.base.ResultDescriptor; | 47 import de.intevation.gnv.geobackend.base.ResultDescriptor; |
185 return size != null | 186 return size != null |
186 ? size | 187 ? size |
187 : GNVArtifactContext.DEFAULT_VERTICAL_CROSS_SECTION_SAMPLES; | 188 : GNVArtifactContext.DEFAULT_VERTICAL_CROSS_SECTION_SAMPLES; |
188 } | 189 } |
189 | 190 |
190 private static List<Filter.Factory> getFilterFactories(CallContext callContext) { | 191 private static List<Filter.Factory> getFilterFactories( |
192 CallContext callContext | |
193 ) { | |
191 GNVArtifactContext context = | 194 GNVArtifactContext context = |
192 (GNVArtifactContext)callContext.globalContext(); | 195 (GNVArtifactContext)callContext.globalContext(); |
193 List<Filter.Factory> factories = (List<Filter.Factory>)context.get( | 196 List<Filter.Factory> factories = (List<Filter.Factory>)context.get( |
194 GNVArtifactContext.VERTICAL_CROSS_SECTION_FILTER_FACTORIES_KEY); | 197 GNVArtifactContext.VERTICAL_CROSS_SECTION_FILTER_FACTORIES_KEY); |
195 return factories != null | 198 return factories != null |
243 | 246 |
244 Dimension rasterSize = getRasterSize(callContext); | 247 Dimension rasterSize = getRasterSize(callContext); |
245 List<Filter.Factory> filterFactories = getFilterFactories(callContext); | 248 List<Filter.Factory> filterFactories = getFilterFactories(callContext); |
246 Interpolation3D interpolation = new Interpolation3D(rasterSize); | 249 Interpolation3D interpolation = new Interpolation3D(rasterSize); |
247 | 250 |
248 double distance = WKTUtils.toKM( | 251 double distance = DistanceCalculator.calculateDistance(path); |
249 DistanceCalculator.calculateDistance(path)); | |
250 | 252 |
251 if (distance < EPSILON) { | 253 if (distance < EPSILON) { |
252 log.warn("distance too short for interpolation"); | 254 log.warn("distance too short for interpolation"); |
253 return null; | 255 return null; |
254 } | 256 } |
257 path, | 259 path, |
258 columns.getXYColumns(), | 260 columns.getXYColumns(), |
259 0d, | 261 0d, |
260 distance, | 262 distance, |
261 LinearMetrics.INSTANCE, | 263 LinearMetrics.INSTANCE, |
262 new ConstantXYDepth(-42d)); // TODO: Use DEM here!! | 264 new ConstantXYDepth(-75d)); // TODO: Use DEM here!! |
263 | 265 |
264 if (!success) { | 266 if (!success) { |
265 log.warn("interpolation failed"); | 267 log.warn("interpolation failed"); |
266 return null; | 268 return null; |
267 } | 269 } |
297 Vectorizer vectorizer = new Vectorizer( | 299 Vectorizer vectorizer = new Vectorizer( |
298 intRaster, rasterSize.width); | 300 intRaster, rasterSize.width); |
299 | 301 |
300 int numRegions = vectorizer.process(pdsp); | 302 int numRegions = vectorizer.process(pdsp); |
301 | 303 |
304 vectorizer = null; intRaster = null; // help gc | |
305 | |
302 PolygonDataset pds = pdsp.getPolygonDataset(); | 306 PolygonDataset pds = pdsp.getPolygonDataset(); |
303 | 307 |
304 if (debug) { | 308 if (debug) { |
305 log.debug("number of regions: " + numRegions); | 309 log.debug("number of regions: " + numRegions); |
306 log.debug("number of series: " + pds.getSeriesCount()); | 310 log.debug("number of series: " + pds.getSeriesCount()); |
307 } | 311 } |
308 | 312 |
309 return null; | 313 columns.setInterpolation(interpolation); |
314 columns.setPolygonDataset(pds); | |
315 | |
316 return columns; | |
310 } | 317 } |
311 | 318 |
312 | 319 |
313 protected AttributedXYColumns preProcess(Collection results) { | 320 protected AttributedXYColumns preProcess(Collection results) { |
314 | 321 |
399 if (chart != null) | 406 if (chart != null) |
400 return chart; | 407 return chart; |
401 | 408 |
402 log.info("Chart not in cache yet."); | 409 log.info("Chart not in cache yet."); |
403 | 410 |
404 log.warn("This sort of chart is not implemented yet."); | 411 AttributedXYColumns columns = |
405 /* TODO Implement a special chart for this sort of charts. | 412 (AttributedXYColumns)result; |
406 chart = new VerticalProfileChart( | 413 |
407 chartLables, | 414 Integer parameterId = |
408 chartTheme, | 415 (Integer)columns.getAttribute("GROUP1"); // XXX: hardcoded |
409 parameters, | 416 |
410 measurements, | 417 if (parameterId == null) { |
411 result, | 418 log.error("missing parameter id"); |
412 dates, | 419 return null; |
413 locale | 420 } |
414 ); | 421 |
422 Map<Integer, PaletteManager> paletteManagers = | |
423 getPalettes(callContext); | |
424 | |
425 PaletteManager paletteManager = paletteManagers.get(parameterId); | |
426 | |
427 if (paletteManager == null) { | |
428 log.error("no palette found for parameter id " + parameterId); | |
429 return null; | |
430 } | |
431 | |
432 chart = new VerticalCrossSectionChart( | |
433 columns, | |
434 paletteManager.getBase(), | |
435 locale); | |
436 | |
415 chart.generateChart(); | 437 chart.generateChart(); |
416 | 438 |
417 if (CACHE_CHART) { | 439 if (CACHE_CHART) { |
418 log.info("Put chart into cache."); | 440 log.info("Put chart into cache."); |
419 purifyChart(chart, uuid); | 441 purifyChart(chart, uuid); |
420 } | 442 } |
421 */ | |
422 | 443 |
423 return chart; | 444 return chart; |
424 } | 445 } |
425 | 446 |
426 /** | 447 /** |