From 91e9b9e9cb7d4acc028e08e4c5ba704c23d9db87 Mon Sep 17 00:00:00 2001 From: crimean Date: Sun, 7 Jul 2019 12:05:25 +0300 Subject: [PATCH] Fix #6240 --- .../net/osmand/search/core/SearchCoreFactory.java | 2 +- .../java/net/osmand/search/core/SearchPhrase.java | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java index f42874d5ad..5525c6bb84 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java @@ -354,7 +354,7 @@ public class SearchCoreFactory { private void searchByName(final SearchPhrase phrase, final SearchResultMatcher resultMatcher) throws IOException { - if (phrase.getRadiusLevel() > 1 || phrase.getUnknownSearchWordLength() > 3 || phrase.getUnknownSearchWords().size() > 0) { + if (phrase.getRadiusLevel() > 1 || phrase.getUnknownSearchWordLength() > 3 || phrase.getUnknownSearchWords().size() > 0 || phrase.isSearchTypeAllowed(ObjectType.POSTCODE, true)) { final boolean locSpecified = phrase.getLastTokenLocation() != null; LatLon loc = phrase.getLastTokenLocation(); final List immediateResults = new ArrayList<>(); 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 39df00cb24..dde22fdc65 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 @@ -422,10 +422,18 @@ public class SearchPhrase { } public boolean isSearchTypeAllowed(ObjectType searchType) { - if (getSearchTypes() == null) { - return true; + return isSearchTypeAllowed(searchType, false); + } + + public boolean isSearchTypeAllowed(ObjectType searchType, boolean exclusive) { + ObjectType[] searchTypes = getSearchTypes(); + if (searchTypes == null) { + return !exclusive; } else { - for (ObjectType type : getSearchTypes()) { + if (exclusive && searchTypes.length > 1) { + return false; + } + for (ObjectType type : searchTypes) { if (type == searchType) { return true; }