Added the tunnel warnings
This commit is contained in:
parent
ed99ee8c73
commit
3117c351d7
7 changed files with 67 additions and 6 deletions
|
@ -52,6 +52,7 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
public final static int TRAFFIC_SIGNALS = 6;
|
public final static int TRAFFIC_SIGNALS = 6;
|
||||||
public final static int RAILWAY_CROSSING = 7;
|
public final static int RAILWAY_CROSSING = 7;
|
||||||
private final static int LANES = 8;
|
private final static int LANES = 8;
|
||||||
|
private static final int TUNNEL = 9;
|
||||||
private final String t;
|
private final String t;
|
||||||
private final String v;
|
private final String v;
|
||||||
private int intValue;
|
private int intValue;
|
||||||
|
@ -201,6 +202,8 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
intValue = Integer.parseInt(v.substring(0, i));
|
intValue = Integer.parseInt(v.substring(0, i));
|
||||||
}
|
}
|
||||||
|
} else if (t.equalsIgnoreCase("tunnel") && v != null) {
|
||||||
|
type = TUNNEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1702,7 +1702,7 @@
|
||||||
<string name="poi_filter_for_tourists">For tourists</string>
|
<string name="poi_filter_for_tourists">For tourists</string>
|
||||||
<string name="poi_filter_fuel">Fuel</string>
|
<string name="poi_filter_fuel">Fuel</string>
|
||||||
<string name="show_warnings_title">Show alerts…</string>
|
<string name="show_warnings_title">Show alerts…</string>
|
||||||
<string name="show_warnings_descr">Configure traffic warnings (speed limits, forced stops, speed bumps), speed camera warnings, and lane information.</string>
|
<string name="show_warnings_descr">Configure traffic warnings (speed limits, forced stops, speed bumps, tunnels), speed camera warnings, and lane information.</string>
|
||||||
<string name="use_compass_navigation_descr">Use the compass when no heading is detected otherwise.</string>
|
<string name="use_compass_navigation_descr">Use the compass when no heading is detected otherwise.</string>
|
||||||
<string name="use_compass_navigation">Use compass</string>
|
<string name="use_compass_navigation">Use compass</string>
|
||||||
<string name="avoid_motorway">Avoid motorways</string>
|
<string name="avoid_motorway">Avoid motorways</string>
|
||||||
|
@ -2859,4 +2859,6 @@
|
||||||
<string name="nautical_renderer">Nautical</string>
|
<string name="nautical_renderer">Nautical</string>
|
||||||
<string name="copy_location_name">Copy Point/POI name</string>
|
<string name="copy_location_name">Copy Point/POI name</string>
|
||||||
<string name="toast_empty_name_error">Location has no name</string>
|
<string name="toast_empty_name_error">Location has no name</string>
|
||||||
|
<string name="tunnel_warning">Tunnel ahead</string>
|
||||||
|
<string name="show_tunnels">Tunnels</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1070,6 +1070,12 @@ public class OsmandSettings {
|
||||||
SHOW_PEDESTRIAN.setModeDefaultValue(ApplicationMode.CAR, true);
|
SHOW_PEDESTRIAN.setModeDefaultValue(ApplicationMode.CAR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final CommonPreference<Boolean> SHOW_TUNNELS = new BooleanPreference("show_tunnels", false).makeProfile().cache();
|
||||||
|
|
||||||
|
{
|
||||||
|
SHOW_TUNNELS.setModeDefaultValue(ApplicationMode.CAR, true);
|
||||||
|
}
|
||||||
|
|
||||||
public final OsmandPreference<Boolean> SHOW_CAMERAS = new BooleanPreference("show_cameras", false).makeProfile().cache();
|
public final OsmandPreference<Boolean> SHOW_CAMERAS = new BooleanPreference("show_cameras", false).makeProfile().cache();
|
||||||
public final CommonPreference<Boolean> SHOW_LANES = new BooleanPreference("show_lanes", false).makeProfile().cache();
|
public final CommonPreference<Boolean> SHOW_LANES = new BooleanPreference("show_lanes", false).makeProfile().cache();
|
||||||
|
|
||||||
|
|
|
@ -630,8 +630,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
return true;
|
return true;
|
||||||
} else if (preference == showAlarms) {
|
} else if (preference == showAlarms) {
|
||||||
showBooleanSettings(new String[] { getString(R.string.show_traffic_warnings), getString(R.string.show_pedestrian_warnings),
|
showBooleanSettings(new String[] { getString(R.string.show_traffic_warnings), getString(R.string.show_pedestrian_warnings),
|
||||||
getString(R.string.show_cameras), getString(R.string.show_lanes) }, new OsmandPreference[] { settings.SHOW_TRAFFIC_WARNINGS,
|
getString(R.string.show_cameras), getString(R.string.show_lanes), getString(R.string.show_tunnels) }, new OsmandPreference[] { settings.SHOW_TRAFFIC_WARNINGS,
|
||||||
settings.SHOW_PEDESTRIAN, settings.SHOW_CAMERAS, settings.SHOW_LANES }, preference.getTitle());
|
settings.SHOW_PEDESTRIAN, settings.SHOW_CAMERAS, settings.SHOW_LANES, settings.SHOW_TUNNELS }, preference.getTitle());
|
||||||
return true;
|
return true;
|
||||||
} else if (preference == speakAlarms) {
|
} else if (preference == speakAlarms) {
|
||||||
AlertDialog dlg = showBooleanSettings(new String[] { getString(R.string.speak_street_names),
|
AlertDialog dlg = showBooleanSettings(new String[] { getString(R.string.speak_street_names),
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.IconsCache;
|
import net.osmand.plus.IconsCache;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||||
|
@ -27,6 +28,7 @@ import net.osmand.plus.routing.AlarmInfo;
|
||||||
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
||||||
import net.osmand.plus.routing.RouteCalculationResult;
|
import net.osmand.plus.routing.RouteCalculationResult;
|
||||||
import net.osmand.plus.routing.VoiceRouter;
|
import net.osmand.plus.routing.VoiceRouter;
|
||||||
|
import net.osmand.router.RouteSegmentResult;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -178,6 +180,7 @@ public class WaypointHelper {
|
||||||
}
|
}
|
||||||
AlarmInfo mostImportant = speedAlarm;
|
AlarmInfo mostImportant = speedAlarm;
|
||||||
int value = speedAlarm != null ? speedAlarm.updateDistanceAndGetPriority(0, 0) : Integer.MAX_VALUE;
|
int value = speedAlarm != null ? speedAlarm.updateDistanceAndGetPriority(0, 0) : Integer.MAX_VALUE;
|
||||||
|
float speed = lastProjection != null && lastProjection.hasSpeed() ? lastProjection.getSpeed() : 0;
|
||||||
if (ALARMS < pointsProgress.size()) {
|
if (ALARMS < pointsProgress.size()) {
|
||||||
int kIterator = pointsProgress.get(ALARMS);
|
int kIterator = pointsProgress.get(ALARMS);
|
||||||
List<LocationPointWrapper> lp = locationPoints.get(ALARMS);
|
List<LocationPointWrapper> lp = locationPoints.get(ALARMS);
|
||||||
|
@ -191,7 +194,6 @@ public class WaypointHelper {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
AlarmInfo inf = (AlarmInfo) lwp.point;
|
AlarmInfo inf = (AlarmInfo) lwp.point;
|
||||||
float speed = lastProjection != null && lastProjection.hasSpeed() ? lastProjection.getSpeed() : 0;
|
|
||||||
float time = speed > 0 ? d / speed : Integer.MAX_VALUE;
|
float time = speed > 0 ? d / speed : Integer.MAX_VALUE;
|
||||||
int vl = inf.updateDistanceAndGetPriority(time, d);
|
int vl = inf.updateDistanceAndGetPriority(time, d);
|
||||||
if (vl < value && (showCameras || inf.getType() != AlarmInfoType.SPEED_CAMERA)) {
|
if (vl < value && (showCameras || inf.getType() != AlarmInfoType.SPEED_CAMERA)) {
|
||||||
|
@ -202,9 +204,32 @@ public class WaypointHelper {
|
||||||
kIterator++;
|
kIterator++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<RouteSegmentResult> segments = route.getUpcomingTunnel(500);
|
||||||
|
if (segments != null && !segments.isEmpty()) {
|
||||||
|
AlarmInfo inf = new AlarmInfo(AlarmInfoType.TUNNEL, 0);
|
||||||
|
int d = route.getDistanceToPoint(segments.get(0).getStartPointIndex());
|
||||||
|
float time = speed > 0 ? d / speed : Integer.MAX_VALUE;
|
||||||
|
inf.setFloatValue(calculateDistance(segments, mc));
|
||||||
|
int vl = inf.updateDistanceAndGetPriority(time, d);
|
||||||
|
if (vl < value && (showCameras || inf.getType() != AlarmInfoType.SPEED_CAMERA)) {
|
||||||
|
mostImportant = inf;
|
||||||
|
}
|
||||||
|
}
|
||||||
return mostImportant;
|
return mostImportant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float calculateDistance(List<RouteSegmentResult> segments, MetricsConstants mc) {
|
||||||
|
float sum = 0f;
|
||||||
|
for (RouteSegmentResult r : segments) {
|
||||||
|
sum += r.getDistance();
|
||||||
|
}
|
||||||
|
if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
|
||||||
|
return sum / 1000f;
|
||||||
|
} else {
|
||||||
|
return sum * 0.00062137f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void enableWaypointType(int type, boolean enable) {
|
public void enableWaypointType(int type, boolean enable) {
|
||||||
//An item will be displayed in the Waypoint list if either "Show..." or "Announce..." is selected for it in the Navigation settings
|
//An item will be displayed in the Waypoint list if either "Show..." or "Announce..." is selected for it in the Navigation settings
|
||||||
//Keep both "Show..." and "Announce..." Nav settings in sync when user changes what to display in the Waypoint list, as follows:
|
//Keep both "Show..." and "Announce..." Nav settings in sync when user changes what to display in the Waypoint list, as follows:
|
||||||
|
|
|
@ -18,7 +18,8 @@ public class AlarmInfo implements LocationPoint {
|
||||||
STOP(7, R.string.traffic_warning_stop),
|
STOP(7, R.string.traffic_warning_stop),
|
||||||
PEDESTRIAN(8, R.string.traffic_warning_pedestrian),
|
PEDESTRIAN(8, R.string.traffic_warning_pedestrian),
|
||||||
HAZARD(9, R.string.traffic_warning_hazard),
|
HAZARD(9, R.string.traffic_warning_hazard),
|
||||||
MAXIMUM(10, R.string.traffic_warning);
|
MAXIMUM(10, R.string.traffic_warning),
|
||||||
|
TUNNEL(8, R.string.tunnel_warning);
|
||||||
|
|
||||||
private int priority;
|
private int priority;
|
||||||
private int string;
|
private int string;
|
||||||
|
@ -41,6 +42,7 @@ public class AlarmInfo implements LocationPoint {
|
||||||
private AlarmInfoType type;
|
private AlarmInfoType type;
|
||||||
protected final int locationIndex;
|
protected final int locationIndex;
|
||||||
private int intValue;
|
private int intValue;
|
||||||
|
private float floatValue;
|
||||||
private double latitude;
|
private double latitude;
|
||||||
private double longitude;
|
private double longitude;
|
||||||
|
|
||||||
|
@ -54,6 +56,14 @@ public class AlarmInfo implements LocationPoint {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getFloatValue() {
|
||||||
|
return floatValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFloatValue(float floatValue) {
|
||||||
|
this.floatValue = floatValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getLatitude() {
|
public double getLatitude() {
|
||||||
return latitude;
|
return latitude;
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.hardware.GeomagneticField;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -55,6 +56,7 @@ import net.osmand.router.RouteResultPreparation;
|
||||||
import net.osmand.router.TurnType;
|
import net.osmand.router.TurnType;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -1214,6 +1216,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
boolean trafficWarnings = settings.SHOW_TRAFFIC_WARNINGS.get();
|
boolean trafficWarnings = settings.SHOW_TRAFFIC_WARNINGS.get();
|
||||||
boolean cams = settings.SHOW_CAMERAS.get();
|
boolean cams = settings.SHOW_CAMERAS.get();
|
||||||
boolean peds = settings.SHOW_PEDESTRIAN.get();
|
boolean peds = settings.SHOW_PEDESTRIAN.get();
|
||||||
|
boolean tunnels = settings.SHOW_TUNNELS.get();
|
||||||
boolean visible = false;
|
boolean visible = false;
|
||||||
if ((rh.isFollowingMode() || trackingUtilities.isMapLinkedToLocation())
|
if ((rh.isFollowingMode() || trackingUtilities.isMapLinkedToLocation())
|
||||||
&& (trafficWarnings || cams)) {
|
&& (trafficWarnings || cams)) {
|
||||||
|
@ -1271,6 +1274,15 @@ public class RouteInfoWidgetsFactory {
|
||||||
} else {
|
} else {
|
||||||
locimgId = R.drawable.warnings_pedestrian;
|
locimgId = R.drawable.warnings_pedestrian;
|
||||||
}
|
}
|
||||||
|
} else if(alarm.getType() == AlarmInfoType.TUNNEL) {
|
||||||
|
DecimalFormat df = new DecimalFormat("0.#");
|
||||||
|
if(settings.DRIVING_REGION.get().americanSigns){
|
||||||
|
locimgId = R.drawable.warnings_tunnel_us;
|
||||||
|
text = df.format(alarm.getFloatValue()) +" mi";
|
||||||
|
} else {
|
||||||
|
locimgId = R.drawable.warnings_tunnel;
|
||||||
|
text = df.format(alarm.getFloatValue()) +" km";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
text = null;
|
text = null;
|
||||||
}
|
}
|
||||||
|
@ -1280,7 +1292,10 @@ public class RouteInfoWidgetsFactory {
|
||||||
visible = cams;
|
visible = cams;
|
||||||
} else if (alarm.getType() == AlarmInfoType.PEDESTRIAN) {
|
} else if (alarm.getType() == AlarmInfoType.PEDESTRIAN) {
|
||||||
visible = peds;
|
visible = peds;
|
||||||
} else {
|
} else if (alarm.getType() == AlarmInfoType.TUNNEL) {
|
||||||
|
visible = tunnels;
|
||||||
|
}
|
||||||
|
else {
|
||||||
visible = trafficWarnings;
|
visible = trafficWarnings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue