Fixed deleted POI being displayed in Configure map - POI

This commit is contained in:
PaulStets 2017-09-16 18:38:27 +03:00
parent 63e8b08a29
commit 883ea72620
3 changed files with 45 additions and 3 deletions

View file

@ -136,6 +136,36 @@ public class Algorithms {
};
}
public static Comparator<String> getStringVersionComparator() {
return new Comparator<String>() {
@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<String, String> decodeMap(String s) {

View file

@ -421,12 +421,20 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
@Override
public ResultMatcher<Amenity> wrapResultMatcher(final ResultMatcher<Amenity> matcher) {
final AmenityNameFilter nm = getNameFilter(filterByName);
final Set<String> searchedPois = new TreeSet<>();
return new ResultMatcher<Amenity>() {
@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;
}
}

View file

@ -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<String> fileNames = new ArrayList<String>(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<Amenity> searchAmenitiesOnThePath(List<Location> locations, double radius, SearchPoiTypeFilter filter,
public List<Amenity> searchAmenitiesOnThePath(List<Location> locations, double radius, SearchPoiTypeFilter filter,
ResultMatcher<Amenity> matcher) {
searchAmenitiesInProgress = true;
final List<Amenity> amenities = new ArrayList<Amenity>();