refactoring

This commit is contained in:
Kseniia 2021-01-05 22:49:39 +02:00
parent b9339cdab5
commit d74e57db84

View file

@ -41,10 +41,13 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class SearchUICore { public class SearchUICore {
@ -68,6 +71,8 @@ public class SearchUICore {
private static boolean debugMode = false; private static boolean debugMode = false;
private static final Set<String> FILTER_DUPLICATE_POI_SUBTYPE = Stream.of("building").collect((Collectors.toCollection(TreeSet::new)));
public SearchUICore(MapPoiTypes poiTypes, String locale, boolean transliterate) { public SearchUICore(MapPoiTypes poiTypes, String locale, boolean transliterate) {
this.poiTypes = poiTypes; this.poiTypes = poiTypes;
taskQueue = new LinkedBlockingQueue<Runnable>(); taskQueue = new LinkedBlockingQueue<Runnable>();
@ -245,13 +250,15 @@ public class SearchUICore {
String subType1 = a1.getSubType(); String subType1 = a1.getSubType();
String subType2 = a2.getSubType(); String subType2 = a2.getSubType();
if (a1.getId().longValue() == a2.getId().longValue() boolean isEqualId = a1.getId().longValue() == a2.getId().longValue();
&& ((subType1.equals("building") || subType2.equals("building")))) {
if (isEqualId && (FILTER_DUPLICATE_POI_SUBTYPE.contains(subType1)
|| FILTER_DUPLICATE_POI_SUBTYPE.contains(subType2))) {
return true; return true;
} }
if (!type1.equals(type2)) { if (!type1.equals(type2)) {
if (a1.getId().longValue() == a2.getId().longValue() && subType1.contains("internet") if (isEqualId && (subType1.contains("internet") || subType2.contains("internet"))) {
|| subType2.contains("internet")) {
return true; return true;
} }
return false; return false;
@ -1000,9 +1007,9 @@ public class SearchUICore {
int cmp; int cmp;
if(subType1.equals("building") || subType1.contains("internet")) { if(FILTER_DUPLICATE_POI_SUBTYPE.contains(subType1) || subType1.contains("internet")) {
cmp = 1; cmp = 1;
} else if(subType2.equals("building") || subType2.contains("internet")) { } else if(FILTER_DUPLICATE_POI_SUBTYPE.contains(subType2) || subType2.contains("internet")) {
cmp = -1; cmp = -1;
} else { } else {
cmp = c.collator.compare(subType1, subType2); cmp = c.collator.compare(subType1, subType2);