Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9866a73670
9 changed files with 113 additions and 14 deletions
|
@ -517,6 +517,22 @@ public class RouteDataObject {
|
|||
return getHighway(types, region);
|
||||
}
|
||||
|
||||
public boolean hasPrivateAccess() {
|
||||
int sz = types.length;
|
||||
for (int i = 0; i < sz; i++) {
|
||||
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||
if ("motorcar".equals(r.getTag())
|
||||
|| "motor_vehicle".equals(r.getTag())
|
||||
|| "vehicle".equals(r.getTag())
|
||||
|| "access".equals(r.getTag())) {
|
||||
if (r.getValue().equals("private")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getValue(String tag) {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||
|
|
|
@ -31,7 +31,8 @@ public class GeneralRouter implements VehicleRouter {
|
|||
public static final String AVOID_MOTORWAY = "avoid_motorway";
|
||||
public static final String AVOID_UNPAVED = "avoid_unpaved";
|
||||
public static final String PREFER_MOTORWAYS = "prefer_motorway";
|
||||
|
||||
public static final String ALLOW_PRIVATE = "allow_private";
|
||||
|
||||
private final RouteAttributeContext[] objectAttributes;
|
||||
public final Map<String, String> attributes;
|
||||
private final Map<String, RoutingParameter> parameters;
|
||||
|
@ -41,7 +42,8 @@ public class GeneralRouter implements VehicleRouter {
|
|||
private final ArrayList<Object> ruleToValue;
|
||||
private boolean shortestRoute;
|
||||
private boolean heightObstacles;
|
||||
|
||||
private boolean allowPrivate;
|
||||
|
||||
private Map<RouteRegion, Map<Integer, Integer>> regionConvert = new LinkedHashMap<RouteRegion, Map<Integer,Integer>>();
|
||||
|
||||
// cached values
|
||||
|
@ -130,6 +132,7 @@ public class GeneralRouter implements VehicleRouter {
|
|||
for (int i = 0; i < objectAttributes.length; i++) {
|
||||
objectAttributes[i] = new RouteAttributeContext(parent.objectAttributes[i], params);
|
||||
}
|
||||
allowPrivate = params.containsKey(ALLOW_PRIVATE) && parseSilentBoolean(params.get(ALLOW_PRIVATE), false);
|
||||
shortestRoute = params.containsKey(USE_SHORTEST_WAY) && parseSilentBoolean(params.get(USE_SHORTEST_WAY), false);
|
||||
heightObstacles = params.containsKey(USE_HEIGHT_OBSTACLES) && parseSilentBoolean(params.get(USE_HEIGHT_OBSTACLES), false);
|
||||
if(shortestRoute) {
|
||||
|
@ -195,7 +198,11 @@ public class GeneralRouter implements VehicleRouter {
|
|||
}
|
||||
return res >= 0;
|
||||
}
|
||||
|
||||
|
||||
public boolean isAllowPrivate() {
|
||||
return allowPrivate;
|
||||
}
|
||||
|
||||
public long[] getImpassableRoadIds() {
|
||||
if(impassableRoads == null) {
|
||||
return new long[0];
|
||||
|
|
|
@ -16,5 +16,5 @@ public class RouteCalculationProgress {
|
|||
public int visitedSegments = 0;
|
||||
|
||||
public boolean isCancelled;
|
||||
|
||||
public boolean requestPrivateAccessRouting;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
package net.osmand.router;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.NativeLibrary;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
|
@ -18,11 +11,19 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
|
||||
import net.osmand.router.BinaryRoutePlanner.RouteSegmentPoint;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class RoutePlannerFrontEnd {
|
||||
|
||||
private boolean useOldVersion;
|
||||
|
@ -110,12 +111,39 @@ public class RoutePlannerFrontEnd {
|
|||
}
|
||||
|
||||
|
||||
private boolean needRequestPrivateAccessRouting(RoutingContext ctx, List<LatLon> points) throws IOException {
|
||||
boolean res = false;
|
||||
GeneralRouter router = (GeneralRouter) ctx.getRouter();
|
||||
if (router != null && !router.isAllowPrivate()) {
|
||||
ctx.setRouter(new GeneralRouter(GeneralRouterProfile.CAR, new LinkedHashMap<String, String>()));
|
||||
for (LatLon latLon : points) {
|
||||
RouteSegmentPoint rp = findRouteSegment(latLon.getLatitude(), latLon.getLongitude(), ctx, null);
|
||||
if (rp != null && rp.road != null) {
|
||||
if (rp.road.hasPrivateAccess()) {
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.setRouter(router);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<RouteSegmentResult> searchRoute(final RoutingContext ctx, LatLon start, LatLon end, List<LatLon> intermediates,
|
||||
PrecalculatedRouteDirection routeDirection) throws IOException, InterruptedException {
|
||||
if (ctx.calculationProgress == null) {
|
||||
ctx.calculationProgress = new RouteCalculationProgress();
|
||||
}
|
||||
boolean intermediatesEmpty = intermediates == null || intermediates.isEmpty();
|
||||
List<LatLon> targets = new ArrayList<>();
|
||||
targets.add(end);
|
||||
if (!intermediatesEmpty) {
|
||||
targets.addAll(intermediates);
|
||||
}
|
||||
if (needRequestPrivateAccessRouting(ctx, targets)) {
|
||||
ctx.calculationProgress.requestPrivateAccessRouting = true;
|
||||
}
|
||||
double maxDistance = MapUtils.getDistance(start, end);
|
||||
if (!intermediatesEmpty) {
|
||||
LatLon b = start;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
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="private_access_routing_req">Your destination is located in the area with a private access. Do you want to allow access to the private roads for this trip?</string>
|
||||
<string name="restart_search">Restart search</string>
|
||||
<string name="increase_search_radius">Increase search radius</string>
|
||||
<string name="nothing_found">Nothing found :(</string>
|
||||
|
|
|
@ -703,6 +703,7 @@ public class OsmandSettings {
|
|||
}
|
||||
|
||||
public final CommonPreference<Boolean> USE_FAST_RECALCULATION = new BooleanPreference("use_fast_recalculation", true).makeGlobal().cache();
|
||||
public final CommonPreference<Boolean> FORCE_PRIVATE_ACCESS_ROUTING_ASKED = new BooleanPreference("force_private_access_routing", false).makeProfile().cache();
|
||||
|
||||
public final CommonPreference<Boolean> SHOW_CARD_TO_CHOOSE_DRAWER = new BooleanPreference("show_card_to_choose_drawer", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> SHOW_DASHBOARD_ON_START = new BooleanPreference("should_show_dashboard_on_start", false).makeGlobal();
|
||||
|
|
|
@ -111,6 +111,7 @@ import net.osmand.plus.views.corenative.NativeCoreContext;
|
|||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -384,6 +385,37 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestPrivateAccessRouting() {
|
||||
if (!settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.getModeValue(getRoutingHelper().getAppMode())) {
|
||||
final OsmandSettings.CommonPreference<Boolean> allowPrivate
|
||||
= settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false);
|
||||
final List<ApplicationMode> modes = ApplicationMode.values(settings);
|
||||
for (ApplicationMode mode : modes) {
|
||||
if (!allowPrivate.getModeValue(mode)) {
|
||||
settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.setModeValue(mode, true);
|
||||
}
|
||||
}
|
||||
if (!allowPrivate.getModeValue(getRoutingHelper().getAppMode())) {
|
||||
AlertDialog.Builder dlg = new AlertDialog.Builder(MapActivity.this);
|
||||
dlg.setMessage(R.string.private_access_routing_req);
|
||||
dlg.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
for (ApplicationMode mode : modes) {
|
||||
if (!allowPrivate.getModeValue(mode)) {
|
||||
allowPrivate.setModeValue(mode, true);
|
||||
}
|
||||
}
|
||||
getRoutingHelper().recalculateRouteDueToSettingsChange();
|
||||
}
|
||||
});
|
||||
dlg.setNegativeButton(R.string.shared_string_no, null);
|
||||
dlg.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
pbExtView.setVisibility(View.GONE);
|
||||
|
|
|
@ -55,6 +55,7 @@ import net.osmand.plus.views.BaseMapLayer;
|
|||
import net.osmand.plus.views.MapControlsLayer;
|
||||
import net.osmand.plus.views.MapTileLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
@ -854,6 +855,13 @@ public class MapActivityActions implements DialogProvider {
|
|||
getMyApplication().stopNavigation();
|
||||
mapActivity.updateApplicationModeSettings();
|
||||
mapActivity.getDashboard().clearDeletedPoints();
|
||||
List<ApplicationMode> modes = ApplicationMode.values(settings);
|
||||
for (ApplicationMode mode : modes) {
|
||||
if (settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.getModeValue(mode)) {
|
||||
settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.setModeValue(mode, false);
|
||||
settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false).setModeValue(mode, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AlertDialog stopNavigationActionConfirm() {
|
||||
|
|
|
@ -956,6 +956,7 @@ public class RoutingHelper {
|
|||
private void updateProgress(final RouteCalculationParams params) {
|
||||
if(progressRoute != null ) {
|
||||
app.runInUIThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
RouteCalculationProgress calculationProgress = params.calculationProgress;
|
||||
|
@ -971,9 +972,15 @@ public class RoutingHelper {
|
|||
// different calculation started
|
||||
return;
|
||||
} else {
|
||||
if (calculationProgress.requestPrivateAccessRouting) {
|
||||
progressRoute.requestPrivateAccessRouting();
|
||||
}
|
||||
updateProgress(params);
|
||||
}
|
||||
} else {
|
||||
if (calculationProgress.requestPrivateAccessRouting) {
|
||||
progressRoute.requestPrivateAccessRouting();
|
||||
}
|
||||
progressRoute.finish();
|
||||
}
|
||||
}
|
||||
|
@ -989,9 +996,8 @@ public class RoutingHelper {
|
|||
|
||||
// set visibility
|
||||
public void updateProgress(int progress);
|
||||
|
||||
public void requestPrivateAccessRouting();
|
||||
public void finish();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue