-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #678 from conveyal/paths-times-freeform
Cleanup of paths, freeform, and OD matrix functionality
- Loading branch information
Showing
31 changed files
with
696 additions
and
430 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
65 changes: 65 additions & 0 deletions
65
src/main/java/com/conveyal/analysis/results/AccessCsvResultWriter.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,65 @@ | ||
package com.conveyal.analysis.results; | ||
|
||
import com.conveyal.file.FileStorage; | ||
import com.conveyal.r5.analyst.cluster.RegionalTask; | ||
import com.conveyal.r5.analyst.cluster.RegionalWorkResult; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class AccessCsvResultWriter extends CsvResultWriter { | ||
|
||
public AccessCsvResultWriter (RegionalTask task, String outputBucket, FileStorage fileStorage) throws IOException { | ||
super(task, outputBucket, fileStorage); | ||
} | ||
|
||
@Override | ||
public CsvResultType resultType () { | ||
return CsvResultType.ACCESS; | ||
} | ||
|
||
@Override | ||
public String[] columnHeaders () { | ||
// We could potentially make the percentile and cutoff columns optional, but it's unnecessary complexity. | ||
return new String[] { "origin", "destinations", "percentile", "cutoff", "access" }; | ||
} | ||
|
||
/** | ||
* Check that each dimension of the 3D accessibility results array | ||
* matches the expected size for the job being processed. | ||
*/ | ||
@Override | ||
protected void checkDimension (RegionalWorkResult workResult) { | ||
checkDimension(workResult, "destination pointsets", workResult.accessibilityValues.length, task.destinationPointSetKeys.length); | ||
for (int[][] percentilesForGrid : workResult.accessibilityValues) { | ||
checkDimension(workResult, "percentiles", percentilesForGrid.length, task.percentiles.length); | ||
for (int[] cutoffsForPercentile : percentilesForGrid) { | ||
checkDimension(workResult, "cutoffs", cutoffsForPercentile.length, task.cutoffsMinutes.length); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public Iterable<String[]> rowValues (RegionalWorkResult workResult) { | ||
String originId = task.originPointSet.getId(workResult.taskId); | ||
List<String[]> rows = new ArrayList<>(); | ||
for (int d = 0; d < task.destinationPointSetKeys.length; d++) { | ||
int[][] percentilesForDestPointset = workResult.accessibilityValues[d]; | ||
for (int p = 0; p < task.percentiles.length; p++) { | ||
int[] cutoffsForPercentile = percentilesForDestPointset[p]; | ||
for (int c = 0; c < task.cutoffsMinutes.length; c++) { | ||
rows.add(new String[] { | ||
originId, | ||
task.destinationPointSetKeys[d], | ||
Integer.toString(task.percentiles[p]), | ||
Integer.toString(task.cutoffsMinutes[c]), | ||
Integer.toString(workResult.accessibilityValues[d][p][c]) | ||
}); | ||
} | ||
} | ||
} | ||
return rows; | ||
} | ||
|
||
} |
Oops, something went wrong.