-
Notifications
You must be signed in to change notification settings - Fork 74
v0.2.52..v0.2.53 changeset Match.cpp
Garret Voltz edited this page Feb 12, 2020
·
1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/conflate/matching/Match.cpp b/hoot-core/src/main/cpp/hoot/core/conflate/matching/Match.cpp
index 6aa56d9..09fa5f8 100644
--- a/hoot-core/src/main/cpp/hoot/core/conflate/matching/Match.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/conflate/matching/Match.cpp
@@ -22,7 +22,7 @@
* This will properly maintain the copyright information. DigitalGlobe
* copyrights will be updated automatically.
*
- * @copyright Copyright (C) 2015, 2017, 2018, 2019 DigitalGlobe (http://www.digitalglobe.com/)
+ * @copyright Copyright (C) 2015, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
*/
#include "Match.h"
@@ -31,6 +31,7 @@
#include <hoot/core/conflate/matching/MatchThreshold.h>
#include <hoot/core/conflate/matching/MatchType.h>
#include <hoot/core/elements/ElementId.h>
+#include <hoot/core/util/CollectionUtils.h>
namespace hoot
{
@@ -55,4 +56,37 @@ MatchType Match::getType() const
return _threshold->getType(*this);
}
+bool Match::operator==(const Match& other) const
+{
+ if (getType() != other.getType())
+ {
+ return false;
+ }
+
+ const std::set<std::pair<ElementId, ElementId>> matchPairs = getMatchPairs();
+ const std::set<std::pair<ElementId, ElementId>> otherMatchPairs = other.getMatchPairs();
+
+ if (matchPairs.size() != otherMatchPairs.size())
+ {
+ return false;
+ }
+
+ const QList<std::pair<ElementId, ElementId>> matchListQ =
+ CollectionUtils::stdSetToQSet(matchPairs).toList();
+ const QList<std::pair<ElementId, ElementId>> otherMatchListQ =
+ CollectionUtils::stdSetToQSet(otherMatchPairs).toList();
+ for (int i = 0; i < matchListQ.size(); i++)
+ {
+ const std::pair<ElementId, ElementId> matchPair = matchListQ.at(i);
+ const std::pair<ElementId, ElementId> otherMatchPair = otherMatchListQ.at(i);
+ // requiring order matches here as well...is that correct?
+ if (matchPair.first != otherMatchPair.first || matchPair.second != otherMatchPair.second)
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
}