v0.2.54..v0.2.55 changeset RandomMapCropper.cpp
Garret Voltz edited this page Aug 14, 2020
·
1 revision
diff --git a/hoot-rnd/src/main/cpp/hoot/rnd/ops/RandomMapCropper.cpp b/hoot-rnd/src/main/cpp/hoot/rnd/ops/RandomMapCropper.cpp
index b7a6b0c..69a2caf 100644
--- a/hoot-rnd/src/main/cpp/hoot/rnd/ops/RandomMapCropper.cpp
+++ b/hoot-rnd/src/main/cpp/hoot/rnd/ops/RandomMapCropper.cpp
@@ -22,7 +22,7 @@
* This will properly maintain the copyright information. DigitalGlobe
* copyrights will be updated automatically.
*
- * @copyright Copyright (C) 2019 DigitalGlobe (http://www.digitalglobe.com/)
+ * @copyright Copyright (C) 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
*/
#include "RandomMapCropper.h"
@@ -31,13 +31,15 @@
#include <hoot/core/elements/OsmMap.h>
#include <hoot/core/util/Factory.h>
#include <hoot/core/util/ConfigOptions.h>
-#include <hoot/core/conflate/tile/TileUtils.h>
#include <hoot/core/util/GeometryUtils.h>
#include <hoot/core/ops/SuperfluousWayRemover.h>
#include <hoot/core/ops/SuperfluousNodeRemover.h>
#include <hoot/core/visitors/CalculateMapBoundsVisitor.h>
#include <hoot/core/util/MapProjector.h>
#include <hoot/core/io/OsmXmlWriter.h>
+#include <hoot/core/conflate/tile/NodeDensityTileBoundsCalculator.h>
+#include <hoot/core/io/TileBoundsWriter.h>
+#include <hoot/core/conflate/tile/TileUtils.h>
namespace hoot
{
@@ -96,16 +98,19 @@ void RandomMapCropper::apply(OsmMapPtr& map)
// compute tiles for the whole dataset, select one tile at random, and crop to the bounds of
// the selected tile
- // TODO: Can we intelligently calculate pixel size here somehow?
- long minNodeCountInOneTile = 0;
- long maxNodeCountInOneTile = 0;
- std::vector<std::vector<long>> nodeCounts;
- const std::vector<std::vector<geos::geom::Envelope>> tiles =
- TileUtils::calculateTiles(
- _maxNodeCount, _pixelSize, map, minNodeCountInOneTile, maxNodeCountInOneTile, nodeCounts);
+
+ // TODO: integrate this with the node density retry params if they end up being useful with
+ // the node-density-tiles command
+ NodeDensityTileBoundsCalculator tileCalc;
+ tileCalc.setPixelSize(_pixelSize);
+ tileCalc.setMaxNodesPerTile(_maxNodeCount);
+ tileCalc.calculateTiles(map);
+ const std::vector<std::vector<geos::geom::Envelope>> tiles = tileCalc.getTiles();
+ const std::vector<std::vector<long>> nodeCounts = tileCalc.getNodeCounts();
+
if (!_tileFootprintOutputPath.isEmpty())
{
- TileUtils::writeTilesToOsm(tiles, nodeCounts, _tileFootprintOutputPath);
+ TileBoundsWriter::writeTilesToOsm(tiles, nodeCounts, _tileFootprintOutputPath);
LOG_INFO("Wrote tile footprints to: " << _tileFootprintOutputPath);
}
_cropper.setBounds(TileUtils::getRandomTile(tiles, _randomSeed));
@@ -122,8 +127,8 @@ void RandomMapCropper::apply(OsmMapPtr& map)
LOG_DEBUG(
"Cropped map bounds: " <<
GeometryUtils::envelopeToConfigString(CalculateMapBoundsVisitor::getGeosBounds(map)));
- LOG_INFO("Minimum nodes in a single tile: " << minNodeCountInOneTile);
- LOG_INFO("Maximum nodes in a single tile: " << maxNodeCountInOneTile);
+ LOG_INFO("Minimum nodes in a single tile: " << tileCalc.getMinNodeCountInOneTile());
+ LOG_INFO("Maximum nodes in a single tile: " << tileCalc.getMaxNodeCountInOneTile());
}
}