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

Skimmatrices little bugfix #3048

Merged
merged 3 commits into from
Jan 11, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public final void loadSamplingPointsFromFile(String filename) throws IOException
int idx = Integer.parseInt(parts[1]);
double x = Double.parseDouble(parts[2]);
double y = Double.parseDouble(parts[3]);
final int length = idx > maxIdx ? idx : maxIdx;
final int length = Math.max(idx, maxIdx);
Coord[] coords = this.coordsPerZone.computeIfAbsent(zoneId, k -> new Coord[length + 1]);
if (coords.length < (idx + 1)) {
Coord[] tmp = new Coord[idx + 1];
Expand Down Expand Up @@ -453,10 +453,25 @@ public final void calculateAndWritePTMatrices(String networkFilename,
double endTime,
Config config,
String outputPrefix,
BiPredicate<TransitLine, TransitRoute> trainDetector) throws IOException {
BiPredicate<TransitLine, TransitRoute> trainDetector,
PTSkimMatrices.CoordAggregator coordAggregator) throws IOException {

var matrices = calculatePTMatrices(networkFilename,
transitScheduleFilename, startTime, endTime, config, trainDetector);
transitScheduleFilename, startTime, endTime, config, trainDetector, coordAggregator);
writePTMatricesAsCSV(matrices, outputPrefix);
}
public final void calculateAndWritePTMatrices(String networkFilename,
String transitScheduleFilename,
double startTime,
double endTime,
Config config,
String outputPrefix,
BiPredicate<TransitLine, TransitRoute> trainDetector
) throws IOException {

var matrices = calculatePTMatrices(networkFilename,
transitScheduleFilename, startTime, endTime, config, trainDetector, new PTSkimMatrices.CoordAggregator() {
});
writePTMatricesAsCSV(matrices, outputPrefix);
}

Expand All @@ -476,11 +491,12 @@ public final void writePTMatricesAsCSV(PTSkimMatrices.PtIndicators<String> matri
}

public final PTSkimMatrices.PtIndicators<String> calculatePTMatrices(String networkFilename,
String transitScheduleFilename,
double startTime,
double endTime,
Config config,
BiPredicate<TransitLine, TransitRoute> trainDetector) {
String transitScheduleFilename,
double startTime,
double endTime,
Config config,
BiPredicate<TransitLine, TransitRoute> trainDetector,
PTSkimMatrices.CoordAggregator coordAggregator) {
Scenario scenario = ScenarioUtils.createScenario(config);
log.info("loading schedule from " + transitScheduleFilename);
new TransitScheduleReader(scenario).readFile(transitScheduleFilename);
Expand All @@ -494,8 +510,7 @@ public final PTSkimMatrices.PtIndicators<String> calculatePTMatrices(String netw

log.info("calc PT matrices for " + Time.writeTime(startTime) + " - " + Time.writeTime(endTime));
PTSkimMatrices.PtIndicators<String> matrices = PTSkimMatrices.calculateSkimMatrices(
raptorData, this.coordsPerZone, startTime, endTime, 120, raptorParameters, this.numberOfThreads, trainDetector, new PTSkimMatrices.CoordAggregator() {
});
raptorData, this.coordsPerZone, startTime, endTime, 120, raptorParameters, this.numberOfThreads, trainDetector, coordAggregator);
return matrices;

}
Expand Down
Loading