Beispiel #1
0
  /**
   * get parking related walking distance of whole day - average per leg
   *
   * @param plan
   * @param facilities
   * @return
   */
  public static double getParkingRelatedWalkingDistanceOfWholeDayAveragePerLeg(
      Plan plan, ActivityFacilities facilities) {
    double travelDistance = 0;
    int numberOfLegs = 0;

    List<PlanElement> pe = plan.getPlanElements();

    for (int i = 0; i < pe.size(); i++) {
      if (pe.get(i) instanceof ActivityImpl) {
        ActivityImpl parkingActivity = (ActivityImpl) pe.get(i);
        if (parkingActivity.getType().equalsIgnoreCase("parking")) {
          Coord coordParking =
              facilities.getFacilities().get(parkingActivity.getFacilityId()).getCoord();
          Leg nextLeg = (Leg) pe.get(i + 1);
          Leg prevLeg = (Leg) pe.get(i - 1);
          if (nextLeg.getMode().equalsIgnoreCase("walk")) {
            ActivityImpl nextAct = (ActivityImpl) pe.get(i + 2);

            if (nextAct.getFacilityId() != null) {
              Coord nextActFacilityCoord =
                  facilities.getFacilities().get(nextAct.getFacilityId()).getCoord();
              travelDistance += GeneralLib.getDistance(coordParking, nextActFacilityCoord);
            } else {
              Coord nextActLinkCoord = nextAct.getCoord();
              travelDistance += GeneralLib.getDistance(coordParking, nextActLinkCoord);
            }
            numberOfLegs++;
          }
          if (prevLeg.getMode().equalsIgnoreCase("walk")) {
            ActivityImpl prevAct = (ActivityImpl) pe.get(i - 2);

            if (prevAct.getFacilityId() != null) {
              Coord prevActFacilityCoord =
                  facilities.getFacilities().get(prevAct.getFacilityId()).getCoord();
              travelDistance += GeneralLib.getDistance(coordParking, prevActFacilityCoord);
            } else {
              Coord prevActLinkCoord = prevAct.getCoord();
              travelDistance += GeneralLib.getDistance(coordParking, prevActLinkCoord);
            }
            numberOfLegs++;
          }
        }
      }
    }

    return travelDistance / numberOfLegs;
  }
  private static PParking getParkingWithShortestWalkingDistance(
      Coord destCoord, Collection<PParking> parkingsInSurroundings) {
    PParking bestParking = null;
    double currentBestDistance = Double.MAX_VALUE;

    for (PParking parking : parkingsInSurroundings) {
      double distance = GeneralLib.getDistance(destCoord, parking.getCoord());
      if (distance < currentBestDistance) {
        bestParking = parking;
        currentBestDistance = distance;
      }
    }

    return bestParking;
  }
Beispiel #3
0
  private static void addIllegalParking(Network network, LinkedList<PParking> parkings) {
    double shareOfLinksWithIllegalParking =
        ZHScenarioGlobal.loadDoubleParam("ParkingLoader.shareOfLinksWithIllegalParking");
    Coord coordinatesLindenhofZH = ParkingHerbieControler.getCoordinatesLindenhofZH();
    Random rand =
        new Random(
            19873); // fixing seed (scenarios with different simulation seeds should still have same
                    // illegal parking infrastructure)

    int i = 0;
    for (Link link : network.getLinks().values()) {
      if (GeneralLib.getDistance(coordinatesLindenhofZH, link.getCoord()) < 7000
          && rand.nextDouble() < shareOfLinksWithIllegalParking) {
        PublicParking parking = new PublicParking(link.getCoord());
        parking.setMaxCapacity(1.0);
        parking.setParkingId(Id.create("illegal-" + i, PParking.class));
        parking.setType("public");
        parkings.add(parking);
        i++;
      }
    }
    System.out.println("number of illegal parking added: " + i / 1000.0 + "k");
  }
  public static boolean isInsideCordon(Coord coord) {
    Coord center = new Coord(683400.75, 247500.0687);
    double radius = 1000;

    return GeneralLib.getDistance(center, coord) < radius;
  }
Beispiel #5
0
 public static double getDistance(Coord coord, Link link) {
   return GeneralLib.getDistance(coord, link.getCoord());
 }