Пример #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");
  }
Пример #2
0
  public static LinkedList<PParking> getParkingsForScenario(String parkingDataBase) {

    LinkedList<PParking> parkingCollection = getParkingCollectionZHCity(parkingDataBase);
    String parkingsFile = parkingDataBase + "publicParkingsOutsideZHCity.xml";

    readParkings(parkingsOutsideZHCityScaling, parkingsFile, parkingCollection);

    LinkedList<PParking> parkingWithNonPositveCapacity = new LinkedList<PParking>();
    for (PParking parking : parkingCollection) {
      if (parking.getIntCapacity() <= 0) {
        parkingWithNonPositveCapacity.add(parking);
      }
    }
    parkingCollection.removeAll(parkingWithNonPositveCapacity);

    int numberOfStreetParking = 0;
    int numberOfGarageParking = 0;
    int numberOfPrivateParking = 0;

    for (PParking parking : parkingCollection) {
      if (parking.getId().toString().contains("stp")) {
        numberOfStreetParking += parking.getIntCapacity();
      } else if (parking.getId().toString().contains("gp")) {
        numberOfGarageParking += parking.getIntCapacity();
      } else if (parking.getId().toString().contains("private")) {
        numberOfPrivateParking += parking.getIntCapacity();
      }
    }

    double totalNumberOfParkingZH =
        numberOfStreetParking + numberOfGarageParking + numberOfPrivateParking;

    System.out.println(
        "streetParking to garageParking (%): "
            + numberOfStreetParking / 1.0 / numberOfGarageParking
            + " - ref: 3.03");
    System.out.println(
        "numberOfStreetParking (%): "
            + numberOfStreetParking / totalNumberOfParkingZH * 100
            + " - ref: 18.5 - ["
            + numberOfStreetParking
            + "]");
    System.out.println(
        "numberOfGarageParking (%):"
            + numberOfGarageParking / totalNumberOfParkingZH * 100
            + " - ref: 6.1 - ["
            + numberOfGarageParking
            + "]");
    System.out.println(
        "numberOfPrivateParking (%):"
            + numberOfPrivateParking / totalNumberOfParkingZH * 100
            + " - ref: 75.4 - ["
            + numberOfPrivateParking
            + "]");

    System.out.println(
        "totalNumberOfParkingZH: "
            + (totalNumberOfParkingZH / 1000)
            + "k - ref: "
            + 267000 * populationScalingFactor / 1000
            + "k");

    return parkingCollection;
  }
  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);
  }