Skip to content

Commit

Permalink
network geometries as optional parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
hzoerner committed Jul 14, 2023
1 parent b4eac8c commit ee6d0d8
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/main/java/org/matsim/prepare/counts/CreateCountsFromVMZ.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ public class CreateCountsFromVMZ implements MATSimAppCommand {
@CommandLine.Option(names = "--network", description = "Path to network", required = true)
private Path network;

@CommandLine.Option(names = "--network-geometries", description = "path to *linkGeometries.csv", required = true)
@CommandLine.Option(names = "--network-geometries", description = "path to *linkGeometries.csv")
private Path networkGeometries;

@CommandLine.Option(names = "--version", description = "scenario version")
private String version = "";

@CommandLine.Option(names = "--output", description = "Base path for the output")
private String output;

Expand Down Expand Up @@ -94,11 +97,15 @@ private void matchWithNetwork(Path network) throws TransformException, IOExcepti

CoordinateTransformation transformation = crs.getTransformation();

NetworkIndex<BerlinCount> index = new NetworkIndex<>(net, NetworkIndex.readGeometriesFromSumo(networkGeometries.toString(), IdentityTransform.create(2)), 100, toMatch -> {
NetworkIndex.GeometryGetter<BerlinCount> getter = toMatch -> {
Coord coord = toMatch.coord;
Coord transform = transformation.transform(coord);
return MGC.coord2Point(transform);
});
};

NetworkIndex<BerlinCount> index = networkGeometries != null ?
new NetworkIndex<>(net, NetworkIndex.readGeometriesFromSumo(networkGeometries.toString(), IdentityTransform.create(2)), 100, getter):
new NetworkIndex<>(net, 100, getter);

index.addLinkFilter((link, berlinCounts) -> {
String orientation = berlinCounts.orientation;
Expand Down Expand Up @@ -200,9 +207,12 @@ private void createCountsFile(String outputFile) {
counter++;
}

if (!version.isBlank())
version += "-";

log.info("Write down {} count stations to file", counter);
new CountsWriter(countsPkw).write(outputFile + "car_counts_from_vmz.xml");
new CountsWriter(countsLkw).write(outputFile + "freight_counts_from_vmz.xml");
new CountsWriter(countsPkw).write(outputFile + version + "car-counts-from-vmz.xml");
new CountsWriter(countsLkw).write(outputFile + version + "freight-counts-from-vmz.xml");

log.info("Write down {} unmatched count stations to file", unmatched.size());
try (CSVPrinter printer = CSVFormat.Builder.create().setHeader("id", "position", "x", "y").build()
Expand Down

0 comments on commit ee6d0d8

Please sign in to comment.