예제 #1
0
  private static void logAllParkingToTextFile(LinkedList<PParking> parkings) {
    ArrayList<String> list = new ArrayList<String>();
    list.add("parkingFacilityId\tcapacity\tx-coord\ty-coord");

    for (PParking p : parkings) {
      list.add(
          p.getId().toString()
              + "\t"
              + p.getIntCapacity()
              + "\t"
              + p.getCoord().getX()
              + "\t"
              + p.getCoord().getY());
    }

    GeneralLib.writeList(list, ZHScenarioGlobal.outputFolder + "parkingProperties.txt");
  }
  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;
  }
  public static void prepare(RentPrivateParkingModel parkingModule, MatsimServices controler) {

    Config config = controler.getConfig();

    String baseDir = config.getParam("parkingChoice.ZH", "parkingDataDirectory");

    LinkedList<PParking> parkings = getParking(config, baseDir);

    parkingScoreManager = prepareParkingScoreManager(parkingModule, parkings);

    //		EventsManager events = EventsUtils.createEventsManager();
    //		EventWriterXML eventsWriter = new EventWriterXML("c:\\tmp\\events.xml.gz");
    //		events.addHandler(eventsWriter);
    //
    //		events.resetHandlers(0);
    //		eventsWriter.init("c:\\tmp\\events.xml.gz");

    ParkingInfrastructureManager pim = new ParkingInfrastructureManager(parkingScoreManager, null);

    ParkingCostModel pcm = new ParkingCostModelZH(config, parkings);
    LinkedList<PublicParking> publicParkings = new LinkedList<PublicParking>();
    LinkedList<PPRestrictedToFacilities> ppRestrictedToFacilities =
        new LinkedList<PPRestrictedToFacilities>();
    LinkedList<RentableParking> rentableParkings = new LinkedList<>();
    for (PParking parking : parkings) {
      String groupName = null;
      if (parking.getId().toString().contains("stp")) {
        groupName = "streetParking";
      } else if (parking.getId().toString().contains("gp")) {
        groupName = "garageParking";
      } else if (parking.getId().toString().contains("publicPOutsideCity")) {
        groupName = "publicPOutsideCity";
      }
      if (groupName != null) {
        PublicParking publicParking =
            new PublicParking(
                Id.create(parking.getId(), PC2Parking.class),
                parking.getIntCapacity(),
                parking.getCoord(),
                pcm,
                groupName);
        publicParkings.add(publicParking);
      } else {
        PrivateParking pp = (PrivateParking) parking;
        HashSet<Id<ActivityFacility>> hs = new HashSet<>();
        hs.add(pp.getActInfo().getFacilityId());
        groupName = "privateParking";
        PPRestrictedToFacilities PPRestrictedToFacilitiesTmp =
            new PPRestrictedToFacilities(
                Id.create(parking.getId(), PC2Parking.class),
                parking.getIntCapacity(),
                parking.getCoord(),
                pcm,
                groupName,
                hs);
        ppRestrictedToFacilities.add(PPRestrictedToFacilitiesTmp);
      }
    }

    // TODO:
    // fill in "rentableParking"
    RentableParking rp =
        new RentableParking(
            Id.create("rentableParking", PC2Parking.class),
            1,
            new Coord(682922.588, 247474.957),
            null,
            "rentableParking");
    rp.setStartRentableTime(1000);
    rp.setEndRentableTime(70000);
    rp.setOwnerId(Id.create("dummyUser", Person.class));
    rp.setRentingPricePerHourInCurrencyUnit(0.0);
    rentableParkings.add(rp);

    // =====================

    publicParkings.addAll(rentableParkings);

    pim.setPublicParkings(publicParkings);
    pim.setPrivateParkingRestrictedToFacilities(ppRestrictedToFacilities);
    pim.setRentableParking(rentableParkings);

    parkingModule.setParkingInfrastructurManager(pim);
    parkingModule.setParkingScoreManager(parkingScoreManager);
    // appendScoringFactory(parkingModule);
  }