From b28a8b5c601ee073f2201315eb07861f792a70d4 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Fri, 13 Nov 2015 10:06:18 +0200 Subject: [PATCH] Fix #1550 WhatsApp location --- .../src/net/osmand/util/GeoPointParserUtil.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java b/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java index a4661d7203..6aa1d46e35 100644 --- a/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java +++ b/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java @@ -397,7 +397,6 @@ public class GeoPointParserUtil { actual = GeoPointParserUtil.parse(url); assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); - // TODO this URL does not work, where is it used? // whatsapp // https://maps.google.com/maps?q=loc:34.99393,-106.61568 (You) z = GeoParsedPoint.NO_ZOOM; @@ -406,6 +405,14 @@ public class GeoPointParserUtil { actual = GeoPointParserUtil.parse(url); assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); + // whatsapp + // https://maps.google.com/maps?q=loc:34.99393,-106.61568 (USERNAME) + z = GeoParsedPoint.NO_ZOOM; + url = "https://maps.google.com/maps?q=loc:" + dlat + "," + dlon + " (USER NAME)"; + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse(url); + 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); @@ -947,10 +954,9 @@ public class GeoPointParserUtil { if(opath.contains(pref)) { opath = opath.substring(opath.lastIndexOf(pref) + pref.length()); } - final String postf = " (You)"; - if (opath.contains(postf)) { - opath = opath.substring(0, opath.indexOf(postf)); - } + final String postf = "\\s\\((\\p{IsAlphabetic}|\\s)*\\)$"; + opath = opath.replaceAll(postf, ""); + System.out.println("opath=" + opath); return parseGoogleMapsPath(opath, params); } if (fragment != null) {