[generator] Add logic to replace OSM tag 'name' with 'name:full' for highway elements when 'name' and 'name:prefix' match with 'name:full'

Signed-off-by: daxgar <daxgar@noreply.codeberg.org>
This commit is contained in:
daxgar
2026-01-15 18:17:49 -07:00
committed by x7z4w
parent 9cd7b49f08
commit 2cd5a0a9df
5 changed files with 128 additions and 0 deletions

View File

@@ -52,6 +52,36 @@ void OsmElement::AddTag(std::string_view key, std::string_view value)
return;
m_tags.emplace_back(key, value);
// Determine if all of these keys are set,
// without having to repeatedly look them up in the tags list
if (key == "name")
m_setKeys |= NAME;
else if (key == "name:prefix")
m_setKeys |= NAME_PREFIX;
else if (key == "name:full")
m_setKeys |= NAME_FULL;
else if (key == "highway")
m_setKeys |= HIGHWAY;
else
return; // Only run the following code if one of the above keys was added
// If a highway has a name, a full name, and a name prefix,
// and the full name is equal to the name prefix joined with a space before the name,
// then replace the name with the full name
// See https://codeberg.org/comaps/comaps/issues/3193
if (m_setKeys & NAME && m_setKeys & NAME_PREFIX && m_setKeys & NAME_FULL && m_setKeys & HIGHWAY)
{
std::string name = GetTag("name");
std::string namePrefix = GetTag("name:prefix");
std::string nameFull = GetTag("name:full");
if ((namePrefix + " " + name) == nameFull)
UpdateTag("name", nameFull);
else
LOG(LDEBUG, ("Highway name tags don't match. name:prefix:", namePrefix, "name:", name, "name:full:", nameFull,
"in OSM Element:", m_id));
}
}
bool OsmElement::HasTag(std::string_view const & key) const