Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java @ 8556:d115d0ed6624
Importer: Remove obsolete interface for bed heights.
author | "Tom Gottfried <tom@intevation.de>" |
---|---|
date | Mon, 16 Feb 2015 09:35:06 +0100 |
parents | 3bb1c62ad732 |
children | 29ab66ce06aa |
comparison
equal
deleted
inserted
replaced
8555:b5c54a6380e8 | 8556:d115d0ed6624 |
---|---|
29 import java.io.FileInputStream; | 29 import java.io.FileInputStream; |
30 import java.io.InputStreamReader; | 30 import java.io.InputStreamReader; |
31 | 31 |
32 import org.apache.log4j.Logger; | 32 import org.apache.log4j.Logger; |
33 | 33 |
34 import org.dive4elements.river.importer.ImportBedHeight; | 34 import org.dive4elements.river.importer.ImportBedHeightSingle; |
35 import org.dive4elements.river.importer.ImportBedHeightType; | 35 import org.dive4elements.river.importer.ImportBedHeightType; |
36 import org.dive4elements.river.importer.ImportElevationModel; | 36 import org.dive4elements.river.importer.ImportElevationModel; |
37 import org.dive4elements.river.importer.ImportLocationSystem; | 37 import org.dive4elements.river.importer.ImportLocationSystem; |
38 import org.dive4elements.river.importer.ImportRange; | 38 import org.dive4elements.river.importer.ImportRange; |
39 import org.dive4elements.river.importer.ImportTimeInterval; | 39 import org.dive4elements.river.importer.ImportTimeInterval; |
87 | 87 |
88 | 88 |
89 protected static NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE); | 89 protected static NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE); |
90 | 90 |
91 | 91 |
92 protected List<ImportBedHeight> bedHeights; | 92 protected List<ImportBedHeightSingle> bedHeights; |
93 | 93 |
94 | 94 |
95 protected abstract ImportBedHeight newImportBedHeight(String description); | 95 protected abstract ImportBedHeightSingle newImportBedHeight(String description); |
96 | 96 |
97 /** Handle a line of file that contains data (in contrast to comments, meta). */ | 97 /** Handle a line of file that contains data (in contrast to comments, meta). */ |
98 protected abstract void handleDataLine( | 98 protected abstract void handleDataLine( |
99 ImportBedHeight importBedHeight, | 99 ImportBedHeightSingle importBedHeight, |
100 String line | 100 String line |
101 ); | 101 ); |
102 | 102 |
103 protected TreeSet<Double> kmExists; | 103 protected TreeSet<Double> kmExists; |
104 | 104 |
105 public BedHeightParser() { | 105 public BedHeightParser() { |
106 bedHeights = new ArrayList<ImportBedHeight>(); | 106 bedHeights = new ArrayList<ImportBedHeightSingle>(); |
107 kmExists = new TreeSet<Double>(EpsilonComparator.CMP); | 107 kmExists = new TreeSet<Double>(EpsilonComparator.CMP); |
108 } | 108 } |
109 | 109 |
110 | 110 |
111 public List<ImportBedHeight> getBedHeights() { | 111 public List<ImportBedHeightSingle> getBedHeights() { |
112 return bedHeights; | 112 return bedHeights; |
113 } | 113 } |
114 | 114 |
115 | 115 |
116 public void parse(File file) throws IOException { | 116 public void parse(File file) throws IOException { |
117 log.info("Parsing bed height single file '" + file + "'"); | 117 log.info("Parsing bed height single file '" + file + "'"); |
118 | 118 |
119 ImportBedHeight obj = newImportBedHeight(file.getName().replaceAll("\\.csv", "")); | 119 ImportBedHeightSingle obj = newImportBedHeight(file.getName().replaceAll("\\.csv", "")); |
120 | 120 |
121 kmExists.clear(); | 121 kmExists.clear(); |
122 | 122 |
123 LineNumberReader in = null; | 123 LineNumberReader in = null; |
124 try { | 124 try { |
162 return tmp; | 162 return tmp; |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 | 166 |
167 protected void handleMetaLine(ImportBedHeight obj, String line) { | 167 protected void handleMetaLine(ImportBedHeightSingle obj, String line) { |
168 String meta = stripMetaLine(line); | 168 String meta = stripMetaLine(line); |
169 | 169 |
170 if (handleMetaYear(obj, meta)) { | 170 if (handleMetaYear(obj, meta)) { |
171 return; | 171 return; |
172 } | 172 } |
201 log.warn("BHP: Meta line did not match any known type: " + line); | 201 log.warn("BHP: Meta line did not match any known type: " + line); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 | 205 |
206 protected boolean handleMetaYear(ImportBedHeight obj, String line) { | 206 protected boolean handleMetaYear(ImportBedHeightSingle obj, String line) { |
207 Matcher m = META_YEAR.matcher(line); | 207 Matcher m = META_YEAR.matcher(line); |
208 | 208 |
209 if (m.matches()) { | 209 if (m.matches()) { |
210 String tmp = m.group(1); | 210 String tmp = m.group(1); |
211 if (tmp.length() > 0) { | 211 if (tmp.length() > 0) { |
219 | 219 |
220 return false; | 220 return false; |
221 } | 221 } |
222 | 222 |
223 | 223 |
224 protected boolean handleMetaTimeInterval(ImportBedHeight obj, String line) { | 224 protected boolean handleMetaTimeInterval(ImportBedHeightSingle obj, String line) { |
225 Matcher m = META_TIMEINTERVAL.matcher(line); | 225 Matcher m = META_TIMEINTERVAL.matcher(line); |
226 | 226 |
227 if (m.matches()) { | 227 if (m.matches()) { |
228 String lo = m.group(1); | 228 String lo = m.group(1); |
229 String up = m.group(2); | 229 String up = m.group(2); |
248 | 248 |
249 return false; | 249 return false; |
250 } | 250 } |
251 | 251 |
252 | 252 |
253 protected boolean handleMetaSoundingWidth(ImportBedHeight obj, String line) { | 253 protected boolean handleMetaSoundingWidth(ImportBedHeightSingle obj, String line) { |
254 Matcher m = META_SOUNDING_WIDTH.matcher(line); | 254 Matcher m = META_SOUNDING_WIDTH.matcher(line); |
255 | 255 |
256 if (m.matches()) { | 256 if (m.matches()) { |
257 String tmp = m.group(1); | 257 String tmp = m.group(1); |
258 | 258 |
270 | 270 |
271 return false; | 271 return false; |
272 } | 272 } |
273 | 273 |
274 | 274 |
275 protected boolean handleMetaComment(ImportBedHeight obj, String line) { | 275 protected boolean handleMetaComment(ImportBedHeightSingle obj, String line) { |
276 Matcher m = META_COMMENTS.matcher(line); | 276 Matcher m = META_COMMENTS.matcher(line); |
277 | 277 |
278 if (m.matches()) { | 278 if (m.matches()) { |
279 String tmp = m.group(1); | 279 String tmp = m.group(1); |
280 | 280 |
286 return false; | 286 return false; |
287 } | 287 } |
288 | 288 |
289 | 289 |
290 protected boolean handleMetaEvaluationBy( | 290 protected boolean handleMetaEvaluationBy( |
291 ImportBedHeight obj, | 291 ImportBedHeightSingle obj, |
292 String line | 292 String line |
293 ) { | 293 ) { |
294 Matcher m = META_EVALUATION_BY.matcher(line); | 294 Matcher m = META_EVALUATION_BY.matcher(line); |
295 | 295 |
296 if (m.matches()) { | 296 if (m.matches()) { |
304 | 304 |
305 return false; | 305 return false; |
306 } | 306 } |
307 | 307 |
308 | 308 |
309 protected boolean handleMetaRange(ImportBedHeight obj, String line) { | 309 protected boolean handleMetaRange(ImportBedHeightSingle obj, String line) { |
310 Matcher m = META_RANGE.matcher(line); | 310 Matcher m = META_RANGE.matcher(line); |
311 | 311 |
312 if (m.matches() && m.groupCount() >= 2) { | 312 if (m.matches() && m.groupCount() >= 2) { |
313 String a = m.group(1).replace(";", ""); | 313 String a = m.group(1).replace(";", ""); |
314 String b = m.group(2).replace(";", ""); | 314 String b = m.group(2).replace(";", ""); |
328 | 328 |
329 return false; | 329 return false; |
330 } | 330 } |
331 | 331 |
332 | 332 |
333 protected boolean handleMetaType(ImportBedHeight obj, String line) { | 333 protected boolean handleMetaType(ImportBedHeightSingle obj, String line) { |
334 Matcher m = META_TYPE.matcher(line); | 334 Matcher m = META_TYPE.matcher(line); |
335 | 335 |
336 if (m.matches()) { | 336 if (m.matches()) { |
337 String tmp = m.group(1).replace(";", "").trim(); | 337 String tmp = m.group(1).replace(";", "").trim(); |
338 | 338 |
351 return false; | 351 return false; |
352 } | 352 } |
353 | 353 |
354 | 354 |
355 protected boolean handleMetaLocationSystem( | 355 protected boolean handleMetaLocationSystem( |
356 ImportBedHeight obj, | 356 ImportBedHeightSingle obj, |
357 String line | 357 String line |
358 ) { | 358 ) { |
359 Matcher m = META_LOCATION_SYSTEM.matcher(line); | 359 Matcher m = META_LOCATION_SYSTEM.matcher(line); |
360 | 360 |
361 if (m.matches()) { | 361 if (m.matches()) { |
369 return false; | 369 return false; |
370 } | 370 } |
371 | 371 |
372 | 372 |
373 protected boolean handleMetaCurElevationModel( | 373 protected boolean handleMetaCurElevationModel( |
374 ImportBedHeight obj, | 374 ImportBedHeightSingle obj, |
375 String line | 375 String line |
376 ) { | 376 ) { |
377 Matcher m = META_CUR_ELEVATION_SYSTEM.matcher(line); | 377 Matcher m = META_CUR_ELEVATION_SYSTEM.matcher(line); |
378 | 378 |
379 if (m.matches()) { | 379 if (m.matches()) { |
392 return false; | 392 return false; |
393 } | 393 } |
394 | 394 |
395 | 395 |
396 protected boolean handleMetaOldElevationModel( | 396 protected boolean handleMetaOldElevationModel( |
397 ImportBedHeight obj, | 397 ImportBedHeightSingle obj, |
398 String line | 398 String line |
399 ) { | 399 ) { |
400 Matcher m = META_OLD_ELEVATION_SYSTEM.matcher(line); | 400 Matcher m = META_OLD_ELEVATION_SYSTEM.matcher(line); |
401 | 401 |
402 if (m.matches()) { | 402 if (m.matches()) { |