Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java @ 721:7298d58a1f5a
Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
flys-artifacts/trunk@2198 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 22 Jun 2011 09:19:16 +0000 |
parents | 45cd58a2a2bb |
children | 8900966ad945 |
comparison
equal
deleted
inserted
replaced
720:d60cc6453d45 | 721:7298d58a1f5a |
---|---|
21 import de.intevation.flys.model.Gauge; | 21 import de.intevation.flys.model.Gauge; |
22 import de.intevation.flys.model.River; | 22 import de.intevation.flys.model.River; |
23 import de.intevation.flys.model.TimeInterval; | 23 import de.intevation.flys.model.TimeInterval; |
24 | 24 |
25 import de.intevation.flys.artifacts.FLYSArtifact; | 25 import de.intevation.flys.artifacts.FLYSArtifact; |
26 import de.intevation.flys.artifacts.model.DischargeTables; | |
27 import de.intevation.flys.artifacts.model.GaugesFactory; | |
28 | 26 |
27 import de.intevation.flys.artifacts.model.WQKms; | |
29 | 28 |
30 /** | 29 /** |
31 * An OutGenerator that generates discharge curves. | 30 * An OutGenerator that generates discharge curves. |
32 * | 31 * |
33 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 32 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
96 | 95 |
97 public void doOut(Artifact artifact, Facet facet, Document attr) { | 96 public void doOut(Artifact artifact, Facet facet, Document attr) { |
98 logger.debug("DischargeCurveGenerator.doOut: " + facet.getName()); | 97 logger.debug("DischargeCurveGenerator.doOut: " + facet.getName()); |
99 | 98 |
100 if (!(artifact instanceof FLYSArtifact)) { | 99 if (!(artifact instanceof FLYSArtifact)) { |
101 logger.error("Artifact is no instance of FLYSArtifact."); | 100 logger.debug("Artifact is no instance of FLYSArtifact."); |
102 return; | 101 return; |
103 } | 102 } |
104 | 103 |
105 FLYSArtifact flysArtifact = (FLYSArtifact) artifact; | 104 FLYSArtifact flysArtifact = (FLYSArtifact) artifact; |
106 | 105 |
107 River river = flysArtifact.getRiver(); | 106 facet = flysArtifact.getNativeFacet(facet); |
108 double[] distance = flysArtifact.getDistance(); | |
109 | 107 |
110 List<double[]> ranges = new ArrayList<double[]>(); | 108 if (facet == null) { |
111 ranges.add(distance); | 109 logger.debug("no facet found"); |
112 | 110 return; |
113 List<Gauge> gauges = GaugesFactory.getGauges(river); | |
114 List<Gauge> filtered = GaugesFactory.filterRanges(gauges, ranges); | |
115 | |
116 if (logger.isDebugEnabled()) { | |
117 int numGauges = gauges != null ? gauges.size() : 0; | |
118 int numFiltered = filtered != null ? filtered.size() : 0; | |
119 | |
120 logger.debug("++++++++++++++++++++"); | |
121 logger.debug("Search gauges for river: " + river.getName()); | |
122 logger.debug("-> ... from range: " + distance[0]); | |
123 logger.debug("-> ... to range: " + distance[1]); | |
124 logger.debug("-> Found " + numGauges + " gauges in total."); | |
125 logger.debug("-> Found " + numFiltered + " gauges after filtering."); | |
126 logger.debug("++++++++++++++++++++"); | |
127 } | 111 } |
128 | 112 |
129 String[] gaugeNames = new String[filtered.size()]; | 113 WQKms wqkms = (WQKms)facet.getData(flysArtifact, context); |
130 int idx = 0; | 114 |
131 for (Gauge gauge: filtered) { | 115 String gaugeName = wqkms.getName(); |
132 gaugeNames[idx++] = gauge.getName(); | 116 |
117 River river = flysArtifact.getRiver(); | |
118 | |
119 if (river == null) { | |
120 logger.debug("no river found"); | |
121 return; | |
133 } | 122 } |
134 | 123 |
135 DischargeTables dt = new DischargeTables(river.getName(), gaugeNames); | 124 Gauge gauge = river.determineGaugeByName(gaugeName); |
136 Map<String, double[][]> gaugeValues = dt.getValues(100d); | |
137 | 125 |
138 for (Gauge gauge: filtered) { | 126 if (gauge == null) { |
139 String gaugeName = gauge.getName(); | 127 logger.debug("no gauge found"); |
128 return; | |
129 } | |
140 | 130 |
141 double[][] values = gaugeValues.get(gaugeName); | 131 String seriesName = getSeriesName(gauge); |
142 dataset.addSeries(getSeriesName(gauge), values); | 132 |
143 } | 133 double [][] values = new double [][] { |
134 wqkms.getQs(), wqkms.getWs() }; | |
135 | |
136 dataset.addSeries(seriesName, values); | |
144 } | 137 } |
145 | 138 |
146 | 139 |
147 protected String getSeriesName(Gauge gauge) { | 140 protected String getSeriesName(Gauge gauge) { |
148 List<DischargeTable> dts = gauge.getDischargeTables(); | 141 List<DischargeTable> dts = gauge.getDischargeTables(); |