Ejemplo n.º 1
0
  public void announceCurrentDirection(Location currentLocation) {
    NextDirectionInfo nextInfo = router.getNextRouteDirectionInfo(new NextDirectionInfo(), true);
    if (nextInfo == null) {
      playGoAheadToDestination();
      return;
    }
    NextDirectionInfo nextNextInfo =
        router.getNextRouteDirectionInfoAfter(nextInfo, new NextDirectionInfo(), false);
    float speed = DEFAULT_SPEED;
    RouteDirectionInfo next = nextInfo.directionInfo;
    int dist = nextInfo.distanceTo;

    if (currentLocation != null && currentLocation.hasSpeed()) {
      speed = Math.max(currentLocation.getSpeed(), speed);
    }

    switch (currentStatus) {
      case STATUS_UTWP_TOLD:
        playMakeUTwp();
        break;
      case STATUS_UNKNOWN:
        if (nextRouteDirection != null && ((next == null) || (next.distance == 0))) {
          playGoAheadToDestination();
        } else {
          playGoAhead(dist);
        }
        break;
      case STATUS_TOLD:
        if (nextRouteDirection != null) {
          playGoAheadToDestination();
        }
        break;
      case STATUS_TURN:
        if (next.distance < TURN_IN_DISTANCE_END && nextNextInfo != null) {
          playMakeTurn(next, nextNextInfo.directionInfo);
        } else {
          playMakeTurn(next, null);
        }
        break;
      case STATUS_TURN_IN:
        if ((isDistanceLess(speed, next.distance, TURN_DISTANCE)
                || next.distance < TURN_IN_DISTANCE_END)
            && nextNextInfo != null) {
          playMakeTurnIn(next, dist, nextNextInfo.directionInfo);
        } else {
          playMakeTurnIn(next, dist, null);
        }
        break;
      case STATUS_PREPARE:
        playPrepareTurn(next, dist);
        break;
      case STATUS_LONG_PREPARE:
        playPrepareTurn(next, dist);
        break;
      default:
        break;
    }
  }
Ejemplo n.º 2
0
  /**
   * Updates status of voice guidance
   *
   * @param currentLocation
   */
  protected void updateStatus(Location currentLocation) {
    // Directly after turn: goAhead (dist), unless:
    // < PREPARE_LONG_DISTANCE (3000m): playPrepareTurn
    // < PREPARE_DISTANCE (1500m): playPrepareTurn
    // < TURN_IN_DISTANCE (300m or 25sec): playMakeTurnIn
    // < TURN_DISTANCE (60m or 5sec): playMakeTurn
    float speed = DEFAULT_SPEED;
    if (currentLocation != null && currentLocation.hasSpeed()) {
      speed = Math.max(currentLocation.getSpeed(), speed);
    }

    NextDirectionInfo nextInfo = router.getNextRouteDirectionInfo(new NextDirectionInfo(), true);
    // after last turn say:
    if (nextInfo == null
        || nextInfo.directionInfo == null
        || nextInfo.directionInfo.distance == 0) {
      // if(currentStatus <= STATUS_UNKNOWN && currentDirection > 0){ This caused this prompt to be
      // suppressed when coming back from a
      if (currentStatus <= STATUS_UNKNOWN) {
        if (playGoAheadToDestination()) {
          currentStatus = STATUS_TOLD;
          playGoAheadDist = 0;
        }
      }
      return;
    }
    if (nextInfo.intermediatePoint) {
      if (currentStatus <= STATUS_UNKNOWN) {
        if (playGoAheadToIntermediate()) {
          currentStatus = STATUS_TOLD;
          playGoAheadDist = 0;
        }
      }
      return;
    }
    int dist = nextInfo.distanceTo;
    RouteDirectionInfo next = nextInfo.directionInfo;

    // if routing is changed update status to unknown
    if (next != nextRouteDirection) {
      nextRouteDirection = next;
      currentStatus = STATUS_UNKNOWN;
      playGoAheadDist = 0;
    }

    if (dist == 0 || currentStatus == STATUS_TOLD) {
      // nothing said possibly that's wrong case we should say before that
      // however it should be checked manually ?
      return;
    }
    // say how much to go if there is next turn is a bit far
    if (currentStatus == STATUS_UNKNOWN) {
      if (!isDistanceLess(speed, dist, TURN_IN_DISTANCE * 1.3)) {
        playGoAheadDist = dist - 80;
      }
      // say long distance message only for long distances > 10 km
      // if (dist >= PREPARE_LONG_DISTANCE && !isDistanceLess(speed, dist, PREPARE_LONG_DISTANCE)) {
      if (dist > PREPARE_LONG_DISTANCE + 300) {
        nextStatusAfter(STATUS_UNKNOWN);
      } else if (dist > PREPARE_DISTANCE + 300) {
        // say prepare message if it is far enough and don't say preare long distance
        nextStatusAfter(STATUS_LONG_PREPARE);
      } else {
        // don't say even prepare message
        nextStatusAfter(STATUS_PREPARE);
      }
    }

    NextDirectionInfo nextNextInfo =
        router.getNextRouteDirectionInfoAfter(nextInfo, new NextDirectionInfo(), true);
    if (statusNotPassed(STATUS_TURN)
        && isDistanceLess(speed, dist, TURN_DISTANCE, TURN_DEFAULT_SPEED)) {
      if (next.distance < TURN_IN_DISTANCE_END && nextNextInfo != null) {
        playMakeTurn(next, nextNextInfo.directionInfo);
      } else {
        playMakeTurn(next, null);
      }
      nextStatusAfter(STATUS_TURN);
    } else if (statusNotPassed(STATUS_TURN_IN) && isDistanceLess(speed, dist, TURN_IN_DISTANCE)) {
      if (dist >= TURN_IN_DISTANCE_END) {
        if ((isDistanceLess(speed, next.distance, TURN_DISTANCE)
                || next.distance < TURN_IN_DISTANCE_END)
            && nextNextInfo != null) {
          playMakeTurnIn(next, dist, nextNextInfo.directionInfo);
        } else {
          playMakeTurnIn(next, dist, null);
        }
      }
      nextStatusAfter(STATUS_TURN_IN);
      // } else if (statusNotPassed(STATUS_PREPARE) && isDistanceLess(speed, dist,
      // PREPARE_DISTANCE)) {
    } else if (statusNotPassed(STATUS_PREPARE) && (dist <= PREPARE_DISTANCE)) {
      if (dist >= PREPARE_DISTANCE_END) {
        if (next.getTurnType().keepLeft() || next.getTurnType().keepRight()) {
          // do not play prepare for keep left/right
        } else {
          playPrepareTurn(next, dist);
        }
      }
      nextStatusAfter(STATUS_PREPARE);
      // } else if (statusNotPassed(STATUS_LONG_PREPARE) && isDistanceLess(speed, dist,
      // PREPARE_LONG_DISTANCE)){
    } else if (statusNotPassed(STATUS_LONG_PREPARE) && (dist <= PREPARE_LONG_DISTANCE)) {
      if (dist >= PREPARE_LONG_DISTANCE_END) {
        playPrepareTurn(next, dist);
      }
      nextStatusAfter(STATUS_LONG_PREPARE);
    } else if (statusNotPassed(STATUS_UNKNOWN)) {
      // strange how we get here but
      nextStatusAfter(STATUS_UNKNOWN);
    } else if (statusNotPassed(STATUS_TURN_IN) && dist < playGoAheadDist) {
      playGoAheadDist = 0;
      playGoAhead(dist);
    }
  }