Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightSingleParser.java @ 6505:128ab9169db1 double-precision
merged changes from default into double-precision branch
author | Tom Gottfried <tom.gottfried@intevation.de> |
---|---|
date | Fri, 28 Jun 2013 17:03:48 +0200 |
parents | f095b58c95d9 |
children | 6c003cbb27f1 |
rev | line source |
---|---|
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5992
4c3ccf2b0304
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5992
4c3ccf2b0304
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5829
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
9 package org.dive4elements.river.importer.parsers; |
2806
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
11 import java.math.BigDecimal; |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
12 |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
13 import java.text.ParseException; |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
14 |
2806
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import org.apache.log4j.Logger; |
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
5829
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
17 import org.dive4elements.river.importer.ImportBedHeight; |
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
18 import org.dive4elements.river.importer.ImportBedHeightSingle; |
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
19 import org.dive4elements.river.importer.ImportBedHeightSingleValue; |
2806
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2809
diff
changeset
|
22 public class BedHeightSingleParser extends BedHeightParser { |
2806
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 private static final Logger log = |
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 Logger.getLogger(BedHeightSingleParser.class); |
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
28 |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2809
diff
changeset
|
29 @Override |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2809
diff
changeset
|
30 protected ImportBedHeight newImportBedHeight(String description) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2809
diff
changeset
|
31 return new ImportBedHeightSingle(description); |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
32 } |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
33 |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
34 |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
35 |
3955
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
36 /** |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
37 * Create ImportBedHeightSingleValue from a line of csv file, add |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
38 * it to the ImportBedHeight. |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
39 */ |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2809
diff
changeset
|
40 @Override |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2809
diff
changeset
|
41 protected void handleDataLine(ImportBedHeight obj, String line) { |
6298
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
42 log.debug(line); |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
43 String[] values = line.split(SEPERATOR_CHAR); |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
44 |
3955
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
45 if (values == null || (values.length != 1 && values.length < 6)) { |
3662
0d27d02b1208
backend: Completed the error messages of the importer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2811
diff
changeset
|
46 //log.warn("BSP: Error while parsing data line: '" + line + "'"); |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
47 return; |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
48 } |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
49 |
6203
a3fb76cf79b6
backout backout as it is now safely in a branch
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6201
diff
changeset
|
50 Double km; |
3955
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
51 |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
52 try { |
6203
a3fb76cf79b6
backout backout as it is now safely in a branch
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6201
diff
changeset
|
53 km = new Double(nf.parse(values[0]).doubleValue()); |
6273
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6203
diff
changeset
|
54 |
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6203
diff
changeset
|
55 Double key = Double.valueOf(km); |
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6203
diff
changeset
|
56 |
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6203
diff
changeset
|
57 if (kmExists.contains(key)) { |
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6203
diff
changeset
|
58 log.warn("duplicate station '" + km + "': -> ignored"); |
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6203
diff
changeset
|
59 return; |
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6203
diff
changeset
|
60 } |
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6203
diff
changeset
|
61 |
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6203
diff
changeset
|
62 kmExists.add(key); |
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6203
diff
changeset
|
63 } |
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6203
diff
changeset
|
64 |
3955
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
65 catch (ParseException e) { |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
66 // We expect a lot of ";;;;;;" lines. |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
67 //log.warn("BSP: Error while parsing km of data row.", e); |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
68 return; |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
69 } |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
70 |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
71 // Handle gaps like "10,0;;;;;". |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
72 if (values.length == 1) { |
6047
1bb4b51ff1e6
BHP: do not import lines without useful data
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
73 // Do not import line without useful data |
3955
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
74 return; |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
75 } |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
76 |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
77 // Because we cannot enforce consistency of values with complete data |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
78 // via null constraints in the database (as there are "gap" values), |
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
79 // do this checks manually. |
6298
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
80 // if (values[3].length() == 0 || values[4].length() == 0 |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
81 // || values[5].length() == 0) { |
3955
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
82 //log.warn("BSP: Error while parsing data row (manual null constraint violated)."); |
6298
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
83 // return; |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
84 //} |
3955
26685b846a29
Let importer handle gappy single bed height values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3662
diff
changeset
|
85 |
6298
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
86 Double height = null; |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
87 if (values[1].length() > 0) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
88 try { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
89 height = new Double(nf.parse(values[1]).doubleValue()); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
90 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
91 catch (ParseException e) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
92 log.warn("BSP: unparseable height " + values[1]); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
93 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
94 } |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
95 |
6298
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
96 Double uncertainty = null; |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
97 if (values[2].length() > 0) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
98 try { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
99 uncertainty = new Double(nf.parse(values[2]).doubleValue()); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
100 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
101 catch (ParseException e) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
102 log.warn("BSP: unparseable uncertainty value " + values[2]); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
103 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
104 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
105 |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
106 Double dataGap = null; |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
107 if (values[3].length() > 0) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
108 try { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
109 dataGap = new Double(nf.parse(values[3]).doubleValue()); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
110 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
111 catch (ParseException e) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
112 log.warn("BSP: unparseable data gap " + values[3]); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
113 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
114 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
115 |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
116 Double soundingWidth = null; |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
117 if (values[4].length() > 0) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
118 try { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
119 soundingWidth = new Double(nf.parse(values[4]).doubleValue()); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
120 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
121 catch (ParseException e) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
122 log.warn("BSP: unparseable sounding width " + values[4]); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
123 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
124 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
125 |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
126 Double width = null; |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
127 if (values[5].length() > 0) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
128 try { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
129 width = new Double(nf.parse(values[5]).doubleValue()); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
130 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
131 catch (ParseException e) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
132 log.warn("BSP: unparseable width " + values[5]); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
133 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
134 } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
135 |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
136 // try { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
137 ImportBedHeightSingleValue value = new ImportBedHeightSingleValue( |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
138 (ImportBedHeightSingle) obj, |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
139 km, |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
140 height,//new Double(nf.parse(values[1]).doubleValue()), |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
141 uncertainty, |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
142 dataGap, |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
143 soundingWidth, |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
144 // parseBigDecimal(values[4], line), |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
145 width |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
146 ); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
147 |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
148 obj.addValue(value); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
149 // } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
150 // catch (ParseException e) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
151 // log.warn("BSP: unparseable value in data row.", e); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
152 //} |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2806
diff
changeset
|
153 } |
5992
4c3ccf2b0304
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
154 |
6298
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
155 // private BigDecimal parseBigDecimal(String value, String line) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
156 // BigDecimal result = null; |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
157 // try { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
158 // Double dValue = Double.valueOf(value.replace(",", ".")); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
159 // result = new BigDecimal(dValue.doubleValue()); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
160 // } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
161 // catch (NumberFormatException nfe) { |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
162 // log.warn( |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
163 // "Could not parse " + |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
164 // value + |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
165 // " in bed heigt single row: " |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
166 // + line); |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
167 // } |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
168 // return result; |
f095b58c95d9
Bedheight single parser: do not reject lines with missing values
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6273
diff
changeset
|
169 // } |
2806
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 } |
33f40b23edd8
Initial checkin for parsing MINFO bed heights.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |