String addressInformation;
String query = matcher.group(4);
if(query != null) {
if(!query.startsWith("q=")) {
throw new NdefDecoderException("Expected address information query starting with parameter 'q', found " + query);
}
addressInformation = query.substring(2);
} else {
addressInformation = null;
}
Double latitude;
Double longitude;
Double altitude;
try {
latitude = Double.parseDouble(matcher.group(1));
if (latitude > 90.0 || latitude < -90.0) {
throw new NdefDecoderException("Expected latitude within 90 positive or negative degrees, found " + latitude + " degrees.");
}
} catch (NumberFormatException nfe) {
throw new NdefDecoderException("Expected float latitude, found '" + matcher.group(1) + "'");
}
try {
longitude = Double.parseDouble(matcher.group(2));
if (longitude > 180.0 || longitude < -180.0) {
throw new NdefDecoderException("Expected longitude within 180 positive or negative degrees, found " + longitude + " degrees.");
}
} catch (NumberFormatException nfe) {
throw new NdefDecoderException("Expected float longitude, found '" + matcher.group(2) + "'");
}
if((longitude.doubleValue() != 0.0 || latitude.doubleValue() != 0.0) && addressInformation != null) {
throw new NdefDecoderException("Expected latitude and longitude coordinates or address information, not both.");
}
if (matcher.group(3) == null) {
altitude = null;
} else {
try {
altitude = Double.parseDouble(matcher.group(3));
} catch (NumberFormatException nfe) {
throw new NdefDecoderException("Expected float altitude, found '" + matcher.group(3) + "'");
}
}
GeoRecord geoRecord = new GeoRecord();