Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/CrossSectionArtifact.java @ 6936:332d2dfa783f
issue1460: prevent NPEs when backstepping and changing Q values for WINFO
projects.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 28 Aug 2013 11:22:40 +0200 |
parents | 4930ea445bdd |
children | 8d5ca5175038 |
comparison
equal
deleted
inserted
replaced
6933:468d9ebda4ce | 6936:332d2dfa783f |
---|---|
133 List<CrossSectionLine> csls = cs.getLines(); | 133 List<CrossSectionLine> csls = cs.getLines(); |
134 if (!csls.isEmpty()) { | 134 if (!csls.isEmpty()) { |
135 CrossSectionLine csl = csls.get(0); | 135 CrossSectionLine csl = csls.get(0); |
136 // Find min-km of cross sections, | 136 // Find min-km of cross sections, |
137 // then set DATA_KM to min(DATA_KM, minCross). | 137 // then set DATA_KM to min(DATA_KM, minCross). |
138 double dataKm = Double.valueOf(getDataAsString(DATA_KM)); | 138 String dataKmValue = getDataAsString(DATA_KM); |
139 double dataKm = (dataKmValue != null) ? Double.valueOf(dataKmValue) : Double.MIN_VALUE; | |
139 if (dataKm < csl.getKm().doubleValue()) { | 140 if (dataKm < csl.getKm().doubleValue()) { |
140 addStringData(DATA_KM, csl.getKm().toString()); | 141 addStringData(DATA_KM, csl.getKm().toString()); |
141 } | 142 } |
142 } | 143 } |
143 fs.add(new CrossSectionFacet(0, cs.getDescription())); | 144 fs.add(new CrossSectionFacet(0, cs.getDescription())); |
246 /** | 247 /** |
247 * Return position (km) from parent (initial km), 0 if not found. | 248 * Return position (km) from parent (initial km), 0 if not found. |
248 */ | 249 */ |
249 private double getParentKm() { | 250 private double getParentKm() { |
250 String val = getDataAsString(PARENT_KM); | 251 String val = getDataAsString(PARENT_KM); |
252 if (val == null) { | |
253 logger.warn("Empty data: " + PARENT_KM); | |
254 return 0; | |
255 } | |
251 try { | 256 try { |
252 return Double.valueOf(val); | 257 return Double.valueOf(val); |
253 } | 258 } |
254 catch (NumberFormatException e) { | 259 catch (NumberFormatException e) { |
255 logger.warn("Could not get data " + PARENT_KM + " as double", e); | 260 logger.warn("Could not get data " + PARENT_KM + " as double", e); |