use of net.osmand.plus.routing.AlarmInfo.AlarmInfoType in project Osmand by osmandapp.
the class WaypointHelper method announceVisibleLocations.
public void announceVisibleLocations() {
Location lastKnownLocation = app.getRoutingHelper().getLastProjection();
if (lastKnownLocation != null && app.getRoutingHelper().isFollowingMode()) {
for (int type = 0; type < locationPoints.size(); type++) {
int currentRoute = route.getCurrentRoute();
List<LocationPointWrapper> approachPoints = new ArrayList<LocationPointWrapper>();
List<LocationPointWrapper> announcePoints = new ArrayList<LocationPointWrapper>();
List<LocationPointWrapper> lp = locationPoints.get(type);
if (lp != null) {
int kIterator = pointsProgress.get(type);
while (kIterator < lp.size() && lp.get(kIterator).routeIndex < currentRoute) {
if (type == ALARMS) {
AlarmInfo alarm = (AlarmInfo) lp.get(kIterator).getPoint();
if (alarm.getLastLocationIndex() >= currentRoute) {
break;
}
}
kIterator++;
}
pointsProgress.set(type, kIterator);
while (kIterator < lp.size()) {
LocationPointWrapper lwp = lp.get(kIterator);
if (type == ALARMS && lwp.routeIndex < currentRoute) {
kIterator++;
continue;
}
if (lwp.announce) {
if (route.getDistanceToPoint(lwp.routeIndex) > LONG_ANNOUNCE_RADIUS * 2) {
break;
}
LocationPoint point = lwp.point;
double d1 = Math.max(0.0, MapUtils.getDistance(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), point.getLatitude(), point.getLongitude()) - lwp.getDeviationDistance());
Integer state = locationPointsStates.get(point);
if (state != null && state.intValue() == ANNOUNCED_ONCE && getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, SHORT_ANNOUNCE_RADIUS, 0f)) {
locationPointsStates.put(point, ANNOUNCED_DONE);
announcePoints.add(lwp);
} else if (type != ALARMS && (state == null || state == NOT_ANNOUNCED) && getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, LONG_ANNOUNCE_RADIUS, 0f)) {
locationPointsStates.put(point, ANNOUNCED_ONCE);
approachPoints.add(lwp);
} else if (type == ALARMS && (state == null || state == NOT_ANNOUNCED) && getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, ALARMS_ANNOUNCE_RADIUS, 0f)) {
locationPointsStates.put(point, ANNOUNCED_ONCE);
approachPoints.add(lwp);
}
}
kIterator++;
}
if (!announcePoints.isEmpty()) {
if (announcePoints.size() > ANNOUNCE_POI_LIMIT) {
announcePoints = announcePoints.subList(0, ANNOUNCE_POI_LIMIT);
}
if (type == WAYPOINTS) {
getVoiceRouter().announceWaypoint(announcePoints);
} else if (type == POI) {
getVoiceRouter().announcePoi(announcePoints);
} else if (type == ALARMS) {
// nothing to announce
} else if (type == FAVORITES) {
getVoiceRouter().announceFavorite(announcePoints);
}
}
if (!approachPoints.isEmpty()) {
if (approachPoints.size() > APPROACH_POI_LIMIT) {
approachPoints = approachPoints.subList(0, APPROACH_POI_LIMIT);
}
if (type == WAYPOINTS) {
getVoiceRouter().approachWaypoint(lastKnownLocation, approachPoints);
} else if (type == POI) {
getVoiceRouter().approachPoi(lastKnownLocation, approachPoints);
} else if (type == ALARMS) {
EnumSet<AlarmInfoType> ait = EnumSet.noneOf(AlarmInfoType.class);
for (LocationPointWrapper pw : approachPoints) {
ait.add(((AlarmInfo) pw.point).getType());
}
for (AlarmInfoType t : ait) {
app.getRoutingHelper().getVoiceRouter().announceAlarm(new AlarmInfo(t, -1), lastKnownLocation.getSpeed());
}
} else if (type == FAVORITES) {
getVoiceRouter().approachFavorite(lastKnownLocation, approachPoints);
}
}
}
}
}
}
use of net.osmand.plus.routing.AlarmInfo.AlarmInfoType in project Osmand by osmandapp.
the class VoiceRouter method announceAlarm.
public void announceAlarm(AlarmInfo info, float speed) {
AlarmInfoType type = info.getType();
if (type == AlarmInfoType.SPEED_LIMIT) {
announceSpeedAlarm(info.getIntValue(), speed);
} else if (type == AlarmInfoType.SPEED_CAMERA) {
if (router.getSettings().SPEAK_SPEED_CAMERA.get()) {
CommandBuilder p = getNewCommandPlayerToPlay();
if (p != null) {
notifyOnVoiceMessage();
p.attention(type + "").play();
}
}
} else if (type == AlarmInfoType.PEDESTRIAN) {
if (router.getSettings().SPEAK_PEDESTRIAN.get()) {
CommandBuilder p = getNewCommandPlayerToPlay();
if (p != null) {
notifyOnVoiceMessage();
p.attention(type + "").play();
}
}
} else {
if (router.getSettings().SPEAK_TRAFFIC_WARNINGS.get()) {
CommandBuilder p = getNewCommandPlayerToPlay();
if (p != null) {
notifyOnVoiceMessage();
p.attention(type + "").play();
}
// See Issue 2377: Announce destination again - after some motorway tolls roads split shortly after the toll
if (type == AlarmInfoType.TOLL_BOOTH) {
suppressDest = false;
}
}
}
}
Aggregations