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);
|
codedIS.seek(offsets[j] + indexOffset);
|
||||||
int len = readInt();
|
int len = readInt();
|
||||||
int oldLim = codedIS.pushLimit(len);
|
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);
|
codedIS.popLimit(oldLim);
|
||||||
if(req.isCancelled()){
|
if(req.isCancelled()){
|
||||||
return;
|
return;
|
||||||
|
@ -489,7 +489,7 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readPoiData(int left31, int right31, int top31, int bottom31,
|
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 x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
int zoom = 0;
|
int zoom = 0;
|
||||||
|
@ -522,15 +522,17 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
int yp = (int) MapUtils.getTileNumberY(zSkip, am.getLocation().getLatitude());
|
int yp = (int) MapUtils.getTileNumberY(zSkip, am.getLocation().getLatitude());
|
||||||
long val = (((long) xp) << zSkip) | yp;
|
long val = (((long) xp) << zSkip) | yp;
|
||||||
if (!toSkip.contains(val)) {
|
if (!toSkip.contains(val)) {
|
||||||
toSkip.add(val);
|
boolean publish = req.publish(am);
|
||||||
result.add(am);
|
if(publish) {
|
||||||
|
toSkip.add(val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(zSkip <= zoom){
|
if(zSkip <= zoom){
|
||||||
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.add(am);
|
req.publish(am);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(sleft, sright, stop, sbottom, zoom,
|
SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(sleft, sright, stop, sbottom, zoom,
|
||||||
poiTypeFilter, matcher);
|
poiTypeFilter, filter == null ? matcher : filter.getResultMatcher(matcher));
|
||||||
try {
|
try {
|
||||||
List<Amenity> result = index.searchPoi(req);
|
List<Amenity> result = index.searchPoi(req);
|
||||||
amenities.addAll(result);
|
amenities.addAll(result);
|
||||||
|
|
|
@ -443,14 +443,18 @@ public class OsmandSettings {
|
||||||
|
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final OsmandPreference<DayNightMode> DAYNIGHT_MODE =
|
public final CommonPreference<DayNightMode> DAYNIGHT_MODE =
|
||||||
new EnumIntPreference<DayNightMode>("daynight_mode", DayNightMode.AUTO, false, DayNightMode.values()) {
|
new EnumIntPreference<DayNightMode>("daynight_mode", DayNightMode.DAY, false, DayNightMode.values()) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean setValue(SharedPreferences prefs, DayNightMode val) {
|
protected boolean setValue(SharedPreferences prefs, DayNightMode val) {
|
||||||
ctx.getDaynightHelper().setDayNightMode(val);
|
ctx.getDaynightHelper().setDayNightMode(val);
|
||||||
return super.setValue(prefs, 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
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class PoiFilter {
|
||||||
if(nameFilter != null) {
|
if(nameFilter != null) {
|
||||||
this.nameFilter = nameFilter.toLowerCase();
|
this.nameFilter = nameFilter.toLowerCase();
|
||||||
} else {
|
} else {
|
||||||
clearFilter();
|
clearNameFilter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,29 +145,32 @@ public class PoiFilter {
|
||||||
|
|
||||||
return searchAmenities(lat, lon, topLatitude, bottomLatitude, leftLongitude, rightLongitude, matcher);
|
return searchAmenities(lat, lon, topLatitude, bottomLatitude, leftLongitude, rightLongitude, matcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResultMatcher<Amenity> getResultMatcher(final ResultMatcher<Amenity> matcher){
|
||||||
|
if(nameFilter != null) {
|
||||||
|
final boolean en = OsmandSettings.getOsmandSettings(application).USE_ENGLISH_NAMES.get();
|
||||||
|
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 isCancelled() {
|
||||||
|
return false || (matcher != null && matcher.isCancelled());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return matcher;
|
||||||
|
}
|
||||||
|
|
||||||
protected List<Amenity> searchAmenities(double lat, double lon, double topLatitude,
|
protected List<Amenity> searchAmenities(double lat, double lon, double topLatitude,
|
||||||
double bottomLatitude, double leftLongitude, double rightLongitude, final ResultMatcher<Amenity> matcher) {
|
double bottomLatitude, double leftLongitude, double rightLongitude, 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>() {
|
|
||||||
|
|
||||||
@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());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return application.getResourceManager().searchAmenities(this,
|
return application.getResourceManager().searchAmenities(this,
|
||||||
topLatitude, leftLongitude, bottomLatitude, rightLongitude, lat, lon, matcher);
|
topLatitude, leftLongitude, bottomLatitude, rightLongitude, lat, lon, matcher);
|
||||||
}
|
}
|
||||||
|
|
|
@ -569,7 +569,7 @@ public class MapActivityLayers {
|
||||||
getApplication().getSettings().setPoiFilterForMap(filterId);
|
getApplication().getSettings().setPoiFilterForMap(filterId);
|
||||||
PoiFilter f = poiFilters.getFilterById(filterId);
|
PoiFilter f = poiFilters.getFilterById(filterId);
|
||||||
if(f != null){
|
if(f != null){
|
||||||
f.clearFilter();
|
f.clearNameFilter();
|
||||||
}
|
}
|
||||||
poiMapLayer.setFilter(f);
|
poiMapLayer.setFilter(f);
|
||||||
mapView.refreshMap();
|
mapView.refreshMap();
|
||||||
|
|
|
@ -252,7 +252,7 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
|
||||||
clearSearchQuery();
|
clearSearchQuery();
|
||||||
}
|
}
|
||||||
if(filter != null) {
|
if(filter != null) {
|
||||||
filter.clearFilter();
|
filter.clearNameFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isNameFinderFilter()){
|
if(isNameFinderFilter()){
|
||||||
|
|
Loading…
Reference in a new issue