This commit is contained in:
crimean 2018-10-08 14:26:52 +03:00
parent 7f6b0ed216
commit d819db7c8e
3 changed files with 33 additions and 1 deletions

View file

@ -514,7 +514,8 @@ public class SearchUICore {
public boolean isSearchMoreAvailable(SearchPhrase phrase) { public boolean isSearchMoreAvailable(SearchPhrase phrase) {
for (SearchCoreAPI api : apis) { for (SearchCoreAPI api : apis) {
if (api.getSearchPriority(phrase) >= 0 && api.isSearchMoreAvailable(phrase)) { if (api.isSearchAvailable(phrase) && api.getSearchPriority(phrase) >= 0
&& api.isSearchMoreAvailable(phrase)) {
return true; return true;
} }
} }

View file

@ -246,6 +246,21 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
return amenityList; return amenityList;
} }
public double getSearchRadius(int radius) {
if (radius < 0) {
distanceInd = 0;
} else if (radius < distanceToSearchValues.length) {
distanceInd = radius;
} else {
distanceInd = distanceToSearchValues.length - 1;
}
return distanceToSearchValues[distanceInd] * 1000;
}
public int getMaxSearchRadiusIndex() {
return distanceToSearchValues.length - 1;
}
public boolean isAutomaticallyIncreaseSearch() { public boolean isAutomaticallyIncreaseSearch() {
return true; return true;
} }

View file

@ -324,6 +324,7 @@ public class QuickSearchHelper implements ResourceListener {
} }
public static class SearchOnlineApi extends SearchBaseAPI { public static class SearchOnlineApi extends SearchBaseAPI {
private static final int SEARCH_RADIUS_INCREMENT = 3;
private OsmandApplication app; private OsmandApplication app;
private NominatimPoiFilter filter; private NominatimPoiFilter filter;
@ -379,6 +380,21 @@ public class QuickSearchHelper implements ResourceListener {
sr.preferredZoom = 17; sr.preferredZoom = 17;
return sr; return sr;
} }
@Override
public int getMinimalSearchRadius(SearchPhrase phrase) {
return (int)filter.getSearchRadius(phrase.getRadiusLevel() + SEARCH_RADIUS_INCREMENT);
}
@Override
public int getNextSearchRadius(SearchPhrase phrase) {
return (int)filter.getSearchRadius(phrase.getRadiusLevel() + SEARCH_RADIUS_INCREMENT + 1);
}
@Override
public boolean isSearchMoreAvailable(SearchPhrase phrase) {
return phrase.getRadiusLevel() + SEARCH_RADIUS_INCREMENT < filter.getMaxSearchRadiusIndex();
}
} }
public static class SearchHistoryAPI extends SearchBaseAPI { public static class SearchHistoryAPI extends SearchBaseAPI {