Skip to content

Commit

Permalink
finish parking capacities
Browse files Browse the repository at this point in the history
  • Loading branch information
GregorRyb committed Jan 24, 2024
1 parent 403aeac commit fcff89c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/main/java/org/matsim/run/prepare/ParkingCapacities.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ public static void main(String[] args) throws IOException {

for (Link l: network.getLinks().values()) {

//skip motorways and nn car links
if (l.getAllowedModes().contains(TransportMode.car) && l.getFreespeed()> 55/3.6) {
//skip motorways and non car links
if (l.getAllowedModes().contains(TransportMode.car) && l.getFreespeed() < 55/3.6) {
double usableLength = (l.getLength() - 10) * 0.9;

double capacity =0;
double maxCapacity = 0;
double minCapacity = 0;
if (usableLength > 0) {
capacity = usableLength / 6;
maxCapacity = usableLength / 6;
minCapacity = usableLength /50;
}

l.getAttributes().putAttribute("parkingCapacity", (int) Math.floor(capacity));
listOfParkingCapacities.add(new ParkingCapacityRecord(l.getId().toString(), (int) Math.floor(capacity)));
l.getAttributes().putAttribute("maxParkingCapacity", Math.floor(maxCapacity));
l.getAttributes().putAttribute("minParkingCapacity", Math.floor(minCapacity));
listOfParkingCapacities.add(new ParkingCapacityRecord(l.getId().toString(), (int) Math.floor(maxCapacity), (int) Math.floor(minCapacity)));
}
}
writeResults(Path.of("../"), listOfParkingCapacities);
Expand All @@ -48,16 +50,16 @@ public static void main(String[] args) throws IOException {

private static void writeResults(Path outputFolder, List<ParkingCapacities.ParkingCapacityRecord> listOfParkingCapacities) throws IOException {
BufferedWriter writer = IOUtils.getBufferedWriter(outputFolder.resolve("parkingCapacities.tsv").toString());
writer.write("linkId\tcapacity");
writer.write("linkId\tmaxCapacity\tminCapacity");
writer.newLine();

for (ParkingCapacities.ParkingCapacityRecord pd : listOfParkingCapacities) {
writer.write(pd.linkId + "\t" + pd.capacity);
writer.write(pd.linkId + "\t" + pd.maxCapacity + "\t" + pd.minCapacity);
writer.newLine();
}
writer.close();

}

private record ParkingCapacityRecord(String linkId, int capacity) { }
private record ParkingCapacityRecord(String linkId, int maxCapacity, int minCapacity) { }
}

0 comments on commit fcff89c

Please sign in to comment.