Small fixes TravelObfHelper
This commit is contained in:
parent
1cd07abf92
commit
bbd7678425
2 changed files with 20 additions and 19 deletions
|
@ -1568,6 +1568,10 @@ public class BinaryMapIndexReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SearchRequest<Amenity> buildSearchPoiRequest(int x, int y, String nameFilter, int sleft, int sright, int stop, int sbottom, ResultMatcher<Amenity> resultMatcher, ResultMatcher<Amenity> rawDataCollector) {
|
public static SearchRequest<Amenity> buildSearchPoiRequest(int x, int y, String nameFilter, int sleft, int sright, int stop, int sbottom, ResultMatcher<Amenity> resultMatcher, ResultMatcher<Amenity> rawDataCollector) {
|
||||||
|
return buildSearchPoiRequest(x, y, nameFilter, sleft, sright, stop, sbottom, null, resultMatcher, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SearchRequest<Amenity> buildSearchPoiRequest(int x, int y, String nameFilter, int sleft, int sright, int stop, int sbottom, SearchPoiTypeFilter poiTypeFilter, ResultMatcher<Amenity> resultMatcher, ResultMatcher<Amenity> rawDataCollector) {
|
||||||
SearchRequest<Amenity> request = new SearchRequest<Amenity>();
|
SearchRequest<Amenity> request = new SearchRequest<Amenity>();
|
||||||
request.x = x;
|
request.x = x;
|
||||||
request.y = y;
|
request.y = y;
|
||||||
|
@ -1575,6 +1579,7 @@ public class BinaryMapIndexReader {
|
||||||
request.right = sright;
|
request.right = sright;
|
||||||
request.top = stop;
|
request.top = stop;
|
||||||
request.bottom = sbottom;
|
request.bottom = sbottom;
|
||||||
|
request.poiTypeFilter = poiTypeFilter;
|
||||||
request.resultMatcher = resultMatcher;
|
request.resultMatcher = resultMatcher;
|
||||||
request.rawDataCollector = rawDataCollector;
|
request.rawDataCollector = rawDataCollector;
|
||||||
request.nameQuery = nameFilter.trim();
|
request.nameQuery = nameFilter.trim();
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class TravelObfHelper implements TravelHelper {
|
||||||
res.lon = amenity.getLocation().getLongitude();
|
res.lon = amenity.getLocation().getLongitude();
|
||||||
res.imageTitle = emptyIfNull(amenity.getTagContent(Amenity.IMAGE_TITLE, lang));
|
res.imageTitle = emptyIfNull(amenity.getTagContent(Amenity.IMAGE_TITLE, lang));
|
||||||
res.routeId = getRouteId(amenity);
|
res.routeId = getRouteId(amenity);
|
||||||
res.originalId = 0; //?
|
res.originalId = 0;
|
||||||
res.lang = lang;
|
res.lang = lang;
|
||||||
res.contentsJson = emptyIfNull(amenity.getTagContent(Amenity.CONTENT_JSON, lang));
|
res.contentsJson = emptyIfNull(amenity.getTagContent(Amenity.CONTENT_JSON, lang));
|
||||||
res.aggregatedPartOf = emptyIfNull(amenity.getTagContent(Amenity.IS_AGGR_PART, lang));
|
res.aggregatedPartOf = emptyIfNull(amenity.getTagContent(Amenity.IS_AGGR_PART, lang));
|
||||||
|
@ -149,8 +149,7 @@ public class TravelObfHelper implements TravelHelper {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public List<WikivoyageSearchResult> search(String searchQuery) {
|
public List<WikivoyageSearchResult> search(String searchQuery) {
|
||||||
List<WikivoyageSearchResult> res = new ArrayList<>();
|
return Collections.emptyList();
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -179,24 +178,23 @@ public class TravelObfHelper implements TravelHelper {
|
||||||
final List<Amenity> amenities = new ArrayList<>();
|
final List<Amenity> amenities = new ArrayList<>();
|
||||||
for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) {
|
for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) {
|
||||||
try {
|
try {
|
||||||
int left = 0;
|
|
||||||
int right = Integer.MAX_VALUE;
|
|
||||||
int top = 0;
|
|
||||||
int bottom = Integer.MAX_VALUE;
|
|
||||||
BinaryMapIndexReader.SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(
|
BinaryMapIndexReader.SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(
|
||||||
left, right, top, bottom, -1, getSearchRouteArticleFilter(),
|
0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, -1, getSearchRouteArticleFilter(),
|
||||||
new ResultMatcher<Amenity>() {
|
new ResultMatcher<Amenity>() {
|
||||||
|
boolean done = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(Amenity amenity) {
|
public boolean publish(Amenity amenity) {
|
||||||
if (getRouteId(amenity).equals(routeId)) {
|
if (getRouteId(amenity).equals(routeId)) {
|
||||||
amenities.add(amenity);
|
amenities.add(amenity);
|
||||||
|
done = true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return false;
|
return done;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -218,28 +216,26 @@ public class TravelObfHelper implements TravelHelper {
|
||||||
final List<Amenity> amenities = new ArrayList<>();
|
final List<Amenity> amenities = new ArrayList<>();
|
||||||
for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) {
|
for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) {
|
||||||
try {
|
try {
|
||||||
int left = 0;
|
|
||||||
int right = Integer.MAX_VALUE;
|
|
||||||
int top = 0;
|
|
||||||
int bottom = Integer.MAX_VALUE;
|
|
||||||
BinaryMapIndexReader.SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(
|
BinaryMapIndexReader.SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(
|
||||||
0, 0, title, left, right, top, bottom,
|
0, 0, title, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, getSearchRouteArticleFilter(),
|
||||||
new ResultMatcher<Amenity>() {
|
new ResultMatcher<Amenity>() {
|
||||||
|
boolean done = false;
|
||||||
|
final Collator collator = OsmAndCollator.primaryCollator();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(Amenity amenity) {
|
public boolean publish(Amenity amenity) {
|
||||||
Collator collator = OsmAndCollator.primaryCollator();
|
if (CollatorStringMatcher.cmatches(collator, title, amenity.getName(lang), CHECK_EQUALS_FROM_SPACE)) {
|
||||||
if (CollatorStringMatcher.cmatches(collator, title, amenity.getName(lang),
|
|
||||||
CHECK_EQUALS_FROM_SPACE) && amenity.getSubType().equals(ROUTE_ARTICLE)) {
|
|
||||||
amenities.add(amenity);
|
amenities.add(amenity);
|
||||||
|
done = true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return false;
|
return done;
|
||||||
}
|
}
|
||||||
});
|
}, null);
|
||||||
|
|
||||||
travelBookReader.searchPoiByName(req);
|
travelBookReader.searchPoiByName(req);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
Loading…
Reference in a new issue