v0.2.48..v0.2.49 changeset ImplicitTypeTaggingRulesCmd.cpp
Garret Voltz edited this page Oct 2, 2019
·
1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/cmd/ImplicitTypeTaggingRulesCmd.cpp b/hoot-core/src/main/cpp/hoot/core/cmd/ImplicitTypeTaggingRulesCmd.cpp
new file mode 100644
index 0000000..d27d6b6
--- /dev/null
+++ b/hoot-core/src/main/cpp/hoot/core/cmd/ImplicitTypeTaggingRulesCmd.cpp
@@ -0,0 +1,109 @@
+/*
+ * This file is part of Hootenanny.
+ *
+ * Hootenanny is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * --------------------------------------------------------------------
+ *
+ * The following copyright notices are generated automatically. If you
+ * have a new notice to add, please use the format:
+ * " * @copyright Copyright ..."
+ * This will properly maintain the copyright information. DigitalGlobe
+ * copyrights will be updated automatically.
+ *
+ * @copyright Copyright (C) 2017, 2018, 2019 DigitalGlobe (http://www.digitalglobe.com/)
+ */
+
+// Hoot
+#include <hoot/core/util/Factory.h>
+#include <hoot/core/cmd/BaseCommand.h>
+#include <hoot/core/schema/ImplicitTagRawRulesDeriver.h>
+#include <hoot/core/schema/ImplicitTagRulesDatabaseDeriver.h>
+#include <hoot/core/io/ImplicitTagRulesSqliteReader.h>
+
+namespace hoot
+{
+
+class ImplicitTypeTaggingRulesCmd : public BaseCommand
+{
+public:
+
+ static std::string className() { return "hoot::ImplicitTypeTaggingRulesCmd"; }
+
+ virtual QString getName() const override { return "type-tagger-rules"; }
+
+ virtual QString getDescription() const override
+ { return "Creates rules for adding missing type tags to a map"; }
+
+ virtual int runSimple(QStringList& args) override
+ {
+ if (args.contains("--create-raw"))
+ {
+ args.removeAt(args.indexOf("--create-raw"));
+ if (args.size() != 3)
+ {
+ std::cout << getHelp() << std::endl << std::endl;
+ throw HootException(
+ QString("%1 with the --create-raw option takes three parameters.").arg(getName()));
+ }
+
+ ImplicitTagRawRulesDeriver rawRulesDeriver;
+ rawRulesDeriver.setConfiguration(conf());
+ rawRulesDeriver.deriveRawRules(
+ args[0].trimmed().split(";"), args[1].trimmed().split(";"), args[2].trimmed());
+ }
+ else if (args.contains("--create-db"))
+ {
+ args.removeAt(args.indexOf("--create-db"));
+ if (args.size() != 2)
+ {
+ std::cout << getHelp() << std::endl << std::endl;
+ throw HootException(
+ QString("%1 with the --create-db option takes two parameters.").arg(getName()));
+ }
+
+ ImplicitTagRulesDatabaseDeriver rulesDatabaseDeriver;
+ rulesDatabaseDeriver.setConfiguration(conf());
+ rulesDatabaseDeriver.deriveRulesDatabase(args[0].trimmed(), args[1].trimmed());
+ }
+ else if (args.contains("--db-stats"))
+ {
+ args.removeAt(args.indexOf("--db-stats"));
+ if (args.size() != 1)
+ {
+ std::cout << getHelp() << std::endl << std::endl;
+ throw HootException(
+ QString("%1 with the --db-stats option takes one parameter.").arg(getName()));
+ }
+
+ ImplicitTagRulesSqliteReader dbReader;
+ dbReader.open(args[0].trimmed());
+ std::cout << dbReader.getStats();
+ dbReader.close();
+ }
+ else
+ {
+ LOG_WARN(
+ "Must supply one of the option parameters: --create-raw, --create-db, --db-stats");
+ std::cout << getHelp() << std::endl << std::endl;
+ return 1;
+ }
+
+ return 0;
+ }
+};
+
+HOOT_FACTORY_REGISTER(Command, ImplicitTypeTaggingRulesCmd)
+
+}