Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parking capacities #41

Merged
merged 8 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified input/v1.3/parkingCostArea/Bewohnerparken_2020.dbf
Binary file not shown.
58 changes: 58 additions & 0 deletions src/main/java/org/matsim/run/prepare/ParkingCapacities.java
Original file line number Diff line number Diff line change
@@ -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<ParkingCapacities.ParkingCapacityRecord> 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<ParkingCapacities.ParkingCapacityRecord> 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) { }
}
Loading