private void initializeFreeFloatingEndWalkLeg(Leg leg, double now) {

    this.state = MobsimAgent.State.LEG;
    this.parkingModule.makeFFVehicleAvailable(
        Id.create((vehID), Vehicle.class), parkingSpot.getParking());
    Route route = leg.getRoute();

    double distance = 0.0; // this will be acquired from the parking module

    LegImpl walkLeg = new LegImpl("walk_ff");

    vehID = null;
    GenericRouteImpl walkRoute = new GenericRouteImpl(route.getEndLinkId(), route.getEndLinkId());

    // for the purposes of consistency setting walking time to 0
    final int travTime = 0;
    walkRoute.setTravelTime(travTime);
    walkRoute.setDistance(distance);

    walkLeg.setRoute(walkRoute);
    this.cachedDestinationLinkId = route.getEndLinkId();
    walkLeg.setDepartureTime(now);
    walkLeg.setTravelTime(travTime);
    walkLeg.setArrivalTime(now + travTime);
    // set the route according to the next leg
    this.currentLeg = walkLeg;
    this.cachedRouteLinkIds = null;
    this.currentLinkIdIndex = 0;
    this.cachedNextLinkId = null;

    return;
  }
  // added methods
  private void initializeFreeFloatingStartWalkLeg(Leg leg, double now) {

    this.state = MobsimAgent.State.LEG;
    Route route = leg.getRoute();
    ParkingLinkInfo vehicleLocation =
        this.parkingModule.getNextFreeFloatingVehicle(
            this.scenario.getNetwork().getLinks().get(route.getStartLinkId()).getCoord(),
            this.person.getId(),
            now);
    if (vehicleLocation == null || vehicleLocation.getLinkId() == null) {
      log.warn(
          "Agent with id: "
              + this.getId().toString()
              + " was aborted because the freefloating vehicle was not avaialble or the vehicle id was not set up.");
      this.state = MobsimAgent.State.ABORT;
      return;
    }
    vehID = vehicleLocation.getVehicleId().toString();
    startLink = this.scenario.getNetwork().getLinks().get(vehicleLocation.getLinkId());
    LegImpl walkLeg = new LegImpl("walk_ff");

    GenericRouteImpl walkRoute = new GenericRouteImpl(route.getStartLinkId(), startLink.getId());
    final double dist =
        CoordUtils.calcEuclideanDistance(
            scenario.getNetwork().getLinks().get(route.getStartLinkId()).getCoord(),
            startLink.getCoord());
    final double estimatedNetworkDistance = dist * this.beelineFactor;

    final int travTime = (int) (estimatedNetworkDistance / this.walkSpeed);
    walkRoute.setTravelTime(travTime);
    walkRoute.setDistance(estimatedNetworkDistance);

    walkLeg.setRoute(walkRoute);
    this.cachedDestinationLinkId = startLink.getId();
    walkLeg.setDepartureTime(now);
    walkLeg.setTravelTime(travTime);
    walkLeg.setArrivalTime(now + travTime);
    // set the route according to the next leg
    this.currentLeg = walkLeg;
    this.cachedRouteLinkIds = null;
    this.currentLinkIdIndex = 0;
    this.cachedNextLinkId = null;

    return;
  }
  private void initializeCSWalkLeg(String mode, double now, Link startLink, Link destinationLink) {
    LegImpl walkLeg = new LegImpl(mode);

    GenericRouteImpl walkRoute = new GenericRouteImpl(startLink.getId(), destinationLink.getId());
    final double dist =
        CoordUtils.calcEuclideanDistance(startLink.getCoord(), destinationLink.getCoord());
    final double estimatedNetworkDistance = dist * beelineFactor;

    final int travTime = (int) (estimatedNetworkDistance / walkSpeed);
    walkRoute.setTravelTime(travTime);
    walkRoute.setDistance(estimatedNetworkDistance);

    walkLeg.setRoute(walkRoute);
    this.cachedDestinationLinkId = destinationLink.getId();

    walkLeg.setDepartureTime(now);
    walkLeg.setTravelTime(travTime);
    walkLeg.setArrivalTime(now + travTime);
    // set the route according to the next leg
    this.currentLeg = walkLeg;
    this.cachedRouteLinkIds = null;
    this.currentLinkIdIndex = 0;
    this.cachedNextLinkId = null;
  }