Skip to content

Commit

Permalink
refactor: Update Converter class to use atomic for g_osm_id
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Jäger committed Aug 2, 2024
1 parent ed52629 commit bd79c34
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/navteq/converter/Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <osmium/osm/types.hpp>
#include <unicode/unistr.h>

osmium::unsigned_object_id_type Converter::g_osm_id = 1;
std::atomic<osmium::unsigned_object_id_type> Converter::g_osm_id = 0;

std::map<std::string, std::string> Converter::lang_code_map;

Expand Down
5 changes: 3 additions & 2 deletions plugins/navteq/converter/Converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef CONVERTER_HPP
#define CONVERTER_HPP

#include <atomic>
#include <filesystem>
#include <map>
#include <ogrsf_frmts.h>
Expand Down Expand Up @@ -122,7 +123,7 @@ class Converter {
osmium::builder::NodeBuilder &builder);

template <typename T> void setObjectProperties(T &builder) {
builder.object().set_id(g_osm_id++);
builder.object().set_id(++g_osm_id);
set_dummy_osm_object_attributes(builder.object());
builder.set_user(USER.data());
}
Expand Down Expand Up @@ -174,7 +175,7 @@ class Converter {
static constexpr std::string_view YES = "yes";
static constexpr std::string_view NO = "no";

static osmium::unsigned_object_id_type g_osm_id;
static std::atomic<osmium::unsigned_object_id_type> g_osm_id;

static constexpr std::string_view FEAT_COD = "FEAT_COD";
static constexpr std::string_view POLYGON_NM = "POLYGON_NM";
Expand Down

0 comments on commit bd79c34

Please sign in to comment.