From 8298dbdf17d9ece341fa7b790019c193e01698c5 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 19 Jun 2020 19:04:08 +0200 Subject: [PATCH] Support dots in street names - https://github.com/osmandapp/Osmand/issues/6154 --- .../main/java/net/osmand/CollatorStringMatcher.java | 11 ++++++++++- .../java/net/osmand/search/core/SearchPhrase.java | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/CollatorStringMatcher.java b/OsmAnd-java/src/main/java/net/osmand/CollatorStringMatcher.java index f5808961d7..8048595615 100644 --- a/OsmAnd-java/src/main/java/net/osmand/CollatorStringMatcher.java +++ b/OsmAnd-java/src/main/java/net/osmand/CollatorStringMatcher.java @@ -33,7 +33,16 @@ public class CollatorStringMatcher implements StringMatcher { public CollatorStringMatcher(String part, StringMatcherMode mode) { this.collator = OsmAndCollator.primaryCollator(); - this.part = simplifyStringAndAlignChars(part); + part = simplifyStringAndAlignChars(part); + if (part.length() > 0 && part.charAt(part.length() - 1) == '.') { + part = part.substring(0, part.length() - 1); + if (mode == StringMatcherMode.CHECK_EQUALS_FROM_SPACE) { + mode = StringMatcherMode.CHECK_STARTS_FROM_SPACE; + } else if (mode == StringMatcherMode.CHECK_EQUALS) { + mode = StringMatcherMode.CHECK_ONLY_STARTS_WITH; + } + } + this.part = part; this.mode = mode; } diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java index 7306d2e48d..4cc5e63a84 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java @@ -281,6 +281,11 @@ public class SearchPhrase { for (String s : searchWords) { if (s.length() > 0 && !Character.isDigit(s.charAt(0)) && !LocationParser.isValidOLC(s)) { mainUnknownWordToSearch = s.trim(); + if (mainUnknownWordToSearch.endsWith(".")) { + mainUnknownWordToSearch = mainUnknownWordToSearch.substring(0, + mainUnknownWordToSearch.length() - 1); + mainUnknownSearchWordComplete = false; + } int unknownInd = unknownSearchWords.indexOf(s); if (!lastUnknownSearchWordComplete && unknownSearchWords.size() - 1 == unknownInd) { mainUnknownSearchWordComplete = false;