Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/osm_lua_processing.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <iostream>
#include <unordered_set>

#include "osm_lua_processing.h"
#include "attribute_store.h"
Expand All @@ -17,7 +18,7 @@ const std::string EMPTY_STRING = "";
thread_local kaguya::State *g_luaState = nullptr;
thread_local OsmLuaProcessing* osmLuaProcessing = nullptr;

std::mutex vectorLayerMetadataMutex;
std::deque<std::mutex> vectorLayerMetadataMutexes;
std::unordered_map<std::string, std::string> OsmLuaProcessing::dataStore;
std::mutex OsmLuaProcessing::dataStoreMutex;

Expand Down Expand Up @@ -241,6 +242,9 @@ OsmLuaProcessing::OsmLuaProcessing(
materializeGeometries(materializeGeometries) {

sigusr1Handler.initialize();
if (vectorLayerMetadataMutexes.size() <= layers.layers.size()) {
vectorLayerMetadataMutexes.resize(layers.layers.size() + 1);
}

// ---- Initialise Lua
g_luaState = &luaState;
Expand Down Expand Up @@ -1031,9 +1035,14 @@ std::string OsmLuaProcessing::FindInRelation(const std::string &key) {
}

// Record attribute name/type for vector_layers table
thread_local std::vector<std::unordered_set<std::string>> alreadySeen;

void OsmLuaProcessing::setVectorLayerMetadata(const uint_least8_t layer, const string &key, const uint type) {
std::lock_guard<std::mutex> lock(vectorLayerMetadataMutex);
if (alreadySeen.size() <= layer) alreadySeen.resize(layer + 1);
if (alreadySeen[layer].count(key)) return;
std::lock_guard<std::mutex> lock(vectorLayerMetadataMutexes[layer]);
layers.layers[layer].attributeMap[key] = type;
alreadySeen[layer].insert(key);
}

// Scan relation (but don't write geometry)
Expand Down
Loading