Fix show on map search by name filter

This commit is contained in:
Victor Shcherb 2016-08-22 18:17:29 +03:00
parent f6a856d374
commit aeaa012f4e
5 changed files with 15 additions and 9 deletions

View file

@ -73,7 +73,7 @@ public class NominatimPoiFilter extends PoiUIFilter {
@Override
protected List<Amenity> searchAmenitiesInternal(double lat, double lon, double topLatitude,
double bottomLatitude, double leftLongitude, double rightLongitude, ResultMatcher<Amenity> matcher) {
double bottomLatitude, double leftLongitude, double rightLongitude, int zoom, ResultMatcher<Amenity> matcher) {
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
String NOMINATIM_API;
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {

View file

@ -202,6 +202,12 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
public void clearPreviousZoom() {
distanceInd = 0;
}
public void clearCurrentResults() {
if (currentSearchResult != null) {
currentSearchResult = new ArrayList<>();
}
}
public List<Amenity> initializeNewSearch(double lat, double lon, int firstTimeLimit, ResultMatcher<Amenity> matcher) {
clearPreviousZoom();
@ -236,7 +242,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
double bottomLatitude = Math.max(lat - (distance / baseDistY), -84.);
double leftLongitude = Math.max(lon - (distance / baseDistX), -180);
double rightLongitude = Math.min(lon + (distance / baseDistX), 180);
return searchAmenitiesInternal(lat, lon, topLatitude, bottomLatitude, leftLongitude, rightLongitude, matcher);
return searchAmenitiesInternal(lat, lon, topLatitude, bottomLatitude, leftLongitude, rightLongitude, -1, matcher);
}
public List<Amenity> searchAmenities(double top, double left, double bottom, double right, int zoom,
@ -254,8 +260,8 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
}
}
}
List<Amenity> amenities = app.getResourceManager().searchAmenities(this, top, left, bottom, right, zoom,
wrapResultMatcher(matcher));
List<Amenity> amenities = searchAmenitiesInternal(top / 2 + bottom / 2, left / 2 + right / 2,
top, bottom, left, right, zoom, matcher);
results.addAll(amenities);
return results;
}
@ -265,9 +271,9 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
}
protected List<Amenity> searchAmenitiesInternal(double lat, double lon, double topLatitude,
double bottomLatitude, double leftLongitude, double rightLongitude, final ResultMatcher<Amenity> matcher) {
double bottomLatitude, double leftLongitude, double rightLongitude, int zoom, final ResultMatcher<Amenity> matcher) {
return app.getResourceManager().searchAmenities(this,
topLatitude, leftLongitude, bottomLatitude, rightLongitude, -1, wrapResultMatcher(matcher));
topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, wrapResultMatcher(matcher));
}
public AmenityNameFilter getNameFilter(String filter) {

View file

@ -32,7 +32,7 @@ public class SearchByNameFilter extends PoiUIFilter {
@Override
protected List<Amenity> searchAmenitiesInternal(double lat, double lon, double topLatitude,
double bottomLatitude, double leftLongitude, double rightLongitude, final ResultMatcher<Amenity> matcher) {
double bottomLatitude, double leftLongitude, double rightLongitude, int zoom, final ResultMatcher<Amenity> matcher) {
currentSearchResult = new ArrayList<Amenity>();
final int limit = distanceInd == 0 ? 500 : -1;
List<Amenity> result = Collections.emptyList();

View file

@ -219,9 +219,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} else if (searchPhrase.isNoSelectedType() || searchPhrase.isLastWord(ObjectType.POI_TYPE)) {
PoiUIFilter filter;
if (searchPhrase.isNoSelectedType()) {
filter = new PoiUIFilter(null, app, "");
filter = app.getPoiFilters().getSearchByNamePOIFilter();
if (!Algorithms.isEmpty(searchPhrase.getUnknownSearchWord())) {
filter.setFilterByName(searchPhrase.getUnknownSearchWord());
filter.clearCurrentResults();
}
} else if (searchPhrase.getLastSelectedWord().getResult().object instanceof AbstractPoiType) {
if (searchPhrase.isNoSelectedType()) {

View file

@ -80,7 +80,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
private Bitmap poiBackgroundSmall;
private OsmandMapTileView view;
private final static int MAXIMUM_SHOW_AMENITIES = 5;
private RoutingHelper routingHelper;
private Set<PoiUIFilter> filters = new TreeSet<>();