use of net.osmand.search.core.SearchPhrase in project Osmand by osmandapp.
the class QuickSearchListAdapter method updateDistanceDirection.
private void updateDistanceDirection(View view, QuickSearchListItem listItem) {
TextView distanceText = (TextView) view.findViewById(R.id.distance);
ImageView direction = (ImageView) view.findViewById(R.id.direction);
SearchPhrase phrase = listItem.getSearchResult().requiredSearchPhrase;
LatLon loc = location;
if (phrase != null && useMapCenter) {
LatLon ol = phrase.getSettings().getOriginalLocation();
if (ol != null) {
loc = ol;
}
}
updateLocationView(useMapCenter, loc, heading, direction, distanceText, listItem.getSearchResult().location.getLatitude(), listItem.getSearchResult().location.getLongitude(), screenOrientation, app, activity);
}
use of net.osmand.search.core.SearchPhrase in project Osmand by osmandapp.
the class SearchUICore method shallowSearch.
public <T extends SearchCoreAPI> SearchResultCollection shallowSearch(Class<T> cl, String text, final ResultMatcher<SearchResult> matcher) throws IOException {
T api = getApiByClass(cl);
if (api != null) {
if (debugMode) {
LOG.info("Start shallow search <" + phrase + "> API=<" + api + ">");
}
SearchPhrase sphrase = this.phrase.generateNewPhrase(text, searchSettings);
preparePhrase(sphrase);
AtomicInteger ai = new AtomicInteger();
SearchResultMatcher rm = new SearchResultMatcher(matcher, sphrase, ai.get(), ai, totalLimit);
api.search(sphrase, rm);
SearchResultCollection collection = new SearchResultCollection(sphrase);
collection.addSearchResults(rm.getRequestResults(), true, true);
if (debugMode) {
LOG.info("Finish shallow search <" + sphrase + "> Results=" + rm.getRequestResults().size());
}
return collection;
}
return null;
}
use of net.osmand.search.core.SearchPhrase in project Osmand by osmandapp.
the class LocationSearchTest method search.
private void search(String string, LatLon latLon) throws IOException {
SearchResultMatcher srm = new SearchUICore.SearchResultMatcher(null, null, 0, null, 100);
new SearchCoreFactory.SearchLocationAndUrlAPI().search(new SearchPhrase(null, OsmAndCollator.primaryCollator()).generateNewPhrase(string, null), srm);
Assert.assertEquals(1, srm.getRequestResults().size());
Assert.assertEquals(latLon, srm.getRequestResults().get(0).location);
}
use of net.osmand.search.core.SearchPhrase in project Osmand by osmandapp.
the class SearchCoreUITest method testDuplicates.
@Test
public void testDuplicates() throws IOException {
SearchSettings ss = new SearchSettings((SearchSettings) null);
ss = ss.setOriginalLocation(new LatLon(0, 0));
SearchPhrase phrase = new SearchPhrase(ss, OsmAndCollator.primaryCollator());
SearchResultCollection cll = new SearchUICore.SearchResultCollection(phrase);
List<SearchResult> rs = new ArrayList<>();
SearchResult a1 = searchResult(rs, phrase, "a", 100);
SearchResult b2 = searchResult(rs, phrase, "b", 200);
SearchResult b1 = searchResult(rs, phrase, "b", 100);
/*SearchResult a3 = */
searchResult(rs, phrase, "a", 100);
cll.addSearchResults(rs, true, true);
Assert.assertEquals(3, cll.getCurrentSearchResults().size());
Assert.assertSame(a1, cll.getCurrentSearchResults().get(0));
Assert.assertSame(b1, cll.getCurrentSearchResults().get(1));
Assert.assertSame(b2, cll.getCurrentSearchResults().get(2));
}
use of net.osmand.search.core.SearchPhrase in project Osmand by osmandapp.
the class SearchCoreUITest method testNoResort.
@Test
public void testNoResort() throws IOException {
SearchSettings ss = new SearchSettings((SearchSettings) null);
ss = ss.setOriginalLocation(new LatLon(0, 0));
SearchPhrase phrase = new SearchPhrase(ss, OsmAndCollator.primaryCollator());
SearchResultCollection cll = new SearchUICore.SearchResultCollection(phrase);
List<SearchResult> rs = new ArrayList<>();
SearchResult a1 = searchResult(rs, phrase, "a", 100);
cll.addSearchResults(rs, false, true);
rs.clear();
SearchResult b2 = searchResult(rs, phrase, "b", 200);
cll.addSearchResults(rs, false, true);
rs.clear();
SearchResult b1 = searchResult(rs, phrase, "b", 100);
cll.addSearchResults(rs, false, true);
rs.clear();
/*SearchResult a3 = */
searchResult(rs, phrase, "a", 100);
cll.addSearchResults(rs, false, true);
rs.clear();
Assert.assertEquals(3, cll.getCurrentSearchResults().size());
Assert.assertSame(a1, cll.getCurrentSearchResults().get(0));
Assert.assertSame(b2, cll.getCurrentSearchResults().get(1));
Assert.assertSame(b1, cll.getCurrentSearchResults().get(2));
}
Aggregations