diff --git a/OsmAnd-java/src/net/osmand/data/Amenity.java b/OsmAnd-java/src/net/osmand/data/Amenity.java index 483fc95d57..332327e92e 100644 --- a/OsmAnd-java/src/net/osmand/data/Amenity.java +++ b/OsmAnd-java/src/net/osmand/data/Amenity.java @@ -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")); } } diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java index 99dce47d5b..c354f61350 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java @@ -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 ids = new HashSet(); + final Set ids = new HashSet(); SearchRequest 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 oo = phrase.getOfflineIndexes(); + Set searchedPois = new TreeSet<>(); for (BinaryMapIndexReader o : oo) { - ResultMatcher rm = getResultMatcher(phrase, resultMatcher, o); + ResultMatcher rm = getResultMatcher(phrase, resultMatcher, o, searchedPois); if (obj instanceof CustomSearchPoiFilter) { rm = ((CustomSearchPoiFilter) obj).wrapResultMatcher(rm); } @@ -750,13 +753,20 @@ public class SearchCoreFactory { } private ResultMatcher getResultMatcher(final SearchPhrase phrase, final SearchResultMatcher resultMatcher, - final BinaryMapIndexReader selected) { + final BinaryMapIndexReader selected, final Set searchedPois) { final NameStringMatcher ns = phrase.getNameStringMatcher(); return new ResultMatcher() { @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)) { diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java b/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java index 10327e832a..40349a6d60 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchPhrase.java @@ -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() {