Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
903d2316a7
7 changed files with 66 additions and 32 deletions
|
@ -87,6 +87,10 @@ public class SearchUICore {
|
|||
}
|
||||
}
|
||||
|
||||
public void setPoiTypes(MapPoiTypes poiTypes) {
|
||||
this.poiTypes = poiTypes;
|
||||
}
|
||||
|
||||
public int getTotalLimit() {
|
||||
return totalLimit;
|
||||
}
|
||||
|
|
|
@ -463,16 +463,20 @@ public class SearchCoreFactory {
|
|||
|
||||
public static class SearchAmenityTypesAPI extends SearchBaseAPI {
|
||||
|
||||
private Map<String, PoiType> translatedNames;
|
||||
private Map<String, PoiType> translatedNames = new LinkedHashMap<>();
|
||||
private List<PoiFilter> topVisibleFilters;
|
||||
private MapPoiTypes types;
|
||||
|
||||
public SearchAmenityTypesAPI(MapPoiTypes types) {
|
||||
translatedNames = types.getAllTranslatedNames(false);
|
||||
topVisibleFilters = types.getTopVisibleFilters();
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean search(SearchPhrase phrase, SearchResultMatcher resultMatcher) throws IOException {
|
||||
if(translatedNames.isEmpty()) {
|
||||
translatedNames = types.getAllTranslatedNames(false);
|
||||
topVisibleFilters = types.getTopVisibleFilters();
|
||||
}
|
||||
// results.clear();
|
||||
TreeSet<AbstractPoiType> results = new TreeSet<>(new Comparator<AbstractPoiType>() {
|
||||
|
||||
|
@ -491,7 +495,7 @@ public class SearchCoreFactory {
|
|||
Iterator<Entry<String, PoiType>> it = translatedNames.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Entry<String, PoiType> e = it.next();
|
||||
if (nm.matches(e.getKey())) {
|
||||
if (nm.matches(e.getKey()) || nm.matches(e.getValue().getTranslation())) {
|
||||
results.add(e.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -522,7 +526,6 @@ public class SearchCoreFactory {
|
|||
|
||||
public static class SearchAmenityByTypeAPI extends SearchBaseAPI {
|
||||
|
||||
|
||||
private MapPoiTypes types;
|
||||
|
||||
public SearchAmenityByTypeAPI(MapPoiTypes types) {
|
||||
|
|
|
@ -15,7 +15,28 @@ public class TestEntry {
|
|||
private boolean ignore;
|
||||
private Map<Long, String> expectedResults;
|
||||
private Map<String, String> params;
|
||||
private int planRoadDirection;
|
||||
private boolean shortWay;
|
||||
|
||||
|
||||
public void setShortWay(boolean shortWay) {
|
||||
this.shortWay = shortWay;
|
||||
}
|
||||
|
||||
public boolean isShortWay() {
|
||||
return shortWay;
|
||||
}
|
||||
|
||||
|
||||
public int getPlanRoadDirection() {
|
||||
return planRoadDirection;
|
||||
}
|
||||
|
||||
|
||||
public void setPlanRoadDirection(int planRoadDirection) {
|
||||
this.planRoadDirection = planRoadDirection;
|
||||
}
|
||||
|
||||
public LatLon getStartPoint() {
|
||||
return startPoint;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"description": "При planRoadDirection='-1' маршрут неверный, при 0 - верный",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"short_way": "true",
|
||||
"shortWay": "true",
|
||||
"planRoadDirection": "0"
|
||||
},
|
||||
"startPoint": {
|
||||
|
@ -25,7 +25,7 @@
|
|||
"description": "Подтверждается только неверный маршрут. От дистанции не зависит, но зависит от planRoadDirection. При -1 маршрут верный, при 0 - нет",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"short_way": "true",
|
||||
"shortWay": "true",
|
||||
"planRoadDirection": "0"
|
||||
},
|
||||
"startPoint": {
|
||||
|
@ -45,7 +45,7 @@
|
|||
"description": "Не воспроизводится",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"short_way": "true",
|
||||
"shortWay": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"startPoint": {
|
||||
|
@ -65,7 +65,7 @@
|
|||
"description": "Не воспроизводится",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"short_way": "true",
|
||||
"shortWay": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"startPoint": {
|
||||
|
@ -86,10 +86,10 @@
|
|||
},
|
||||
{
|
||||
"testName": "10.Longer route preferred? https://github.com/osmandapp/Osmand/issues/1941",
|
||||
"description": "short_way строит не самый короткий путь. Транзит через MEX 261 короче.",
|
||||
"description": "shortWay строит не самый короткий путь. Транзит через MEX 261 короче.",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"short_way": "true",
|
||||
"shortWay": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"startPoint": {
|
||||
|
@ -108,7 +108,7 @@
|
|||
"testName": "12.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA https://github.com/osmandapp/Osmand/issues/1743",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"short_way": "true",
|
||||
"shortWay": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"startPoint": {
|
||||
|
@ -128,7 +128,7 @@
|
|||
"testName": "12.1.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA (transit2 point) https://github.com/osmandapp/Osmand/issues/1743",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"short_way": "true",
|
||||
"shortWay": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"startPoint": {
|
||||
|
@ -151,7 +151,7 @@
|
|||
"testName": "12.2.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA (reverse) https://github.com/osmandapp/Osmand/issues/1743",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"short_way": "true",
|
||||
"shortWay": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"startPoint": {
|
||||
|
|
|
@ -364,9 +364,7 @@ public class AppInitializer implements IProgress {
|
|||
app.geocodingLookupService = startupInit(new GeocodingLookupService(app), GeocodingLookupService.class);
|
||||
app.targetPointsHelper = startupInit(new TargetPointsHelper(app), TargetPointsHelper.class);
|
||||
app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class);
|
||||
|
||||
app.searchUICore = startupInit(new SearchUICore(app.poiTypes, app.getSettings().MAP_PREFERRED_LOCALE.get(), new BinaryMapIndexReader[]{}), SearchUICore.class);
|
||||
QuickSearchHelper.initSearchUICore(app);
|
||||
app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class);
|
||||
}
|
||||
|
||||
|
||||
|
@ -508,9 +506,9 @@ public class AppInitializer implements IProgress {
|
|||
// restore backuped favorites to normal file
|
||||
restoreBackupForFavoritesFiles();
|
||||
notifyEvent(InitEvents.RESTORE_BACKUPS);
|
||||
app.searchUICore.initSearchUICore();
|
||||
checkLiveUpdatesAlerts();
|
||||
LocalIndexHelper helper = new LocalIndexHelper(app);
|
||||
QuickSearchHelper.setRepositoriesForSearchUICore(app);
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
warnings.add(e.getMessage());
|
||||
|
|
|
@ -22,7 +22,6 @@ import android.view.accessibility.AccessibilityManager;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.AccessibilityPlugin;
|
||||
|
@ -46,9 +45,9 @@ import net.osmand.plus.poi.PoiFiltersHelper;
|
|||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.search.QuickSearchHelper;
|
||||
import net.osmand.plus.voice.CommandPlayer;
|
||||
import net.osmand.router.RoutingConfiguration;
|
||||
import net.osmand.search.SearchUICore;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
|
@ -98,7 +97,7 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
BRouterServiceConnection bRouterServiceConnection;
|
||||
OsmandRegions regions;
|
||||
GeocodingLookupService geocodingLookupService;
|
||||
SearchUICore searchUICore;
|
||||
QuickSearchHelper searchUICore;
|
||||
|
||||
RoutingConfiguration.Builder defaultRoutingConfig;
|
||||
private Locale preferredLocale = null;
|
||||
|
@ -360,7 +359,7 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
return geocodingLookupService;
|
||||
}
|
||||
|
||||
public SearchUICore getSearchUICore() {
|
||||
public QuickSearchHelper getSearchUICore() {
|
||||
return searchUICore;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,13 +26,22 @@ public class QuickSearchHelper {
|
|||
public static final int SEARCH_WPT_OBJECT_PRIORITY = 10;
|
||||
public static final int SEARCH_HISTORY_API_PRIORITY = 3;
|
||||
public static final int SEARCH_HISTORY_OBJECT_PRIORITY = 10;
|
||||
private OsmandApplication app;
|
||||
private SearchUICore core;
|
||||
|
||||
public QuickSearchHelper(OsmandApplication app) {
|
||||
this.app = app;
|
||||
core = new SearchUICore(app.getPoiTypes(), app.getSettings().MAP_PREFERRED_LOCALE.get(), new BinaryMapIndexReader[]{});
|
||||
}
|
||||
|
||||
public SearchUICore getCore() {
|
||||
return core;
|
||||
}
|
||||
|
||||
public static void initSearchUICore(final OsmandApplication app) {
|
||||
|
||||
SearchUICore searchUICore = app.getSearchUICore();
|
||||
|
||||
public void initSearchUICore() {
|
||||
setRepositoriesForSearchUICore(app);
|
||||
// Register favorites search api
|
||||
searchUICore.registerAPI(new SearchCoreFactory.SearchBaseAPI() {
|
||||
core.registerAPI(new SearchCoreFactory.SearchBaseAPI() {
|
||||
|
||||
@Override
|
||||
public boolean search(SearchPhrase phrase, SearchUICore.SearchResultMatcher resultMatcher) {
|
||||
|
@ -66,17 +75,17 @@ public class QuickSearchHelper {
|
|||
});
|
||||
|
||||
// Register WptPt search api
|
||||
searchUICore.registerAPI(new SearchWptAPI(app));
|
||||
core.registerAPI(new SearchWptAPI(app));
|
||||
}
|
||||
|
||||
public static void setRepositoriesForSearchUICore(final OsmandApplication app) {
|
||||
public void setRepositoriesForSearchUICore(final OsmandApplication app) {
|
||||
Collection<RegionAddressRepository> regionAddressRepositories = app.getResourceManager().getAddressRepositories();
|
||||
BinaryMapIndexReader[] binaryMapIndexReaderArray = new BinaryMapIndexReader[regionAddressRepositories.size()];
|
||||
int i = 0;
|
||||
for (RegionAddressRepository rep : regionAddressRepositories) {
|
||||
binaryMapIndexReaderArray[i++] = rep.getFile();
|
||||
}
|
||||
app.getSearchUICore().getSearchSettings().setOfflineIndexes(Arrays.asList(binaryMapIndexReaderArray));
|
||||
core.getSearchSettings().setOfflineIndexes(Arrays.asList(binaryMapIndexReaderArray));
|
||||
}
|
||||
|
||||
public static class SearchWptAPI extends SearchCoreFactory.SearchBaseAPI {
|
||||
|
@ -158,7 +167,7 @@ public class QuickSearchHelper {
|
|||
|
||||
@Override
|
||||
public int getSearchPriority(SearchPhrase p) {
|
||||
if(!p.isNoSelectedType()) {
|
||||
if (!p.isNoSelectedType()) {
|
||||
return -1;
|
||||
}
|
||||
return SEARCH_HISTORY_API_PRIORITY;
|
||||
|
|
Loading…
Reference in a new issue