Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalculation.java @ 9582:8b457ca70512
Punkt 8.1 Grundberührungen Header
author | gernotbelger |
---|---|
date | Wed, 09 Jan 2019 14:47:21 +0100 |
parents | 0c114309d2a0 |
children | f2473dc34535 |
comparison
equal
deleted
inserted
replaced
9581:b61e2a9fa5d6 | 9582:8b457ca70512 |
---|---|
112 */ | 112 */ |
113 private void calculateOverview(final Collection<ResultRow> rows, final River river, final double fromKm, final double toKm, final int fromYear, | 113 private void calculateOverview(final Collection<ResultRow> rows, final River river, final double fromKm, final double toKm, final int fromYear, |
114 final int toYear, final boolean isEpoch) { | 114 final int toYear, final boolean isEpoch) { |
115 for (final CollisionAggregateValue aggregate : CollisionAggregateValue.getValuesByKm(river, fromKm, toKm, fromYear, toYear)) { | 115 for (final CollisionAggregateValue aggregate : CollisionAggregateValue.getValuesByKm(river, fromKm, toKm, fromYear, toYear)) { |
116 rows.add(ResultRow.create().putValue(GeneralResultType.station, aggregate.getStation()) | 116 rows.add(ResultRow.create().putValue(GeneralResultType.station, aggregate.getStation()) |
117 .putValue(SInfoResultType.years, yearsToString(isEpoch, fromYear, toYear)) | 117 .putValue(SInfoResultType.years, yearsToString(isEpoch, fromYear, toYear)).putValue(SInfoResultType.collisionCount, aggregate.getCount())); |
118 .putValue(SInfoResultType.collisionCount, aggregate.getCount())); | |
119 } | 118 } |
120 } | 119 } |
121 | 120 |
122 /** | 121 /** |
123 * Returns the string representation of a year or epoch | 122 * Returns the string representation of a year or epoch |
134 } | 133 } |
135 | 134 |
136 /** | 135 /** |
137 * Calculates the collision details for a km range of a river and a year, and adds them to a ResultRow collection | 136 * Calculates the collision details for a km range of a river and a year, and adds them to a ResultRow collection |
138 */ | 137 */ |
139 private void calculateDetails(final Collection<ResultRow> rows, final River river, final double fromKm, final double toKm, | 138 private void calculateDetails(final Collection<ResultRow> rows, final River river, final double fromKm, final double toKm, final int year, |
140 final int year, final Map<String, GaugeDischargeValuesFinder> qFinders, final Map<String, GaugeMainValueFinder> zoneFinders, | 139 final Map<String, GaugeDischargeValuesFinder> qFinders, final Map<String, GaugeMainValueFinder> zoneFinders, final Calculation problems) { |
141 final Calculation problems) { | |
142 | 140 |
143 for (final CollisionValue collision : CollisionValue.getValues(river, fromKm, toKm, DateUtil.getStartDateFromYear(year), | 141 for (final CollisionValue collision : CollisionValue.getValues(river, fromKm, toKm, DateUtil.getStartDateFromYear(year), |
144 DateUtil.getEndDateFromYear(year))) { | 142 DateUtil.getEndDateFromYear(year))) { |
145 final String gaugeName = collision.getGaugeName(); | 143 final String gaugeName = collision.getGaugeName(); |
146 final double q = getQ(qFinders, gaugeName, collision.getGaugeW().doubleValue(), river, problems); | 144 final double q = getQ(qFinders, gaugeName, collision.getGaugeW().doubleValue(), river, problems); |
147 final double qOut = Double.isInfinite(q) ? Double.NaN : q; | 145 final double qOut = Double.isInfinite(q) ? Double.NaN : q; |
148 final String zone = getZone(zoneFinders, gaugeName, q, river, problems); | 146 final String zone = getZone(zoneFinders, gaugeName, q, river, problems); |
149 rows.add(ResultRow.create().putValue(GeneralResultType.station, collision.getStation()) | 147 rows.add(ResultRow.create().putValue(GeneralResultType.station, collision.getStation()) |
150 .putValue(GeneralResultType.dateShort, collision.getEventDate()) | 148 .putValue(GeneralResultType.dateShort, collision.getEventDate()).putValue(SInfoResultType.collisionGaugeW, collision.getGaugeW()) |
151 .putValue(SInfoResultType.collisionGaugeW, collision.getGaugeW()) | 149 .putValue(GeneralResultType.gaugeLabel, gaugeName).putValue(SInfoResultType.dischargeLong, qOut) |
152 .putValue(GeneralResultType.gaugeLabelCm, gaugeName) | |
153 .putValue(SInfoResultType.dischargeLong, qOut) | |
154 .putValue(SInfoResultType.dischargeZone, zone)); | 150 .putValue(SInfoResultType.dischargeZone, zone)); |
155 } | 151 } |
156 } | 152 } |
157 | 153 |
158 /** | 154 /** |
159 * Gets the discharge of a gauge and a W | 155 * Gets the discharge of a gauge and a W |
160 */ | 156 */ |
161 private double getQ(final Map<String, GaugeDischargeValuesFinder> qFinders, final String gaugeName, final double w, | 157 private double getQ(final Map<String, GaugeDischargeValuesFinder> qFinders, final String gaugeName, final double w, final River river, |
162 final River river, final Calculation problems) { | 158 final Calculation problems) { |
163 // Find the gauge and load its discharge table, if not already in the map | 159 // Find the gauge and load its discharge table, if not already in the map |
164 final String gnKey = gaugeName.toLowerCase(); | 160 final String gnKey = gaugeName.toLowerCase(); |
165 if (!qFinders.containsKey(gnKey)) | 161 if (!qFinders.containsKey(gnKey)) |
166 qFinders.put(gnKey, GaugeDischargeValuesFinder.loadValues(river, gaugeName, problems)); | 162 qFinders.put(gnKey, GaugeDischargeValuesFinder.loadValues(river, gaugeName, problems)); |
167 // Interpolate W. | 163 // Interpolate W. |
171 } | 167 } |
172 | 168 |
173 /** | 169 /** |
174 * Gets the main value zone name of a gauge and a Q | 170 * Gets the main value zone name of a gauge and a Q |
175 */ | 171 */ |
176 private String getZone(final Map<String, GaugeMainValueFinder> zoneFinders, final String gaugeName, final double q, | 172 private String getZone(final Map<String, GaugeMainValueFinder> zoneFinders, final String gaugeName, final double q, final River river, |
177 final River river, final Calculation problems) { | 173 final Calculation problems) { |
178 // Find the gauge and load its main value list, if not already in the map | 174 // Find the gauge and load its main value list, if not already in the map |
179 final String gnKey = gaugeName.toLowerCase(); | 175 final String gnKey = gaugeName.toLowerCase(); |
180 if (!zoneFinders.containsKey(gnKey)) | 176 if (!zoneFinders.containsKey(gnKey)) |
181 zoneFinders.put(gnKey, GaugeMainValueFinder.loadValues(MainValueTypeKey.Q, river, gaugeName, problems, "GLQ")); | 177 zoneFinders.put(gnKey, GaugeMainValueFinder.loadValues(MainValueTypeKey.Q, river, gaugeName, problems, "GLQ")); |
182 // Build the zone name | 178 // Build the zone name |