}
}
/** Sets the location Wpt properties from a raw XMP tag key-value-pair.*/
private void setGPSProperty(String key, String value) throws ParseException{
Wpt location = xmp.location;
if(key.equals("GPSAltitude")){
BigDecimal val = parseRational(key, value);
if (location.getEle() != null){
val = location.getEle().multiply(val);
}
location.setEle(val);
} else if (key.equals("GPSAltitudeRef")){
int val = Integer.parseInt(value);
switch(val){
case 0: //above sea level: nothing to do
break;
case 1: //below sea level
BigDecimal dval = new BigDecimal(-1);
if(location.getEle() == null){
location.setEle(dval);
} else {
location.setEle(dval.multiply(location.getEle()));
}
break;
default:
throw new ParseException("Illegal value " + value + " for GPSAltitudeRef.",0);
}
} else if (key.equals("GPSLatitude")){
location.setLat(parseCoordinate(key, value));
} else if (key.equals("GPSLongitude")){
location.setLon(parseCoordinate(key, value));
} else if (key.equals("GPSMapDatum")){
if(value == null || value.equals("")){
System.err.println("Warning: GPS datum missing. Assuming WGS84.");
} else if(!value.toUpperCase().replaceAll("[^0-9A-Z]", "").equals("WGS84")){
throw new ParseException("Unsupported map datum: " + value.toString() +
". Currently only the WGS84 map datum is supported.", 0);
}
} else if (key.equals("GPSVersionID")){
if(!"2.0.0.0".equals(value)){
throw new ParseException("Unsupported GPSVersionID: " + value,0);
}
} else if (key.equals("GPSTimeStamp")){
location.setTime(parseDate(value).getTime());
}
}