# HG changeset patch # User Sascha L. Teichmann # Date 1404914508 -7200 # Node ID 139b057a39ddbcb75a11e8ca6973e87854d06de0 # Parent bcb05a98bb3fe60bc3bdafa660372e2aa907c55a Support the "new" HYK format which enables setting the end of the last flow zone. diff -r bcb05a98bb3f -r 139b057a39dd backend/src/main/java/org/dive4elements/river/importer/parsers/HYKParser.java --- a/backend/src/main/java/org/dive4elements/river/importer/parsers/HYKParser.java Tue Jul 08 19:44:54 2014 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/HYKParser.java Wed Jul 09 16:01:48 2014 +0200 @@ -111,6 +111,8 @@ ImportHYKEntry entry = null; ImportHYKFormation formation = null; + BigDecimal lastZoneEnd = null; + while ((line = in.readLine()) != null) { if (line.startsWith("*") || line.startsWith("----")) { @@ -186,6 +188,22 @@ "failed in line " + in.getLineNumber()); return false; } + + if (parts.length > 3) { + try { + lastZoneEnd = new BigDecimal(parts[3]); + } + catch (NumberFormatException nfe) { + log.error( + "HYK: parsing last flow zone end in " + + "failed in line " + in.getLineNumber()); + return false; + } + } + else { + lastZoneEnd = null; + } + formation = new ImportHYKFormation(); formation.setBottom(bottom); formation.setTop(top); @@ -247,7 +265,10 @@ } for (int i = 0; i < coords.length; ++i) { BigDecimal a = coords[i]; - BigDecimal b = coords[i == coords.length-1 ? i : i+1]; + BigDecimal b = i == coords.length-1 + ? (lastZoneEnd != null ? lastZoneEnd : coords[i]) + : coords[i+1]; + if (a.compareTo(b) > 0) { log.warn("HYK: zone coordinates swapped in line " + in.getLineNumber());