Skip to content

Commit

Permalink
Add back Temporal Density Writer
Browse files Browse the repository at this point in the history
Was missing after the merge.
  • Loading branch information
trevorgerhardt committed Nov 3, 2023
1 parent 79ac804 commit be2c736
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.conveyal.analysis.results.MultiOriginAssembler;
import com.conveyal.analysis.results.PathCsvResultWriter;
import com.conveyal.analysis.results.RegionalResultWriter;
import com.conveyal.analysis.results.TemporalDensityCsvResultWriter;
import com.conveyal.analysis.results.TimeCsvResultWriter;
import com.conveyal.analysis.util.JsonUtil;
import com.conveyal.file.FileStorage;
Expand Down Expand Up @@ -524,10 +525,12 @@ private RegionalAnalysis createRegionalAnalysis (Request req, Response res) thro
if (!task.makeTauiSite) {
if (task.recordAccessibility) {
if (task.originPointSet != null) {
// Freeform origins - create CSV regional analysis results
var accessWriter = new AccessCsvResultWriter(task, fileStorage);
resultWriters.add(accessWriter);
regionalAnalysis.resultStorage.put(accessWriter.resultType(), accessWriter.getFileName());
} else {
// Gridded origins - create gridded regional analysis results
resultWriters.addAll(GridResultWriter.createWritersFromTask(regionalAnalysis, task, fileStorage));
}
}
Expand All @@ -543,6 +546,20 @@ private RegionalAnalysis createRegionalAnalysis (Request req, Response res) thro
resultWriters.add(pathsWriter);
regionalAnalysis.resultStorage.put(pathsWriter.resultType(), pathsWriter.getFileName());
}

if (task.includeTemporalDensity) {
if (task.originPointSet == null) {
// Gridded origins. The full temporal density information is probably too voluminous to be useful.
// We might want to record a grid of dual accessibility values, but this will require some serious
// refactoring of the GridResultWriter.
// if (job.templateTask.dualAccessibilityThreshold > 0) { ... }
throw AnalysisServerException.badRequest("Temporal density of opportunities cannot be recorded for gridded origin points.");
} else {
var tDensityWriter = new TemporalDensityCsvResultWriter(task, fileStorage);
resultWriters.add(tDensityWriter);
regionalAnalysis.resultStorage.put(tDensityWriter.resultType(), tDensityWriter.getFileName());
}
}
checkArgument(notNullOrEmpty(resultWriters), "A regional analysis should always create at least one grid or CSV file.");
}

Expand Down

0 comments on commit be2c736

Please sign in to comment.