mirror of
https://github.com/zxing/zxing.git
synced 2025-01-14 20:57:40 -08:00
Fix Issue 143, failure on invalid geo: URIs
git-svn-id: https://zxing.googlecode.com/svn/trunk@842 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
1c539c66a4
commit
089cc3ac44
|
@ -48,10 +48,10 @@ final class GeoResultParser extends ResultParser {
|
||||||
if (latitudeEnd < 0) {
|
if (latitudeEnd < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
double latitude = Double.parseDouble(geoURIWithoutQuery.substring(0, latitudeEnd));
|
|
||||||
int longitudeEnd = geoURIWithoutQuery.indexOf(',', latitudeEnd + 1);
|
int longitudeEnd = geoURIWithoutQuery.indexOf(',', latitudeEnd + 1);
|
||||||
double longitude;
|
double latitude, longitude, altitude;
|
||||||
double altitude; // in meters
|
try {
|
||||||
|
latitude = Double.parseDouble(geoURIWithoutQuery.substring(0, latitudeEnd));
|
||||||
if (longitudeEnd < 0) {
|
if (longitudeEnd < 0) {
|
||||||
longitude = Double.parseDouble(geoURIWithoutQuery.substring(latitudeEnd + 1));
|
longitude = Double.parseDouble(geoURIWithoutQuery.substring(latitudeEnd + 1));
|
||||||
altitude = 0.0;
|
altitude = 0.0;
|
||||||
|
@ -59,6 +59,9 @@ final class GeoResultParser extends ResultParser {
|
||||||
longitude = Double.parseDouble(geoURIWithoutQuery.substring(latitudeEnd + 1, longitudeEnd));
|
longitude = Double.parseDouble(geoURIWithoutQuery.substring(latitudeEnd + 1, longitudeEnd));
|
||||||
altitude = Double.parseDouble(geoURIWithoutQuery.substring(longitudeEnd + 1));
|
altitude = Double.parseDouble(geoURIWithoutQuery.substring(longitudeEnd + 1));
|
||||||
}
|
}
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new GeoParsedResult(rawText, latitude, longitude, altitude);
|
return new GeoParsedResult(rawText, latitude, longitude, altitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue