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