diff --git a/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java b/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java index 26b0a947e2..2bb5216ba4 100644 --- a/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java +++ b/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java @@ -7,71 +7,71 @@ import java.util.regex.Pattern; public class GeoPointParserUtil { public static void main(String[] args) { - final double lat = 34.99, lon = -106.61; + final int ilat = 34, ilon = -106; + final double dlat = 34.99, dlon = -106.61; final String name = "Treasure Island"; int z = GeoParsedPoint.NO_ZOOM; String url; - // geo:34.99,-106.61 - url = "geo:" + lat + "," + lon; + // geo:34,-106 + url = "geo:" + ilat + "," + ilon; System.out.println("url: " + url); GeoParsedPoint actual = GeoPointParserUtil.parse("geo", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon)); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon)); + + // geo:34.99,-106.61 + url = "geo:" + dlat + "," + dlon; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("geo", url); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon)); // geo:34.99,-106.61?z=11 z = 11; - url = "geo:" + lat + "," + lon + "?z=" + z; + url = "geo:" + dlat + "," + dlon + "?z=" + z; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("geo", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); // geo:34.99,-106.61 (Treasure Island) - url = "geo:" + lat + "," + lon + " (" + name + ")"; + url = "geo:" + dlat + "," + dlon + " (" + name + ")"; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("geo", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, name)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, name)); // geo:34.99,-106.61?z=11 (Treasure Island) z = 11; - url = "geo:" + lat + "," + lon + "?z=" + z + " (" + name + ")"; + url = "geo:" + dlat + "," + dlon + "?z=" + z + " (" + name + ")"; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("geo", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z, name)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z, name)); + + // 0,0?q=34,-106(Treasure Island) + z = GeoParsedPoint.NO_ZOOM; + url = "geo:0,0?q=" + ilat + "," + ilon + " (" + name + ")"; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("geo", url); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z, name)); // 0,0?q=34.99,-106.61(Treasure Island) z = GeoParsedPoint.NO_ZOOM; - url = "geo:0,0?q=" + lat + "," + lon + " (" + name + ")"; + url = "geo:0,0?q=" + dlat + "," + dlon + " (" + name + ")"; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("geo", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z, name)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z, name)); // geo:0,0?z=11&q=34.99,-106.61(Treasure Island) z = 11; - url = "geo:0,0?z=" + z + "&q=" + lat + "," + lon + " (" + name + ")"; + url = "geo:0,0?z=" + z + "&q=" + dlat + "," + dlon + " (" + name + ")"; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("geo", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z, name)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z, name)); // geo:0,0?z=11&q=34.99,-106.61 z = 11; - url = "geo:0,0?z=" + z + "&q=" + lat + "," + lon; + url = "geo:0,0?z=" + z + "&q=" + dlat + "," + dlon; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("geo", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); - - // geo:34.99,-106.61 - z = -1; - url = "geo:" + lat + "," + lon; - System.out.println("url: " + url); - actual = GeoPointParserUtil.parse("geo", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); - - // geo:34.99,-106.61?z=11 - z = 11; - url = "geo:" + lat + "," + lon + "?" + "z=" + z; - System.out.println("url: " + url); - actual = GeoPointParserUtil.parse("geo", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); // google calendar // geo:0,0?q=760 West Genesee Street Syracuse NY 13204 @@ -88,82 +88,153 @@ public class GeoPointParserUtil { actual = GeoPointParserUtil.parse("geo", url); assertGeoPoint(actual, new GeoParsedPoint(qstr)); - // http://download.osmand.net/go?lat=34.99&lon=-106.61&z=11 - url = "http://download.osmand.net/go?lat=" + lat + "&lon=" + lon + "&z=" + z; + // http://download.osmand.net/go?lat=34&lon=-106&z=11 + url = "http://download.osmand.net/go?lat=" + ilat + "&lon=" + ilon + "&z=" + z; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); + + // http://download.osmand.net/go?lat=34.99&lon=-106.61&z=11 + url = "http://download.osmand.net/go?lat=" + dlat + "&lon=" + dlon + "&z=" + z; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + + // http://openstreetmap.org/map=11/34/-106 + url = "http://openstreetmap.org/map=" + z + "/" + ilat + "/" + ilon; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); // http://openstreetmap.org/map=11/34.99/-106.61 - url = "http://openstreetmap.org/map=" + z + "/" + lat + "/" + lon; + url = "http://openstreetmap.org/map=" + z + "/" + dlat + "/" + dlon; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + + // http://openstreetmap.de/zoom=11&lat=34&lon=-106 + url = "http://openstreetmap.de/zoom=" + z + "&lat=" + ilat + "&lon=" + ilon; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); // http://openstreetmap.de/zoom=11&lat=34.99&lon=-106.61 - url = "http://openstreetmap.de/zoom=" + z + "&lat=" + lat + "&lon=" + lon; + url = "http://openstreetmap.de/zoom=" + z + "&lat=" + dlat + "&lon=" + dlon; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); // http://openstreetmap.de/lat=34.99&lon=-106.61&zoom=11 - url = "http://openstreetmap.de/lat=" + lat + "&lon=" + lon + "&zoom=" + z; + url = "http://openstreetmap.de/lat=" + dlat + "&lon=" + dlon + "&zoom=" + z; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + + // http://maps.google.com/maps/@34,-106,11z + url = "http://maps.google.com/maps/@" + ilat + "," + ilon + "," + z + "z"; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); // http://maps.google.com/maps/@34.99,-106.61,11z - url = "http://maps.google.com/maps/@" + lat + "," + lon + "," + z + "z"; + url = "http://maps.google.com/maps/@" + dlat + "," + dlon + "," + z + "z"; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + + // http://maps.google.com/maps/ll=34,-106,z=11 + url = "http://maps.google.com/maps/ll=" + ilat + "," + ilon + ",z=" + z; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); // http://maps.google.com/maps/ll=34.99,-106.61,z=11 - url = "http://maps.google.com/maps/ll=" + lat + "," + lon + ",z=" + z; + url = "http://maps.google.com/maps/ll=" + dlat + "," + dlon + ",z=" + z; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + + // http://maps.google.com/maps/q=loc:34,-106&z=11 + url = "http://maps.google.com/maps/q=loc:" + ilat + "," + ilon + "&z=" + z; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); // http://maps.google.com/maps/q=loc:34.99,-106.61&z=11 - url = "http://maps.google.com/maps/q=loc:" + lat + "," + lon + "&z=" + z; + url = "http://maps.google.com/maps/q=loc:" + dlat + "," + dlon + "&z=" + z; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + + // whatsapp + // http://maps.google.com/maps/q=loc:34,-106 (You) + z = GeoParsedPoint.NO_ZOOM; + url = "http://maps.google.com/maps/q=loc:" + ilat + "," + ilon + " (You)"; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); // whatsapp // http://maps.google.com/maps/q=loc:34.99,-106.61 (You) z = GeoParsedPoint.NO_ZOOM; - url = "http://maps.google.com/maps/q=loc:" + lat + "," + lon + " (You)"; + url = "http://maps.google.com/maps/q=loc:" + dlat + "," + dlon + " (You)"; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + + // http://www.google.com/maps/search/food/34,-106,14z + url = "http://www.google.com/maps/search/food/" + ilat + "," + ilon + "," + z + "z"; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); // http://www.google.com/maps/search/food/34.99,-106.61,14z - url = "http://www.google.com/maps/search/food/" + lat + "," + lon + "," + z + "z"; + url = "http://www.google.com/maps/search/food/" + dlat + "," + dlon + "," + z + "z"; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + + // http://maps.google.com?saddr=Current+Location&daddr=34,-106 + z = GeoParsedPoint.NO_ZOOM; + url = "http://maps.google.com?saddr=Current+Location&daddr=" + ilat + "," + ilon; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); // http://maps.google.com?saddr=Current+Location&daddr=34.99,-106.61 z = GeoParsedPoint.NO_ZOOM; - url = "http://maps.google.com?saddr=Current+Location&daddr=" + lat + "," + lon; + url = "http://maps.google.com?saddr=Current+Location&daddr=" + dlat + "," + dlon; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + + // http://www.google.com/maps/dir/Current+Location/34,-106 + z = GeoParsedPoint.NO_ZOOM; + url = "http://www.google.com/maps/dir/Current+Location/" + ilat + "," + ilon; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); // http://www.google.com/maps/dir/Current+Location/34.99,-106.61 z = GeoParsedPoint.NO_ZOOM; - url = "http://www.google.com/maps/dir/Current+Location/" + lat + "," + lon; + url = "http://www.google.com/maps/dir/Current+Location/" + dlat + "," + dlon; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + + // http://maps.google.com/maps?q=34,-106 + z = GeoParsedPoint.NO_ZOOM; + url = "http://maps.google.com/maps?q=" + ilat + "," + ilon; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); // http://maps.google.com/maps?q=34.99,-106.61 z = GeoParsedPoint.NO_ZOOM; - url = "http://maps.google.com/maps?q=" + lat + "," + lon; + url = "http://maps.google.com/maps?q=" + dlat + "," + dlon; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); // http://www.google.com/maps/place/760+West+Genesee+Street+Syracuse+NY+13204 qstr = "760+West+Genesee+Street+Syracuse+NY+13204"; @@ -193,13 +264,19 @@ public class GeoPointParserUtil { actual = GeoPointParserUtil.parse("http", url); assertGeoPoint(actual, new GeoParsedPoint(qstr)); - // http://maps.yandex.ru/?ll=34.99,-106.61&z=11 + // http://maps.yandex.ru/?ll=34,-106&z=11 z = 11; - url = "http://maps.yandex.ru/?ll=" + lat + "," + lon + "&z=" + z; + url = "http://maps.yandex.ru/?ll=" + ilat + "," + ilon + "&z=" + z; System.out.println("url: " + url); actual = GeoPointParserUtil.parse("http", url); - assertGeoPoint(actual, new GeoParsedPoint(lat, lon, z)); + assertGeoPoint(actual, new GeoParsedPoint(ilat, ilon, z)); + // http://maps.yandex.ru/?ll=34.99,-106.61&z=11 + z = 11; + url = "http://maps.yandex.ru/?ll=" + dlat + "," + dlon + "&z=" + z; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse("http", url); + assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); } private static void assertGeoPoint(GeoParsedPoint actual, GeoParsedPoint expected) { @@ -265,32 +342,33 @@ public class GeoPointParserUtil { final String[] osmandNetSite = { "//download.osmand.net/go?" }; - final String[] osmandNetPattern = { "lat=(-?\\d{1,3}\\.\\d+)&lon=(-?\\d{1,3}\\.\\d+)&z=(\\d{1,2})" }; + final String[] osmandNetPattern = { "lat=([+-]?\\d+(?:\\.\\d+)?)&lon=([+-]?\\d+(?:\\.\\d+)?)&?(z=\\d{1,2})" }; final String[] openstreetmapOrgSite = { "//openstreetmap.org/", "//www.openstreetmap.org/" }; - final String[] openstreetmapOrgPattern = { "(?:.*)(?:map=)(\\d{1,2})/(-?\\d{1,3}\\.\\d+)/(-?\\d{1,3}\\.\\d+)(?:.*)" }; + final String[] openstreetmapOrgPattern = { "(?:.*)(?:map=)(\\d{1,2})/([+-]?\\d+(?:\\.\\d+)?)/([+-]?\\d+(?:\\.\\d+)?)(?:.*)" }; final String[] openstreetmapDeSite = { "//openstreetmap.de/", "//www.openstreetmap.de/" }; final String[] openstreetmapDePattern = { - "(?:.*)zoom=(\\d{1,2})&lat=(-?\\d{1,3}\\.\\d+)&lon=(-?\\d{1,3}\\.\\d+)(?:.*)", - "(?:.*)lat=(-?\\d{1,3}\\.\\d+)&lon=(-?\\d{1,3}\\.\\d+)&z(?:oom)?=(\\d{1,2})(?:.*)" }; + "(?:.*)zoom=(\\d{1,2})&lat=([+-]?\\d+(?:\\.\\d+)?)&lon=([+-]?\\d+(?:\\.\\d+)?)(?:.*)", + "(?:.*)lat=([+-]?\\d+(?:\\.\\d+)?)&lon=([+-]?\\d+(?:\\.\\d+)?)&?(z(?:oom)?=\\d{1,2})(?:.*)" }; final String[] googleComSite = { "//www.google.com/maps/", "//maps.google.com/maps", "//maps.google.com" }; - final String[] googleComPattern = { "(?:.*)[@/](-?\\d{1,3}\\.\\d+),(-?\\d{1,3}\\.\\d+),(\\d{1,2})z(?:.*)", - "(?:.*)ll=(-?\\d{1,3}\\.\\d+),(-?\\d{1,3}\\.\\d+)(?:.+)z=(\\d{1,2})(?:.*)", - "(?:.*)q=([\\-+]?\\d{1,3}\\.\\d+),([\\-+]?\\d{1,3}\\.\\d+)(?:.*)&z=(\\d{1,2})", - "(?:.*)(q=)(-?\\d{1,3}\\.\\d+),(-?\\d{1,3}\\.\\d+)(?:.*)", - "(?:.*)q=loc:(-?\\d{1,3}\\.\\d+),(-?\\d{1,3}\\.\\d+)&z=(\\d{1,2})(?:.*)", - "(?:.*)(q=loc:)(-?\\d{1,3}\\.\\d+),(-?\\d{1,3}\\.\\d+)(?:.*)", - "(.*)daddr=(-?\\d{1,3}\\.\\d+),(-?\\d{1,3}\\.\\d+)(?:.*)", - "(.*)/(-?\\d{1,3}\\.\\d+),(-?\\d{1,3}\\.\\d+)(?:.*)" }; + final String[] googleComPattern = { + "(?:.*)[@/]([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?),(\\d{1,2}z)(?:.*)", + "(?:.*)ll=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:.+)(z=\\d{1,2})(?:.*)", + "(?:.*)q=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:.*)&?(z=\\d{1,2})", + "(?:.*)(q=)([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:.*)", + "(?:.*)q=loc:([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)&?(z=\\d{1,2})(?:.*)", + "(?:.*)(q=loc:)([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:.*)", + "(.*)daddr=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:.*)", + "(.*)/([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:.*)" }; final String[] yandexRuSite = { "//maps.yandex.ru/" }; - final String[] yandexRuPattern = { "(?:.*)ll=(-?\\d{1,3}.\\d+),(-?\\d{1,3}.\\d+)(?:.+)z=(\\d{1,2})(?:.*)" }; + final String[] yandexRuPattern = { "(?:.*)ll=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:.+)(z=\\d{1,2})(?:.*)" }; final String sites[][] = { osmandNetSite, openstreetmapOrgSite, openstreetmapDeSite, googleComSite, yandexRuSite }; @@ -318,10 +396,19 @@ public class GeoPointParserUtil { int zoom; // check sequence of values - if (!matcher.group(3).contains(".")) { + if (matcher.group(3).contains("z=")) { lat = Double.valueOf(matcher.group(1)); lon = Double.valueOf(matcher.group(2)); - zoom = Integer.valueOf(matcher.group(3)); + zoom = Integer.valueOf(matcher.group(3).substring("z=".length())); + } else if (matcher.group(3).contains("zoom=")) { + lat = Double.valueOf(matcher.group(1)); + lon = Double.valueOf(matcher.group(2)); + zoom = Integer.valueOf(matcher.group(3).substring("zoom=".length())); + } else if (matcher.group(3).contains("z")) { + lat = Double.valueOf(matcher.group(1)); + lon = Double.valueOf(matcher.group(2)); + zoom = Integer.valueOf(matcher.group(3).substring(0, + matcher.group(3).length() - 1)); } else { lat = Double.valueOf(matcher.group(2)); lon = Double.valueOf(matcher.group(3)); @@ -364,7 +451,7 @@ public class GeoPointParserUtil { // geo:0,0?q=34.99,-106.61(Treasure Island) // geo:0,0?z=11&q=34.99,-106.61(Treasure Island) String query = schemeSpecific.substring("0,0?".length()); - final String pattern = "(?:z=([0-9]{1,2}))?&?q=([\\-0-9\\.]+)?,([\\-0-9\\.]+)?[\\+]*(?:\\((.+?)\\))?"; + final String pattern = "(?:z=(\\d{1,2}))?&?q=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)[\\+]?(?:\\((.+?)\\))?"; final Matcher matcher = Pattern.compile(pattern).matcher(query); if (matcher.matches()) { final String z = matcher.group(1); @@ -382,7 +469,7 @@ public class GeoPointParserUtil { } else { // geo:47.6,-122.3 // geo:47.6,-122.3?z=11 (Treasure Island) - final String pattern = "([\\-\\d{1,2}\\.\\d]+),([\\-\\d{1,3}\\.\\d]+)(?:\\?z=(\\d{1,2}))?[\\+]?(?:\\((.*?)\\))?"; + final String pattern = "([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:\\?z=(\\d{1,2}))?[\\+]?(?:\\((.*?)\\))?"; final Matcher matcher = Pattern.compile(pattern).matcher(schemeSpecific); if (matcher.matches()) { final double lat = Double.valueOf(matcher.group(1)); diff --git a/OsmAnd/res/values-be/strings.xml b/OsmAnd/res/values-be/strings.xml index aaca49e593..e9085d99fe 100644 --- a/OsmAnd/res/values-be/strings.xml +++ b/OsmAnd/res/values-be/strings.xml @@ -1,4 +1,4 @@ - + Без аўтаматычнага масштабіраваньня Зачыніць Для сярэдняга масштаба @@ -1937,9 +1937,9 @@ OsmAnd мае адкрыты зыходны код і актыўна разві Больш... Усе Кропкі шляху - Перашкоды - Абвяшчаць выбраныя - Абвяшчаць POI + Дарожныя папярэджаньні + Абвяшчаць выбраныя паблізу + Абвяшчаць POI паблізу Цэлі Усе Паездкі diff --git a/OsmAnd/res/values-ca/strings.xml b/OsmAnd/res/values-ca/strings.xml index ff15294d93..730c265ad3 100644 --- a/OsmAnd/res/values-ca/strings.xml +++ b/OsmAnd/res/values-ca/strings.xml @@ -856,7 +856,7 @@ \n\nLa caixa de diàleg s\'amaga altre cop prement i aguantant dins seu. "OsmAnd és una aplicació de navegació amb moltes funcionalitats. -\n\nEs disposa d\'una introducció bàsica, de consells d\'ús i d\'una ajuda avançada via «Menú» → «Ajuda» des la pantalla del mapa. " +\n\nEs disposa d\'una introducció bàsica, de consells d\'ús i de trucs via «Menú» → «Ajuda» des la pantalla del mapa. " Comparteix l\'ubicació usant Format de mapa discontinuat «{0}» no esta suportat Selecciona el màxim zoom per precarregar @@ -1870,7 +1870,7 @@ La llista de països inclosos (bàsicament tot el món!): Afganistan, Albània, Totes Fites Destinacions - Obstacles + Notificacions de tràfic Indica els preferits Indica els PDI Itineraris diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml index 2fb378b79a..fe34624220 100644 --- a/OsmAnd/res/values-da/strings.xml +++ b/OsmAnd/res/values-da/strings.xml @@ -1964,7 +1964,7 @@ Afghanistan, Albanien, Algeriet, Andorra, Angola, Anguilla, Antigua og Barbuda, Alle Rutepunkter Destinationer - Forhindringer + Trafikadvarsler Favoritter Interessepunkt (IP) Alle diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index c4236d09fd..47f4bb0602 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -1,5 +1,7 @@ - + + Nahegelegene Favoriten ankündigen + Nahegelegene POI ankündigen Navigation starten Die Route zu einem Ziel erhält man entweder durch direktes lang-anklicken eines Punktes in der Karte, (dann Kurzklick auf den Positionsmarker und das Auswählen des Menüpunktes \'Navigiere zu\'), oder über die Funktion \'Navigiere zu\' bei Klick auf ein Ergebnis einer Such-Liste oder einen Favoriten. \n\nDer Zielpunkt wird als orangefarbener Punkt auf der Karte markiert. Zu einem gewählten Ziel zeigt OsmAnd auf der Karte die Entfernung und die Richtung (orangefarbenes Dreieck) an. @@ -1448,7 +1450,7 @@ Höchstgeschwindigkeit ansagen Blitzer ansagen - Verkehrsmeldungen ansagen + Verkehrswarnungen ansagen Bitte OSM-Nutzername und Passwort in den Einstellungen eingeben Zwischenziele löschen Zwischenziele behalten @@ -1963,9 +1965,7 @@ Afghanistan, Ägypten, Albanien, Algerien, Andorra, Angola, Anguilla, Antigua an Alle Wegpunkte Ziele - Hindernisse - Favoriten ankündigen - POI ankündigen + Verkehrswarnungen Speichern Sie Ihre Tracks mit einem Klick. Zeigt die Einstellung, wie Strecken aufgezeichnet werden – in lokale GPX-Dateien oder online via Web-Service. diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 2983b16572..b72b4af2d0 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -1803,9 +1803,9 @@ Afghanistan, Albanie, Algérie, Allemagne, Andorre, Angola, Anguilla, Antigua-et Tous Points de cheminement Destinations - Obstacles - Annoncer les favoris - Annoncer les points d\'intérêt + Alertes de circulation + Annoncer les favoris proches + Annoncer les points d\'intérêt proches Tous Tours Enregistrer vos traces en touchant le bouton de l\'écran principal. Monter les paramètres pour l\'enregistrement des traces dans des fichiers GPX locaux ou en ligne avec un service Web. diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index baf91c41a1..4f0a322325 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -1740,9 +1740,9 @@ Összes Útpontok Úti célok - Akadályok - Kedvenc helyek - Érdekes helyek (POI) + Forgalmi figyelmeztetések + Közeli kedvenc helyek + Közeli érdekes helyek (POI) Letöltöd a hiányzó térképeket %1$s (%2$d MB)? Térképböngészés Autó diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index a6eca53ebe..866a15a42c 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -388,15 +388,13 @@ \n\nJe kan een ander startpunt kiezen door het punt te selecteren op de kaart en \'Aanwijzingen vanaf\' te kiezen. Met navigatie wordt de route dan automatisch opnieuw berekend zodra je echte positie bekend is. Zo kan je snel starten op een plaats zonder GPS-ontvangst. Als je \'Toon route\' kiest wordt de route niet herberekend. Zoeken - \tJe kan direct op de kaart naar plaatsen zoeken of zoeken naar een locatie (\'Kaartcontextmenu\' → \'Zoek hier dichtbij\'), of met het zoekscherm met \'Menu\' → \'Zoeken\'. - \n\nOp het zoekscherm kan je zoeken: - \n\t* op adres - \n\t* op coördinaten - \n\t* interessepunten (op categorie of op naam) - \n\t* uit de zoekgeschiedenis - \n\t* in de favorieten -Kies daarna om er heen te navigeren, op de kaart te tonen, aan een route of de favorieten toe te voegen. - + "Je kan direct op de kaart naar plaatsen zoeken of zoeken naar een locatie (\'Kaartcontextmenu\' → \'Zoek hier dichtbij\'), of met het zoekscherm met \'Menu\' → \'Zoeken\'. +\n\nOp het zoekscherm kan je zoeken: +\n\t* op adres +\n\t* op coördinaten +\n\t* interessepunten (op categorie of op naam) +\n\t* uit de zoekgeschiedenis +\n\t* in de favorieten\n\nKies daarna om er heen te navigeren, op de kaart te tonen, of aan een route of de favorieten toe te voegen. " Menu \'Gebruik locatie\' \tHet contextmenu op de kaart biedt alle acties die te maken hebben met een punt op de kaart. \n\nHet wordt getoond als je (lang) op een punt op de kaart drukt en dan op de markering tikt, of door op de trackball-knop te drukken, of via \'Menu\' → \'Gebruik locatie\'. @@ -404,7 +402,7 @@ Kies daarna om er heen te navigeren, op de kaart te tonen, aan een route of de f \n\tEen markering kan worden gesloten door er lang op te drukken. Help - "OsmAnd is een navigatieprogramma met vele mogelijkheden.\n\nEen inleiding, tips en uitgebreide hulp zijn te vinden onder \'Menu\' → \'Help\', in het kaartscherm. " + "OsmAnd is een navigatieprogramma met vele mogelijkheden.\n\nEen inleiding, tips en hulp zijn te vinden onder \'Menu\' → \'Help\', in het kaartscherm. " Volgende Vorige Wijzig eenheden van afstand en snelheid @@ -1947,7 +1945,7 @@ Afghanistan, Albanie, Algerije, Andorra, Angola, Anguilla, Antigua en Barbuda, A alle Routepunt(en) Bestemming(en) - Obstakel(s) + Filemeldingen Meld favorieten Meld interessepunt (POI) Alle diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index 50c03f5eee..be8c9708fa 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -1715,7 +1715,7 @@ Si cussigiat de annànghere unu o prus puntos intermedios pro megiorare sas pres Totus Puntos mesanos Destinatziones - Impèigos + Avisos de tràficu Annùntzia Prefèrridos Annùntzia PDI Totus diff --git a/OsmAnd/res/values-sv/strings.xml b/OsmAnd/res/values-sv/strings.xml index f34500d511..f7fc326946 100644 --- a/OsmAnd/res/values-sv/strings.xml +++ b/OsmAnd/res/values-sv/strings.xml @@ -623,7 +623,7 @@ Byt destination Du har redan en angiven destination. Waypoint %1$s - Vägpunkter + Waypoints Waypointen %1$s för långt från närmaste väg. Du har anlänt till din waypoint Lägg till som waypoint @@ -1671,7 +1671,7 @@ Alla Waypoints Mål - Hinder + Trafikskyltar Meddela favoriter Meddela POI Rundturer diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index d554699826..8fdd09e7c8 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,9 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Announce nearby Favorites + Announce nearby POI + Traffic warnings Navigation To get directions to a place, either directly long-click on it on the map, (then tap its description marker and select \'Directions to\'), or select \'Directions to\' after tapping any entry in a search results list or favorite list. \n\nThe destination is marked as a target flag marker on the map and OsmAnd displays the distance to it and the direction to it (orange triangle). @@ -63,9 +66,6 @@ All Waypoints Destinations - Obstacles - Announce Favorites - Announce POI Announce GPX waypoints Download missing maps %1$s (%2$d MB)? More... diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index a9d7dfc82e..342922a2c7 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -825,7 +825,7 @@ public class OsmandSettings { public final OsmandPreference ANNOUNCE_NEARBY_POI = new BooleanPreference("announce_nearby_poi", false).makeProfile().cache(); public final OsmandPreference SHOW_WPT = new BooleanPreference("show_gpx_wpt", true).makeGlobal().cache(); public final OsmandPreference SHOW_NEARBY_POI = new BooleanPreference("show_nearby_poi", false).makeGlobal().cache(); - public final OsmandPreference SHOW_NEARBY_FAVORIES = new BooleanPreference("show_nearby_favorites", false).makeGlobal().cache(); + public final OsmandPreference SHOW_NEARBY_FAVORITES = new BooleanPreference("show_nearby_favorites", false).makeGlobal().cache(); public final OsmandPreference AVOID_TOLL_ROADS = new BooleanPreference("avoid_toll_roads", false).makeProfile().cache(); public final OsmandPreference AVOID_MOTORWAY = new BooleanPreference("avoid_motorway", false).makeProfile().cache(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index be51b03601..d1f03e911b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -237,13 +237,13 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { settings.SHOW_CAMERAS, settings.SHOW_LANES }, preference.getTitle()); return true; } else if (preference == speakAlarms) { - showBooleanSettings(new String[] { getString(R.string.speak_street_names), getString(R.string.speak_traffic_warnings), getString(R.string.speak_cameras), - getString(R.string.speak_speed_limit), + showBooleanSettings(new String[] { getString(R.string.speak_street_names), getString(R.string.speak_traffic_warnings), + getString(R.string.speak_speed_limit), getString(R.string.speak_cameras), getString(R.string.speak_favorites), getString(R.string.speak_poi), getString(R.string.announce_gpx_waypoints)}, new OsmandPreference[] { settings.SPEAK_STREET_NAMES, settings.SPEAK_TRAFFIC_WARNINGS, - settings.SPEAK_SPEED_CAMERA , settings.SPEAK_SPEED_LIMIT, + settings.SPEAK_SPEED_LIMIT, settings.SPEAK_SPEED_CAMERA, settings.ANNOUNCE_NEARBY_FAVORITES, settings.ANNOUNCE_NEARBY_POI, settings.ANNOUNCE_WPT}, preference.getTitle()); return true; } diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java index 3119531c8d..3980c00fbb 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java @@ -46,6 +46,7 @@ public class WaypointHelper { private int searchDeviationRadius = 500; private static final int LONG_ANNOUNCE_RADIUS = 700; private static final int SHORT_ANNOUNCE_RADIUS = 150; + private static final int ALARMS_ANNOUNCE_RADIUS = 150; OsmandApplication app; // every time we modify this collection, we change the reference (copy on write list) @@ -193,13 +194,17 @@ public class WaypointHelper { public void enableWaypointType(int type, boolean enable) { if(type == ALARMS) { + app.getSettings().SHOW_TRAFFIC_WARNINGS.set(enable); app.getSettings().SPEAK_TRAFFIC_WARNINGS.set(enable); } else if(type == POI) { app.getSettings().SHOW_NEARBY_POI.set(enable); + app.getSettings().ANNOUNCE_NEARBY_POI.set(enable); } else if(type == FAVORITES) { - app.getSettings().SHOW_NEARBY_FAVORIES.set(enable); + app.getSettings().SHOW_NEARBY_FAVORITES.set(enable); + app.getSettings().ANNOUNCE_NEARBY_FAVORITES.set(enable); } else if(type == WAYPOINTS) { app.getSettings().SHOW_WPT.set(enable); + app.getSettings().ANNOUNCE_WPT.set(enable); } recalculatePoints(route, type, locationPoints); } @@ -221,13 +226,37 @@ public class WaypointHelper { public boolean isTypeEnabled(int type) { if(type == ALARMS) { - return showAlarms(); - } else if(type == POI) { - return showPOI(); - } else if(type == FAVORITES) { - return showFavorites(); - } else if(type == WAYPOINTS) { - return showGPXWaypoints(); + return showAlarms() || announceAlarms(); + } else if (type == POI) { + //sync SHOW (which has no item in nav settings) to automatically load points in the dialogue + if (announcePOI()) { + app.getSettings().SHOW_NEARBY_POI.set(true); + } else { + app.getSettings().SHOW_NEARBY_POI.set(false); + } + //no SHOW item in nav settings, hence only query ANNOUNCE here (makes inital Waypoint dialogue consistent with nav settings) + //return showPOI() || announcePOI(); + return announcePOI(); + } else if (type == FAVORITES) { + //sync SHOW (which has no item in nav settings) to automatically load points in the dialogue + if (announceFavorites()) { + app.getSettings().SHOW_NEARBY_FAVORITES.set(true); + } else { + app.getSettings().SHOW_NEARBY_FAVORITES.set(false); + } + //no SHOW item in nav settings, hence only query ANNOUNCE here (makes inital Waypoint dialogue consistent with nav settings) + //return showFavorites() || announceFavorites(); + return announceFavorites(); + } else if (type == WAYPOINTS) { + //sync SHOW (which has no item in nav settings) to automatically load points in the dialogue + if (announceGPXWaypoints()) { + app.getSettings().SHOW_WPT.set(true); + } else { + app.getSettings().SHOW_WPT.set(false); + } + //no SHOW item in nav settings, hence only query ANNOUNCE here (makes inital Waypoint dialogue consistent with nav settings) + //return showGPXWaypoints() || announceGPXWaypoints(); + return announceGPXWaypoints(); } return true; } @@ -302,17 +331,19 @@ public class WaypointHelper { break; } LocationPoint point = lwp.point; - double d1 = MapUtils.getDistance(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), - point.getLatitude(), point.getLongitude()) + lwp.getDeviationDistance(); + double d1 = Math.max(0.0, MapUtils.getDistance(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), + point.getLatitude(), point.getLongitude()) - lwp.getDeviationDistance()); Integer state = locationPointsStates.get(point); if (state != null && state.intValue() == ANNOUNCED_ONCE - && getVoiceRouter() - .isDistanceLess(lastKnownLocation.getSpeed(), d1, SHORT_ANNOUNCE_RADIUS)) { + && getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, SHORT_ANNOUNCE_RADIUS)) { locationPointsStates.put(point, ANNOUNCED_DONE); announcePoints.add(lwp); - } else if ((state == null || state == NOT_ANNOUNCED) - && getVoiceRouter() - .isDistanceLess(lastKnownLocation.getSpeed(), d1, LONG_ANNOUNCE_RADIUS)) { + } else if (type != ALARMS && (state == null || state == NOT_ANNOUNCED) + && getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, LONG_ANNOUNCE_RADIUS)) { + locationPointsStates.put(point, ANNOUNCED_ONCE); + approachPoints.add(lwp); + } else if (type == ALARMS && (state == null || state == NOT_ANNOUNCED) + && getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, ALARMS_ANNOUNCE_RADIUS)) { locationPointsStates.put(point, ANNOUNCED_ONCE); approachPoints.add(lwp); } @@ -336,7 +367,7 @@ public class WaypointHelper { getVoiceRouter().approachPoi(lastKnownLocation, approachPoints); } else if (type == ALARMS) { EnumSet ait = EnumSet.noneOf(AlarmInfoType.class); - for(LocationPointWrapper pw : announcePoints) { + for(LocationPointWrapper pw : approachPoints) { ait.add(((AlarmInfo) pw.point).getType()); } for(AlarmInfoType t : ait) { @@ -587,19 +618,26 @@ public class WaypointHelper { } public boolean showFavorites() { - return app.getSettings().SHOW_NEARBY_FAVORIES.get(); - } - - public boolean showAlarms() { - // I think this line was a bug: - //return app.getSettings().SPEAK_SPEED_CAMERA.get() || app.getSettings().SPEAK_TRAFFIC_WARNINGS.get(); - return app.getSettings().SHOW_CAMERAS.get() || app.getSettings().SHOW_TRAFFIC_WARNINGS.get(); + return app.getSettings().SHOW_NEARBY_FAVORITES.get(); } public boolean announceFavorites() { return app.getSettings().ANNOUNCE_NEARBY_FAVORITES.get(); } - + + public boolean showAlarms() { + //I think here only traffic warnings other than the speed cam are needed. speed cam setting is a separate setting for explicit allow/disallow by user. + //return app.getSettings().SHOW_CAMERAS.get() || app.getSettings().SHOW_TRAFFIC_WARNINGS.get(); + return app.getSettings().SHOW_TRAFFIC_WARNINGS.get(); + } + + public boolean announceAlarms() { + //I think here only traffic warnings other than the speed cam are needed. speed cam setting is a separate setting for explicit allow/disallow by user. + //return app.getSettings().SPEAK_SPEED_CAMERA.get() || app.getSettings().SPEAK_TRAFFIC_WARNINGS.get(); + return app.getSettings().SPEAK_TRAFFIC_WARNINGS.get(); + } + + public class LocationPointWrapper { LocationPoint point; float deviationDistance; @@ -646,8 +684,12 @@ public class WaypointHelper { return uiCtx.getResources().getDrawable( !((TargetPoint)point).intermediate? R.drawable.list_destination: R.drawable.list_intermediate); - } else { + } else if(type == FAVORITES || type == WAYPOINTS) { return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor()); + } else if(type == ALARMS) { + return null; + } else { + return null; } }