Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCrossSectionProcessor.java @ 9509:6146358c4842
Fixed: f2 sign corrected in vegetation zone height calculation, vegetation zone limit handling changed in the importer
author | mschaefer |
---|---|
date | Mon, 01 Oct 2018 09:53:36 +0200 |
parents | 8b7bf26b8782 |
children | ee6508687e3f |
rev | line source |
---|---|
9499 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.uinfo.vegetationzones; | |
11 | |
12 import java.awt.Color; | |
13 import java.util.HashSet; | |
14 import java.util.List; | |
15 import java.util.Set; | |
16 | |
17 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
18 import org.dive4elements.artifactdatabase.state.Facet; | |
19 import org.dive4elements.artifacts.Artifact; | |
20 import org.dive4elements.artifacts.CallContext; | |
21 import org.dive4elements.artifacts.DataProvider; | |
9506
8b7bf26b8782
Predefined artifact for standard vegetation zones.
gernotbelger
parents:
9501
diff
changeset
|
22 import org.dive4elements.river.artifacts.D4EArtifact; |
9499 | 23 import org.dive4elements.river.artifacts.common.AbstractProcessor; |
24 import org.dive4elements.river.artifacts.model.CrossSectionFacetUtils; | |
25 import org.dive4elements.river.artifacts.model.river.MainWstValuesCalculator; | |
26 import org.dive4elements.river.exports.CrossSectionGenerator; | |
27 import org.dive4elements.river.exports.DiagramGenerator; | |
28 import org.dive4elements.river.jfree.StripedAreaDataset; | |
29 import org.dive4elements.river.jfree.StripedAreaDataset.Stripe; | |
30 import org.dive4elements.river.model.FastCrossSectionLine; | |
31 import org.dive4elements.river.model.River; | |
32 import org.dive4elements.river.themes.ThemeDocument; | |
33 | |
34 /** | |
35 * @author Domenico Nardi Tironi | |
36 * | |
37 */ | |
38 public class VegetationZonesCrossSectionProcessor extends AbstractProcessor { | |
39 | |
40 private static final String MAIN_VALUE_MQ = "mq"; | |
41 | |
42 public static final String FACET_VEGETATION_ZONES_CROSS_SECTION = "uinfo_facet_vegetation_zones_cross_section"; | |
43 | |
44 | |
45 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); | |
46 | |
47 static { | |
48 HANDLED_FACET_TYPES.add(FACET_VEGETATION_ZONES_CROSS_SECTION); | |
49 } | |
50 | |
9506
8b7bf26b8782
Predefined artifact for standard vegetation zones.
gernotbelger
parents:
9501
diff
changeset
|
51 public static Facet createVegetationZonesCrossSectionFacet(final String description) { |
8b7bf26b8782
Predefined artifact for standard vegetation zones.
gernotbelger
parents:
9501
diff
changeset
|
52 |
8b7bf26b8782
Predefined artifact for standard vegetation zones.
gernotbelger
parents:
9501
diff
changeset
|
53 return new VegetationZonesCrossSectionFacet(FACET_VEGETATION_ZONES_CROSS_SECTION, description); |
9499 | 54 } |
55 | |
56 public static void generateSeries(final CrossSectionGenerator generator, final ArtifactAndFacet bundle, final CallContext context, | |
57 final ThemeDocument theme, final boolean visible) { | |
58 | |
59 final DataProvider provider = CrossSectionFacetUtils.getDataProvider(context); | |
60 final FastCrossSectionLine crossSection = CrossSectionFacetUtils.getCrossSection(provider, context); | |
61 if (crossSection == null) | |
62 return; | |
63 final double currentStation = crossSection.getKm(); | |
64 | |
65 if (bundle.getFacetName().equals(FACET_VEGETATION_ZONES_CROSS_SECTION)) { | |
66 | |
67 final StripedAreaDataset dataset = new StripedAreaDataset(theme); | |
68 | |
69 final Artifact artifact = bundle.getArtifact(); | |
9506
8b7bf26b8782
Predefined artifact for standard vegetation zones.
gernotbelger
parents:
9501
diff
changeset
|
70 final VegetationzonesAccess vAccess = new VegetationzonesAccess((D4EArtifact) artifact); |
9499 | 71 final River river = vAccess.getRiver(); |
72 final List<VegetationZoneServerClientXChange> zones = VegetationZoneServerClientXChange.parse(vAccess.getVegZones()); | |
73 | |
74 for (final VegetationZoneServerClientXChange zone : zones) { | |
75 | |
76 final double lower = uefdToHeight(context, river, currentStation, zone.getLowerFromTo()); | |
77 final double upper = uefdToHeight(context, river, currentStation, zone.getUpperFromTo()); | |
78 | |
79 final Color color = Color.decode(zone.getHexColor()); | |
9501 | 80 final String label = String.format("%s (%dd-%dd)", zone.getZoneName(), zone.getLowerFromTo(), zone.getUpperFromTo()); |
81 dataset.addStripe(new Stripe(label, color, lower, upper)); | |
9499 | 82 } |
83 | |
84 generator.addAxisDataset(dataset, 0, visible); | |
85 return; | |
86 } | |
87 | |
88 throw new UnsupportedOperationException(); | |
89 } | |
90 | |
91 private static double uefdToHeight(final CallContext context, final River river, final double station, final int uefd) { | |
92 | |
93 final MainWstValuesCalculator mainWstValues = MainWstValuesCalculator.forRiver(context, river, null, MAIN_VALUE_MQ); | |
94 | |
95 final double mw = mainWstValues.interpolateW(station, MAIN_VALUE_MQ); | |
96 | |
97 // Üfd = -70,559 ∗ ln((DGM - MW) + 0,5) + 80,711 | |
98 final double f1 = -70.559; | |
9509
6146358c4842
Fixed: f2 sign corrected in vegetation zone height calculation, vegetation zone limit handling changed in the importer
mschaefer
parents:
9506
diff
changeset
|
99 final double f2 = 88.711; |
9499 | 100 |
101 final double dgm = Math.exp((uefd - f2) / f1) + mw - 0.5; | |
102 return dgm; | |
103 } | |
104 | |
105 public VegetationZonesCrossSectionProcessor() { | |
106 super(CrossSectionGenerator.I18N_YAXIS_LABEL, HANDLED_FACET_TYPES); | |
107 | |
108 throw new UnsupportedOperationException(); | |
109 } | |
110 | |
111 @Override | |
112 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | |
113 throw new UnsupportedOperationException(); | |
114 } | |
115 | |
116 } |