From 3566ec765254ceaa1150463ab12fa8463fb4aa1b Mon Sep 17 00:00:00 2001 From: Skalii Date: Fri, 8 Jan 2021 19:05:02 +0200 Subject: [PATCH] fix previous changes; add new check; --- .../java/net/osmand/util/GeoPointParserUtil.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java b/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java index f46f4f6f70..3906aff004 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java @@ -553,14 +553,19 @@ public class GeoPointParserUtil { } if (searchRequest != null) { + String searchPattern = Pattern.compile("(?:\\.|,|\\s+|\\+|[+-]?\\d+(?:\\.\\d+)?)").pattern(); + String[] search = searchRequest.split(searchPattern); + if (search.length > 0) { + return new GeoParsedPoint(searchRequest); + } final Matcher positionInSearchRequestMatcher = positionPattern.matcher(searchRequest); if (lat == 0.0 && lon == 0.0 && positionInSearchRequestMatcher.find()) { - lat = Double.valueOf(positionInSearchRequestMatcher.group(1)); - lon = Double.valueOf(positionInSearchRequestMatcher.group(2)); - if (lat < -90 || lat > 90 || lon < -180 || lon > 180) { - lat = 0.0; - lon = 0.0; + double tempLat = Double.valueOf(positionInSearchRequestMatcher.group(1)); + double tempLon = Double.valueOf(positionInSearchRequestMatcher.group(2)); + if (tempLat >= -90 && tempLat <= 90 && tempLon >= -180 && tempLon <= 180) { + lat = tempLat; + lon = tempLon; } } }