Skip to content

v0.2.49..v0.2.50 changeset ExportResource.java

Garret Voltz edited this page Nov 6, 2019 · 1 revision
diff --git a/hoot-services/src/main/java/hoot/services/controllers/export/ExportResource.java b/hoot-services/src/main/java/hoot/services/controllers/export/ExportResource.java
index ac20be6..32c833e 100644
--- a/hoot-services/src/main/java/hoot/services/controllers/export/ExportResource.java
+++ b/hoot-services/src/main/java/hoot/services/controllers/export/ExportResource.java
@@ -71,6 +71,7 @@ import com.querydsl.core.Tuple;
 
 import hoot.services.command.Command;
 import hoot.services.command.common.ZIPDirectoryContentsCommand;
+import hoot.services.command.common.ZIPFileCommand;
 import hoot.services.controllers.osm.map.FolderResource;
 import hoot.services.controllers.osm.map.MapResource;
 import hoot.services.job.Job;
@@ -95,8 +96,10 @@ public class ExportResource {
 
     private Class<? extends ExportCommand> getCommand(String outputType) {
         Class<? extends ExportCommand> exportCommand = null;
-        if (outputType.equals("tiles")) {
+        if (outputType.startsWith("tiles")) {
             exportCommand = CalculateTilesCommand.class;
+        } else if (outputType.startsWith("alpha")) {
+            exportCommand = AlphaShapeCommand.class;
         } else {
             exportCommand = ExportCommand.class;
         }
@@ -205,6 +208,24 @@ public class ExportResource {
                 Command zipCommand = getZIPCommand(workDir, outputName); // zip maps into single folder...
                 workflow.add(zipCommand);
 
+            //generates density tiles and alpha shape and clips the first with the second
+            } else if (params.getOutputType().startsWith("alpha.tiles")) {
+                params.setOutputType("tiles.geojson");
+                workflow.add(getCommand(user, jobId, params, debugLevel));
+                params.setOutputType("alpha.shp");
+                workflow.add(getCommand(user, jobId, params, debugLevel));
+                params.setInputType("file");
+                params.setTagOverrides(params.getInput());
+                params.setInput(workDir.getAbsolutePath() + "/" + params.getOutputName());
+                Command ogrClipCommand = new OgrClipCommand(jobId, params, this.getClass());
+                workflow.add(ogrClipCommand);
+                Command ogrFormatCommand = new OgrFormatCommand(jobId, params, this.getClass());
+                workflow.add(ogrFormatCommand);
+                Command sedSourceCommand = new SedSourceCommand(jobId, params, this.getClass());
+                workflow.add(sedSourceCommand);
+                Command zipCommand = new ZIPFileCommand(new File(workDir, params.getOutputName() + ".zip"), workDir, outputName + ".alpha.tiles.geojson", this.getClass());
+                workflow.add(zipCommand);
+
             } else {
                 // These functions ensure the map + containing folder are either owned by the user -or- public.
                 MapResource.getMapForUser(user, params.getInput(), false, false);
@@ -355,11 +376,12 @@ public class ExportResource {
     @Path("/geojson/{id}")
     @Produces(MediaType.APPLICATION_JSON)
     public Response getGeoJsonOutput(@PathParam("id") String jobId,
+                                 @QueryParam("outputname") String outputname,
                                  @QueryParam("ext") String ext) {
         Response response;
 
         try {
-            File out = getExportFile(jobId, jobId, StringUtils.isEmpty(ext) ? "geojson" : ext);
+            File out = getExportFile(jobId, StringUtils.isEmpty(outputname) ? jobId : outputname, StringUtils.isEmpty(ext) ? "geojson" : ext);
             response = Response.ok(FileUtils.readFileToString(out, "UTF-8")).build();
         }
         catch (WebApplicationException e) {
Clone this wiki locally