diff --git a/hoot-core/src/main/cpp/hoot/core/cmd/ChangesetDeriveReplacementCmd.cpp b/hoot-core/src/main/cpp/hoot/core/cmd/ChangesetDeriveReplacementCmd.cpp
index 3f5ed22..15880d6 100644
--- a/hoot-core/src/main/cpp/hoot/core/cmd/ChangesetDeriveReplacementCmd.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/cmd/ChangesetDeriveReplacementCmd.cpp
@@ -56,7 +56,7 @@ public:
static std::string className() { return "hoot::ChangesetDeriveReplacementCmd"; }
- ChangesetDeriveReplacementCmd() {}
+ ChangesetDeriveReplacementCmd() = default;
virtual QString getName() const { return "changeset-derive-replacement"; }
@@ -69,6 +69,18 @@ public:
timer.start();
LOG_VARD(args);
+ // If needed for testing, can manually load separate implementations with
+ // ConfigOptions().getChangesetReplacementImplementation().
+ run(args);
+
+ LOG_STATUS(
+ "Changeset generated in " << StringUtils::millisecondsToDhms(timer.elapsed()) << " total.");
+
+ return 0;
+ }
+
+ void run(QStringList& args)
+ {
// process optional params
bool fullReplacement = false;
@@ -77,7 +89,7 @@ public:
fullReplacement = true;
args.removeAll("--full-replacement");
}
- LOG_VAR(fullReplacement);
+ LOG_VARD(fullReplacement);
QStringList geometryFilters;
if (args.contains("--geometry-filters"))
@@ -87,7 +99,7 @@ public:
args.removeAt(optionNameIndex + 1);
args.removeAt(optionNameIndex);
}
- LOG_VAR(geometryFilters);
+ LOG_VARD(geometryFilters);
QStringList replacementFilters;
if (args.contains("--replacement-filters"))
@@ -97,7 +109,7 @@ public:
args.removeAt(optionNameIndex + 1);
args.removeAt(optionNameIndex);
}
- LOG_VAR(replacementFilters);
+ LOG_VARD(replacementFilters);
bool chainReplacementFilters = false;
if (args.contains("--chain-replacement-filters"))
@@ -105,7 +117,7 @@ public:
chainReplacementFilters = true;
args.removeAll("--chain-replacement-filters");
}
- LOG_VAR(chainReplacementFilters);
+ LOG_VARD(chainReplacementFilters);
QStringList replacementFilterOptions;
if (args.contains("--replacement-filter-options"))
@@ -115,7 +127,7 @@ public:
args.removeAt(optionNameIndex + 1);
args.removeAt(optionNameIndex);
}
- LOG_VAR(replacementFilterOptions);
+ LOG_VARD(replacementFilterOptions);
QStringList retainmentFilters;
if (args.contains("--retainment-filters"))
@@ -125,7 +137,7 @@ public:
args.removeAt(optionNameIndex + 1);
args.removeAt(optionNameIndex);
}
- LOG_VAR(retainmentFilters);
+ LOG_VARD(retainmentFilters);
bool chainRetainmentFilters = false;
if (args.contains("--chain-retainment-filters"))
@@ -133,7 +145,7 @@ public:
chainRetainmentFilters = true;
args.removeAll("--chain-retainment-filters");
}
- LOG_VAR(chainRetainmentFilters);
+ LOG_VARD(chainRetainmentFilters);
QStringList retainmentFilterOptions;
if (args.contains("--retainment-filter-options"))
@@ -143,41 +155,29 @@ public:
args.removeAt(optionNameIndex + 1);
args.removeAt(optionNameIndex);
}
- LOG_VAR(retainmentFilterOptions);
+ LOG_VARD(retainmentFilterOptions);
- bool lenientBounds = true;
+ if (args.contains("--strict-bounds") && args.contains("--hybrid-bounds"))
+ {
+ throw IllegalArgumentException(
+ "Only one of '--strict-bounds' and '--hybrid-bounds' may be specified.");
+ }
+ ChangesetReplacementCreator::BoundsInterpretation boundsHandling =
+ ChangesetReplacementCreator::BoundsInterpretation::Lenient;
if (args.contains("--strict-bounds"))
{
- lenientBounds = false;
+ boundsHandling = ChangesetReplacementCreator::BoundsInterpretation::Strict;
args.removeAll("--strict-bounds");
}
- LOG_VAR(lenientBounds);
+ else if (args.contains("--hybrid-bounds"))
+ {
+ boundsHandling = ChangesetReplacementCreator::BoundsInterpretation::Hybrid;
+ args.removeAll("--hybrid-bounds");
+ }
bool printStats = false;
QString outputStatsFile;
- if (args.contains("--stats"))
- {
- printStats = true;
- const int statsIndex = args.indexOf("--stats");
- // See similar note in ChangesetDeriveCmd.
- if (statsIndex != -1 && statsIndex != (args.size() - 1) &&
- !args[statsIndex + 1].startsWith("--"))
- {
- outputStatsFile = args[statsIndex + 1];
- QFileInfo statsInfo(outputStatsFile);
- if (!ChangesetStatsFormat::isValidFileOutputFormat(statsInfo.completeSuffix()))
- {
- outputStatsFile = "";
- }
- else
- {
- args.removeAll(outputStatsFile);
- }
- }
- args.removeAll("--stats");
- }
- LOG_VAR(printStats);
- LOG_VAR(outputStatsFile);
+ processStatsParams(args, printStats, outputStatsFile);
bool enableWaySnapping = true;
if (args.contains("--disable-way-snapping"))
@@ -185,7 +185,7 @@ public:
enableWaySnapping = false;
args.removeAll("--disable-way-snapping");
}
- LOG_VAR(enableWaySnapping);
+ LOG_VARD(enableWaySnapping);
bool enableConflation = true;
if (args.contains("--disable-conflation"))
@@ -193,7 +193,7 @@ public:
enableConflation = false;
args.removeAll("--disable-conflation");
}
- LOG_VAR(enableConflation);
+ LOG_VARD(enableConflation);
bool enableCleaning = true;
if (args.contains("--disable-cleaning"))
@@ -210,7 +210,7 @@ public:
}
args.removeAll("--disable-cleaning");
}
- LOG_VAR(enableCleaning);
+ LOG_VARD(enableCleaning);
bool tagOobConnectedWays = true;
if (args.contains("--disable-oob-way-handling"))
@@ -218,7 +218,7 @@ public:
tagOobConnectedWays = false;
args.removeAll("--disable-oob-way-handling");
}
- LOG_VAR(tagOobConnectedWays);
+ LOG_VARD(tagOobConnectedWays);
QString boundsStr = "";
if (args.size() >= 3)
@@ -233,13 +233,13 @@ public:
// process non-optional params
const QString input1 = args[0].trimmed();
- LOG_VAR(input1);
+ LOG_VARD(input1);
const QString input2 = args[1].trimmed();
- LOG_VAR(input2);
+ LOG_VARD(input2);
const geos::geom::Envelope bounds = GeometryUtils::envelopeFromConfigString(boundsStr);
- LOG_VAR(bounds);
+ LOG_VARD(bounds);
const QString output = args[3].trimmed();
- LOG_VAR(output);
+ LOG_VARD(output);
QString osmApiDbUrl;
if (output.endsWith(".osc.sql"))
@@ -255,7 +255,7 @@ public:
ChangesetReplacementCreator changesetCreator(printStats, outputStatsFile, osmApiDbUrl);
changesetCreator.setFullReplacement(fullReplacement);
- changesetCreator.setLenientBounds(lenientBounds);
+ changesetCreator.setBoundsInterpretation(boundsHandling);
changesetCreator.setGeometryFilters(geometryFilters);
// chain param must be set before the filters themselves
changesetCreator.setChainReplacementFilters(chainReplacementFilters);
@@ -269,11 +269,33 @@ public:
changesetCreator.setCleaningEnabled(enableCleaning);
changesetCreator.setTagOobConnectedWays(tagOobConnectedWays);
changesetCreator.create(input1, input2, bounds, output);
+ }
- LOG_STATUS(
- "Changeset generated in " << StringUtils::millisecondsToDhms(timer.elapsed()) << " total.");
-
- return 0;
+ void processStatsParams(QStringList& args, bool& printStats, QString& outputStatsFile)
+ {
+ if (args.contains("--stats"))
+ {
+ printStats = true;
+ const int statsIndex = args.indexOf("--stats");
+ // See similar note in ChangesetDeriveCmd.
+ if (statsIndex != -1 && statsIndex != (args.size() - 1) &&
+ !args[statsIndex + 1].startsWith("--"))
+ {
+ outputStatsFile = args[statsIndex + 1];
+ QFileInfo statsInfo(outputStatsFile);
+ if (!ChangesetStatsFormat::isValidFileOutputFormat(statsInfo.completeSuffix()))
+ {
+ outputStatsFile = "";
+ }
+ else
+ {
+ args.removeAll(outputStatsFile);
+ }
+ }
+ args.removeAll("--stats");
+ }
+ LOG_VARD(printStats);
+ LOG_VARD(outputStatsFile);
}
void checkParameterCount(int count)