Add small fixes

This commit is contained in:
Alexander Sytnyk 2017-10-24 16:03:54 +03:00
parent be21c20bbe
commit 0eff2e7850
2 changed files with 14 additions and 15 deletions

View file

@ -57,7 +57,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
protected int distanceInd = 0; protected int distanceInd = 0;
// in kilometers // in kilometers
protected double[] distanceToSearchValues = new double[] { 1, 2, 5, 10, 20, 50, 100, 200, 500 }; protected double[] distanceToSearchValues = new double[]{1, 2, 5, 10, 20, 50, 100, 200, 500};
private final MapPoiTypes poiTypes; private final MapPoiTypes poiTypes;
@ -96,7 +96,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
// constructor for user defined filters // constructor for user defined filters
public PoiUIFilter(String name, String filterId, public PoiUIFilter(String name, String filterId,
Map<PoiCategory, LinkedHashSet<String>> acceptedTypes, OsmandApplication app) { Map<PoiCategory, LinkedHashSet<String>> acceptedTypes, OsmandApplication app) {
this.app = app; this.app = app;
isStandardFilter = false; isStandardFilter = false;
poiTypes = app.getPoiTypes(); poiTypes = app.getPoiTypes();
@ -214,6 +214,8 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
clearPreviousZoom(); clearPreviousZoom();
} else if (radius < distanceToSearchValues.length) { } else if (radius < distanceToSearchValues.length) {
distanceInd = radius; distanceInd = radius;
} else {
distanceInd = distanceToSearchValues.length - 1;
} }
List<Amenity> amenityList = searchAmenities(lat, lon, matcher); List<Amenity> amenityList = searchAmenities(lat, lon, matcher);
MapUtils.sortListOfMapObject(amenityList, lat, lon); MapUtils.sortListOfMapObject(amenityList, lat, lon);
@ -250,7 +252,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
} }
public List<Amenity> searchAmenities(double top, double left, double bottom, double right, int zoom, public List<Amenity> searchAmenities(double top, double left, double bottom, double right, int zoom,
ResultMatcher<Amenity> matcher) { ResultMatcher<Amenity> matcher) {
List<Amenity> results = new ArrayList<Amenity>(); List<Amenity> results = new ArrayList<Amenity>();
List<Amenity> tempResults = currentSearchResult; List<Amenity> tempResults = currentSearchResult;
if (tempResults != null) { if (tempResults != null) {
@ -275,7 +277,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
} }
protected List<Amenity> searchAmenitiesInternal(double lat, double lon, double topLatitude, protected List<Amenity> searchAmenitiesInternal(double lat, double lon, double topLatitude,
double bottomLatitude, double leftLongitude, double rightLongitude, int zoom, final ResultMatcher<Amenity> matcher) { double bottomLatitude, double leftLongitude, double rightLongitude, int zoom, final ResultMatcher<Amenity> matcher) {
return app.getResourceManager().searchAmenities(this, return app.getResourceManager().searchAmenities(this,
topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, wrapResultMatcher(matcher)); topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, wrapResultMatcher(matcher));
} }
@ -319,10 +321,10 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
} }
private AmenityNameFilter getNameFilterInternal(StringBuilder nmFilter, private AmenityNameFilter getNameFilterInternal(StringBuilder nmFilter,
final boolean allTime, final boolean open, final List<PoiType> poiAdditionals) { final boolean allTime, final boolean open, final List<PoiType> poiAdditionals) {
final CollatorStringMatcher sm = final CollatorStringMatcher sm =
nmFilter.length() > 0 ? nmFilter.length() > 0 ?
new CollatorStringMatcher(nmFilter.toString().trim(), StringMatcherMode.CHECK_CONTAINS) : null; new CollatorStringMatcher(nmFilter.toString().trim(), StringMatcherMode.CHECK_CONTAINS) : null;
return new AmenityNameFilter() { return new AmenityNameFilter() {
@Override @Override
@ -337,8 +339,8 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
if (poiAdditionals != null) { if (poiAdditionals != null) {
Map<PoiType, PoiType> textPoiAdditionalsMap = new HashMap<>(); Map<PoiType, PoiType> textPoiAdditionalsMap = new HashMap<>();
Map<String, List<PoiType>> poiAdditionalCategoriesMap = new HashMap<>(); Map<String, List<PoiType>> poiAdditionalCategoriesMap = new HashMap<>();
for (PoiType pt : poiAdditionals) { for (PoiType pt : poiAdditionals) {
String category = pt.getPoiAdditionalCategory(); String category = pt.getPoiAdditionalCategory();
List<PoiType> types = poiAdditionalCategoriesMap.get(category); List<PoiType> types = poiAdditionalCategoriesMap.get(category);
if (types == null) { if (types == null) {
types = new ArrayList<>(); types = new ArrayList<>();

View file

@ -39,7 +39,8 @@ public class QuickSearchHelper implements ResourceListener {
public static final int SEARCH_WPT_OBJECT_PRIORITY = 52; public static final int SEARCH_WPT_OBJECT_PRIORITY = 52;
public static final int SEARCH_HISTORY_API_PRIORITY = 50; public static final int SEARCH_HISTORY_API_PRIORITY = 50;
public static final int SEARCH_HISTORY_OBJECT_PRIORITY = 53; public static final int SEARCH_HISTORY_OBJECT_PRIORITY = 53;
public static final int SEARCH_ONLINE_PRIORITY = 53; public static final int SEARCH_ONLINE_AMENITY_PRIORITY = 700;
public static final int SEARCH_ONLINE_ADDRESS_PRIORITY = 500;
private OsmandApplication app; private OsmandApplication app;
private SearchUICore core; private SearchUICore core;
private SearchResultCollection resultCollection; private SearchResultCollection resultCollection;
@ -302,15 +303,11 @@ public class QuickSearchHelper implements ResourceListener {
SearchResult sr = new SearchResult(phrase); SearchResult sr = new SearchResult(phrase);
sr.localeName = amenity.getName(); sr.localeName = amenity.getName();
sr.object = amenity; sr.object = amenity;
sr.priority = SEARCH_ONLINE_PRIORITY + (p++); sr.priority = poi ? SEARCH_ONLINE_AMENITY_PRIORITY : SEARCH_ONLINE_ADDRESS_PRIORITY + (p++);
sr.objectType = poi ? ObjectType.POI : ObjectType.POI; // todo sr.objectType = poi ? ObjectType.POI : ObjectType.POI; // todo
sr.location = amenity.getLocation(); sr.location = amenity.getLocation();
sr.preferredZoom = 17; sr.preferredZoom = 17;
if (phrase.getUnknownSearchWordLength() <= 1 && phrase.isNoSelectedType()) { matcher.publish(sr);
matcher.publish(sr);
} else if (phrase.getNameStringMatcher().matches(sr.localeName)) {
matcher.publish(sr);
}
} }
} }
} }