changeset 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 bcb05a98bb3f
children 4ec43afaa263
files backend/src/main/java/org/dive4elements/river/importer/parsers/HYKParser.java
diffstat 1 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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());

http://dive4elements.wald.intevation.org