[Dive4elements-commits] [PATCH 2 of 2] Flow velocity model parser: be more tolerant with main value strings in meta line

Wald Commits scm-commit at wald.intevation.org
Fri Jun 21 14:36:46 CEST 2013


# HG changeset patch
# User Tom Gottfried <tom.gottfried at intevation.de>
# Date 1371818118 -7200
# Branch double-precision
# Node ID b95504c340608954a62d4bc9ef6218b875b52414
# Parent  a81fbbda28e73441f39fd5d69abce1602f7ec45a
Flow velocity model parser: be more tolerant with main value strings in meta line

diff -r a81fbbda28e7 -r b95504c34060 backend/src/main/java/org/dive4elements/river/importer/parsers/FlowVelocityModelParser.java
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/FlowVelocityModelParser.java	Fri Jun 21 14:34:06 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/FlowVelocityModelParser.java	Fri Jun 21 14:35:18 2013 +0200
@@ -43,16 +43,16 @@
         Pattern.compile("([a-zA-Z]+)+(\\d+)*");
 
     private static final Pattern META_MAINVALUE_B =
-        Pattern.compile("(([a-zA-Z]+)+(\\d+)*)\\s*-\\s*(([a-zA-Z]+)+(\\d+)*)");
+        Pattern.compile("(([a-zA-Z]+)+(\\d+)*)\\s*-\\s*(([a-zA-Z]+)+(\\d+)*.*)");
 
     private static final Pattern META_MAINVALUE_C =
         Pattern.compile("([0-9]++)\\s?(\\w*)|([0-9]++,[0-9]++)\\s?(\\w*)");
 
     private static final Pattern META_MAINVALUE_D =
-        Pattern.compile("(([0-9]*)\\s?(\\w*)|([0-9]++,[0-9]++)\\s?(\\w*)) bis (([0-9]*)\\s?([a-zA-Z_0-9()]*)|([0-9]++,[0-9]++)\\s?([a-zA-Z_0-9()]*))");
+        Pattern.compile("(([0-9]*)\\s?(\\w*)|([0-9]++,[0-9]++)\\s?(\\w*))\\s*bis (([0-9]*)\\s?([a-zA-Z_0-9()]*)|([0-9]++,[0-9]++)\\s?(.*))");
 
     private static final Pattern META_MAINVALUE_E =
-        Pattern.compile("(([a-zA-Z]+)+(\\d+)*) bis (([a-zA-Z]+)+(\\d+)*[a-zA-Z()]*)");
+        Pattern.compile("(([a-zA-Z]+)+(\\d+)*)\\s*bis (([a-zA-Z]+)+(\\d+)*.*)");
 
     private static final NumberFormat nf =
         NumberFormat.getInstance(DEFAULT_LOCALE);
@@ -150,7 +150,7 @@
 
 
     protected Object[] handleMainValueString(String mainValueStr) {
-        Matcher mA = META_MAINVALUE_A.matcher(mainValueStr);
+        Matcher mA = META_MAINVALUE_A.matcher(mainValueStr.trim());
         if (mA.matches()) {
 	    log.debug("mainValueStr matches META_MAINVALUE_A");
             String name = mA.group(0);
@@ -158,7 +158,7 @@
             return new Object[] { name, name };
         }
 
-        Matcher mB = META_MAINVALUE_B.matcher(mainValueStr);
+        Matcher mB = META_MAINVALUE_B.matcher(mainValueStr.trim());
         if (mB.matches()) {
 	    log.debug("mainValueStr matches META_MAINVALUE_B");
             String lower = mB.group(1);
@@ -167,7 +167,7 @@
             return new Object[] { lower, upper };
         }
 
-        Matcher mC = META_MAINVALUE_C.matcher(mainValueStr);
+        Matcher mC = META_MAINVALUE_C.matcher(mainValueStr.trim());
         if (mC.matches()) {
 	    log.debug("mainValueStr matches META_MAINVALUE_C");
             String facA  = mC.group(1);
@@ -183,7 +183,7 @@
             return new Object[] { mainValue, mainValue };
         }
 
-        Matcher mD = META_MAINVALUE_D.matcher(mainValueStr);
+        Matcher mD = META_MAINVALUE_D.matcher(mainValueStr.trim());
         if (mD.matches()) {
 	    log.debug("mainValueStr matches META_MAINVALUE_D");
             String loFacA  = mD.group(2);
@@ -208,7 +208,7 @@
             return new Object[] { loMainValue, upMainValue };
         }
 
-        Matcher mE = META_MAINVALUE_E.matcher(mainValueStr);
+        Matcher mE = META_MAINVALUE_E.matcher(mainValueStr.trim());
         if (mE.matches()) {
 	    log.debug("mainValueStr matches META_MAINVALUE_E");
             String lower = mE.group(1);


More information about the Dive4elements-commits mailing list