|
7 | 7 | import com.conveyal.file.FileStorage;
|
8 | 8 | import com.conveyal.file.FileStorageFormat;
|
9 | 9 | import com.conveyal.r5.analyst.PointSet;
|
| 10 | +import com.conveyal.r5.analyst.cluster.PathResult; |
| 11 | +import com.conveyal.r5.analyst.cluster.RegionalTask; |
10 | 12 | import com.conveyal.r5.analyst.cluster.RegionalWorkResult;
|
11 | 13 | import com.conveyal.r5.util.ExceptionUtils;
|
12 | 14 | import org.slf4j.Logger;
|
@@ -89,21 +91,27 @@ public MultiOriginAssembler (RegionalAnalysis regionalAnalysis, Job job, FileSto
|
89 | 91 | this.job = job;
|
90 | 92 | this.nOriginsTotal = job.nTasksTotal;
|
91 | 93 | this.originsReceived = new BitSet(job.nTasksTotal);
|
92 |
| - // Check that origin and destination sets are not too big for generating CSV files. |
93 |
| - if (!job.templateTask.makeTauiSite && |
94 |
| - job.templateTask.destinationPointSetKeys[0].endsWith(FileStorageFormat.FREEFORM.extension) |
95 |
| - ) { |
96 |
| - // This requires us to have already loaded this destination pointset instance into the transient field. |
97 |
| - PointSet destinationPointSet = job.templateTask.destinationPointSets[0]; |
98 |
| - if ((job.templateTask.recordTimes || job.templateTask.includePathResults) && !job.templateTask.oneToOne) { |
99 |
| - if (nOriginsTotal * destinationPointSet.featureCount() > MAX_FREEFORM_OD_PAIRS || |
100 |
| - destinationPointSet.featureCount() > MAX_FREEFORM_DESTINATIONS |
101 |
| - ) { |
102 |
| - throw new AnalysisServerException(String.format( |
103 |
| - "Freeform requests limited to %d destinations and %d origin-destination pairs.", |
104 |
| - MAX_FREEFORM_DESTINATIONS, MAX_FREEFORM_OD_PAIRS |
105 |
| - )); |
106 |
| - } |
| 94 | + // If results have been requested for freeform origins, check that the origin and |
| 95 | + // destination pointsets are not too big for generating CSV files. |
| 96 | + RegionalTask task = job.templateTask; |
| 97 | + if (!task.makeTauiSite && task.destinationPointSetKeys[0].endsWith(FileStorageFormat.FREEFORM.extension)) { |
| 98 | + // This requires us to have already loaded this destination pointset instance into the transient field. |
| 99 | + PointSet destinationPointSet = task.destinationPointSets[0]; |
| 100 | + int nDestinations = destinationPointSet.featureCount(); |
| 101 | + int nODPairs = task.oneToOne ? nOriginsTotal : nOriginsTotal * nDestinations; |
| 102 | + if (task.recordTimes && |
| 103 | + (nDestinations > MAX_FREEFORM_DESTINATIONS || nODPairs > MAX_FREEFORM_OD_PAIRS)) { |
| 104 | + throw AnalysisServerException.badRequest(String.format( |
| 105 | + "Travel time results limited to %d destinations and %d origin-destination pairs.", |
| 106 | + MAX_FREEFORM_DESTINATIONS, MAX_FREEFORM_OD_PAIRS |
| 107 | + )); |
| 108 | + } |
| 109 | + if (task.includePathResults && |
| 110 | + (nDestinations > PathResult.MAX_PATH_DESTINATIONS || nODPairs > MAX_FREEFORM_OD_PAIRS)) { |
| 111 | + throw AnalysisServerException.badRequest(String.format( |
| 112 | + "Path results limited to %d destinations and %d origin-destination pairs.", |
| 113 | + PathResult.MAX_PATH_DESTINATIONS, MAX_FREEFORM_OD_PAIRS |
| 114 | + )); |
107 | 115 | }
|
108 | 116 | }
|
109 | 117 |
|
|
0 commit comments