Fixed POI search for OSM Live
This commit is contained in:
parent
8248b34ee9
commit
49f3c2f765
3 changed files with 18 additions and 10 deletions
|
@ -39,7 +39,6 @@ public class Amenity extends MapObject {
|
|||
// context menu geometry;
|
||||
private TIntArrayList y;
|
||||
private TIntArrayList x;
|
||||
private boolean isClosed = false;
|
||||
|
||||
public Amenity() {
|
||||
}
|
||||
|
@ -309,11 +308,7 @@ public class Amenity extends MapObject {
|
|||
return x;
|
||||
}
|
||||
|
||||
public void setIsClosed(boolean closed) {
|
||||
isClosed = closed;
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
return isClosed;
|
||||
return "delete".equals(getAdditionalInfo("osmand_change"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,8 +46,10 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
import gnu.trove.set.hash.TLongHashSet;
|
||||
|
||||
|
||||
public class SearchCoreFactory {
|
||||
|
@ -488,7 +490,7 @@ public class SearchCoreFactory {
|
|||
SearchPhraseDataType.POI);
|
||||
final NameStringMatcher nm = phrase.getNameStringMatcher();
|
||||
QuadRect bbox = phrase.getRadiusBBoxToSearch(BBOX_RADIUS_INSIDE);
|
||||
final Set<Long> ids = new HashSet();
|
||||
final Set<Long> ids = new HashSet<Long>();
|
||||
SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(
|
||||
(int)bbox.centerX(), (int)bbox.centerY(),
|
||||
phrase.getUnknownSearchWord(),
|
||||
|
@ -502,7 +504,7 @@ public class SearchCoreFactory {
|
|||
return false;
|
||||
}
|
||||
if (ids.contains(object.getId())) {
|
||||
object.setIsClosed(true);
|
||||
return false;
|
||||
}
|
||||
SearchResult sr = new SearchResult(phrase);
|
||||
sr.otherNames = object.getAllNames(true);
|
||||
|
@ -733,8 +735,9 @@ public class SearchCoreFactory {
|
|||
|
||||
QuadRect bbox = phrase.getRadiusBBoxToSearch(10000);
|
||||
List<BinaryMapIndexReader> oo = phrase.getOfflineIndexes();
|
||||
Set<String> searchedPois = new TreeSet<>();
|
||||
for (BinaryMapIndexReader o : oo) {
|
||||
ResultMatcher<Amenity> rm = getResultMatcher(phrase, resultMatcher, o);
|
||||
ResultMatcher<Amenity> rm = getResultMatcher(phrase, resultMatcher, o, searchedPois);
|
||||
if (obj instanceof CustomSearchPoiFilter) {
|
||||
rm = ((CustomSearchPoiFilter) obj).wrapResultMatcher(rm);
|
||||
}
|
||||
|
@ -750,13 +753,20 @@ public class SearchCoreFactory {
|
|||
}
|
||||
|
||||
private ResultMatcher<Amenity> getResultMatcher(final SearchPhrase phrase, final SearchResultMatcher resultMatcher,
|
||||
final BinaryMapIndexReader selected) {
|
||||
final BinaryMapIndexReader selected, final Set<String> searchedPois) {
|
||||
final NameStringMatcher ns = phrase.getNameStringMatcher();
|
||||
return new ResultMatcher<Amenity>() {
|
||||
|
||||
@Override
|
||||
public boolean publish(Amenity object) {
|
||||
SearchResult res = new SearchResult(phrase);
|
||||
String poiID = object.getType().getKeyName() + "_" + object.getId();
|
||||
if(!searchedPois.add(poiID)) {
|
||||
return false;
|
||||
}
|
||||
if(object.isClosed()) {
|
||||
return false;
|
||||
}
|
||||
res.localeName = object.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
|
||||
res.otherNames = object.getAllNames(true);
|
||||
if (Algorithms.isEmpty(res.localeName)) {
|
||||
|
|
|
@ -535,6 +535,9 @@ public class SearchPhrase {
|
|||
if(indexes == null) {
|
||||
indexes = new ArrayList<>(getOfflineIndexes());
|
||||
}
|
||||
if (indexes.get(0).getFile().getName().matches("[a-zA-Z_-]+([0-9]+_*{3}).+[a-z]+")) {
|
||||
return;
|
||||
}
|
||||
final LatLon ll = getLastTokenLocation();
|
||||
if(ll != null) {
|
||||
Collections.sort(indexes, new Comparator<BinaryMapIndexReader>() {
|
||||
|
|
Loading…
Reference in a new issue