Skip to content

Commit

Permalink
Enable returning freeform points
Browse files Browse the repository at this point in the history
Allows `getOpportunityDataset` to return Freeform files to be visualized in the UI.
  • Loading branch information
trevorgerhardt committed Feb 11, 2025
1 parent 5648f0b commit df6f5ae
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.conveyal.analysis.persistence.Persistence;
import com.conveyal.analysis.util.FileItemInputStreamProvider;
import com.conveyal.analysis.util.HttpUtils;
import com.conveyal.analysis.util.JsonUtil;
import com.conveyal.file.FileStorage;
import com.conveyal.file.FileStorageFormat;
import com.conveyal.file.FileStorageKey;
Expand All @@ -28,7 +27,6 @@
import com.conveyal.r5.util.ExceptionUtils;
import com.conveyal.r5.util.InputStreamProvider;
import com.conveyal.r5.util.ProgressListener;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.io.Files;
import com.mongodb.QueryBuilder;
import org.apache.commons.fileupload.FileItem;
Expand Down Expand Up @@ -116,13 +114,11 @@ private UrlWithHumanName getOpportunityDataset(Request req, Response res) {
if (dataset.format == FileStorageFormat.GRID) {
res.type(APPLICATION_JSON.asString());
return fileStorage.getJsonUrl(dataset.getStorageKey(), dataset.sourceName + "_" + dataset.name, "grid");
} else if (dataset.format == FileStorageFormat.FREEFORM) {
res.type(APPLICATION_JSON.asString());
return fileStorage.getJsonUrl(dataset.getStorageKey(), dataset.sourceName + "_" + dataset.name, "freeform");
} else {
// Currently the UI can only visualize grids, not other kinds of datasets (freeform points).
// We do generate a rasterized grid for each of the freeform pointsets we create, so ideally we'd redirect
// to that grid for display and preview, but the freeform and corresponding grid pointset have different
// IDs and there are no references between them.
LOG.error("We cannot yet visualize freeform pointsets. Returning nothing to the UI.");
return null;
throw AnalysisServerException.badRequest("Format " + dataset.format + " cannot be downloaded.");
}
}

Expand Down

0 comments on commit df6f5ae

Please sign in to comment.