示例#1
0
 private void playPrepareTurn(RouteDirectionInfo next, int dist) {
   CommandBuilder play = getNewCommandPlayerToPlay();
   if (play != null) {
     String tParam = getTurnType(next.getTurnType());
     if (tParam != null) {
       play.prepareTurn(tParam, dist).play();
     } else if (next.getTurnType().isRoundAbout()) {
       play.prepareRoundAbout(dist).play();
     } else if (next.getTurnType().getValue().equals(TurnType.TU)
         || next.getTurnType().getValue().equals(TurnType.TRU)) {
       play.prepareMakeUT(dist).play();
     }
   }
 }
示例#2
0
 private void playMakeTurn(RouteDirectionInfo next, RouteDirectionInfo nextNext) {
   CommandBuilder play = getNewCommandPlayerToPlay();
   if (play != null) {
     String tParam = getTurnType(next.getTurnType());
     boolean isplay = true;
     if (tParam != null) {
       play.turn(tParam);
     } else if (next.getTurnType().isRoundAbout()) {
       play.roundAbout(next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut());
     } else if (next.getTurnType().getValue().equals(TurnType.TU)
         || next.getTurnType().getValue().equals(TurnType.TRU)) {
       play.makeUT();
       // do not say it
       //				} else if(next.getTurnType().getValue().equals(TurnType.C)){
       //					play.goAhead();
     } else {
       isplay = false;
     }
     // add turn after next
     if (nextNext != null) {
       String t2Param = getTurnType(nextNext.getTurnType());
       if (t2Param != null) {
         if (isplay) {
           play.then();
         }
         play.turn(t2Param, next.distance);
       } else if (nextNext.getTurnType().isRoundAbout()) {
         if (isplay) {
           play.then();
         }
         play.roundAbout(
             next.distance,
             nextNext.getTurnType().getTurnAngle(),
             nextNext.getTurnType().getExitOut());
       } else if (nextNext.getTurnType().getValue().equals(TurnType.TU)) {
         if (isplay) {
           play.then();
         }
         play.makeUT(next.distance);
       }
       isplay = true;
     }
     if (isplay) {
       play.play();
     }
   }
 }
示例#3
0
 private void playMakeTurnIn(
     RouteDirectionInfo next, int dist, RouteDirectionInfo pronounceNextNext) {
   CommandBuilder play = getNewCommandPlayerToPlay();
   if (play != null) {
     String tParam = getTurnType(next.getTurnType());
     boolean isPlay = true;
     if (tParam != null) {
       play.turn(tParam, dist);
     } else if (next.getTurnType().isRoundAbout()) {
       play.roundAbout(dist, next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut());
     } else if (next.getTurnType().getValue().equals(TurnType.TU)
         || next.getTurnType().getValue().equals(TurnType.TRU)) {
       play.makeUT(dist);
     } else {
       isPlay = false;
     }
     // small preparation to next after next
     if (pronounceNextNext != null) {
       TurnType t = pronounceNextNext.getTurnType();
       isPlay = true;
       if (next.getTurnType().getValue().equals(TurnType.C) && !TurnType.C.equals(t.getValue())) {
         play.goAhead(dist);
       }
       if (TurnType.TL.equals(t.getValue())
           || TurnType.TSHL.equals(t.getValue())
           || TurnType.TSLL.equals(t.getValue())
           || TurnType.TU.equals(t.getValue())
           || TurnType.KL.equals(t.getValue())) {
         play.then().bearLeft();
       } else if (TurnType.TR.equals(t.getValue())
           || TurnType.TSHR.equals(t.getValue())
           || TurnType.TSLR.equals(t.getValue())
           || TurnType.KR.equals(t.getValue())) {
         play.then().bearRight();
       }
     }
     if (isPlay) {
       play.play();
     }
   }
 }
示例#4
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);
    }
  }