diff --git a/hoot-core/src/main/cpp/hoot/core/conflate/polygon/BuildingMerger.cpp b/hoot-core/src/main/cpp/hoot/core/conflate/polygon/BuildingMerger.cpp
index c0932a4..10b3058 100644
--- a/hoot-core/src/main/cpp/hoot/core/conflate/polygon/BuildingMerger.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/conflate/polygon/BuildingMerger.cpp
@@ -35,6 +35,8 @@
#include <hoot/core/criterion/ElementTypeCriterion.h>
#include <hoot/core/elements/InMemoryElementSorter.h>
#include <hoot/core/elements/OsmUtils.h>
+#include <hoot/core/elements/ElementIdUtils.h>
+#include <hoot/core/elements/TagUtils.h>
#include <hoot/core/elements/Relation.h>
#include <hoot/core/io/OsmMapWriterFactory.h>
#include <hoot/core/ops/IdSwapOp.h>
@@ -246,6 +248,9 @@ void BuildingMerger::apply(const OsmMapPtr& map, vector<pair<ElementId, ElementI
ReuseNodeIdsOnWayOp(scrap->getElementId(), keeper->getElementId()).apply(map);
// Replace the scrap with the keeper in any parents
ReplaceElementOp(scrap->getElementId(), keeper->getElementId()).apply(map);
+ // Favor the positive ID over the negative ID
+ if (keeper->getId() < 0 && scrap->getId() > 0)
+ preserveBuildingId = true;
// Swap the IDs of the two elements if keeper isn't UNKNOWN1
if (preserveBuildingId)
{
@@ -581,12 +586,12 @@ RelationPtr BuildingMerger::combineConstituentBuildingsIntoRelation(
threeDBuildingKeys.append(MetadataTags::BuildingLevels());
threeDBuildingKeys.append(MetadataTags::BuildingHeight());
const bool allAreBuildingParts =
- OsmUtils::allElementsHaveAnyTagKey(threeDBuildingKeys, constituentBuildings);
+ TagUtils::allElementsHaveAnyTagKey(threeDBuildingKeys, constituentBuildings);
LOG_VART(allAreBuildingParts);
// Here, we're skipping a building relation and doing a multipoly if only some of the buildings
// have height tags. This behavior is debatable...
if (!allAreBuildingParts &&
- OsmUtils::anyElementsHaveAnyTagKey(threeDBuildingKeys, constituentBuildings))
+ TagUtils::anyElementsHaveAnyTagKey(threeDBuildingKeys, constituentBuildings))
{
if (logWarnCount < Log::getWarnMessageLimit())
{
@@ -595,7 +600,7 @@ RelationPtr BuildingMerger::combineConstituentBuildingsIntoRelation(
LOG_DEBUG(
"Merging building group where some buildings have 3D tags and others do not. A " <<
"multipolygon relation will be created instead of a building relation. Buildings: " <<
- OsmUtils::elementsToElementIds(constituentBuildings));
+ ElementIdUtils::elementsToElementIds(constituentBuildings));
}
else if (logWarnCount == Log::getWarnMessageLimit())
{
@@ -619,7 +624,7 @@ RelationPtr BuildingMerger::combineConstituentBuildingsIntoRelation(
TagMergerPtr tagMerger;
LOG_VART(preserveTypes);
- std::set<QString> overwriteExcludeTags;
+ QSet<QString> overwriteExcludeTags;
if (allAreBuildingParts)
{
// exclude building part type tags from the type tag preservation by passing them in to be