Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/FlowVelocityModelParser.java @ 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 | 61e55f36e764 |
comparison
equal
deleted
inserted
replaced
6386:a81fbbda28e7 | 6387:b95504c34060 |
---|---|
41 | 41 |
42 private static final Pattern META_MAINVALUE_A = | 42 private static final Pattern META_MAINVALUE_A = |
43 Pattern.compile("([a-zA-Z]+)+(\\d+)*"); | 43 Pattern.compile("([a-zA-Z]+)+(\\d+)*"); |
44 | 44 |
45 private static final Pattern META_MAINVALUE_B = | 45 private static final Pattern META_MAINVALUE_B = |
46 Pattern.compile("(([a-zA-Z]+)+(\\d+)*)\\s*-\\s*(([a-zA-Z]+)+(\\d+)*)"); | 46 Pattern.compile("(([a-zA-Z]+)+(\\d+)*)\\s*-\\s*(([a-zA-Z]+)+(\\d+)*.*)"); |
47 | 47 |
48 private static final Pattern META_MAINVALUE_C = | 48 private static final Pattern META_MAINVALUE_C = |
49 Pattern.compile("([0-9]++)\\s?(\\w*)|([0-9]++,[0-9]++)\\s?(\\w*)"); | 49 Pattern.compile("([0-9]++)\\s?(\\w*)|([0-9]++,[0-9]++)\\s?(\\w*)"); |
50 | 50 |
51 private static final Pattern META_MAINVALUE_D = | 51 private static final Pattern META_MAINVALUE_D = |
52 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()]*))"); | 52 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?(.*))"); |
53 | 53 |
54 private static final Pattern META_MAINVALUE_E = | 54 private static final Pattern META_MAINVALUE_E = |
55 Pattern.compile("(([a-zA-Z]+)+(\\d+)*) bis (([a-zA-Z]+)+(\\d+)*[a-zA-Z()]*)"); | 55 Pattern.compile("(([a-zA-Z]+)+(\\d+)*)\\s*bis (([a-zA-Z]+)+(\\d+)*.*)"); |
56 | 56 |
57 private static final NumberFormat nf = | 57 private static final NumberFormat nf = |
58 NumberFormat.getInstance(DEFAULT_LOCALE); | 58 NumberFormat.getInstance(DEFAULT_LOCALE); |
59 | 59 |
60 | 60 |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 | 151 |
152 protected Object[] handleMainValueString(String mainValueStr) { | 152 protected Object[] handleMainValueString(String mainValueStr) { |
153 Matcher mA = META_MAINVALUE_A.matcher(mainValueStr); | 153 Matcher mA = META_MAINVALUE_A.matcher(mainValueStr.trim()); |
154 if (mA.matches()) { | 154 if (mA.matches()) { |
155 log.debug("mainValueStr matches META_MAINVALUE_A"); | 155 log.debug("mainValueStr matches META_MAINVALUE_A"); |
156 String name = mA.group(0); | 156 String name = mA.group(0); |
157 | 157 |
158 return new Object[] { name, name }; | 158 return new Object[] { name, name }; |
159 } | 159 } |
160 | 160 |
161 Matcher mB = META_MAINVALUE_B.matcher(mainValueStr); | 161 Matcher mB = META_MAINVALUE_B.matcher(mainValueStr.trim()); |
162 if (mB.matches()) { | 162 if (mB.matches()) { |
163 log.debug("mainValueStr matches META_MAINVALUE_B"); | 163 log.debug("mainValueStr matches META_MAINVALUE_B"); |
164 String lower = mB.group(1); | 164 String lower = mB.group(1); |
165 String upper = mB.group(4); | 165 String upper = mB.group(4); |
166 | 166 |
167 return new Object[] { lower, upper }; | 167 return new Object[] { lower, upper }; |
168 } | 168 } |
169 | 169 |
170 Matcher mC = META_MAINVALUE_C.matcher(mainValueStr); | 170 Matcher mC = META_MAINVALUE_C.matcher(mainValueStr.trim()); |
171 if (mC.matches()) { | 171 if (mC.matches()) { |
172 log.debug("mainValueStr matches META_MAINVALUE_C"); | 172 log.debug("mainValueStr matches META_MAINVALUE_C"); |
173 String facA = mC.group(1); | 173 String facA = mC.group(1); |
174 String nameA = mC.group(2); | 174 String nameA = mC.group(2); |
175 String facB = mC.group(3); | 175 String facB = mC.group(3); |
181 String mainValue = fac + " " + name; | 181 String mainValue = fac + " " + name; |
182 | 182 |
183 return new Object[] { mainValue, mainValue }; | 183 return new Object[] { mainValue, mainValue }; |
184 } | 184 } |
185 | 185 |
186 Matcher mD = META_MAINVALUE_D.matcher(mainValueStr); | 186 Matcher mD = META_MAINVALUE_D.matcher(mainValueStr.trim()); |
187 if (mD.matches()) { | 187 if (mD.matches()) { |
188 log.debug("mainValueStr matches META_MAINVALUE_D"); | 188 log.debug("mainValueStr matches META_MAINVALUE_D"); |
189 String loFacA = mD.group(2); | 189 String loFacA = mD.group(2); |
190 String loNameA = mD.group(3); | 190 String loNameA = mD.group(3); |
191 String loFacB = mD.group(4); | 191 String loFacB = mD.group(4); |
206 String upMainValue = upFac + " " + upName; | 206 String upMainValue = upFac + " " + upName; |
207 | 207 |
208 return new Object[] { loMainValue, upMainValue }; | 208 return new Object[] { loMainValue, upMainValue }; |
209 } | 209 } |
210 | 210 |
211 Matcher mE = META_MAINVALUE_E.matcher(mainValueStr); | 211 Matcher mE = META_MAINVALUE_E.matcher(mainValueStr.trim()); |
212 if (mE.matches()) { | 212 if (mE.matches()) { |
213 log.debug("mainValueStr matches META_MAINVALUE_E"); | 213 log.debug("mainValueStr matches META_MAINVALUE_E"); |
214 String lower = mE.group(1); | 214 String lower = mE.group(1); |
215 String upper = mE.group(4); | 215 String upper = mE.group(4); |
216 | 216 |