diff --git a/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java b/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java index c170c8c4f6..322cf18932 100644 --- a/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java +++ b/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java @@ -172,6 +172,22 @@ public class GeoPointParserUtil { actual = GeoPointParserUtil.parse(url); assertApproximateGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + // http://osm.org/go/TyFYuF6P~~-?m // current shortlink format with "~" + // https://www.openstreetmap.org/?mlat=34.993933029174805&mlon=-106.61568069458008#map=15/34.99393/-106.61568 + z = 20; + url = "http://osm.org/go/TyFYuF6P~~-?m"; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse(url); + assertApproximateGeoPoint(actual, new GeoParsedPoint(longLat, longLon, z)); + + // http://osm.org/go/TyFYuF6P@@--?m= // old, deprecated shortlink format with "@" + // https://www.openstreetmap.org/?mlat=34.993933029174805&mlon=-106.61568069458008#map=15/34.99393/-106.61568 + z = 21; + url = "http://osm.org/go/TyFYuF6P@@--?m="; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse(url); + assertApproximateGeoPoint(actual, new GeoParsedPoint(longLat, longLon, z)); + // http://openstreetmap.de/zoom=11&lat=34&lon=-106 z = 11; url = "http://openstreetmap.de/zoom=" + z + "&lat=" + ilat + "&lon=" + ilon; @@ -355,6 +371,10 @@ public class GeoPointParserUtil { "http://osm.org/go/0LQ127-?m", "http://osm.org/go/0EEQjE==", "http://osm.org/go/0EEQjEEb", + "http://osm.org/go/0EE~jEEb", + "http://osm.org/go/0EE@jEEb", + "http://osm.org/go/~~~~", + "http://osm.org/go/@@@@", "https://www.openstreetmap.org/#map=0/0/0", "https://www.openstreetmap.org/#map=0/180/180", "https://www.openstreetmap.org/#map=0/-180/-180", diff --git a/OsmAnd-java/src/net/osmand/util/MapUtils.java b/OsmAnd-java/src/net/osmand/util/MapUtils.java index 38d2f179eb..f9855eebd3 100644 --- a/OsmAnd-java/src/net/osmand/util/MapUtils.java +++ b/OsmAnd-java/src/net/osmand/util/MapUtils.java @@ -35,7 +35,7 @@ public class MapUtils { 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_', '@' + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_', '~' }; public static double getDistance(LatLon l, double latitude, double longitude){ @@ -308,6 +308,8 @@ public class MapUtils { } public static GeoParsedPoint decodeShortLinkString(String s) { + // convert old shortlink format to current one + s = s.replaceAll("@", "~"); int i = 0; long x = 0; long y = 0;