From 883ea72620922407be6271240df8669d492e4387 Mon Sep 17 00:00:00 2001 From: PaulStets Date: Sat, 16 Sep 2017 18:38:27 +0300 Subject: [PATCH] Fixed deleted POI being displayed in Configure map - POI --- .../src/net/osmand/util/Algorithms.java | 30 +++++++++++++++++++ .../src/net/osmand/plus/poi/PoiUIFilter.java | 8 +++++ .../plus/resources/ResourceManager.java | 10 +++++-- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/util/Algorithms.java b/OsmAnd-java/src/net/osmand/util/Algorithms.java index 4d3637bf98..09d5126d33 100644 --- a/OsmAnd-java/src/net/osmand/util/Algorithms.java +++ b/OsmAnd-java/src/net/osmand/util/Algorithms.java @@ -136,6 +136,36 @@ public class Algorithms { }; } + public static Comparator getStringVersionComparator() { + return new Comparator() { + @Override + public int compare(String o1, String o2) { + return -simplifyFileName(o1).compareTo(simplifyFileName(o2)); + } + + public String simplifyFileName(String fn) { + String lc = fn.toLowerCase(); + if (lc.contains(".")) { + lc = lc.substring(0, lc.indexOf(".")); + } + if (lc.endsWith("_2")) { + lc = lc.substring(0, lc.length() - "_2".length()); + } + boolean hasTimestampEnd = false; + for (int i = 0; i < lc.length(); i++) { + if (lc.charAt(i) >= '0' && lc.charAt(i) <= '9') { + hasTimestampEnd = true; + break; + } + } + if (!hasTimestampEnd) { + lc += "_00_00_00"; + } + return lc; + } + }; + } + private static final char CHAR_TOSPLIT = 0x01; public static Map decodeMap(String s) { diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java index 58b53cb878..3d826314a2 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java @@ -421,12 +421,20 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable @Override public ResultMatcher wrapResultMatcher(final ResultMatcher matcher) { final AmenityNameFilter nm = getNameFilter(filterByName); + final Set searchedPois = new TreeSet<>(); return new ResultMatcher() { @Override public boolean publish(Amenity a) { if (nm.accept(a)) { if (matcher == null || matcher.publish(a)) { + String poiID = a.getType().getKeyName() + "_" + a.getId(); + if(!searchedPois.add(poiID)) { + return false; + } + if(a.isClosed()) { + return false; + } return true; } } diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index 98255722b9..803945c8a7 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -60,6 +60,7 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -715,7 +716,10 @@ public class ResourceManager { int left31 = MapUtils.get31TileNumberX(leftLongitude); int bottom31 = MapUtils.get31TileNumberY(bottomLatitude); int right31 = MapUtils.get31TileNumberX(rightLongitude); - for (AmenityIndexRepository index : amenityRepositories.values()) { + List fileNames = new ArrayList(amenityRepositories.keySet()); + Collections.sort(fileNames, Algorithms.getStringVersionComparator()); + for (String name : fileNames) { + AmenityIndexRepository index = amenityRepositories.get(name); if (matcher != null && matcher.isCancelled()) { searchAmenitiesInProgress = false; break; @@ -734,8 +738,8 @@ public class ResourceManager { } return amenities; } - - public List searchAmenitiesOnThePath(List locations, double radius, SearchPoiTypeFilter filter, + + public List searchAmenitiesOnThePath(List locations, double radius, SearchPoiTypeFilter filter, ResultMatcher matcher) { searchAmenitiesInProgress = true; final List amenities = new ArrayList();