예제 #1
0
  /**
   * Finds all egress paths from to coordinate to end stop and adds routers to egressRouter
   *
   * @param request
   * @param egressRouter
   */
  private void findEgressPaths(ProfileRequest request, Map<LegMode, StreetRouter> egressRouter) {
    // For egress
    // TODO: this must be reverse search
    for (LegMode mode : request.egressModes) {
      StreetRouter streetRouter = new StreetRouter(transportNetwork.streetLayer);
      streetRouter.transitStopSearch = true;
      streetRouter.dominanceVariable = StreetRouter.State.RoutingVariable.DURATION_SECONDS;
      if (egressUnsupportedModes.contains(mode)) {
        continue;
      }
      // TODO: add support for bike sharing
      streetRouter.streetMode = StreetMode.valueOf(mode.toString());
      streetRouter.profileRequest = request;
      streetRouter.timeLimitSeconds = request.getTimeLimit(mode);
      if (streetRouter.setOrigin(request.toLat, request.toLon)) {
        streetRouter.route();
        TIntIntMap stops = streetRouter.getReachedStops();
        egressRouter.put(mode, streetRouter);
        LOG.info("Added {} edgres stops for mode {}", stops.size(), mode);

      } else {
        LOG.warn(
            "MODE:{}, Edge near the origin coordinate wasn't found. Routing didn't start!", mode);
      }
    }
  }
예제 #2
0
  /**
   * Finds direct paths between from and to coordinates in request and adds them to option
   *
   * @param request
   * @param option
   */
  private void findDirectPaths(ProfileRequest request, ProfileOption option) {
    // For direct modes
    for (LegMode mode : request.directModes) {
      StreetRouter streetRouter = new StreetRouter(transportNetwork.streetLayer);
      StreetPath streetPath;
      streetRouter.profileRequest = request;
      if (mode == LegMode.BICYCLE_RENT) {
        if (!transportNetwork.streetLayer.bikeSharing) {
          LOG.warn("Bike sharing trip requested but no bike sharing stations in the streetlayer");
          continue;
        }
        streetRouter = findBikeRentalPath(request, streetRouter, true);
        if (streetRouter != null) {
          StreetRouter.State lastState = streetRouter.getState(request.toLat, request.toLon);
          if (lastState != null) {
            streetPath =
                new StreetPath(lastState, streetRouter, LegMode.BICYCLE_RENT, transportNetwork);

          } else {
            LOG.warn(
                "MODE:{}, Edge near the destination coordinate wasn't found. Routing didn't start!",
                mode);
            continue;
          }
        } else {
          LOG.warn("Not found path from cycle to end");
          continue;
        }
      } else {
        streetRouter.streetMode = StreetMode.valueOf(mode.toString());
        streetRouter.timeLimitSeconds = request.streetTime * 60;
        if (streetRouter.setOrigin(request.fromLat, request.fromLon)) {
          if (!streetRouter.setDestination(request.toLat, request.toLon)) {
            LOG.warn("Direct mode {} destination wasn't found!", mode);
            continue;
          }
          streetRouter.route();
          StreetRouter.State lastState = streetRouter.getState(streetRouter.getDestinationSplit());
          if (lastState == null) {
            LOG.warn("Direct mode {} last state wasn't found", mode);
            continue;
          }
          streetPath = new StreetPath(lastState, transportNetwork);
        } else {
          LOG.warn("Direct mode {} origin wasn't found!", mode);
          continue;
        }
      }

      StreetSegment streetSegment =
          new StreetSegment(streetPath, mode, transportNetwork.streetLayer);
      option.addDirect(streetSegment, request.getFromTimeDateZD());
    }
  }
예제 #3
0
  /**
   * Finds access paths from from coordinate in request and adds all routers with paths to
   * accessRouter map
   *
   * @param request
   * @param accessRouter
   */
  private void findAccessPaths(ProfileRequest request, Map<LegMode, StreetRouter> accessRouter) {
    // Routes all access modes
    for (LegMode mode : request.accessModes) {
      StreetRouter streetRouter = new StreetRouter(transportNetwork.streetLayer);
      streetRouter.profileRequest = request;
      if (mode == LegMode.CAR_PARK) {
        streetRouter = findParkRidePath(request, streetRouter);
        if (streetRouter != null) {
          accessRouter.put(LegMode.CAR_PARK, streetRouter);
        } else {
          LOG.warn(
              "MODE:{}, Edge near the origin coordinate wasn't found. Routing didn't start!", mode);
        }
      } else if (mode == LegMode.BICYCLE_RENT) {
        if (!transportNetwork.streetLayer.bikeSharing) {
          LOG.warn("Bike sharing trip requested but no bike sharing stations in the streetlayer");
          continue;
        }
        streetRouter = findBikeRentalPath(request, streetRouter, false);
        if (streetRouter != null) {
          accessRouter.put(LegMode.BICYCLE_RENT, streetRouter);
        } else {
          LOG.warn("Not found path from cycle to end");
        }
      } else {
        streetRouter.streetMode = StreetMode.valueOf(mode.toString());

        // Gets correct maxCar/Bike/Walk time in seconds for access leg based on mode since it
        // depends on the mode
        streetRouter.timeLimitSeconds = request.getTimeLimit(mode);
        streetRouter.transitStopSearch = true;
        streetRouter.dominanceVariable = StreetRouter.State.RoutingVariable.DURATION_SECONDS;

        if (streetRouter.setOrigin(request.fromLat, request.fromLon)) {
          streetRouter.route();
          // Searching for access paths
          accessRouter.put(mode, streetRouter);
        } else {
          LOG.warn(
              "MODE:{}, Edge near the origin coordinate wasn't found. Routing didn't start!", mode);
        }
      }
    }
  }