Add fuel test

This commit is contained in:
Victor Shcherb 2020-06-04 16:46:05 +02:00
parent 8d1fc4d61a
commit f55ecd0719
3 changed files with 42 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import net.osmand.data.City;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.MapObject; import net.osmand.data.MapObject;
import net.osmand.data.Street; import net.osmand.data.Street;
import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes; import net.osmand.osm.MapPoiTypes;
import net.osmand.search.core.CustomSearchPoiFilter; import net.osmand.search.core.CustomSearchPoiFilter;
import net.osmand.search.core.ObjectType; import net.osmand.search.core.ObjectType;
@ -858,6 +859,7 @@ public class SearchUICore {
TOP_VISIBLE, TOP_VISIBLE,
FOUND_WORD_COUNT, // more is better (top) FOUND_WORD_COUNT, // more is better (top)
UNKNOWN_PHRASE_MATCH_WEIGHT, // more is better (top) UNKNOWN_PHRASE_MATCH_WEIGHT, // more is better (top)
COMPARE_AMENITY_TYPE_ADDITIONAL,
SEARCH_DISTANCE_IF_NOT_BY_NAME, SEARCH_DISTANCE_IF_NOT_BY_NAME,
COMPARE_FIRST_NUMBER_IN_NAME, COMPARE_FIRST_NUMBER_IN_NAME,
COMPARE_DISTANCE_TO_PARENT_SEARCH_RESULT, // makes sense only for inner subqueries COMPARE_DISTANCE_TO_PARENT_SEARCH_RESULT, // makes sense only for inner subqueries
@ -908,6 +910,17 @@ public class SearchUICore {
} }
break; break;
} }
case COMPARE_AMENITY_TYPE_ADDITIONAL: {
if(o1.object instanceof AbstractPoiType && o2.object instanceof AbstractPoiType ) {
boolean additional1 = ((AbstractPoiType) o1.object).isAdditional();
boolean additional2 = ((AbstractPoiType) o2.object).isAdditional();
if (additional1 != additional2) {
// -1 - means 1st is less than 2nd
return additional1 ? 1 : -1;
}
}
break;
}
case COMPARE_DISTANCE_TO_PARENT_SEARCH_RESULT: case COMPARE_DISTANCE_TO_PARENT_SEARCH_RESULT:
double ps1 = o1.parentSearchResult == null ? 0 : o1.parentSearchResult.getSearchDistance(c.loc); double ps1 = o1.parentSearchResult == null ? 0 : o1.parentSearchResult.getSearchDistance(c.loc);
double ps2 = o2.parentSearchResult == null ? 0 : o2.parentSearchResult.getSearchDistance(c.loc); double ps2 = o2.parentSearchResult == null ? 0 : o2.parentSearchResult.getSearchDistance(c.loc);

View file

@ -702,6 +702,9 @@ public class SearchCoreFactory {
if (nm.matches(pf.getEnTranslation())) { if (nm.matches(pf.getEnTranslation())) {
lst = addToList(pf.getEnTranslation(), lst); lst = addToList(pf.getEnTranslation(), lst);
} }
if (nm.matches(pf.getKeyName())) {
lst = addToList(pf.getKeyName().replace('_', ' '), lst);
}
if (nm.matches(pf.getSynonyms())) { if (nm.matches(pf.getSynonyms())) {
String[] synonyms = pf.getSynonyms().split(";"); String[] synonyms = pf.getSynonyms().split(";");
@ -784,6 +787,7 @@ public class SearchCoreFactory {
String stdFilterId , SearchResult res) { String stdFilterId , SearchResult res) {
res.priorityDistance = 0; res.priorityDistance = 0;
res.objectType = ObjectType.POI_TYPE; res.objectType = ObjectType.POI_TYPE;
res.firstUnknownWordMatches = true;
if (showTopFiltersOnly) { if (showTopFiltersOnly) {
if (activePoiFilters.containsKey(stdFilterId)) { if (activePoiFilters.containsKey(stdFilterId)) {
res.priority = getPoiTypePriority(stdFilterId); res.priority = getPoiTypePriority(stdFilterId);

View file

@ -0,0 +1,25 @@
{
"settings": {
"lat": "51.04933",
"lon": "13.73815",
"radiusLevel": 1,
"totalLimit": -1,
"lang": "",
"transliterateIfMissing": false,
"emptyQueryAllowed": false,
"sortByName": false
},
"phrase": ["Fuel", "Fuel "],
"results": [[
"Aircraft fuel station (Filling station) [[1, POI_TYPE, 1.000, 0.00 km]]",
"Gas station (Filling station) [[1, POI_TYPE, 1.000, 0.00 km]]",
"Gas station for boats (Filling station) [[1, POI_TYPE, 1.000, 0.00 km]]"
],
[
"Aircraft fuel station (Filling station) [[1, POI_TYPE, 1.000, 0.00 km]]",
"Gas station (Filling station) [[1, POI_TYPE, 1.000, 0.00 km]]",
"Gas station for boats (Filling station) [[1, POI_TYPE, 1.000, 0.00 km]]"
]],
"amenities": [],
"cities": []
}