Skip to content

Commit

Permalink
check for freeform origins before creating CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
abyrd committed Aug 17, 2023
1 parent e688365 commit 7513337
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.io.FileWriter;
import java.io.IOException;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;

/**
Expand Down Expand Up @@ -55,6 +57,7 @@ public abstract class CsvResultWriter extends BaseResultWriter implements Region
*/
CsvResultWriter (RegionalTask task, FileStorage fileStorage) throws IOException {
super(fileStorage);
checkArgument(task.originPointSet != null, "CsvResultWriters require FreeFormPointSet origins.");
super.prepare(task.jobId);
this.fileName = task.jobId + "_" + resultType() +".csv";
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(bufferFile));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,17 @@ public MultiOriginAssembler (RegionalAnalysis regionalAnalysis, Job job, FileSto
}

if (job.templateTask.includeTemporalDensity) {
resultWriters.add(new TemporalDensityCsvResultWriter(job.templateTask, fileStorage));
if (job.templateTask.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 new IllegalArgumentException("Temporal density of opportunities cannot be recorded for gridded origin points.");
} else {
// Freeform origins.
// Output includes temporal density of opportunities and optionally dual accessibility.
resultWriters.add(new TemporalDensityCsvResultWriter(job.templateTask, fileStorage));
}
}

checkArgument(job.templateTask.makeTauiSite || notNullOrEmpty(resultWriters),
Expand Down

0 comments on commit 7513337

Please sign in to comment.