Skip to content

v0.2.55..v0.2.56 changeset ChangesetDeriver.cpp

Garret Voltz edited this page Aug 14, 2020 · 3 revisions
diff --git a/hoot-core/src/main/cpp/hoot/core/algorithms/changeset/ChangesetDeriver.cpp b/hoot-core/src/main/cpp/hoot/core/algorithms/changeset/ChangesetDeriver.cpp
index 3905a07..80d35b1 100644
--- a/hoot-core/src/main/cpp/hoot/core/algorithms/changeset/ChangesetDeriver.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/algorithms/changeset/ChangesetDeriver.cpp
@@ -40,7 +40,8 @@ _from(from),
 _to(to),
 _numFromElementsParsed(0),
 _numToElementsParsed(0),
-_allowDeletingReferenceFeatures(ConfigOptions().getChangesetAllowDeletingReferenceFeatures())
+_allowDeletingReferenceFeatures(ConfigOptions().getChangesetAllowDeletingReferenceFeatures()),
+_metadataAllowKeys(ConfigOptions().getChangesetMetadataAllowedTagKeys())
 {
   LOG_VART(_from.get());
   LOG_VART(_to.get());
@@ -88,7 +89,7 @@ bool ChangesetDeriver::hasMoreChanges()
 
 Change ChangesetDeriver::_nextChange()
 {
-  // TODO: this method is a bit of mess now...refactor into smaller chunks
+  // TODO: this method is a bit of a mess now...refactor into smaller chunks
 
   LOG_TRACE("Reading next change...");
 
@@ -202,7 +203,12 @@ Change ChangesetDeriver::_nextChange()
   {
     // while the elements are exactly the same, there is nothing to do.
     while (_fromE.get() && _toE.get() && _fromE->getElementId() == _toE->getElementId() &&
-           _elementComparer.isSame(_fromE, _toE))
+           _elementComparer.isSame(_fromE, _toE) &&
+           // ElementComparer always ignores metadata tags during comparison. So, if there is a
+           // specific metadata tag in the target element that isn't in the original element and we
+           // want to allow in the changeset output, this allows that to happen.
+           !(!_fromE->getTags().hasAnyKey(_metadataAllowKeys) &&
+             _toE->getTags().hasAnyKey(_metadataAllowKeys)))
     {
       LOG_TRACE(
         "skipping identical elements - 'from' element: " << _fromE->getElementId() <<
Clone this wiki locally