Fix gmaps geo
This commit is contained in:
parent
f81cae9a69
commit
e3ef7c1329
1 changed files with 29 additions and 5 deletions
|
@ -89,7 +89,7 @@ public class GeoPointParserUtil {
|
|||
actual = GeoPointParserUtil.parse(url);
|
||||
assertUrlEquals(url, actual.getGeoUriString());
|
||||
assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon));
|
||||
|
||||
|
||||
// geo:34.99393,-106.61568?z=11
|
||||
z = 11;
|
||||
url = "geo:" + dlat + "," + dlon + "?z=" + z;
|
||||
|
@ -201,7 +201,7 @@ public class GeoPointParserUtil {
|
|||
actual = GeoPointParserUtil.parse(url);
|
||||
assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z));
|
||||
|
||||
// http://download.osmand.net/go?lat=34.99393&lon=-106.61568&z=11
|
||||
// http://download.osmand.net/go?lat=c&lon=-106.61568&z=11
|
||||
url = "http://download.osmand.net/go?lat=" + dlat + "&lon=" + dlon + "&z=" + z;
|
||||
System.out.println("url: " + url);
|
||||
actual = GeoPointParserUtil.parse(url);
|
||||
|
@ -212,6 +212,12 @@ public class GeoPointParserUtil {
|
|||
System.out.println("url: " + url);
|
||||
actual = GeoPointParserUtil.parse(url);
|
||||
assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z));
|
||||
|
||||
// http://maps.google.com/maps?q=N34.939,E-106
|
||||
url = "http://maps.google.com/maps?q=N" + dlat + ",E" + Math.abs(dlon);
|
||||
System.out.println("url: " + url);
|
||||
actual = GeoPointParserUtil.parse(url);
|
||||
assertGeoPoint(actual, new GeoParsedPoint(dlat, -Math.abs(dlon)));
|
||||
|
||||
// http://www.osmand.net/go?lat=34.99393&lon=-106.61568&z=11
|
||||
url = "http://www.osmand.net/go.html?lat=" + dlat + "&lon=" + dlon + "&z=" + z;
|
||||
|
@ -811,7 +817,7 @@ public class GeoPointParserUtil {
|
|||
simpleDomains.add("www.openstreetmap.de");
|
||||
|
||||
|
||||
final Pattern commaSeparatedPairPattern = Pattern.compile("(?:loc:)?([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)");
|
||||
final Pattern commaSeparatedPairPattern = Pattern.compile("(?:loc:)?([N|S]?[+-]?\\d+(?:\\.\\d+)?),([E|W]?[+-]?\\d+(?:\\.\\d+)?)");
|
||||
|
||||
try {
|
||||
if (host.equals("osm.org") || host.endsWith("openstreetmap.org")) {
|
||||
|
@ -1288,12 +1294,30 @@ public class GeoPointParserUtil {
|
|||
}
|
||||
|
||||
public GeoParsedPoint(String latString, String lonString, String zoomString) throws NumberFormatException {
|
||||
this(Double.valueOf(latString), Double.valueOf(lonString));
|
||||
this(parseLat(latString), parseLon(lonString));
|
||||
this.zoom = parseZoom(zoomString);
|
||||
}
|
||||
|
||||
private static double parseLon(String lonString) {
|
||||
if(lonString.startsWith("E")) {
|
||||
return -Double.valueOf(lonString.substring(1));
|
||||
} else if(lonString.startsWith("W")) {
|
||||
return Double.valueOf(lonString.substring(1));
|
||||
}
|
||||
return Double.valueOf(lonString);
|
||||
}
|
||||
|
||||
private static double parseLat(String latString) {
|
||||
if(latString.startsWith("S")) {
|
||||
return -Double.valueOf(latString.substring(1));
|
||||
} else if(latString.startsWith("N")) {
|
||||
return Double.valueOf(latString.substring(1));
|
||||
}
|
||||
return Double.valueOf(latString);
|
||||
}
|
||||
|
||||
public GeoParsedPoint(String latString, String lonString) throws NumberFormatException {
|
||||
this(Double.valueOf(latString), Double.valueOf(lonString));
|
||||
this(parseLat(latString), parseLon(lonString));
|
||||
this.zoom = NO_ZOOM;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue