Update warnings & settings with new routing
This commit is contained in:
parent
da25b2869b
commit
1370e3050d
10 changed files with 82 additions and 59 deletions
|
@ -188,11 +188,6 @@ public class BinaryMapRouteReaderAdapter {
|
|||
|
||||
public static class RouteRegion extends BinaryIndexPart {
|
||||
public int regionsRead;
|
||||
public int borderBoxPointer = 0;
|
||||
public int baseBorderBoxPointer = 0;
|
||||
public int borderBoxLength = 0;
|
||||
public int baseBorderBoxLength = 0;
|
||||
|
||||
List<RouteSubregion> subregions = new ArrayList<RouteSubregion>();
|
||||
List<RouteSubregion> basesubregions = new ArrayList<RouteSubregion>();
|
||||
List<RouteTypeRule> routeEncodingRules = new ArrayList<BinaryMapRouteReaderAdapter.RouteTypeRule>();
|
||||
|
@ -258,6 +253,15 @@ public class BinaryMapRouteReaderAdapter {
|
|||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public boolean contains(int x31, int y31) {
|
||||
for(RouteSubregion s : subregions) {
|
||||
if(s.left <= x31 && s.right >= x31 && s.top <= y31 && s.bottom >= y31) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Used in C++
|
||||
|
@ -360,20 +364,6 @@ public class BinaryMapRouteReaderAdapter {
|
|||
codedIS.popLimit(oldLimit);
|
||||
break;
|
||||
}
|
||||
case OsmandOdb.OsmAndRoutingIndex.BASEBORDERBOX_FIELD_NUMBER:
|
||||
case OsmandOdb.OsmAndRoutingIndex.BORDERBOX_FIELD_NUMBER: {
|
||||
int length = readInt();
|
||||
int filePointer = codedIS.getTotalBytesRead();
|
||||
if(tag == OsmandOdb.OsmAndRoutingIndex.BORDERBOX_FIELD_NUMBER) {
|
||||
region.borderBoxLength = length;
|
||||
region.borderBoxPointer = filePointer;
|
||||
} else {
|
||||
region.baseBorderBoxLength = length;
|
||||
region.baseBorderBoxPointer = filePointer;
|
||||
}
|
||||
codedIS.skipRawBytes(length);
|
||||
break;
|
||||
}
|
||||
case OsmandOdb.OsmAndRoutingIndex.BLOCKS_FIELD_NUMBER : {
|
||||
// Finish reading file!
|
||||
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
||||
|
|
|
@ -195,6 +195,8 @@ public class RoutePlannerFrontEnd {
|
|||
private List<RouteSegmentResult> runNativeRouting(final RoutingContext ctx) throws IOException {
|
||||
refreshProgressDistance(ctx);
|
||||
RouteRegion[] regions = ctx.reverseMap.keySet().toArray(new BinaryMapRouteReaderAdapter.RouteRegion[ctx.reverseMap.size()]);
|
||||
ctx.checkOldRoutingFiles(ctx.startX, ctx.startY);
|
||||
ctx.checkOldRoutingFiles(ctx.targetX, ctx.targetY);
|
||||
RouteSegmentResult[] res = ctx.nativeLib.runNativeRouting(ctx.startX, ctx.startY, ctx.targetX, ctx.targetY,
|
||||
ctx.config, regions, ctx.calculationProgress, ctx.precalculatedRouteDirection, ctx.calculationMode == RouteCalculationMode.BASE);
|
||||
ArrayList<RouteSegmentResult> result = new ArrayList<RouteSegmentResult>(Arrays.asList(res));
|
||||
|
|
|
@ -53,24 +53,20 @@ public class RoutingConfiguration {
|
|||
private Map<String, String> attributes = new LinkedHashMap<String, String>();
|
||||
|
||||
public RoutingConfiguration build(String router, int memoryLimitMB) {
|
||||
return build(router, null, memoryLimitMB, new String[0]);
|
||||
return build(router, null, memoryLimitMB, null);
|
||||
}
|
||||
|
||||
public RoutingConfiguration build(String router, int memoryLimitMB, String[] specialization) {
|
||||
return build(router, null, memoryLimitMB, specialization);
|
||||
public RoutingConfiguration build(String router, int memoryLimitMB, Map<String, String> params) {
|
||||
return build(router, null, memoryLimitMB, params);
|
||||
}
|
||||
public RoutingConfiguration build(String router, Double direction, int memoryLimitMB, String[] specialization) {
|
||||
public RoutingConfiguration build(String router, Double direction, int memoryLimitMB, Map<String, String> params) {
|
||||
if (!routers.containsKey(router)) {
|
||||
router = defaultRouter;
|
||||
}
|
||||
RoutingConfiguration i = new RoutingConfiguration();
|
||||
if (routers.containsKey(router)) {
|
||||
i.router = routers.get(router);
|
||||
if (specialization != null) {
|
||||
Map<String, String> params = new LinkedHashMap<String, String>();
|
||||
for (String s : specialization) {
|
||||
params.put(s, "true");
|
||||
}
|
||||
if (params != null) {
|
||||
i.router = i.router.build(params);
|
||||
}
|
||||
i.routerName = router;
|
||||
|
|
|
@ -102,16 +102,9 @@ public class RoutingContext {
|
|||
// callback of processing segments
|
||||
RouteSegmentVisitor visitor = null;
|
||||
|
||||
|
||||
// old planner
|
||||
public FinalRouteSegment finalRouteSegment;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public RoutingContext(RoutingContext cp) {
|
||||
this.config = cp.config;
|
||||
this.map.putAll(cp.map);
|
||||
|
@ -370,6 +363,24 @@ public class RoutingContext {
|
|||
int tileY = y31 >> zoomToLoad;
|
||||
return loadTileHeaders(zoomToLoad, tileX, tileY);
|
||||
}
|
||||
|
||||
public void checkOldRoutingFiles(BinaryMapIndexReader key) {
|
||||
if(calculationMode == RouteCalculationMode.BASE && key.getDateCreated() < 1390431600000l) { // new SimpleDateFormat("dd-MM-yyyy").parse("23-01-2014").getTime()
|
||||
throw new RuntimeException("Update map '"+key.getRegionNames()+ "' !");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkOldRoutingFiles(int x31, int y31) {
|
||||
for (Entry<BinaryMapIndexReader, List<RouteSubregion>> r : map.entrySet()) {
|
||||
BinaryMapIndexReader reader = r.getKey();
|
||||
for(RouteRegion reg : reader.getRoutingIndexes()) {
|
||||
if(reg.contains(x31, y31)) {
|
||||
checkOldRoutingFiles(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<RoutingSubregionTile> loadTileHeaders(final int zoomToLoadM31, int tileX, int tileY) {
|
||||
SearchRequest<RouteDataObject> request = BinaryMapIndexReader.buildSearchRouteRequest(tileX << zoomToLoadM31,
|
||||
|
@ -382,6 +393,9 @@ public class RoutingContext {
|
|||
long now = System.nanoTime();
|
||||
// int rg = r.getValue().get(0).routeReg.regionsRead;
|
||||
List<RouteSubregion> subregs = r.getKey().searchRouteIndexTree(request, r.getValue());
|
||||
if(subregs.size() > 0) {
|
||||
checkOldRoutingFiles(r.getKey());
|
||||
}
|
||||
for (RouteSubregion sr : subregs) {
|
||||
int ind = searchSubregionTile(sr);
|
||||
RoutingSubregionTile found;
|
||||
|
|
|
@ -9,6 +9,13 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="tip_recent_changes_1_7_t">Changes in 1.7:
|
||||
* Completely updated routing (fast and precise)
|
||||
* Active simulation in tunnels
|
||||
</string>
|
||||
<string name="complex_route_calculation_failed">Fast route calculation failed (%s), fallback to slow calculation.</string>
|
||||
<string name="disable_complex_routing_descr">Disable 2-phase routing for car navigation</string>
|
||||
<string name="disable_complex_routing">Disable complex routing</string>
|
||||
<string name="amenity_type_seamark">Seamark</string>
|
||||
<string name="app_modes_choose_descr">Choose use profiles visible in application</string>
|
||||
<string name="app_modes_choose">Application Profiles</string>
|
||||
|
|
|
@ -15,6 +15,4 @@
|
|||
<Preference android:title="@string/prefer_in_routing_title" android:summary="@string/prefer_in_routing_descr" android:key="prefer_in_routing"/>
|
||||
<CheckBoxPreference android:summary="@string/use_compass_navigation_descr" android:title="@string/use_compass_navigation"
|
||||
android:key="use_compass_navigation"></CheckBoxPreference>
|
||||
<CheckBoxPreference android:summary="@string/precise_routing_mode_descr" android:title="@string/precise_routing_mode"
|
||||
android:key="precise_routing_mode"></CheckBoxPreference>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -723,11 +723,7 @@ public class OsmandSettings {
|
|||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> FAST_ROUTE_MODE = new BooleanPreference("fast_route_mode", true).makeProfile();
|
||||
// temporarily for new version
|
||||
public final CommonPreference<Boolean> PRECISE_ROUTING_MODE = new BooleanPreference("precise_routing_mode", false).makeProfile();
|
||||
public final CommonPreference<Boolean> OPTIMAL_ROUTE_MODE = new BooleanPreference("optimal_route_mode", true).makeProfile();
|
||||
{
|
||||
OPTIMAL_ROUTE_MODE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false);
|
||||
}
|
||||
public final CommonPreference<Boolean> DISABLE_COMPLEX_ROUTING = new BooleanPreference("disable_complex_routing", false).makeGlobal();
|
||||
|
||||
public final OsmandPreference<Boolean> SHOW_TRAFFIC_WARNINGS = new BooleanPreference("show_traffic_warnings", true).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> SHOW_CAMERAS = new BooleanPreference("show_cameras", true).makeProfile().cache();
|
||||
|
|
|
@ -64,7 +64,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
settings = getMyApplication().getSettings();
|
||||
|
||||
registerBooleanPreference(settings.FAST_ROUTE_MODE, screen);
|
||||
registerBooleanPreference(settings.PRECISE_ROUTING_MODE, screen);
|
||||
registerBooleanPreference(settings.SNAP_TO_ROAD, screen);
|
||||
registerBooleanPreference(settings.USE_COMPASS_IN_NAVIGATION, screen);
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
|||
R.string.trace_rendering, R.string.trace_rendering_descr);
|
||||
cat.addPreference(dbg);
|
||||
|
||||
cat.addPreference(createCheckBoxPreference(settings.DISABLE_COMPLEX_ROUTING, R.string.disable_complex_routing, R.string.disable_complex_routing_descr));
|
||||
|
||||
cat.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr));
|
||||
|
||||
Preference pref = new Preference(this);
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.net.URLConnection;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -390,26 +391,24 @@ public class RouteProvider {
|
|||
} else {
|
||||
return applicationModeNotSupported(params);
|
||||
}
|
||||
// order matters
|
||||
List<String> specs = new ArrayList<String>();
|
||||
Map<String, String> paramsR = new LinkedHashMap<String, String>();
|
||||
if (!settings.FAST_ROUTE_MODE.getModeValue(params.mode)) {
|
||||
specs.add(GeneralRouter.USE_SHORTEST_WAY);
|
||||
paramsR.put(GeneralRouter.USE_SHORTEST_WAY, "true");
|
||||
}
|
||||
if(settings.AVOID_FERRIES.getModeValue(params.mode)){
|
||||
specs.add(GeneralRouter.AVOID_FERRIES);
|
||||
paramsR.put(GeneralRouter.AVOID_FERRIES, "true");
|
||||
}
|
||||
if(settings.AVOID_TOLL_ROADS.getModeValue(params.mode)){
|
||||
specs.add(GeneralRouter.AVOID_TOLL);
|
||||
paramsR.put(GeneralRouter.AVOID_TOLL, "true");
|
||||
}
|
||||
if(settings.AVOID_MOTORWAY.getModeValue(params.mode)){
|
||||
specs.add(GeneralRouter.AVOID_MOTORWAY);
|
||||
paramsR.put(GeneralRouter.AVOID_MOTORWAY, "true");
|
||||
} else if(settings.PREFER_MOTORWAYS.getModeValue(params.mode)){
|
||||
specs.add(GeneralRouter.PREFER_MOTORWAYS);
|
||||
paramsR.put(GeneralRouter.PREFER_MOTORWAYS, "true");
|
||||
}
|
||||
if(settings.AVOID_UNPAVED_ROADS.getModeValue(params.mode)){
|
||||
specs.add(GeneralRouter.AVOID_UNPAVED);
|
||||
paramsR.put(GeneralRouter.AVOID_UNPAVED, "true");
|
||||
}
|
||||
String[] specialization = specs.toArray(new String[specs.size()]);
|
||||
float mb = (1 << 20);
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
// make visible
|
||||
|
@ -418,13 +417,21 @@ public class RouteProvider {
|
|||
|
||||
RoutingConfiguration cf = config.build(p.name().toLowerCase(), params.start.hasBearing() ?
|
||||
params.start.getBearing() / 180d * Math.PI : null,
|
||||
memoryLimit, specialization);
|
||||
RoutingContext ctx = router.buildRoutingContext(cf, params.ctx.getInternalAPI().getNativeLibrary(), files,
|
||||
params.mode.isDerivedRoutingFrom(ApplicationMode.CAR) ?
|
||||
RouteCalculationMode.COMPLEX : RouteCalculationMode.NORMAL);
|
||||
memoryLimit, paramsR);
|
||||
boolean complex = params.mode.isDerivedRoutingFrom(ApplicationMode.CAR) && !settings.DISABLE_COMPLEX_ROUTING.get();
|
||||
RoutingContext ctx = router.buildRoutingContext(cf, params.ctx.getInternalAPI().getNativeLibrary(), files,
|
||||
RouteCalculationMode.NORMAL);
|
||||
RoutingContext complexCtx = null;
|
||||
if(complex) {
|
||||
complexCtx = router.buildRoutingContext(cf, params.ctx.getInternalAPI().getNativeLibrary(), files,
|
||||
RouteCalculationMode.COMPLEX);
|
||||
complexCtx.calculationProgress = params.calculationProgress;
|
||||
}
|
||||
ctx.leftSideNavigation = params.leftSide;
|
||||
ctx.calculationProgress = params.calculationProgress;
|
||||
if(params.previousToRecalculate != null) {
|
||||
ctx.previouslyCalculatedRoute = params.previousToRecalculate.getOriginalRoute();
|
||||
// not used any more
|
||||
// ctx.previouslyCalculatedRoute = params.previousToRecalculate.getOriginalRoute();
|
||||
}
|
||||
LatLon st = new LatLon(params.start.getLatitude(), params.start.getLongitude());
|
||||
LatLon en = new LatLon(params.end.getLatitude(), params.end.getLongitude());
|
||||
|
@ -433,8 +440,20 @@ public class RouteProvider {
|
|||
inters = new ArrayList<LatLon>(params.intermediates);
|
||||
}
|
||||
try {
|
||||
ctx.leftSideNavigation = params.leftSide;
|
||||
List<RouteSegmentResult> result = router.searchRoute(ctx, st, en, inters);
|
||||
List<RouteSegmentResult> result ;
|
||||
if(complexCtx != null) {
|
||||
try {
|
||||
result = router.searchRoute(complexCtx, st, en, inters);
|
||||
// discard ctx and replace with calculated
|
||||
ctx = complexCtx;
|
||||
} catch(RuntimeException e) {
|
||||
params.ctx.showToastMessage(R.string.complex_route_calculation_failed, e.getMessage());
|
||||
result = router.searchRoute(ctx, st, en, inters);
|
||||
}
|
||||
} else {
|
||||
result = router.searchRoute(ctx, st, en, inters);
|
||||
}
|
||||
|
||||
if(result == null || result.isEmpty()) {
|
||||
if(ctx.calculationProgress.segmentNotFound == 0) {
|
||||
return new RouteCalculationResult(params.ctx.getString(R.string.starting_point_too_far));
|
||||
|
|
Loading…
Reference in a new issue