v0.2.49..v0.2.50 changeset ConflateCmd.cpp
Garret Voltz edited this page Nov 6, 2019
·
1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/cmd/ConflateCmd.cpp b/hoot-core/src/main/cpp/hoot/core/cmd/ConflateCmd.cpp
index 998948a..3cd2244 100644
--- a/hoot-core/src/main/cpp/hoot/core/cmd/ConflateCmd.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/cmd/ConflateCmd.cpp
@@ -43,7 +43,7 @@
#include <hoot/core/ops/NamedOp.h>
#include <hoot/core/util/ConfigOptions.h>
#include <hoot/core/util/Factory.h>
-#include <hoot/core/util/IoUtils.h>
+#include <hoot/core/io/IoUtils.h>
#include <hoot/core/util/Log.h>
#include <hoot/core/util/MapProjector.h>
#include <hoot/core/util/Progress.h>
@@ -55,6 +55,8 @@
#include <hoot/core/visitors/CountUniqueReviewsVisitor.h>
#include <hoot/core/util/ConfigUtils.h>
#include <hoot/core/elements/OsmUtils.h>
+#include <hoot/core/ops/RemoveRoundabouts.h>
+#include <hoot/core/ops/ReplaceRoundabouts.h>
// Standard
#include <fstream>
@@ -163,19 +165,33 @@ int ConflateCmd::runSimple(QStringList& args)
Progress progress(ConfigOptions().getJobId(), JOB_SOURCE, Progress::JobState::Running);
const int maxFilePrintLength = ConfigOptions().getProgressVarPrintLengthMax();
QString msg =
- "Conflating ..." + input1.right(maxFilePrintLength) + " with ..." +
- input2.right(maxFilePrintLength) + " and writing the output to ..." +
+ "Conflating " + input1.right(maxFilePrintLength) + " with " +
+ input2.right(maxFilePrintLength) + " and writing the output to " +
output.right(maxFilePrintLength);
if (isDiffConflate)
{
- msg = msg.prepend("Differentially ");
+ if (diffConflator.conflatingTags())
+ {
+ msg = msg.replace("Conflating", "Differentially conflating (tags only) ");
+ }
+ else
+ {
+ msg = msg.replace("Conflating", "Differentially conflating ");
+ }
}
+
progress.set(0.0, msg);
double bytesRead = IoSingleStat(IoSingleStat::RChar).value;
LOG_VART(bytesRead);
QList<QList<SingleStat>> allStats;
+ _updateConfigOptionsForAttributeConflation();
+ if (isDiffConflate)
+ {
+ _updateConfigOptionsForDifferentialConflation();
+ }
+
// The number of steps here must be updated as you add/remove job steps in the logic.
_numTotalTasks = 5;
if (displayStats)
@@ -256,6 +272,7 @@ int ConflateCmd::runSimple(QStringList& args)
map, input2, ConfigOptions().getConflateUseDataSourceIds2(), Status::Unknown2);
currentTask++;
}
+ LOG_INFO("Conflating map with " << StringUtils::formatLargeNumber(map->size()) << " elements...");
double inputBytes = IoSingleStat(IoSingleStat::RChar).value - bytesRead;
LOG_VART(inputBytes);
@@ -333,7 +350,6 @@ int ConflateCmd::runSimple(QStringList& args)
stats.append(SingleStat("Conflation Time (sec)", t.getElapsedAndRestart()));
currentTask++;
- _updatePostConfigOptionsForAttributeConflation();
if (ConfigOptions().getConflatePostOps().size() > 0)
{
// apply any user specified post-conflate operations
@@ -352,7 +368,9 @@ int ConflateCmd::runSimple(QStringList& args)
progress.set(_getJobPercentComplete(currentTask - 1), "Counting feature reviews...");
CountUniqueReviewsVisitor countReviewsVis;
result->visitRo(countReviewsVis);
- LOG_INFO("Generated " << countReviewsVis.getStat() << " feature reviews.");
+ LOG_INFO(
+ "Generated " << StringUtils::formatLargeNumber(countReviewsVis.getStat()) <<
+ " feature reviews.");
currentTask++;
MapProjector::projectToWgs84(result);
@@ -454,8 +472,10 @@ int ConflateCmd::runSimple(QStringList& args)
progress.set(
1.0, Progress::JobState::Successful,
- "Conflation job completed for reference: ..." + input1.right(maxFilePrintLength) +
- " and secondary: ..." + input2.right(maxFilePrintLength) + " and written to output: ..." +
+ "Conflation job completed in " +
+ StringUtils::millisecondsToDhms((qint64)(totalElapsed * 1000)) + " for reference map: ..." +
+ input1.right(maxFilePrintLength) + " and secondary map: ..." +
+ input2.right(maxFilePrintLength) + " and written to output: ..." +
output.right(maxFilePrintLength));
return 0;
@@ -471,7 +491,32 @@ float ConflateCmd::_getJobPercentComplete(const int currentTaskNum) const
return (float)currentTaskNum / (float)_numTotalTasks;
}
-void ConflateCmd::_updatePostConfigOptionsForAttributeConflation()
+void ConflateCmd::_updateConfigOptionsForDifferentialConflation()
+{
+ // Since Differential throws out all matches, there's no way we can have a bad merge between
+ // ref/secondary roundabouts. Therefore, no need to replace/remove them. If there's a match, we'll
+ // end with no secondary roundabout in the diff output and only the ref roundabout when the diff
+ // is applied back to the ref.
+
+ QStringList preConflateOps = ConfigOptions().getConflatePreOps();
+ const QString removeRoundaboutsClassName = QString::fromStdString(RemoveRoundabouts::className());
+ if (preConflateOps.contains(removeRoundaboutsClassName))
+ {
+ preConflateOps.removeAll(removeRoundaboutsClassName);
+ conf().set(ConfigOptions::getConflatePreOpsKey(), preConflateOps);
+ }
+
+ QStringList postConflateOps = ConfigOptions().getConflatePostOps();
+ const QString replaceRoundaboutsClassName =
+ QString::fromStdString(ReplaceRoundabouts::className());
+ if (postConflateOps.contains(replaceRoundaboutsClassName))
+ {
+ postConflateOps.removeAll(replaceRoundaboutsClassName);
+ conf().set(ConfigOptions::getConflatePostOpsKey(), postConflateOps);
+ }
+}
+
+void ConflateCmd::_updateConfigOptionsForAttributeConflation()
{
// These are some custom adjustments to config opts that must be done for Attribute Conflation.
// There may be a way to eliminate these by adding more custom behavior to the UI.