Merge pull request #11437 from osmandapp/fix_11328

Fix out of memory error
This commit is contained in:
vshcherb 2021-04-16 17:00:52 +02:00 committed by GitHub
commit 59484136b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -124,8 +124,8 @@ public class TravelObfHelper implements TravelHelper {
final LatLon location = app.getMapViewTrackingUtilities().getMapLocation(); final LatLon location = app.getMapViewTrackingUtilities().getMapLocation();
for (final BinaryMapIndexReader reader : getReaders()) { for (final BinaryMapIndexReader reader : getReaders()) {
try { try {
searchAmenity(foundAmenities, location, reader, searchRadius, -1, ROUTE_ARTICLE); searchAmenity(foundAmenities, location, reader, searchRadius, -1, ROUTE_ARTICLE, lang);
searchAmenity(foundAmenities, location, reader, searchRadius / 5, 15, ROUTE_TRACK); searchAmenity(foundAmenities, location, reader, searchRadius / 5, 15, ROUTE_TRACK, null);
} catch (Exception e) { } catch (Exception e) {
LOG.error(e.getMessage(), e); LOG.error(e.getMessage(), e);
} }
@ -172,12 +172,14 @@ public class TravelObfHelper implements TravelHelper {
private void searchAmenity(final List<Pair<File, Amenity>> amenitiesList, LatLon location, private void searchAmenity(final List<Pair<File, Amenity>> amenitiesList, LatLon location,
final BinaryMapIndexReader reader, int searchRadius, int zoom, final BinaryMapIndexReader reader, int searchRadius, int zoom,
String searchFilter) throws IOException { String searchFilter, final String lang) throws IOException {
reader.searchPoi(BinaryMapIndexReader.buildSearchPoiRequest( reader.searchPoi(BinaryMapIndexReader.buildSearchPoiRequest(
location, searchRadius, zoom, getSearchFilter(searchFilter), new ResultMatcher<Amenity>() { location, searchRadius, zoom, getSearchFilter(searchFilter), new ResultMatcher<Amenity>() {
@Override @Override
public boolean publish(Amenity object) { public boolean publish(Amenity object) {
if (lang == null || object.getNamesMap(true).containsKey(lang)) {
amenitiesList.add(new Pair<>(reader.getFile(), object)); amenitiesList.add(new Pair<>(reader.getFile(), object));
}
return false; return false;
} }
@ -231,7 +233,7 @@ public class TravelObfHelper implements TravelHelper {
} }
res.user = Algorithms.emptyIfNull(amenity.getTagContent(USER)); res.user = Algorithms.emptyIfNull(amenity.getTagContent(USER));
res.activityType = Algorithms.emptyIfNull(amenity.getTagContent(ACTIVITY_TYPE)); res.activityType = Algorithms.emptyIfNull(amenity.getTagContent(ACTIVITY_TYPE));
articles.put("en", res); articles.put("", res);
return articles; return articles;
} }