diff --git a/input/v1.3/parkingCostArea/Bewohnerparken_2020.dbf b/input/v1.3/parkingCostArea/Bewohnerparken_2020.dbf index 69dff29a..e5aa1420 100644 Binary files a/input/v1.3/parkingCostArea/Bewohnerparken_2020.dbf and b/input/v1.3/parkingCostArea/Bewohnerparken_2020.dbf differ diff --git a/src/main/java/org/matsim/run/prepare/ParkingCapacities.java b/src/main/java/org/matsim/run/prepare/ParkingCapacities.java new file mode 100644 index 00000000..b454516c --- /dev/null +++ b/src/main/java/org/matsim/run/prepare/ParkingCapacities.java @@ -0,0 +1,58 @@ +package org.matsim.run.prepare; + +import org.matsim.api.core.v01.TransportMode; +import org.matsim.api.core.v01.network.Link; +import org.matsim.api.core.v01.network.Network; +import org.matsim.core.network.NetworkUtils; +import org.matsim.core.utils.io.IOUtils; +import java.io.BufferedWriter; +import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +/** + * This class writes out a network and a tsv file with the parking capacites of Leipzig according to a simplified calculation based on the RASt. + */ + +public final class ParkingCapacities { + + private static Network network = NetworkUtils.readNetwork("https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/leipzig-v1.2/input/leipzig-v1.2-network-with-pt.xml.gz"); + private static List listOfParkingCapacities = new ArrayList<>(); + private ParkingCapacities() { + throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); + } + + public static void main(String[] args) throws IOException { + for (Link l: network.getLinks().values()) { + //skip motorways and non car links + if (l.getAllowedModes().contains(TransportMode.car) && l.getFreespeed() < 55/3.6) { + double usableLength = (l.getLength() - 10) * 0.9; + int maxCapacity = 0; + int minCapacity = 0; + if (usableLength > 0) { + maxCapacity = (int) Math.floor(usableLength / 6); + minCapacity = (int) Math.floor(usableLength /50); + } + + l.getAttributes().putAttribute("maxParkingCapacity", maxCapacity); + l.getAttributes().putAttribute("minParkingCapacity", minCapacity); + listOfParkingCapacities.add(new ParkingCapacityRecord(l.getId().toString(), maxCapacity, minCapacity)); + } + } + writeResults(Path.of("../"), listOfParkingCapacities); + NetworkUtils.writeNetwork(network, "networkWithParkingCap.xml.gz"); + } + + private static void writeResults(Path outputFolder, List listOfParkingCapacities) throws IOException { + BufferedWriter writer = IOUtils.getBufferedWriter(outputFolder.resolve("parkingCapacities.tsv").toString()); + writer.write("linkId\tmaxCapacity\tminCapacity"); + writer.newLine(); + for (ParkingCapacities.ParkingCapacityRecord pd : listOfParkingCapacities) { + writer.write(pd.linkId + "\t" + pd.maxCapacity + "\t" + pd.minCapacity); + writer.newLine(); + } + writer.close(); + } + + private record ParkingCapacityRecord(String linkId, int maxCapacity, int minCapacity) { } +}