Fix 3.6 Search
This commit is contained in:
parent
eeeda95f2c
commit
c734cb6256
1 changed files with 34 additions and 27 deletions
|
@ -857,25 +857,26 @@ public class SearchUICore {
|
||||||
sortByName = sp.isSortByName();
|
sortByName = sp.isSortByName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(SearchResult o1, SearchResult o2) {
|
public int compare(SearchResult o1, SearchResult o2) {
|
||||||
boolean topVisible1 = ObjectType.isTopVisible(o1.objectType);
|
boolean topVisible1 = ObjectType.isTopVisible(o1.objectType);
|
||||||
boolean topVisible2 = ObjectType.isTopVisible(o2.objectType);
|
boolean topVisible2 = ObjectType.isTopVisible(o2.objectType);
|
||||||
if ((!topVisible1 && !topVisible2) || (topVisible1 && topVisible2)) {
|
if (topVisible1 != topVisible2) {
|
||||||
if (o1.getUnknownPhraseMatchWeight() != o2.getUnknownPhraseMatchWeight()) {
|
// -1 - means 1st is less than 2nd
|
||||||
return -Double.compare(o1.getUnknownPhraseMatchWeight(), o2.getUnknownPhraseMatchWeight());
|
return topVisible1 ? -1 : 1;
|
||||||
} else {
|
}
|
||||||
|
// if (o1.getUnknownPhraseMatchWeight() != o2.getUnknownPhraseMatchWeight()) {
|
||||||
|
// return -Double.compare(o1.getUnknownPhraseMatchWeight(), o2.getUnknownPhraseMatchWeight());
|
||||||
|
// }
|
||||||
if (o1.getFoundWordCount() != o2.getFoundWordCount()) {
|
if (o1.getFoundWordCount() != o2.getFoundWordCount()) {
|
||||||
return -Algorithms.compare(o1.getFoundWordCount(), o2.getFoundWordCount());
|
return -Algorithms.compare(o1.getFoundWordCount(), o2.getFoundWordCount());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!sortByName) {
|
if (!sortByName) {
|
||||||
double s1 = o1.getSearchDistance(loc);
|
double s1 = o1.getSearchDistance(loc);
|
||||||
double s2 = o2.getSearchDistance(loc);
|
double s2 = o2.getSearchDistance(loc);
|
||||||
int cmp = Double.compare(s1, s2);
|
if (s1 != s2) {
|
||||||
if (cmp != 0) {
|
return Double.compare(s1, s2);
|
||||||
return cmp;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int st1 = o1.localeName == null ? -10000 : Algorithms.extractFirstIntegerNumber(o1.localeName);
|
int st1 = o1.localeName == null ? -10000 : Algorithms.extractFirstIntegerNumber(o1.localeName);
|
||||||
|
@ -885,22 +886,30 @@ public class SearchUICore {
|
||||||
}
|
}
|
||||||
String localeName1 = o1.localeName == null ? "" : o1.localeName;
|
String localeName1 = o1.localeName == null ? "" : o1.localeName;
|
||||||
String localeName2 = o2.localeName == null ? "" : o2.localeName;
|
String localeName2 = o2.localeName == null ? "" : o2.localeName;
|
||||||
if (o1.parentSearchResult != null && o2.parentSearchResult != null) {
|
|
||||||
if (o1.parentSearchResult == o2.parentSearchResult) {
|
|
||||||
int cmp = collator.compare(localeName1, localeName2);
|
|
||||||
if (cmp != 0) {
|
|
||||||
return cmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
double s1 = o1.getSearchDistance(loc, 1);
|
double s1 = o1.getSearchDistance(loc, 1);
|
||||||
double s2 = o2.getSearchDistance(loc, 1);
|
double s2 = o2.getSearchDistance(loc, 1);
|
||||||
return Double.compare(s1, s2);
|
// ????
|
||||||
}
|
// if (o1.parentSearchResult != null && o2.parentSearchResult != null) {
|
||||||
|
// if (o1.parentSearchResult == o2.parentSearchResult) {
|
||||||
|
// int cmp = collator.compare(localeName1, localeName2);
|
||||||
|
// if (cmp != 0) {
|
||||||
|
// return cmp;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return Double.compare(s1, s2);
|
||||||
|
// }
|
||||||
int cmp = collator.compare(localeName1, localeName2);
|
int cmp = collator.compare(localeName1, localeName2);
|
||||||
if (cmp != 0) {
|
if (cmp != 0) {
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
if (o1.object instanceof Amenity && o2.object instanceof Amenity) {
|
if (s1 != s2) {
|
||||||
|
return Double.compare(s1, s2);
|
||||||
|
}
|
||||||
|
boolean am1 = o2.object instanceof Amenity;
|
||||||
|
boolean am2 = o2.object instanceof Amenity;
|
||||||
|
if (am1 != am2) {
|
||||||
|
return Boolean.compare(am1, am2);
|
||||||
|
} else if (am1 && am2) {
|
||||||
// here 2 points are amenity
|
// here 2 points are amenity
|
||||||
Amenity a1 = (Amenity) o1.object;
|
Amenity a1 = (Amenity) o1.object;
|
||||||
Amenity a2 = (Amenity) o2.object;
|
Amenity a2 = (Amenity) o2.object;
|
||||||
|
@ -910,6 +919,7 @@ public class SearchUICore {
|
||||||
if (cmp != 0) {
|
if (cmp != 0) {
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
String subType1 = a1.getSubType() == null ? "" : a1.getSubType();
|
String subType1 = a1.getSubType() == null ? "" : a1.getSubType();
|
||||||
String subType2 = a2.getSubType() == null ? "" : a2.getSubType();
|
String subType2 = a2.getSubType() == null ? "" : a2.getSubType();
|
||||||
cmp = collator.compare(subType1, subType2);
|
cmp = collator.compare(subType1, subType2);
|
||||||
|
@ -917,10 +927,7 @@ public class SearchUICore {
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
double s1 = o1.getSearchDistance(loc, 1);
|
|
||||||
double s2 = o2.getSearchDistance(loc, 1);
|
|
||||||
return Double.compare(s1, s2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue