Fix search & terrain action
This commit is contained in:
parent
f980ec4340
commit
d587bee309
5 changed files with 26 additions and 32 deletions
|
@ -45,27 +45,27 @@ public enum ObjectType {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static double getTypeWeight(ObjectType t) {
|
||||
public static int getTypeWeight(ObjectType t) {
|
||||
if (t == null) {
|
||||
return 1.0;
|
||||
return 1;
|
||||
}
|
||||
switch (t) {
|
||||
case CITY:
|
||||
return 1.0;
|
||||
return 1;
|
||||
case VILLAGE:
|
||||
return 1.0;
|
||||
return 1;
|
||||
case POSTCODE:
|
||||
return 1.0;
|
||||
return 1;
|
||||
case STREET:
|
||||
return 2.0;
|
||||
return 2;
|
||||
case HOUSE:
|
||||
return 3.0;
|
||||
return 3;
|
||||
case STREET_INTERSECTION:
|
||||
return 3.0;
|
||||
return 3;
|
||||
case POI:
|
||||
return 2.0;
|
||||
return 2;
|
||||
default:
|
||||
return 1.0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -724,16 +724,17 @@ public class SearchPhrase {
|
|||
}
|
||||
|
||||
public void countUnknownWordsMatch(SearchResult sr, String localeName, Collection<String> otherNames) {
|
||||
if(unknownWords.size() > 0) {
|
||||
for(int i = 0; i < unknownWords.size(); i++) {
|
||||
if(unknownWordsMatcher.size() == i) {
|
||||
unknownWordsMatcher.add(new NameStringMatcher(unknownWords.get(i),
|
||||
i < unknownWords.size() - 1 || isLastUnknownSearchWordComplete() ? StringMatcherMode.CHECK_EQUALS_FROM_SPACE :
|
||||
StringMatcherMode.CHECK_STARTS_FROM_SPACE));
|
||||
if (unknownWords.size() > 0) {
|
||||
for (int i = 0; i < unknownWords.size(); i++) {
|
||||
if (unknownWordsMatcher.size() == i) {
|
||||
unknownWordsMatcher.add(new NameStringMatcher(unknownWords.get(i),
|
||||
i < unknownWords.size() - 1 || isLastUnknownSearchWordComplete()
|
||||
? StringMatcherMode.CHECK_EQUALS_FROM_SPACE
|
||||
: StringMatcherMode.CHECK_STARTS_FROM_SPACE));
|
||||
}
|
||||
NameStringMatcher ms = unknownWordsMatcher.get(i);
|
||||
if(ms.matches(localeName) || ms.matches(otherNames)) {
|
||||
if(sr.otherWordsMatch == null) {
|
||||
if (ms.matches(localeName) || ms.matches(otherNames)) {
|
||||
if (sr.otherWordsMatch == null) {
|
||||
sr.otherWordsMatch = new TreeSet<>();
|
||||
}
|
||||
sr.otherWordsMatch.add(unknownWords.get(i));
|
||||
|
|
|
@ -33,20 +33,13 @@ public class SearchResult {
|
|||
this.requiredSearchPhrase = sp;
|
||||
}
|
||||
|
||||
public double getUnknownPhraseMatchWeight() {
|
||||
return getUnknownPhraseMatchWeight(false);
|
||||
}
|
||||
|
||||
private double getUnknownPhraseMatchWeight(boolean isHouse) {
|
||||
double res = 0;
|
||||
isHouse = isHouse || objectType == ObjectType.HOUSE;
|
||||
public int getUnknownPhraseMatchWeight() {
|
||||
if (unknownPhraseMatches) {
|
||||
res = isHouse ? ObjectType.getTypeWeight(ObjectType.HOUSE) : ObjectType.getTypeWeight(objectType);
|
||||
return ObjectType.getTypeWeight(objectType);
|
||||
} else if (parentSearchResult != null) {
|
||||
return parentSearchResult.getUnknownPhraseMatchWeight();
|
||||
}
|
||||
if (res == 0 && parentSearchResult != null) {
|
||||
return parentSearchResult.getUnknownPhraseMatchWeight(isHouse);
|
||||
}
|
||||
return res;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getFoundWordCount() {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<string name="parking_positions">Parking positions</string>
|
||||
<string name="create_edit_poi">Create / Edit POI</string>
|
||||
<string name="quick_action_transport_descr">Button showing or hiding public transport on the map.</string>
|
||||
<string name="quick_action_show_hide_transport">Show / hide public transport</string>
|
||||
<string name="quick_action_show_hide_transport">Show/hide public transport</string>
|
||||
<string name="quick_action_transport_show">Show public transport</string>
|
||||
<string name="quick_action_transport_hide">Hide public transport</string>
|
||||
<string name="release_3_7">
|
||||
|
|
|
@ -16,7 +16,7 @@ import net.osmand.plus.quickaction.QuickActionType;
|
|||
public class TerrainAction extends QuickAction {
|
||||
|
||||
public static final QuickActionType TYPE = new QuickActionType(30,
|
||||
"contourlines.showhide", TerrainAction.class).
|
||||
"terrain.showhide", TerrainAction.class).
|
||||
nameRes(R.string.quick_action_show_hide_hillshade).iconRes(R.drawable.ic_action_hillshade_dark).nonEditable().
|
||||
category(QuickActionType.CONFIGURE_MAP);
|
||||
|
||||
|
|
Loading…
Reference in a new issue