From 4054f6a983b86303194aff87787c30cefb370cfe Mon Sep 17 00:00:00 2001 From: GregorRyb <43266258+GregorRyb@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:48:11 +0100 Subject: [PATCH] Parking capacities (#41) * update shape file to be consistent with the car cost calculation * start parking capacities implementation * finish parking capacities * finish parking capacities * satisfy checkstyle * Formatting * implement suggestion from pull request * fix check style --------- Co-authored-by: GregorRyb --- .../parkingCostArea/Bewohnerparken_2020.dbf | Bin 5098 -> 5098 bytes .../matsim/run/prepare/ParkingCapacities.java | 58 ++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/main/java/org/matsim/run/prepare/ParkingCapacities.java diff --git a/input/v1.3/parkingCostArea/Bewohnerparken_2020.dbf b/input/v1.3/parkingCostArea/Bewohnerparken_2020.dbf index 69dff29acab587bb20b74f3e804de44c6aa6246e..e5aa1420ddacf58ee5585debe82e95037f5c8d73 100644 GIT binary patch delta 259 zcmaE*{z{#NxrUKzBg-sCW_9%z%|6VYOmK;{tPqKXjG~(> z*y><9MJMxdz;#T%iNs#Qi4f1{La?p45o}f-1p5LKdp0jj9O5#dYbG1=L&O#`icJ2^ nzXj?rk;%sd5bTM95VnU9%ts=V)rGh41AVCg2F7{@1_n|9=Q~NC delta 259 zcmaE*{z{#Nxtf)KBg-sCW&;b8$qN}zKxxs*jZB-t>_9%z%|6VYOmK;{tPqKXjG~(> z*y><9MJMxdz;#T%iNs#Qi4f1{La?p45o}f-1p5LKdp0jj9O5#dYbG1=L&O#`icJ2^ nzXj?rk;%sd5bTM95VnU9%ts=V)rGh41AVCg2F7{@1_n|9E$&Js 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) { } +}