From 26b7ece3717f764db78308380b4810a0e53186e6 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 16 Apr 2021 12:23:44 +0300 Subject: [PATCH 1/2] Fix out of memory error --- .../osmand/plus/wikivoyage/data/TravelObfHelper.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 1cde05050b..60c51a8879 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -124,8 +124,8 @@ public class TravelObfHelper implements TravelHelper { final LatLon location = app.getMapViewTrackingUtilities().getMapLocation(); for (final BinaryMapIndexReader reader : getReaders()) { try { - searchAmenity(foundAmenities, location, reader, searchRadius, -1, ROUTE_ARTICLE); - searchAmenity(foundAmenities, location, reader, searchRadius / 5, 15, ROUTE_TRACK); + searchAmenity(foundAmenities, location, reader, searchRadius, -1, ROUTE_ARTICLE, lang); + searchAmenity(foundAmenities, location, reader, searchRadius / 5, 15, ROUTE_TRACK, null); } catch (Exception e) { LOG.error(e.getMessage(), e); } @@ -172,12 +172,14 @@ public class TravelObfHelper implements TravelHelper { private void searchAmenity(final List> amenitiesList, LatLon location, final BinaryMapIndexReader reader, int searchRadius, int zoom, - String searchFilter) throws IOException { + String searchFilter, final String lang) throws IOException { reader.searchPoi(BinaryMapIndexReader.buildSearchPoiRequest( location, searchRadius, zoom, getSearchFilter(searchFilter), new ResultMatcher() { @Override public boolean publish(Amenity object) { - amenitiesList.add(new Pair<>(reader.getFile(), object)); + if (lang == null || object.getNamesMap(true).containsKey(lang)) { + amenitiesList.add(new Pair<>(reader.getFile(), object)); + } return false; } @@ -231,7 +233,7 @@ public class TravelObfHelper implements TravelHelper { } res.user = Algorithms.emptyIfNull(amenity.getTagContent(USER)); res.activityType = Algorithms.emptyIfNull(amenity.getTagContent(ACTIVITY_TYPE)); - articles.put("en", res); + articles.put("", res); return articles; } From 99c42b954ce2375b454e7894519ec4cfb80e866b Mon Sep 17 00:00:00 2001 From: vshcherb Date: Fri, 16 Apr 2021 17:16:02 +0200 Subject: [PATCH 2/2] Update TravelObfHelper.java --- .../src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 60c51a8879..7e8a0a3f02 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -72,7 +72,7 @@ public class TravelObfHelper implements TravelHelper { public static final String ROUTE_TRACK = "route_track"; public static final int ARTICLE_SEARCH_RADIUS = 50 * 1000; public static final int SAVED_ARTICLE_SEARCH_RADIUS = 30 * 1000; - public static final int MAX_SEARCH_RADIUS = 10000 * 1000; + public static final int MAX_SEARCH_RADIUS = 800 * 1000; public static final String REF_TAG = "ref"; public static final String NAME_TAG = "name"; @@ -1085,4 +1085,4 @@ public class TravelObfHelper implements TravelHelper { } } } -} \ No newline at end of file +}