示例#1
0
  private synchronized void setNewRoute(RouteCalculationResult res, Location start) {
    final boolean newRoute = !this.route.isCalculated();
    route = res;
    if (isFollowingMode) {
      if (lastFixedLocation != null) {
        start = lastFixedLocation;
      }
      // try remove false route-recalculated prompts by checking direction to second route node
      boolean wrongMovementDirection = false;
      List<Location> routeNodes = res.getImmutableAllLocations();
      if (routeNodes != null && !routeNodes.isEmpty()) {
        int newCurrentRoute =
            lookAheadFindMinOrthogonalDistance(start, routeNodes, res.currentRoute, 15);
        if (newCurrentRoute + 1 < routeNodes.size()) {
          // This check is valid for Online/GPX services (offline routing is aware of route
          // direction)
          wrongMovementDirection =
              checkWrongMovementDirection(start, routeNodes.get(newCurrentRoute + 1));
          // set/reset evalWaitInterval only if new route is in forward direction
          if (!wrongMovementDirection) {
            evalWaitInterval = 3000;
          } else {
            evalWaitInterval = evalWaitInterval * 3 / 2;
            evalWaitInterval = Math.min(evalWaitInterval, 120000);
          }
        }
      }

      // trigger voice prompt only if new route is in forward direction
      // If route is in wrong direction after one more setLocation it will be recalculated
      if (!wrongMovementDirection || newRoute) {
        voiceRouter.newRouteIsCalculated(newRoute);
      }
    }

    app.runInUIThread(
        new Runnable() {
          @Override
          public void run() {
            for (IRouteInformationListener l : listeners) {
              l.newRouteIsCalculated(newRoute);
            }
          }
        });
  }
示例#2
0
 public void notifyIfRouteIsCalculated() {
   if (route.isCalculated()) {
     voiceRouter.newRouteIsCalculated(true);
   }
 }