From 5a84df2dde0cb179478eb999df976538c1157867 Mon Sep 17 00:00:00 2001 From: MadWasp79 Date: Tue, 1 Dec 2020 10:45:06 +0200 Subject: [PATCH] Wikivoyage to OBF migration: Show detailed articles. PR fixes --- .../plus/wikivoyage/data/TravelObfHelper.java | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 298d0f3d9d..0b9398a908 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -205,9 +205,8 @@ public class TravelObfHelper implements TravelHelper{ } } } catch (Exception e) { - e.printStackTrace(); + LOG.error(e.getMessage()); } - return popularArticles; } @@ -220,16 +219,7 @@ public class TravelObfHelper implements TravelHelper{ res.lat = amenity.getLocation().getLatitude(); res.lon = amenity.getLocation().getLongitude(); res.imageTitle = amenity.getTagContent(Amenity.IMAGE_TITLE, lang) == null ? "" : amenity.getTagContent(Amenity.IMAGE_TITLE, lang); - long tripId = -1; - String val = amenity.getTagContent(Amenity.ROUTE_ID, null); - if (val != null && val.startsWith("Q")) { - try { - tripId = Long.parseLong(val.substring(1)); - } catch (NumberFormatException nfe) { - LOG.error(nfe.getMessage()); - } - } - res.tripId = tripId; + res.tripId = getTripId(amenity); res.originalId = 0; //? res.lang = lang; res.contentsJson = amenity.getTagContent(Amenity.CONTENT_JSON, lang) == null ? "" : amenity.getTagContent(Amenity.CONTENT_JSON, lang); @@ -246,6 +236,19 @@ public class TravelObfHelper implements TravelHelper{ return res; } + private long getTripId(Amenity amenity) { + long tripId = -1; + String val = amenity.getTagContent(Amenity.ROUTE_ID, null); + if (val != null && val.startsWith("Q")) { + try { + tripId = Long.parseLong(val.substring(1)); + } catch (NumberFormatException nfe) { + LOG.error(nfe.getMessage()); + } + } + return tripId; + } + private BinaryMapIndexReader getBookBinaryIndex() throws IOException { application.getSettings().SELECTED_TRAVEL_BOOK.set(selectedTravelBook.getName()); try { @@ -302,10 +305,7 @@ public class TravelObfHelper implements TravelHelper{ int top = 0; int right = Integer.MAX_VALUE; int bottom = Integer.MAX_VALUE; - final List results = new ArrayList<>(); - LatLon ll = application.getMapViewTrackingUtilities().getMapLocation(); - BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( MapUtils.get31TileNumberX(ll.getLongitude()), MapUtils.get31TileNumberY(ll.getLatitude()), title, @@ -314,7 +314,6 @@ public class TravelObfHelper implements TravelHelper{ @Override public boolean publish(Amenity object) { if (object.getName(lang).equals(title)) { - results.add(object); return true; } return false;