diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java index 380656e28a..56537a581d 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java @@ -49,12 +49,12 @@ import com.jwetherell.openmap.common.UTMPoint; public class SearchCoreFactory { // TODO add full text search with comma correct order // TODO MED add full text search without comma and different word order - // TODO MED edit in the middle (with words and comma)? // TODO exclude duplicate streets/cities/pois... - - // TODO UI support poi additional select type and search - // TODO UI display results momentarily - // TODO UI automatically increase radius if nothing found (log radius search) + + // UI edit in the middle (with words and comma)? + // UI support poi additional select type and search + // UI display results momentarily + // UI automatically increase radius if nothing found (log radius search) //////////////// CONSTANTS ////////// @@ -456,6 +456,9 @@ public class SearchCoreFactory { if (p.hasObjectType(ObjectType.POI) || p.hasObjectType(ObjectType.POI_TYPE)) { return -1; } + if(!p.isNoSelectedType() && p.getLastWord().isEmpty()) { + return -1; + } return SEARCH_AMENITY_TYPE_API_PRIORITY; } } diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java b/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java index 59998d1868..55a74b5cce 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java @@ -27,6 +27,8 @@ public class SearchPhrase { private List indexes; private String lastWordTrim; private QuadRect cache1kmRect; + private static final String DELIMITER = " "; + public enum SearchPhraseDataType { MAP, ADDRESS, ROUTING, POI @@ -39,35 +41,30 @@ public class SearchPhrase { public SearchPhrase generateNewPhrase(String text, SearchSettings settings) { SearchPhrase sp = new SearchPhrase(settings); - String atext = text; + String restText = text; List leftWords = this.words; String thisTxt = getText(true); if (text.startsWith(thisTxt)) { // string is longer - atext = text.substring(getText(false).length()); + restText = text.substring(getText(false).length()); sp.words = new ArrayList<>(this.words); leftWords = leftWords.subList(leftWords.size(), leftWords.size()); } - if (!atext.contains(",")) { - sp.lastWord = atext; - + if (!restText.contains(DELIMITER)) { + sp.lastWord = restText; } else { - String[] ws = atext.split(","); - for (int i = 0; i < ws.length - 1; i++) { - boolean unknown = true; - if (ws[i].trim().length() > 0) { - if (leftWords.size() > 0) { - if (leftWords.get(0).getWord().equalsIgnoreCase(ws[i].trim())) { - sp.words.add(leftWords.get(0)); - leftWords = leftWords.subList(1, leftWords.size()); - unknown = false; - } - } - if(unknown) { - sp.words.add(new SearchWord(ws[i].trim())); - } + for(SearchWord w : leftWords) { + if(restText.startsWith(w.getWord() + DELIMITER)) { + sp.words.add(w); + restText = restText.substring(w.getWord().length() + DELIMITER.length()).trim(); + } else { + break; } } + String[] ws = restText.split(DELIMITER); + for (int i = 0; i < ws.length - 1; i++) { + sp.words.add(new SearchWord(ws[i].trim())); + } sp.lastWord = ws[ws.length - 1]; } sp.lastWordTrim = sp.lastWord.trim(); @@ -261,7 +258,7 @@ public class SearchPhrase { public String getText(boolean includeLastWord) { StringBuilder sb = new StringBuilder(); for(SearchWord s : words) { - sb.append(s.getWord()).append(", "); + sb.append(s.getWord()).append(DELIMITER.trim() + " "); } if(includeLastWord) { sb.append(lastWord); diff --git a/OsmAnd/src/net/osmand/plus/resources/AmenityIndexRepositoryBinary.java b/OsmAnd/src/net/osmand/plus/resources/AmenityIndexRepositoryBinary.java index aff03fcfc9..7da7f5b4ce 100644 --- a/OsmAnd/src/net/osmand/plus/resources/AmenityIndexRepositoryBinary.java +++ b/OsmAnd/src/net/osmand/plus/resources/AmenityIndexRepositoryBinary.java @@ -15,7 +15,6 @@ import net.osmand.binary.BinaryMapIndexReader.SearchPoiTypeFilter; import net.osmand.binary.BinaryMapIndexReader.SearchRequest; import net.osmand.data.Amenity; import net.osmand.osm.PoiCategory; -import net.osmand.plus.poi.PoiUIFilter; import net.osmand.util.MapUtils; import org.apache.commons.logging.Log;