Fixed NumberFormatException for empty string. However, maybe the element should not be processed at all if value is just empty string or just spaces.

This commit is contained in:
Victor Shcherb 2011-08-16 12:52:36 +03:00
parent 1ef6087e5c
commit f53c9a4acf

View file

@ -345,12 +345,17 @@ public class OsmDbAccessor implements OsmDbAccessorContext {
}
if (key.charAt(0) == '0') {
assertToken(ArraySerializer.ELEMENT, tokenizer.next(), value);
double lat = Double.parseDouble(tokenizer.value());
assertToken(ArraySerializer.ELEMENT, tokenizer.next(), value);
double lon = Double.parseDouble(tokenizer.value());
((Node)e).setLatitude(lat);
((Node)e).setLongitude(lon);
try {
assertToken(ArraySerializer.ELEMENT, tokenizer.next(), value);
double lat = Double.parseDouble(tokenizer.value());
assertToken(ArraySerializer.ELEMENT, tokenizer.next(), value);
double lon = Double.parseDouble(tokenizer.value());
((Node)e).setLatitude(lat);
((Node)e).setLongitude(lon);
} catch (java.lang.NumberFormatException ex) {
log.warn("Cannot parse lat/log for Node with key:" + key + " value:" + value);
e = null;
}
} else if (key.charAt(0) == '1') {
assertToken(ArraySerializer.START_ARRAY, tokenizer.next(), value);
int n = tokenizer.next();