Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/PorosityParser.java @ 7862:cdef048c4ac5
Fixed porosity importer. Find existing db entries and parse values from string, not via double.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 08 May 2014 13:48:45 +0200 |
parents | 02711de579cc |
children | d9d2bd78eff6 |
comparison
equal
deleted
inserted
replaced
7861:c288309a5dcb | 7862:cdef048c4ac5 |
---|---|
135 String lo = m.group(1); | 135 String lo = m.group(1); |
136 String up = m.group(2); | 136 String up = m.group(2); |
137 | 137 |
138 log.info("Found porosity depth: " + lo + " - " + up + " cm"); | 138 log.info("Found porosity depth: " + lo + " - " + up + " cm"); |
139 | 139 |
140 ImportDepth depth = null; | |
140 try { | 141 try { |
141 ImportDepth depth = new ImportDepth( | 142 depth = new ImportDepth( |
142 new BigDecimal(nf.parse(lo).doubleValue()), | 143 new BigDecimal(lo), |
143 new BigDecimal(nf.parse(up).doubleValue()) | 144 new BigDecimal(up) |
144 ); | 145 ); |
145 | 146 } |
147 catch (NumberFormatException nfe) { | |
148 log.warn("Unparsable number for depth: " + line, nfe); | |
149 } | |
150 | |
151 if (depth != null) { | |
146 current.setDepth(depth); | 152 current.setDepth(depth); |
147 | |
148 return true; | 153 return true; |
149 } | 154 } |
150 catch (ParseException pe) { | 155 return false; |
151 log.warn("Unparseable numbers in: '" + line + "'"); | |
152 } | |
153 } | 156 } |
154 else { | 157 else { |
155 log.debug("Meta line doesn't contain depth information: " + line); | 158 log.debug("Meta line doesn't contain depth information: " + line); |
156 } | 159 } |
157 | 160 |
168 } | 171 } |
169 | 172 |
170 BigDecimal km = null; | 173 BigDecimal km = null; |
171 BigDecimal shoreOffset = null; | 174 BigDecimal shoreOffset = null; |
172 BigDecimal porosity = null; | 175 BigDecimal porosity = null; |
176 vals[0] = vals[0].replace(",", "."); | |
177 vals[2] = vals[2].replace(",", "."); | |
173 try { | 178 try { |
174 km = new BigDecimal(nf.parse(vals[0]).doubleValue()); | 179 km = new BigDecimal(vals[0]); |
175 porosity = new BigDecimal(nf.parse(vals[2]).doubleValue()); | 180 porosity = new BigDecimal(vals[2]); |
176 if (!vals[1].isEmpty()) { | 181 if (!vals[1].isEmpty()) { |
177 shoreOffset = new BigDecimal(nf.parse(vals[1]).doubleValue()); | 182 vals[1] = vals[1].replace(",", "."); |
178 } | 183 shoreOffset = new BigDecimal(vals[1]); |
179 } | 184 } |
180 catch (ParseException pe) { | 185 } |
181 log.warn("Unparseable numbers in '" + line + "'"); | 186 catch(NumberFormatException nfe) { |
187 log.warn("Unparsable number in line: " + line, nfe); | |
182 } | 188 } |
183 | 189 |
184 if (km == null || porosity == null) { | 190 if (km == null || porosity == null) { |
185 log.warn("PP: No km nor porosity given. Skip line"); | 191 log.warn("PP: No km nor porosity given. Skip line"); |
186 return; | 192 return; |