Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-07-16 19:54:17 +02:00
commit 51788c9a0d
3 changed files with 25 additions and 26 deletions

View file

@ -49,12 +49,12 @@ import com.jwetherell.openmap.common.UTMPoint;
public class SearchCoreFactory { public class SearchCoreFactory {
// TODO add full text search with comma correct order // TODO add full text search with comma correct order
// TODO MED add full text search without comma and different word 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 exclude duplicate streets/cities/pois...
// TODO UI support poi additional select type and search // UI edit in the middle (with words and comma)?
// TODO UI display results momentarily // UI support poi additional select type and search
// TODO UI automatically increase radius if nothing found (log radius search) // UI display results momentarily
// UI automatically increase radius if nothing found (log radius search)
//////////////// CONSTANTS ////////// //////////////// CONSTANTS //////////
@ -456,6 +456,9 @@ public class SearchCoreFactory {
if (p.hasObjectType(ObjectType.POI) || p.hasObjectType(ObjectType.POI_TYPE)) { if (p.hasObjectType(ObjectType.POI) || p.hasObjectType(ObjectType.POI_TYPE)) {
return -1; return -1;
} }
if(!p.isNoSelectedType() && p.getLastWord().isEmpty()) {
return -1;
}
return SEARCH_AMENITY_TYPE_API_PRIORITY; return SEARCH_AMENITY_TYPE_API_PRIORITY;
} }
} }

View file

@ -27,6 +27,8 @@ public class SearchPhrase {
private List<BinaryMapIndexReader> indexes; private List<BinaryMapIndexReader> indexes;
private String lastWordTrim; private String lastWordTrim;
private QuadRect cache1kmRect; private QuadRect cache1kmRect;
private static final String DELIMITER = " ";
public enum SearchPhraseDataType { public enum SearchPhraseDataType {
MAP, ADDRESS, ROUTING, POI MAP, ADDRESS, ROUTING, POI
@ -39,35 +41,30 @@ public class SearchPhrase {
public SearchPhrase generateNewPhrase(String text, SearchSettings settings) { public SearchPhrase generateNewPhrase(String text, SearchSettings settings) {
SearchPhrase sp = new SearchPhrase(settings); SearchPhrase sp = new SearchPhrase(settings);
String atext = text; String restText = text;
List<SearchWord> leftWords = this.words; List<SearchWord> leftWords = this.words;
String thisTxt = getText(true); String thisTxt = getText(true);
if (text.startsWith(thisTxt)) { if (text.startsWith(thisTxt)) {
// string is longer // string is longer
atext = text.substring(getText(false).length()); restText = text.substring(getText(false).length());
sp.words = new ArrayList<>(this.words); sp.words = new ArrayList<>(this.words);
leftWords = leftWords.subList(leftWords.size(), leftWords.size()); leftWords = leftWords.subList(leftWords.size(), leftWords.size());
} }
if (!atext.contains(",")) { if (!restText.contains(DELIMITER)) {
sp.lastWord = atext; sp.lastWord = restText;
} else { } else {
String[] ws = atext.split(","); 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++) { 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())); sp.words.add(new SearchWord(ws[i].trim()));
} }
}
}
sp.lastWord = ws[ws.length - 1]; sp.lastWord = ws[ws.length - 1];
} }
sp.lastWordTrim = sp.lastWord.trim(); sp.lastWordTrim = sp.lastWord.trim();
@ -261,7 +258,7 @@ public class SearchPhrase {
public String getText(boolean includeLastWord) { public String getText(boolean includeLastWord) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for(SearchWord s : words) { for(SearchWord s : words) {
sb.append(s.getWord()).append(", "); sb.append(s.getWord()).append(DELIMITER.trim() + " ");
} }
if(includeLastWord) { if(includeLastWord) {
sb.append(lastWord); sb.append(lastWord);

View file

@ -15,7 +15,6 @@ import net.osmand.binary.BinaryMapIndexReader.SearchPoiTypeFilter;
import net.osmand.binary.BinaryMapIndexReader.SearchRequest; import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiCategory;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;