Skip to content

v0.2.49..v0.2.50 changeset GenerateAlphaShapeCmd.cpp

Garret Voltz edited this page Nov 6, 2019 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/cmd/GenerateAlphaShapeCmd.cpp b/hoot-core/src/main/cpp/hoot/core/cmd/GenerateAlphaShapeCmd.cpp
index fe8314d..6897a51 100644
--- a/hoot-core/src/main/cpp/hoot/core/cmd/GenerateAlphaShapeCmd.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/cmd/GenerateAlphaShapeCmd.cpp
@@ -29,13 +29,14 @@
 #include <geos/geom/GeometryFactory.h>
 
 // Hoot
-#include <hoot/core/util/Factory.h>
-#include <hoot/core/util/MapProjector.h>
+#include <hoot/core/algorithms/alpha-shape/AlphaShapeGenerator.h>
 #include <hoot/core/cmd/BaseCommand.h>
+#include <hoot/core/io/IoUtils.h>
+#include <hoot/core/io/OsmGeoJsonWriter.h>
 #include <hoot/core/io/ShapefileWriter.h>
-#include <hoot/core/algorithms/alpha-shape/AlphaShapeGenerator.h>
+#include <hoot/core/util/Factory.h>
 #include <hoot/core/util/Log.h>
-#include <hoot/core/util/IoUtils.h>
+#include <hoot/core/util/MapProjector.h>
 
 namespace hoot
 {
@@ -52,7 +53,7 @@ public:
   virtual QString getName() const override { return "generate-alpha-shape"; }
 
   virtual QString getDescription() const override
-  { return "Generates a concave hull for a set of points; useful in cookie cutting"; }
+  { return "Generates a shape that covers a set of features in a map"; }
 
   virtual int runSimple(QStringList& args) override
   {
@@ -81,10 +82,21 @@ public:
       ShapefileWriter writer;
       writer.writePolygons(result, outputPath);
     }
+    else if (outputPath.toLower().endsWith(".geojson"))
+    {
+      OsmGeoJsonWriter writer;
+      Settings s;
+      //  Output the source tags in the geojson writer
+      s.set(ConfigOptions::getJsonOutputTaskingManagerAoiKey(), true);
+      writer.setConfiguration(s);
+      writer.open(outputPath);
+      writer.write(result);
+    }
     else
     {
       IoUtils::saveMap(result, outputPath);
     }
+    LOG_INFO("Alpha-shape writen to " << outputPath);
 
     return 0;
   }
Clone this wiki locally