Skip to content

v0.2.47..v0.2.48 changeset ConflateCommand.java

Garret Voltz edited this page Sep 27, 2019 · 1 revision
diff --git a/hoot-services/src/main/java/hoot/services/controllers/conflation/ConflateCommand.java b/hoot-services/src/main/java/hoot/services/controllers/conflation/ConflateCommand.java
index 6ac3a16..24b3249 100644
--- a/hoot-services/src/main/java/hoot/services/controllers/conflation/ConflateCommand.java
+++ b/hoot-services/src/main/java/hoot/services/controllers/conflation/ConflateCommand.java
@@ -57,14 +57,7 @@ class ConflateCommand extends ExternalCommand {
 
     private final ConflateParams conflateParams;
 
-    private static List<String> conflationTypes = Arrays.asList(
-        "HorizontalConflation",
-        "AttributeConflation",
-        "ReferenceConflation",
-        "DifferentialConflation"
-    );
-
-    private static final List<String> conflationAlgorithms = Arrays.asList("NetworkAlgorithm");
+    private static final List<String> conflationAlgorithms = Arrays.asList("Network");
 
     private String conflationType = null;
     private String conflationAlgorithm = null;
@@ -182,19 +175,21 @@ class ConflateCommand extends ExternalCommand {
             });
         }
 
+        //Attribute Reference Layer is not default
+        if ("2".equals(params.getReferenceLayer())) {
+            options.add("tag.merger.default=hoot::OverwriteTag1Merger");
+        }
+
         if (params.getHoot2() != null) { // hoot 2
             conflationType = params.getConflationType();
-            conflationType = conflationType == null ? "" : conflationType + "Conflation";
             conflationAlgorithm = params.getConflateAlgorithm();
-            conflationAlgorithm = conflationAlgorithm == null ? "" : conflationAlgorithm + "Algorithm";
-
             List<String> disabledFeatures = params.getDisabledFeatures();
 
             if (disabledFeatures != null && !disabledFeatures.isEmpty()) {
                 List<String> matchers = new ArrayList<>();
                 List<String> mergers = new ArrayList<>();
 
-                String roadType = conflationAlgorithm.equals("NetworkAlgorithm") ? "Roads" : "RoadsNetwork";
+                String roadType = "Network".equals(conflationAlgorithm) ? "Roads" : "RoadsNetwork";
                 for (String feature: conflationFeatures.keySet()) {
                     // ignore the road matcher/mergers not relevant conflation type/algorithm confs...
                     if (feature.equals(roadType)) continue;
@@ -236,6 +231,8 @@ class ConflateCommand extends ExternalCommand {
 
         substitutionMap.put("CONFLATION_COMMAND", conflationCommand);
         substitutionMap.put("DEBUG_LEVEL", debugLevel);
+        substitutionMap.put("CONFLATION_TYPE", "");
+        substitutionMap.put("CONFLATION_ALGORITHM", "");
         substitutionMap.put("HOOT_OPTIONS", toHootOptions(options));
         substitutionMap.put("INPUT1", input1);
         substitutionMap.put("INPUT2", input2);
@@ -247,24 +244,39 @@ class ConflateCommand extends ExternalCommand {
         String command = null;
         if (params.getHoot2() == null) { // hoot1
             command = "hoot ${CONFLATION_COMMAND} --${DEBUG_LEVEL} ${HOOT_OPTIONS} ${INPUT1} ${INPUT2} ${OUTPUT} ${DIFFERENTIAL} ${DIFF_TAGS} ${STATS}";
-        } else if (conflationType.isEmpty()) {
-            if (conflationAlgorithms.stream().noneMatch(a -> a.equals(conflationAlgorithm))) {
-                throw new IllegalArgumentException(String.format("Conflation Algorithm \"%s\" is not valid.", conflationAlgorithm));
+        } else {
+
+            if (conflationType != null) {
+                if (AdvancedConflationOptionsResource.getConflationTypes().stream().noneMatch(t -> t.equals(conflationType))) {
+                    throw new IllegalArgumentException(String.format("Conflation Type \"%s\" is not valid.", conflationType));
+                }
+                //Differential w/Tags maps to Differential
+                if (conflationType.equals("Differential w/Tags")) {
+                    conflationType = "Differential";
+                }
+
+                //Network maps to a conflation algorithm
+                if (conflationType.equals("Network")) {
+                    if (conflationAlgorithm == null)
+                        conflationAlgorithm = "Network";
+                    conflationType = null;
+
+                } else {
+                    substitutionMap.put("CONFLATION_TYPE", conflationType + "Conflation.conf");
+                }
             }
 
-            substitutionMap.put("CONFLATION_ALGORITHM", conflationAlgorithm + ".conf");
-            command = "hoot ${CONFLATION_COMMAND} --${DEBUG_LEVEL} -C ${CONFLATION_ALGORITHM} ${HOOT_OPTIONS} ${INPUT1} ${INPUT2} ${OUTPUT} ${DIFFERENTIAL} ${DIFF_TAGS} ${STATS}";
-        } else if (conflationAlgorithm.isEmpty()) {
-            if (conflationTypes.stream().noneMatch(t -> t.equals(conflationType))) {
-                throw new IllegalArgumentException(String.format("Conflation Type \"%s\" is not valid.", conflationType));
+            if (conflationAlgorithm != null) {
+                if (conflationAlgorithms.stream().noneMatch(a -> a.equals(conflationAlgorithm))) {
+                    throw new IllegalArgumentException(String.format("Conflation Algorithm \"%s\" is not valid.", conflationAlgorithm));
+                }
+                substitutionMap.put("CONFLATION_ALGORITHM", conflationAlgorithm + "Algorithm.conf");
             }
 
-            substitutionMap.put("CONFLATION_TYPE", conflationType + ".conf");
-            command = "hoot ${CONFLATION_COMMAND} --${DEBUG_LEVEL} -C ${CONFLATION_TYPE} ${HOOT_OPTIONS} ${INPUT1} ${INPUT2} ${OUTPUT} ${DIFFERENTIAL} ${DIFF_TAGS} ${STATS}";
-        } else {
-            substitutionMap.put("CONFLATION_TYPE", conflationType + ".conf");
-              substitutionMap.put("CONFLATION_ALGORITHM", conflationAlgorithm + ".conf");
-            command = "hoot ${CONFLATION_COMMAND} --${DEBUG_LEVEL} -C ${CONFLATION_TYPE} -C ${CONFLATION_ALGORITHM} ${HOOT_OPTIONS} ${INPUT1} ${INPUT2} ${OUTPUT} ${DIFFERENTIAL} ${DIFF_TAGS} ${STATS}";
+            command = "hoot ${CONFLATION_COMMAND} --${DEBUG_LEVEL}"
+                    + (conflationType != null ? " -C ${CONFLATION_TYPE}" : "")
+                    + (conflationAlgorithm != null ? " -C ${CONFLATION_ALGORITHM}" : "")
+                    + " ${HOOT_OPTIONS} ${INPUT1} ${INPUT2} ${OUTPUT} ${DIFFERENTIAL} ${DIFF_TAGS} ${STATS}";
         }
 
         super.configureCommand(command, substitutionMap, caller);
Clone this wiki locally