Improved search by name filter now displayed on the map
This commit is contained in:
parent
3cff2e0d77
commit
c9c2d491ba
6 changed files with 40 additions and 31 deletions
|
@ -433,7 +433,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
codedIS.seek(offsets[j] + indexOffset);
|
||||
int len = readInt();
|
||||
int oldLim = codedIS.pushLimit(len);
|
||||
readPoiData(left31, right31, top31, bottom31, req, req.getSearchResults(), region, skipTiles, zoomToSkip);
|
||||
readPoiData(left31, right31, top31, bottom31, req, region, skipTiles, zoomToSkip);
|
||||
codedIS.popLimit(oldLim);
|
||||
if(req.isCancelled()){
|
||||
return;
|
||||
|
@ -489,7 +489,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
}
|
||||
|
||||
private void readPoiData(int left31, int right31, int top31, int bottom31,
|
||||
SearchRequest<Amenity> req, List<Amenity> result, PoiRegion region, TLongHashSet toSkip, int zSkip) throws IOException {
|
||||
SearchRequest<Amenity> req, PoiRegion region, TLongHashSet toSkip, int zSkip) throws IOException {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int zoom = 0;
|
||||
|
@ -522,15 +522,17 @@ public class BinaryMapPoiReaderAdapter {
|
|||
int yp = (int) MapUtils.getTileNumberY(zSkip, am.getLocation().getLatitude());
|
||||
long val = (((long) xp) << zSkip) | yp;
|
||||
if (!toSkip.contains(val)) {
|
||||
toSkip.add(val);
|
||||
result.add(am);
|
||||
boolean publish = req.publish(am);
|
||||
if(publish) {
|
||||
toSkip.add(val);
|
||||
}
|
||||
}
|
||||
if(zSkip <= zoom){
|
||||
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
result.add(am);
|
||||
req.publish(am);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -83,7 +83,7 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
|
|||
}
|
||||
};
|
||||
SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(sleft, sright, stop, sbottom, zoom,
|
||||
poiTypeFilter, matcher);
|
||||
poiTypeFilter, filter == null ? matcher : filter.getResultMatcher(matcher));
|
||||
try {
|
||||
List<Amenity> result = index.searchPoi(req);
|
||||
amenities.addAll(result);
|
||||
|
|
|
@ -443,14 +443,18 @@ public class OsmandSettings {
|
|||
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<DayNightMode> DAYNIGHT_MODE =
|
||||
new EnumIntPreference<DayNightMode>("daynight_mode", DayNightMode.AUTO, false, DayNightMode.values()) {
|
||||
public final CommonPreference<DayNightMode> DAYNIGHT_MODE =
|
||||
new EnumIntPreference<DayNightMode>("daynight_mode", DayNightMode.DAY, false, DayNightMode.values()) {
|
||||
@Override
|
||||
protected boolean setValue(SharedPreferences prefs, DayNightMode val) {
|
||||
ctx.getDaynightHelper().setDayNightMode(val);
|
||||
return super.setValue(prefs, val);
|
||||
}
|
||||
};
|
||||
{
|
||||
DAYNIGHT_MODE.setModeDefaultValue(ApplicationMode.CAR, DayNightMode.AUTO);
|
||||
DAYNIGHT_MODE.setModeDefaultValue(ApplicationMode.BICYCLE, DayNightMode.AUTO);
|
||||
}
|
||||
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
|
|
|
@ -73,7 +73,7 @@ public class PoiFilter {
|
|||
if(nameFilter != null) {
|
||||
this.nameFilter = nameFilter.toLowerCase();
|
||||
} else {
|
||||
clearFilter();
|
||||
clearNameFilter();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,28 +146,31 @@ public class PoiFilter {
|
|||
return searchAmenities(lat, lon, topLatitude, bottomLatitude, leftLongitude, rightLongitude, matcher);
|
||||
}
|
||||
|
||||
protected List<Amenity> searchAmenities(double lat, double lon, double topLatitude,
|
||||
double bottomLatitude, double leftLongitude, double rightLongitude, final ResultMatcher<Amenity> matcher) {
|
||||
public ResultMatcher<Amenity> getResultMatcher(final ResultMatcher<Amenity> matcher){
|
||||
if(nameFilter != null) {
|
||||
final boolean en = OsmandSettings.getOsmandSettings(application).USE_ENGLISH_NAMES.get();
|
||||
application.getResourceManager().searchAmenities(this,
|
||||
topLatitude, leftLongitude, bottomLatitude, rightLongitude, lat, lon, new ResultMatcher<Amenity>() {
|
||||
return new ResultMatcher<Amenity>() {
|
||||
@Override
|
||||
public boolean publish(Amenity object) {
|
||||
if(!OsmAndFormatter.getPoiStringWithoutType(object, en).toLowerCase().contains(nameFilter) ||
|
||||
(matcher != null && !matcher.publish(object))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean publish(Amenity object) {
|
||||
if(!OsmAndFormatter.getPoiStringWithoutType(object, en).toLowerCase().contains(nameFilter) ||
|
||||
(matcher != null && !matcher.publish(object))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return false || (matcher != null && matcher.isCancelled());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return false || (matcher != null && matcher.isCancelled());
|
||||
}
|
||||
};
|
||||
}
|
||||
return matcher;
|
||||
}
|
||||
|
||||
protected List<Amenity> searchAmenities(double lat, double lon, double topLatitude,
|
||||
double bottomLatitude, double leftLongitude, double rightLongitude, final ResultMatcher<Amenity> matcher) {
|
||||
|
||||
return application.getResourceManager().searchAmenities(this,
|
||||
topLatitude, leftLongitude, bottomLatitude, rightLongitude, lat, lon, matcher);
|
||||
}
|
||||
|
|
|
@ -569,7 +569,7 @@ public class MapActivityLayers {
|
|||
getApplication().getSettings().setPoiFilterForMap(filterId);
|
||||
PoiFilter f = poiFilters.getFilterById(filterId);
|
||||
if(f != null){
|
||||
f.clearFilter();
|
||||
f.clearNameFilter();
|
||||
}
|
||||
poiMapLayer.setFilter(f);
|
||||
mapView.refreshMap();
|
||||
|
|
|
@ -252,7 +252,7 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
|
|||
clearSearchQuery();
|
||||
}
|
||||
if(filter != null) {
|
||||
filter.clearFilter();
|
||||
filter.clearNameFilter();
|
||||
}
|
||||
|
||||
if(isNameFinderFilter()){
|
||||
|
|
Loading…
Reference in a new issue