Fix search & terrain action

This commit is contained in:
Victor Shcherb 2020-05-24 17:30:43 +02:00
parent f980ec4340
commit d587bee309
5 changed files with 26 additions and 32 deletions

View file

@ -45,27 +45,27 @@ public enum ObjectType {
return null; return null;
} }
public static double getTypeWeight(ObjectType t) { public static int getTypeWeight(ObjectType t) {
if (t == null) { if (t == null) {
return 1.0; return 1;
} }
switch (t) { switch (t) {
case CITY: case CITY:
return 1.0; return 1;
case VILLAGE: case VILLAGE:
return 1.0; return 1;
case POSTCODE: case POSTCODE:
return 1.0; return 1;
case STREET: case STREET:
return 2.0; return 2;
case HOUSE: case HOUSE:
return 3.0; return 3;
case STREET_INTERSECTION: case STREET_INTERSECTION:
return 3.0; return 3;
case POI: case POI:
return 2.0; return 2;
default: default:
return 1.0; return 1;
} }
} }
} }

View file

@ -724,16 +724,17 @@ public class SearchPhrase {
} }
public void countUnknownWordsMatch(SearchResult sr, String localeName, Collection<String> otherNames) { public void countUnknownWordsMatch(SearchResult sr, String localeName, Collection<String> otherNames) {
if(unknownWords.size() > 0) { if (unknownWords.size() > 0) {
for(int i = 0; i < unknownWords.size(); i++) { for (int i = 0; i < unknownWords.size(); i++) {
if(unknownWordsMatcher.size() == i) { if (unknownWordsMatcher.size() == i) {
unknownWordsMatcher.add(new NameStringMatcher(unknownWords.get(i), unknownWordsMatcher.add(new NameStringMatcher(unknownWords.get(i),
i < unknownWords.size() - 1 || isLastUnknownSearchWordComplete() ? StringMatcherMode.CHECK_EQUALS_FROM_SPACE : i < unknownWords.size() - 1 || isLastUnknownSearchWordComplete()
StringMatcherMode.CHECK_STARTS_FROM_SPACE)); ? StringMatcherMode.CHECK_EQUALS_FROM_SPACE
: StringMatcherMode.CHECK_STARTS_FROM_SPACE));
} }
NameStringMatcher ms = unknownWordsMatcher.get(i); NameStringMatcher ms = unknownWordsMatcher.get(i);
if(ms.matches(localeName) || ms.matches(otherNames)) { if (ms.matches(localeName) || ms.matches(otherNames)) {
if(sr.otherWordsMatch == null) { if (sr.otherWordsMatch == null) {
sr.otherWordsMatch = new TreeSet<>(); sr.otherWordsMatch = new TreeSet<>();
} }
sr.otherWordsMatch.add(unknownWords.get(i)); sr.otherWordsMatch.add(unknownWords.get(i));

View file

@ -33,20 +33,13 @@ public class SearchResult {
this.requiredSearchPhrase = sp; this.requiredSearchPhrase = sp;
} }
public double getUnknownPhraseMatchWeight() { public int getUnknownPhraseMatchWeight() {
return getUnknownPhraseMatchWeight(false);
}
private double getUnknownPhraseMatchWeight(boolean isHouse) {
double res = 0;
isHouse = isHouse || objectType == ObjectType.HOUSE;
if (unknownPhraseMatches) { 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 0;
return parentSearchResult.getUnknownPhraseMatchWeight(isHouse);
}
return res;
} }
public int getFoundWordCount() { public int getFoundWordCount() {

View file

@ -23,7 +23,7 @@
<string name="parking_positions">Parking positions</string> <string name="parking_positions">Parking positions</string>
<string name="create_edit_poi">Create / Edit POI</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_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_show">Show public transport</string>
<string name="quick_action_transport_hide">Hide public transport</string> <string name="quick_action_transport_hide">Hide public transport</string>
<string name="release_3_7"> <string name="release_3_7">

View file

@ -16,7 +16,7 @@ import net.osmand.plus.quickaction.QuickActionType;
public class TerrainAction extends QuickAction { public class TerrainAction extends QuickAction {
public static final QuickActionType TYPE = new QuickActionType(30, 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(). nameRes(R.string.quick_action_show_hide_hillshade).iconRes(R.drawable.ic_action_hillshade_dark).nonEditable().
category(QuickActionType.CONFIGURE_MAP); category(QuickActionType.CONFIGURE_MAP);