more readable error if geo coordinates do not parse
@@ -73,10 +73,18 @@ public final class PositionDataType {
DegreesParser d = new DegreesParser(str);
return valueOf((int)(d.longitude * 1000000), (int)(d.latitude * 1000000));
} catch (IllegalArgumentException e) {
+ try {
+ String[] arr = str.split(";");
+ if (arr.length == 2) {
+ int x = Integer.parseInt(arr[0]);
+ int y = Integer.parseInt(arr[1]);
+ return valueOf(x, y);
+ }
+ } catch (NumberFormatException nfe) {
// empty
}
- String[] arr = str.split(";", 2);
- return valueOf(Integer.parseInt(arr[0]), Integer.parseInt(arr[1]));
+ throw new IllegalArgumentException("Could not parse '"+str+"' as geo coordinates: "+e.getMessage());
+ }
}
public static IntegerFieldValue getXValue(FieldValue pos) {
