-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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 <[email protected]>
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
58 changes: 58 additions & 0 deletions
58
src/main/java/org/matsim/run/prepare/ParkingCapacities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { } | ||
} |