Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/HYKParser.java @ 8020:139b057a39dd
Support the "new" HYK format which enables setting the end of the last flow zone.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 09 Jul 2014 16:01:48 +0200 |
parents | 4c3ccf2b0304 |
children | 5e38e2924c07 |
comparison
equal
deleted
inserted
replaced
8017:bcb05a98bb3f | 8020:139b057a39dd |
---|---|
109 int coordPos = 0; | 109 int coordPos = 0; |
110 | 110 |
111 ImportHYKEntry entry = null; | 111 ImportHYKEntry entry = null; |
112 ImportHYKFormation formation = null; | 112 ImportHYKFormation formation = null; |
113 | 113 |
114 BigDecimal lastZoneEnd = null; | |
115 | |
114 while ((line = in.readLine()) != null) { | 116 while ((line = in.readLine()) != null) { |
115 | 117 |
116 if (line.startsWith("*") || line.startsWith("----")) { | 118 if (line.startsWith("*") || line.startsWith("----")) { |
117 continue; | 119 continue; |
118 } | 120 } |
184 log.error( | 186 log.error( |
185 "HYK: parsing num zones, bottom or top height " + | 187 "HYK: parsing num zones, bottom or top height " + |
186 "failed in line " + in.getLineNumber()); | 188 "failed in line " + in.getLineNumber()); |
187 return false; | 189 return false; |
188 } | 190 } |
191 | |
192 if (parts.length > 3) { | |
193 try { | |
194 lastZoneEnd = new BigDecimal(parts[3]); | |
195 } | |
196 catch (NumberFormatException nfe) { | |
197 log.error( | |
198 "HYK: parsing last flow zone end in " + | |
199 "failed in line " + in.getLineNumber()); | |
200 return false; | |
201 } | |
202 } | |
203 else { | |
204 lastZoneEnd = null; | |
205 } | |
206 | |
189 formation = new ImportHYKFormation(); | 207 formation = new ImportHYKFormation(); |
190 formation.setBottom(bottom); | 208 formation.setBottom(bottom); |
191 formation.setTop(top); | 209 formation.setTop(top); |
192 entry.addFormation(formation); | 210 entry.addFormation(formation); |
193 | 211 |
245 in.getLineNumber()); | 263 in.getLineNumber()); |
246 return false; | 264 return false; |
247 } | 265 } |
248 for (int i = 0; i < coords.length; ++i) { | 266 for (int i = 0; i < coords.length; ++i) { |
249 BigDecimal a = coords[i]; | 267 BigDecimal a = coords[i]; |
250 BigDecimal b = coords[i == coords.length-1 ? i : i+1]; | 268 BigDecimal b = i == coords.length-1 |
269 ? (lastZoneEnd != null ? lastZoneEnd : coords[i]) | |
270 : coords[i+1]; | |
271 | |
251 if (a.compareTo(b) > 0) { | 272 if (a.compareTo(b) > 0) { |
252 log.warn("HYK: zone coordinates swapped in line " + | 273 log.warn("HYK: zone coordinates swapped in line " + |
253 in.getLineNumber()); | 274 in.getLineNumber()); |
254 BigDecimal c = a; a = b; b = c; | 275 BigDecimal c = a; a = b; b = c; |
255 } | 276 } |