Added getMinimalSearchRadius to searchuicore
This commit is contained in:
parent
d2ab7c0477
commit
b49156d938
3 changed files with 39 additions and 1 deletions
|
@ -490,6 +490,17 @@ public class SearchUICore {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMinimalSearchRadius(SearchPhrase phrase) {
|
||||||
|
int radius = Integer.MAX_VALUE;
|
||||||
|
for (SearchCoreAPI api : apis) {
|
||||||
|
int apiMinimalRadius = api.getMinimalSearchRadius(phrase);
|
||||||
|
if (apiMinimalRadius > 0 && apiMinimalRadius < radius) {
|
||||||
|
radius = apiMinimalRadius;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return radius;
|
||||||
|
}
|
||||||
|
|
||||||
private void searchInBackground(final SearchPhrase phrase, SearchResultMatcher matcher) {
|
private void searchInBackground(final SearchPhrase phrase, SearchResultMatcher matcher) {
|
||||||
preparePhrase(phrase);
|
preparePhrase(phrase);
|
||||||
ArrayList<SearchCoreAPI> lst = new ArrayList<>(apis);
|
ArrayList<SearchCoreAPI> lst = new ArrayList<>(apis);
|
||||||
|
|
|
@ -21,4 +21,10 @@ public interface SearchCoreAPI {
|
||||||
public boolean isSearchMoreAvailable(SearchPhrase phrase);
|
public boolean isSearchMoreAvailable(SearchPhrase phrase);
|
||||||
|
|
||||||
boolean isSearchAvailable(SearchPhrase p);
|
boolean isSearchAvailable(SearchPhrase p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param phrase
|
||||||
|
* @return minimal search radius in meters
|
||||||
|
*/
|
||||||
|
int getMinimalSearchRadius(SearchPhrase phrase);
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,11 @@ public class SearchCoreFactory {
|
||||||
return phrase.getRadiusLevel() < MAX_DEFAULT_SEARCH_RADIUS;
|
return phrase.getRadiusLevel() < MAX_DEFAULT_SEARCH_RADIUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinimalSearchRadius(SearchPhrase phrase) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected void subSearchApiOrPublish(SearchPhrase phrase,
|
protected void subSearchApiOrPublish(SearchPhrase phrase,
|
||||||
SearchResultMatcher resultMatcher, SearchResult res, SearchBaseAPI api)
|
SearchResultMatcher resultMatcher, SearchResult res, SearchBaseAPI api)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
@ -258,6 +263,11 @@ public class SearchCoreFactory {
|
||||||
return getSearchPriority(phrase) != -1 && super.isSearchMoreAvailable(phrase);
|
return getSearchPriority(phrase) != -1 && super.isSearchMoreAvailable(phrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinimalSearchRadius(SearchPhrase phrase) {
|
||||||
|
return phrase.getRadiusSearch(DEFAULT_ADDRESS_BBOX_RADIUS);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean search(final SearchPhrase phrase, final SearchResultMatcher resultMatcher) throws IOException {
|
public boolean search(final SearchPhrase phrase, final SearchResultMatcher resultMatcher) throws IOException {
|
||||||
if (!phrase.isUnknownSearchWordPresent() && !phrase.isEmptyQueryAllowed()) {
|
if (!phrase.isUnknownSearchWordPresent() && !phrase.isEmptyQueryAllowed()) {
|
||||||
|
@ -575,6 +585,11 @@ public class SearchCoreFactory {
|
||||||
public boolean isSearchMoreAvailable(SearchPhrase phrase) {
|
public boolean isSearchMoreAvailable(SearchPhrase phrase) {
|
||||||
return super.isSearchMoreAvailable(phrase) && getSearchPriority(phrase) != -1;
|
return super.isSearchMoreAvailable(phrase) && getSearchPriority(phrase) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinimalSearchRadius(SearchPhrase phrase) {
|
||||||
|
return phrase.getRadiusSearch(BBOX_RADIUS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -700,6 +715,7 @@ public class SearchCoreFactory {
|
||||||
|
|
||||||
|
|
||||||
public static class SearchAmenityByTypeAPI extends SearchBaseAPI {
|
public static class SearchAmenityByTypeAPI extends SearchBaseAPI {
|
||||||
|
private static final int BBOX_RADIUS = 10000;
|
||||||
|
|
||||||
private MapPoiTypes types;
|
private MapPoiTypes types;
|
||||||
|
|
||||||
|
@ -713,6 +729,11 @@ public class SearchCoreFactory {
|
||||||
return getSearchPriority(phrase) != -1 && super.isSearchMoreAvailable(phrase);
|
return getSearchPriority(phrase) != -1 && super.isSearchMoreAvailable(phrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinimalSearchRadius(SearchPhrase phrase) {
|
||||||
|
return phrase.getRadiusSearch(BBOX_RADIUS);
|
||||||
|
}
|
||||||
|
|
||||||
private Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<PoiCategory,
|
private Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<PoiCategory,
|
||||||
LinkedHashSet<String>>();
|
LinkedHashSet<String>>();
|
||||||
private Map<String, PoiType> poiAdditionals = new HashMap<String, PoiType>();
|
private Map<String, PoiType> poiAdditionals = new HashMap<String, PoiType>();
|
||||||
|
@ -750,7 +771,7 @@ public class SearchCoreFactory {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
QuadRect bbox = phrase.getRadiusBBoxToSearch(10000);
|
QuadRect bbox = phrase.getRadiusBBoxToSearch(BBOX_RADIUS);
|
||||||
List<BinaryMapIndexReader> oo = phrase.getOfflineIndexes();
|
List<BinaryMapIndexReader> oo = phrase.getOfflineIndexes();
|
||||||
Set<String> searchedPois = new TreeSet<>();
|
Set<String> searchedPois = new TreeSet<>();
|
||||||
for (BinaryMapIndexReader o : oo) {
|
for (BinaryMapIndexReader o : oo) {
|
||||||
|
|
Loading…
Reference in a new issue