Exemplo n.º 1
0
 /**
  * Uses 2 streetSearches to get P+R path
  *
  * <p>First CAR search from fromLat/fromLon to all car parks. Then from those found places WALK
  * search.
  *
  * <p>Result is then used as access part. Since P+R in direct mode is useless.
  *
  * @param request profileRequest from which from/to destination is used
  * @param streetRouter where profileRequest was already set
  * @return null if path isn't found
  */
 private StreetRouter findParkRidePath(ProfileRequest request, StreetRouter streetRouter) {
   streetRouter.streetMode = StreetMode.CAR;
   streetRouter.timeLimitSeconds = request.maxCarTime * 60;
   streetRouter.flagSearch = VertexStore.VertexFlag.PARK_AND_RIDE;
   streetRouter.dominanceVariable = StreetRouter.State.RoutingVariable.DURATION_SECONDS;
   if (streetRouter.setOrigin(request.fromLat, request.fromLon)) {
     streetRouter.route();
     TIntObjectMap<StreetRouter.State> carParks =
         streetRouter.getReachedVertices(VertexStore.VertexFlag.PARK_AND_RIDE);
     LOG.info("CAR PARK: Found {} car parks", carParks.size());
     StreetRouter walking = new StreetRouter(transportNetwork.streetLayer);
     walking.streetMode = StreetMode.WALK;
     walking.profileRequest = request;
     walking.timeLimitSeconds = request.maxCarTime * 60;
     walking.transitStopSearch = true;
     walking.setOrigin(carParks, CAR_PARK_DROPOFF_TIME_S, CAR_PARK_DROPOFF_COST, LegMode.CAR_PARK);
     walking.dominanceVariable = StreetRouter.State.RoutingVariable.DURATION_SECONDS;
     walking.route();
     walking.previousRouter = streetRouter;
     return walking;
   } else {
     return null;
   }
 }
Exemplo n.º 2
0
 @Override
 public int size() {
   return _jumpingTracks.size();
 }
Exemplo n.º 3
0
 /**
  * Returns the attribute count.
  *
  * @return The number of attributes
  */
 public int getAttributeCount() {
   return attributes.size();
 }
Exemplo n.º 4
0
  /**
   * Uses 3 streetSearches to first search from fromLat/fromLon to all the bike renting places in
   * WALK mode. Then from all found bike renting places to other bike renting places with BIKE and
   * then just routing from those found bike renting places in WALK mode.
   *
   * <p>This can then be used as streetRouter for access paths or as a direct search for specific
   * destination
   *
   * <p>Last streetRouter (WALK from bike rentals) is returned
   *
   * @param request profileRequest from which from/to destination is used
   * @param streetRouter where profileRequest was already set
   * @param direct
   * @return null if path isn't found
   */
  private StreetRouter findBikeRentalPath(
      ProfileRequest request, StreetRouter streetRouter, boolean direct) {
    streetRouter.streetMode = StreetMode.WALK;
    // TODO add time and distance limits to routing, not just weight.
    streetRouter.timeLimitSeconds = request.maxWalkTime * 60;
    if (!direct) {
      streetRouter.dominanceVariable = StreetRouter.State.RoutingVariable.DURATION_SECONDS;
    }
    streetRouter.flagSearch = VertexStore.VertexFlag.BIKE_SHARING;
    if (streetRouter.setOrigin(request.fromLat, request.fromLon)) {
      // if we can't find destination we can stop search before even trying
      if (direct && !streetRouter.setDestination(request.toLat, request.toLon)) {
        return null;
      }
      Split destinationSplit = streetRouter.getDestinationSplit();

      // reset destinationSplit since we need it at the last part of routing
      streetRouter.setDestination(null);
      streetRouter.route();
      // This finds all the nearest bicycle rent stations when walking
      TIntObjectMap<StreetRouter.State> bikeStations =
          streetRouter.getReachedVertices(VertexStore.VertexFlag.BIKE_SHARING);
      LOG.info(
          "BIKE RENT: Found {} bike stations which are {} minutes away",
          bikeStations.size(),
          streetRouter.timeLimitSeconds / 60);
      /*LOG.info("Start to bike share:");
      bikeStations.forEachEntry((idx, state) -> {
          LOG.info("   {} ({}m)", idx, state.distance);
          return true;
      });*/

      // This finds best cycling path from best start bicycle station to end bicycle station
      StreetRouter bicycle = new StreetRouter(transportNetwork.streetLayer);
      bicycle.previousRouter = streetRouter;
      bicycle.streetMode = StreetMode.BICYCLE;
      bicycle.profileRequest = request;
      bicycle.flagSearch = streetRouter.flagSearch;
      bicycle.maxVertices = Integer.MAX_VALUE;
      // Longer bike part if this is direct search
      if (direct) {
        bicycle.timeLimitSeconds = request.streetTime * 60;
      } else {
        bicycle.timeLimitSeconds = request.maxBikeTime * 60;
        bicycle.dominanceVariable = StreetRouter.State.RoutingVariable.DURATION_SECONDS;
      }
      bicycle.setOrigin(
          bikeStations, BIKE_RENTAL_PICKUP_TIME_S, BIKE_RENTAL_PICKUP_COST, LegMode.BICYCLE_RENT);
      bicycle.setDestination(destinationSplit);
      bicycle.route();
      TIntObjectMap<StreetRouter.State> cycledStations =
          bicycle.getReachedVertices(VertexStore.VertexFlag.BIKE_SHARING);
      LOG.info(
          "BIKE RENT: Found {} cycled stations which are {} minutes away",
          cycledStations.size(),
          bicycle.timeLimitSeconds / 60);
      /*LOG.info("Bike share to bike share:");
      cycledStations.retainEntries((idx, state) -> {
          if (bikeStations.containsKey(idx)) {
              LOG.warn("  MM:{} ({}m)", idx, state.distance/1000);
              return false;
          } else {
              LOG.info("   {} ({}m)", idx, state.distance / 1000);
              return true;
          }

      });*/
      // This searches for walking path from end bicycle station to end point
      StreetRouter end = new StreetRouter(transportNetwork.streetLayer);
      end.streetMode = StreetMode.WALK;
      end.profileRequest = request;
      end.timeLimitSeconds = bicycle.timeLimitSeconds;
      if (!direct) {
        end.transitStopSearch = true;
        end.dominanceVariable = StreetRouter.State.RoutingVariable.DURATION_SECONDS;
      }
      end.setOrigin(
          cycledStations,
          BIKE_RENTAL_DROPOFF_TIME_S,
          BIKE_RENTAL_DROPOFF_COST,
          LegMode.BICYCLE_RENT);
      end.route();
      end.previousRouter = bicycle;
      return end;
    } else {
      return null;
    }
  }