Improved search for OSM Live

This commit is contained in:
PaulStets 2017-09-10 17:42:26 +03:00
parent b9a6571527
commit b730a4bee3

View file

@ -38,12 +38,14 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TIntArrayList;
@ -486,6 +488,7 @@ public class SearchCoreFactory {
SearchPhraseDataType.POI); SearchPhraseDataType.POI);
final NameStringMatcher nm = phrase.getNameStringMatcher(); final NameStringMatcher nm = phrase.getNameStringMatcher();
QuadRect bbox = phrase.getRadiusBBoxToSearch(BBOX_RADIUS_INSIDE); QuadRect bbox = phrase.getRadiusBBoxToSearch(BBOX_RADIUS_INSIDE);
final Set<Long> ids = new HashSet();
SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest( SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(
(int)bbox.centerX(), (int)bbox.centerY(), (int)bbox.centerX(), (int)bbox.centerY(),
phrase.getUnknownSearchWord(), phrase.getUnknownSearchWord(),
@ -498,6 +501,9 @@ public class SearchCoreFactory {
if (limit ++ > LIMIT) { if (limit ++ > LIMIT) {
return false; return false;
} }
if (ids.contains(object.getId())) {
object.setName(object.getName() + " (closed)");
}
SearchResult sr = new SearchResult(phrase); SearchResult sr = new SearchResult(phrase);
sr.otherNames = object.getAllNames(true); sr.otherNames = object.getAllNames(true);
sr.localeName = object.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate()); sr.localeName = object.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
@ -523,6 +529,7 @@ public class SearchCoreFactory {
phrase.countUnknownWordsMatch(sr); phrase.countUnknownWordsMatch(sr);
sr.objectType = ObjectType.POI; sr.objectType = ObjectType.POI;
resultMatcher.publish(sr); resultMatcher.publish(sr);
ids.add(object.getId());
return false; return false;
} }