From be2c736a08694aac33d081c8f5536ca9c5c399ee Mon Sep 17 00:00:00 2001 From: Trevor Gerhardt Date: Fri, 3 Nov 2023 11:27:41 +0800 Subject: [PATCH] Add back Temporal Density Writer Was missing after the merge. --- .../controllers/RegionalAnalysisController.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/conveyal/analysis/controllers/RegionalAnalysisController.java b/src/main/java/com/conveyal/analysis/controllers/RegionalAnalysisController.java index fde0cc225..91744fdb5 100644 --- a/src/main/java/com/conveyal/analysis/controllers/RegionalAnalysisController.java +++ b/src/main/java/com/conveyal/analysis/controllers/RegionalAnalysisController.java @@ -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; @@ -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)); } } @@ -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."); }