Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightSingleParser.java @ 7372:495cde925702
Removed obsolete import + whitespace cleanup.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 17 Oct 2013 12:11:09 +0200 |
parents | d12478cc5bb0 |
children | cf8d37ed4d34 |
comparison
equal
deleted
inserted
replaced
7371:6baaa700eada | 7372:495cde925702 |
---|---|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | 5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.importer.parsers; | 9 package org.dive4elements.river.importer.parsers; |
10 | |
11 import java.math.BigDecimal; | |
12 | 10 |
13 import java.text.ParseException; | 11 import java.text.ParseException; |
14 | 12 |
15 import org.apache.log4j.Logger; | 13 import org.apache.log4j.Logger; |
16 | 14 |
23 | 21 |
24 private static final Logger log = | 22 private static final Logger log = |
25 Logger.getLogger(BedHeightSingleParser.class); | 23 Logger.getLogger(BedHeightSingleParser.class); |
26 | 24 |
27 | 25 |
28 | |
29 @Override | 26 @Override |
30 protected ImportBedHeight newImportBedHeight(String description) { | 27 protected ImportBedHeight newImportBedHeight(String description) { |
31 return new ImportBedHeightSingle(description); | 28 return new ImportBedHeightSingle(description); |
32 } | 29 } |
33 | |
34 | 30 |
35 | 31 |
36 /** | 32 /** |
37 * Create ImportBedHeightSingleValue from a line of csv file, add | 33 * Create ImportBedHeightSingleValue from a line of csv file, add |
38 * it to the ImportBedHeight. | 34 * it to the ImportBedHeight. |
48 | 44 |
49 Double km; | 45 Double km; |
50 | 46 |
51 try { | 47 try { |
52 km = new Double(nf.parse(values[0]).doubleValue()); | 48 km = new Double(nf.parse(values[0]).doubleValue()); |
53 | 49 |
54 Double key = Double.valueOf(km); | 50 Double key = Double.valueOf(km); |
55 | 51 |
56 if (kmExists.contains(key)) { | 52 if (kmExists.contains(key)) { |
57 log.warn("duplicate station '" + km + "': -> ignored"); | 53 log.warn("duplicate station '" + km + "': -> ignored"); |
58 return; | 54 return; |
59 } | 55 } |
60 | 56 |
61 kmExists.add(key); | 57 kmExists.add(key); |
62 } | 58 } |
63 | |
64 catch (ParseException e) { | 59 catch (ParseException e) { |
65 // We expect a lot of ";;;;;;" lines. | 60 // We expect a lot of ";;;;;;" lines. |
66 return; | 61 return; |
67 } | 62 } |
68 | 63 |
70 if (values.length == 1) { | 65 if (values.length == 1) { |
71 // Do not import line without useful data | 66 // Do not import line without useful data |
72 return; | 67 return; |
73 } | 68 } |
74 | 69 |
75 Double height = null; | 70 Double height = null; |
76 if (values[1].length() > 0) { | 71 if (values[1].length() > 0) { |
77 try { | 72 try { |
78 height = new Double(nf.parse(values[1]).doubleValue()); | 73 height = new Double(nf.parse(values[1]).doubleValue()); |
79 } | 74 } |
80 catch (ParseException e) { | 75 catch (ParseException e) { |
81 log.warn("BSP: unparseable height " + values[1]); | 76 log.warn("BSP: unparseable height " + values[1]); |
82 } | 77 } |
83 } | 78 } |
84 | 79 |
85 Double uncertainty = null; | 80 Double uncertainty = null; |
86 if (values[2].length() > 0) { | 81 if (values[2].length() > 0) { |
87 try { | 82 try { |
88 uncertainty = new Double(nf.parse(values[2]).doubleValue()); | 83 uncertainty = new Double(nf.parse(values[2]).doubleValue()); |
89 } | 84 } |
90 catch (ParseException e) { | 85 catch (ParseException e) { |
91 log.warn("BSP: unparseable uncertainty value " + values[2]); | 86 log.warn("BSP: unparseable uncertainty value " + values[2]); |
92 } | 87 } |
93 } | 88 } |
94 | 89 |
95 Double dataGap = null; | 90 Double dataGap = null; |
96 if (values[3].length() > 0) { | 91 if (values[3].length() > 0) { |
97 try { | 92 try { |
98 dataGap = new Double(nf.parse(values[3]).doubleValue()); | 93 dataGap = new Double(nf.parse(values[3]).doubleValue()); |
99 } | 94 } |
100 catch (ParseException e) { | 95 catch (ParseException e) { |
101 log.warn("BSP: unparseable data gap " + values[3]); | 96 log.warn("BSP: unparseable data gap " + values[3]); |
102 } | 97 } |
103 } | 98 } |
104 | 99 |
105 Double soundingWidth = null; | 100 Double soundingWidth = null; |
106 if (values[4].length() > 0) { | 101 if (values[4].length() > 0) { |
107 try { | 102 try { |
108 soundingWidth = new Double(nf.parse(values[4]).doubleValue()); | 103 soundingWidth = new Double(nf.parse(values[4]).doubleValue()); |
109 } | 104 } |
110 catch (ParseException e) { | 105 catch (ParseException e) { |
111 log.warn("BSP: unparseable sounding width " + values[4]); | 106 log.warn("BSP: unparseable sounding width " + values[4]); |
112 } | 107 } |
113 } | 108 } |
114 | 109 |
115 Double width = null; | 110 Double width = null; |
116 if (values[5].length() > 0) { | 111 if (values[5].length() > 0) { |
117 try { | 112 try { |
118 width = new Double(nf.parse(values[5]).doubleValue()); | 113 width = new Double(nf.parse(values[5]).doubleValue()); |
119 } | 114 } |
120 catch (ParseException e) { | 115 catch (ParseException e) { |
121 log.warn("BSP: unparseable width " + values[5]); | 116 log.warn("BSP: unparseable width " + values[5]); |
122 } | 117 } |
123 } | 118 } |
124 | 119 |
125 ImportBedHeightSingleValue value = new ImportBedHeightSingleValue( | 120 ImportBedHeightSingleValue value = new ImportBedHeightSingleValue( |
126 (ImportBedHeightSingle) obj, | 121 (ImportBedHeightSingle) obj, |
127 km, | 122 km, |
128 height, | 123 height, |
129 uncertainty, | 124 uncertainty, |
130 dataGap, | 125 dataGap, |
131 soundingWidth, | 126 soundingWidth, |
132 width | 127 width); |
133 ); | |
134 | 128 |
135 obj.addValue(value); | 129 obj.addValue(value); |
136 } | 130 } |
137 } | 131 } |
138 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 132 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |