Skip to content

Commit

Permalink
Tag kv as structured binding
Browse files Browse the repository at this point in the history
  • Loading branch information
mmd-osm committed Jul 6, 2024
1 parent ec6bfb8 commit 95a6e9f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
13 changes: 6 additions & 7 deletions src/backend/apidb/changeset_upload/changeset_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ void ApiDB_Changeset_Updater::changeset_insert_tags (
if (tags.empty())
return;


m.prepare (
"changeset_insert_tags",
R"(
Expand All @@ -299,13 +298,13 @@ void ApiDB_Changeset_Updater::changeset_insert_tags (
std::vector<std::string> vs;
unsigned total_tags = 0;

for (const auto& tag : tags)
{
cs.emplace_back (changeset);
ks.emplace_back (escape (tag.first));
vs.emplace_back (escape (tag.second));
for (const auto& [key, value] : tags)
{
cs.emplace_back(changeset);
ks.emplace_back(escape(key));
vs.emplace_back(escape(value));
++total_tags;
}
}

pqxx::result r = m.exec_prepared ("changeset_insert_tags", cs, ks, vs);

Expand Down
8 changes: 4 additions & 4 deletions src/backend/apidb/changeset_upload/node_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ void ApiDB_Node_Updater::add_node(double lat, double lon,
new_node.tile = xy2tile(lon2x(lon), lat2y(lat));
new_node.changeset_id = changeset_id;
new_node.old_id = old_id;
for (const auto &tag : tags)
new_node.tags.emplace_back(tag.first, tag.second);
for (const auto &[key, value] : tags)
new_node.tags.emplace_back(key, value);
create_nodes.push_back(new_node);

ct.osmchange_orig_sequence.push_back({ operation::op_create,
Expand All @@ -74,8 +74,8 @@ void ApiDB_Node_Updater::modify_node(double lat, double lon,
modify_node.lon = round(lon * global_settings::get_scale());
modify_node.tile = xy2tile(lon2x(lon), lat2y(lat));
modify_node.changeset_id = changeset_id;
for (const auto &tag : tags)
modify_node.tags.emplace_back(std::make_pair(tag.first, tag.second));
for (const auto &[key, value] : tags)
modify_node.tags.emplace_back(key, value);
modify_nodes.push_back(modify_node);

ct.osmchange_orig_sequence.push_back({ operation::op_modify,
Expand Down
8 changes: 4 additions & 4 deletions src/backend/apidb/changeset_upload/relation_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ void ApiDB_Relation_Updater::add_relation(osm_changeset_id_t changeset_id,
new_relation.changeset_id = changeset_id;
new_relation.old_id = old_id;

for (const auto &tag : tags)
new_relation.tags.emplace_back(tag.first, tag.second);
for (const auto &[key, value] : tags)
new_relation.tags.emplace_back(key, value);

osm_sequence_id_t member_seq = 0;
for (const auto &member : members) {
Expand Down Expand Up @@ -80,8 +80,8 @@ void ApiDB_Relation_Updater::modify_relation(osm_changeset_id_t changeset_id,
modify_relation.version = version;
modify_relation.changeset_id = changeset_id;

for (const auto &tag : tags)
modify_relation.tags.emplace_back(tag.first, tag.second);
for (const auto &[key, value] : tags)
modify_relation.tags.emplace_back(key, value);

osm_sequence_id_t member_seq = 0;
for (const auto &member : members) {
Expand Down
8 changes: 4 additions & 4 deletions src/backend/apidb/changeset_upload/way_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ void ApiDB_Way_Updater::add_way(osm_changeset_id_t changeset_id,
new_way.changeset_id = changeset_id;
new_way.old_id = old_id;

for (const auto &tag : tags)
new_way.tags.emplace_back(tag.first, tag.second);
for (const auto &[key, value] : tags)
new_way.tags.emplace_back(key, value);

// If the following conditions are still not met, although our XML parser
// raised an exception for it, it's clearly a programming error.
Expand Down Expand Up @@ -79,8 +79,8 @@ void ApiDB_Way_Updater::modify_way(osm_changeset_id_t changeset_id,
modify_way.version = version;
modify_way.changeset_id = changeset_id;

for (const auto &tag : tags)
modify_way.tags.emplace_back(tag.first, tag.second);
for (const auto &[key, value] : tags)
modify_way.tags.emplace_back(key, value);

// If the following conditions are still not met, although our XML parser
// raised an exception for it, it's clearly a programming error.
Expand Down

0 comments on commit 95a6e9f

Please sign in to comment.