Skip to content

v0.2.54..v0.2.55 changeset IoUtils.cpp

Garret Voltz edited this page Aug 14, 2020 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/io/IoUtils.cpp b/hoot-core/src/main/cpp/hoot/core/io/IoUtils.cpp
index d014b5b..d6f7e5b 100644
--- a/hoot-core/src/main/cpp/hoot/core/io/IoUtils.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/io/IoUtils.cpp
@@ -28,19 +28,19 @@
 #include "IoUtils.h"
 
 // Hoot
+#include <hoot/core/criterion/ChainCriterion.h>
+#include <hoot/core/criterion/ElementTypeCriterion.h>
+#include <hoot/core/criterion/TagKeyCriterion.h>
 #include <hoot/core/io/OgrReader.h>
 #include <hoot/core/io/OgrUtilities.h>
 #include <hoot/core/io/OsmMapReaderFactory.h>
 #include <hoot/core/io/OsmMapWriterFactory.h>
+#include <hoot/core/ops/ImmediatelyConnectedOutOfBoundsWayTagger.h>
+#include <hoot/core/ops/MapCropper.h>
+#include <hoot/core/util/Factory.h>
 #include <hoot/core/util/FileUtils.h>
 #include <hoot/core/util/Log.h>
 #include <hoot/core/util/Progress.h>
-#include <hoot/core/ops/MapCropper.h>
-#include <hoot/core/criterion/ElementTypeCriterion.h>
-#include <hoot/core/criterion/ChainCriterion.h>
-#include <hoot/core/criterion/TagKeyCriterion.h>
-#include <hoot/core/ops/ImmediatelyConnectedOutOfBoundsWayTagger.h>
-#include <hoot/core/util/Factory.h>
 
 // Qt
 #include <QFileInfo>
@@ -192,6 +192,7 @@ void IoUtils::cropToBounds(OsmMapPtr& map, const geos::geom::Envelope& bounds,
   const bool strictBoundsHandling =
     ConfigOptions().getConvertBoundingBoxKeepOnlyFeaturesInsideBounds();
   cropper.setKeepOnlyFeaturesInsideBounds(strictBoundsHandling);
+  cropper.setRemoveMissingElements(ConfigOptions().getConvertBoundingBoxRemoveMissingElements());
 
   // If we want to keep ways that are outside of the crop bounds but connected to a way that's
   // inside the bounds, we need to tag them before cropping and then tell the cropper to leave
@@ -220,7 +221,7 @@ void IoUtils::cropToBounds(OsmMapPtr& map, const geos::geom::Envelope& bounds,
   LOG_VARD(StringUtils::formatLargeNumber(map->getElementCount()));
 }
 
-std::shared_ptr<ElementVisitorInputStream> getVisitorInputStream(
+std::shared_ptr<ElementVisitorInputStream> IoUtils::getVisitorInputStream(
   const QString& input, const QString& visitorClassName, const bool useDataSourceIds)
 {
   std::shared_ptr<PartialOsmMapReader> reader =
@@ -238,4 +239,22 @@ std::shared_ptr<ElementVisitorInputStream> getVisitorInputStream(
           Factory::getInstance().constructObject<ElementVisitor>(visitorClassName.toStdString()))));
 }
 
+bool IoUtils::isUrl(const QString& str)
+{
+  // this works in the hoot world
+  return str.contains("://");
+}
+
+void IoUtils::writeOutputDir(const QString& dirName)
+{
+  QFileInfo outputInfo(dirName);
+  LOG_VART(outputInfo.dir().absolutePath());
+  const bool outputDirSuccess = FileUtils::makeDir(outputInfo.dir().absolutePath());
+  LOG_VART(outputDirSuccess);
+  if (!outputDirSuccess)
+  {
+    throw IllegalArgumentException("Unable to create output path for: " + dirName);
+  }
+}
+
 }
Clone this wiki locally