changeset 6387:b95504c34060 double-precision

Flow velocity model parser: be more tolerant with main value strings in meta line
author Tom Gottfried <tom.gottfried@intevation.de>
date Fri, 21 Jun 2013 14:35:18 +0200
parents a81fbbda28e7
children df867072d003
files backend/src/main/java/org/dive4elements/river/importer/parsers/FlowVelocityModelParser.java
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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);

http://dive4elements.wald.intevation.org