Skip to content

Commit

Permalink
Merge pull request #912 from conveyal/dual-access-tweaks
Browse files Browse the repository at this point in the history
Change dual accessibility CSV headers and column order
  • Loading branch information
abyrd authored Nov 22, 2023
2 parents e857fcd + 46abd8a commit 6363b28
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public CsvResultType resultType () {
public String[] columnHeaders () {
List<String> headers = new ArrayList<>();
// The ids of the freeform origin point and destination set
headers.add("originId");
headers.add("destId");
headers.add("origin");
headers.add("destinations");
headers.add("percentile");
// The number of minutes needed to reach d destination opportunities
headers.add("dual");
// The opportunity density during each of 120 minutes
for (int m = 0; m < 120; m += 1) {
// The opportunity density over travel minute m
headers.add(Integer.toString(m));
}
// The number of minutes needed to reach d destination opportunities
headers.add("D" + dualThreshold);
return headers.toArray(new String[0]);
}

Expand Down Expand Up @@ -67,20 +67,24 @@ public Iterable<String[]> rowValues (RegionalWorkResult workResult) {
List<String> row = new ArrayList<>(125);
row.add(originId);
row.add(task.destinationPointSetKeys[d]);
row.add(Integer.toString(p));
// One density value for each of 120 minutes
row.add(Integer.toString(task.percentiles[p]));
// One column containing dual accessibility value
double[] densitiesPerMinute = percentilesForDestPointset[p];
for (int m = 0; m < 120; m++) {
row.add(Double.toString(densitiesPerMinute[m]));
}
// One dual accessibility value
int m = 0;
double sum = 0;
// Find smallest integer M such that we have already reached D destinations after M minutes of travel.
while (sum < dualThreshold && m < 120) {
sum += densitiesPerMinute[m];
m += 1;
}
// -1 indicates the threshold number of opportunities had still not been reached after the highest
// travel time cutoff specified in the analysis.
row.add(Integer.toString(m >= 120 ? -1 : m));
// One density value for each of 120 one-minute bins.
// Column labeled 10 contains the number of opportunities reached after 10 to 11 minutes of travel.
for (m = 0; m < 120; m++) {
row.add(Double.toString(densitiesPerMinute[m]));
}
rows.add(row.toArray(new String[row.size()]));
}
}
Expand Down

0 comments on commit 6363b28

Please sign in to comment.