Skip to content

v0.2.49..v0.2.50 changeset Node.cpp

Garret Voltz edited this page Nov 6, 2019 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/elements/Node.cpp b/hoot-core/src/main/cpp/hoot/core/elements/Node.cpp
index 9c7ecd8..dde5bb6 100644
--- a/hoot-core/src/main/cpp/hoot/core/elements/Node.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/elements/Node.cpp
@@ -127,4 +127,22 @@ void Node::visitRw(ElementProvider& map, ConstElementVisitor& filter)
   filter.visit(std::dynamic_pointer_cast<const Node>(map.getNode(getId())));
 }
 
+bool Node::coordsMatch(const Node& other) const
+{
+  const int comparisonSensitivity = ConfigOptions().getNodeComparisonCoordinateSensitivity();
+  const double x =
+    std::round(getX() * std::pow(10.0, comparisonSensitivity)) /
+    std::pow(10.0, comparisonSensitivity);
+  const double otherX =
+    std::round(other.getX() * std::pow(10.0, comparisonSensitivity)) /
+    std::pow(10.0, comparisonSensitivity);
+  const double y =
+    std::round(getY() * std::pow(10.0, comparisonSensitivity)) /
+    std::pow(10.0, comparisonSensitivity);
+  const double otherY =
+    std::round(other.getY() * std::pow(10.0, comparisonSensitivity)) /
+    std::pow(10.0, comparisonSensitivity);
+  return ((x - otherX) == 0.0) && ((y - otherY) == 0.0);
+}
+
 }
Clone this wiki locally