From bbd7678425c995eb921135ff9082390b9107bfb4 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Fri, 18 Dec 2020 14:43:44 +0300 Subject: [PATCH] Small fixes TravelObfHelper --- .../osmand/binary/BinaryMapIndexReader.java | 5 +++ .../plus/wikivoyage/data/TravelObfHelper.java | 34 ++++++++----------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java index 035b33d470..f0b26d09e8 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java @@ -1568,6 +1568,10 @@ public class BinaryMapIndexReader { } public static SearchRequest buildSearchPoiRequest(int x, int y, String nameFilter, int sleft, int sright, int stop, int sbottom, ResultMatcher resultMatcher, ResultMatcher rawDataCollector) { + return buildSearchPoiRequest(x, y, nameFilter, sleft, sright, stop, sbottom, null, resultMatcher, null); + } + + public static SearchRequest buildSearchPoiRequest(int x, int y, String nameFilter, int sleft, int sright, int stop, int sbottom, SearchPoiTypeFilter poiTypeFilter, ResultMatcher resultMatcher, ResultMatcher rawDataCollector) { SearchRequest request = new SearchRequest(); request.x = x; request.y = y; @@ -1575,6 +1579,7 @@ public class BinaryMapIndexReader { request.right = sright; request.top = stop; request.bottom = sbottom; + request.poiTypeFilter = poiTypeFilter; request.resultMatcher = resultMatcher; request.rawDataCollector = rawDataCollector; request.nameQuery = nameFilter.trim(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index c760baa04b..bb1a86fcb4 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -126,7 +126,7 @@ public class TravelObfHelper implements TravelHelper { res.lon = amenity.getLocation().getLongitude(); res.imageTitle = emptyIfNull(amenity.getTagContent(Amenity.IMAGE_TITLE, lang)); res.routeId = getRouteId(amenity); - res.originalId = 0; //? + res.originalId = 0; res.lang = lang; res.contentsJson = emptyIfNull(amenity.getTagContent(Amenity.CONTENT_JSON, lang)); res.aggregatedPartOf = emptyIfNull(amenity.getTagContent(Amenity.IS_AGGR_PART, lang)); @@ -149,8 +149,7 @@ public class TravelObfHelper implements TravelHelper { @NonNull @Override public List search(String searchQuery) { - List res = new ArrayList<>(); - return res; + return Collections.emptyList(); } @NonNull @@ -179,24 +178,23 @@ public class TravelObfHelper implements TravelHelper { final List amenities = new ArrayList<>(); for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { try { - int left = 0; - int right = Integer.MAX_VALUE; - int top = 0; - int bottom = Integer.MAX_VALUE; BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - left, right, top, bottom, -1, getSearchRouteArticleFilter(), + 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, -1, getSearchRouteArticleFilter(), new ResultMatcher() { + boolean done = false; + @Override public boolean publish(Amenity amenity) { if (getRouteId(amenity).equals(routeId)) { amenities.add(amenity); + done = true; } return false; } @Override public boolean isCancelled() { - return false; + return done; } }); @@ -218,28 +216,26 @@ public class TravelObfHelper implements TravelHelper { final List amenities = new ArrayList<>(); for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { try { - int left = 0; - int right = Integer.MAX_VALUE; - int top = 0; - int bottom = Integer.MAX_VALUE; BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - 0, 0, title, left, right, top, bottom, + 0, 0, title, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, getSearchRouteArticleFilter(), new ResultMatcher() { + boolean done = false; + final Collator collator = OsmAndCollator.primaryCollator(); + @Override public boolean publish(Amenity amenity) { - Collator collator = OsmAndCollator.primaryCollator(); - if (CollatorStringMatcher.cmatches(collator, title, amenity.getName(lang), - CHECK_EQUALS_FROM_SPACE) && amenity.getSubType().equals(ROUTE_ARTICLE)) { + if (CollatorStringMatcher.cmatches(collator, title, amenity.getName(lang), CHECK_EQUALS_FROM_SPACE)) { amenities.add(amenity); + done = true; } return false; } @Override public boolean isCancelled() { - return false; + return done; } - }); + }, null); travelBookReader.searchPoiByName(req); } catch (IOException e) {