This commit is contained in:
crimean 2019-07-16 14:44:56 +03:00
parent 56778e1724
commit 78e7bb4d3d
5 changed files with 8139 additions and 9 deletions

View file

@ -853,8 +853,8 @@ public class SearchUICore {
boolean topVisible1 = ObjectType.isTopVisible(o1.objectType);
boolean topVisible2 = ObjectType.isTopVisible(o2.objectType);
if ((!topVisible1 && !topVisible2) || (topVisible1 && topVisible2)) {
if (o1.isUnknownPhraseMatches() != o2.isUnknownPhraseMatches()) {
return o1.isUnknownPhraseMatches() ? -1 : 1;
if (o1.getUnknownPhraseMatchWeight() != o2.getUnknownPhraseMatchWeight()) {
return -Double.compare(o1.getUnknownPhraseMatchWeight(), o2.getUnknownPhraseMatchWeight());
} else if (o1.getFoundWordCount() != o2.getFoundWordCount()) {
return -Algorithms.compare(o1.getFoundWordCount(), o2.getFoundWordCount());
}

View file

@ -44,4 +44,28 @@ public enum ObjectType {
}
return null;
}
public static double getTypeWeight(ObjectType t) {
if (t == null) {
return 1.0;
}
switch (t) {
case CITY:
return 1.0;
case VILLAGE:
return 1.0;
case POSTCODE:
return 1.0;
case STREET:
return 2.0;
case HOUSE:
return 3.0;
case STREET_INTERSECTION:
return 3.0;
case POI:
return 2.0;
default:
return 1.0;
}
}
}

View file

@ -1,7 +1,6 @@
package net.osmand.search.core;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
import net.osmand.data.City;
import net.osmand.data.LatLon;
import net.osmand.data.Street;
@ -30,10 +29,18 @@ public class SearchResult {
public boolean firstUnknownWordMatches = true;
public boolean unknownPhraseMatches = false;
public boolean isUnknownPhraseMatches() {
boolean res = unknownPhraseMatches;
if (!res && parentSearchResult != null) {
res = parentSearchResult.unknownPhraseMatches;
public double getUnknownPhraseMatchWeight() {
double res = 0;
boolean isHouse = objectType == ObjectType.HOUSE;
if (unknownPhraseMatches) {
res = ObjectType.getTypeWeight(objectType);
}
if (res == 0 && parentSearchResult != null && parentSearchResult.unknownPhraseMatches) {
if (isHouse && parentSearchResult.objectType == ObjectType.STREET) {
res = ObjectType.getTypeWeight(ObjectType.HOUSE);
} else {
res = ObjectType.getTypeWeight(parentSearchResult.objectType);
}
}
return res;
}

File diff suppressed because it is too large Load diff

View file

@ -32,8 +32,7 @@
"Carrer Santa Clara, Castelló d'Empúries",
"Carrer de Santa Clara, Vilafranca del Penedès",
"Carrer de Santa Clara, Castelló d'Empúries",
"Carrer Clara Campoamor, Santa Coloma de Gramenet",
"Santa Clara"
"Carrer Clara Campoamor, Santa Coloma de Gramenet"
],
"amenities": [
{