Skip to content

Commit

Permalink
feat(grid-dual-access): add comments
Browse files Browse the repository at this point in the history
And return 0 for origins without access (instead of magic number)
  • Loading branch information
ansoncfit committed Mar 18, 2024
1 parent aa2f44c commit 81e0151
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/main/java/com/conveyal/r5/analyst/TemporalDensityResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ public int[][] minutesToReachOpportunities(int n) {
return result;
}

/**
* Writes dual access travel time values (in minutes) to our standard access grid format. The value returned (for
* an origin) is the number of minutes required to reach a threshold number of opportunities (specified by
* the cutoffs and task.dualAccessibilityThreshold) in the specified destination layer at a given percentile of
* travel time. If the threshold cannot be reached in less than 120 minutes, returns 0.
* This is a temporary experimental feature, (ab)using existing features in the UI and backend so that grid access
* results can be obtained without any changes to those other components of our system. It uses the supplied
* task.cutoffsMinutes, except for the last one, as dual access thresholds. In place of the last cutoffsMinutes
* value, it uses task.dualAccessibilityThreshold (which is initialized to 0, so this is safe even if a user does
* not supply it).
*/
public int[][][] fakeDualAccess (RegionalTask task) {
int nPointSets = task.destinationPointSets.length;
int nCutoffs = task.cutoffsMinutes.length;
Expand All @@ -104,17 +115,17 @@ public int[][][] fakeDualAccess (RegionalTask task) {
sum += opportunitiesPerMinute[d][p][m];
m += 1;
}
dualAccess[d][p][c] = m == 0 ? 999 : m;
dualAccess[d][p][c] = m;
}
// But hack above won't allow thresholds over 120; so use the dualAccessibilityThreshold instead of
// the last cutoff
// But the hack above won't allow thresholds over 120 (see validateCutoffsMinutes()); so use the
// dualAccessibilityThreshold instead of the last cutoff.
int m = 0;
double sum = 0;
while (sum < task.dualAccessibilityThreshold && m < 120) {
sum += opportunitiesPerMinute[d][p][m];
m += 1;
}
dualAccess[d][p][nCutoffs - 1] = m == 0 ? 999 : m;
dualAccess[d][p][nCutoffs - 1] = m;
}
}
return dualAccess;
Expand Down

0 comments on commit 81e0151

Please sign in to comment.