Giter Club home page Giter Club logo

Comments (1)

oobayly avatar oobayly commented on September 12, 2024

I've create a patch for this, but my C++ isn't great, so while it does work, there are probably better methods. I'll leave this up here for any comments, and I can create a PR is desired.

diff --git a/include/osm_lua_processing.h b/include/osm_lua_processing.h
index f4d664d..ca7627a 100644
--- a/include/osm_lua_processing.h
+++ b/include/osm_lua_processing.h
@@ -111,6 +111,9 @@ public:
 	// Get the ID of the current object
 	std::string Id() const;
 
+	// Gets a table of all the OSM tags
+	kaguya::LuaTable AllTags(kaguya::State& luaState);
+
 	// Check if there's a value for a given key
 	bool Holds(const std::string& key) const;
 
diff --git a/src/osm_lua_processing.cpp b/src/osm_lua_processing.cpp
index 545b1f3..e2ea791 100644
--- a/src/osm_lua_processing.cpp
+++ b/src/osm_lua_processing.cpp
@@ -118,6 +118,20 @@ template<>  struct kaguya::lua_type_traits<protozero::data_view> {
 };
 
 std::string rawId() { return osmLuaProcessing->Id(); }
+kaguya::LuaTable rawAllTags() {
+	if (osmLuaProcessing->isPostScanRelation) {
+		return osmLuaProcessing->AllTags(*g_luaState);
+	}
+
+	auto tags = osmLuaProcessing->currentTags->exportToBoostMap();
+	kaguya::LuaTable tagsTable = g_luaState->newTable();
+
+	for (const auto& kv : tags) {
+		tagsTable[kv.first] = kv.second;
+	}
+
+	return tagsTable;
+}
 bool rawHolds(const KnownTagKey& key) {
 	if (osmLuaProcessing->isPostScanRelation) {
 		return osmLuaProcessing->Holds(key.stringValue);
@@ -196,6 +210,7 @@ OsmLuaProcessing::OsmLuaProcessing(
 
 	osmLuaProcessing = this;
 	luaState["Id"] = &rawId;
+	luaState["AllTags"] = &rawAllTags;
 	luaState["Holds"] = &rawHolds;
 	luaState["Find"] = &rawFind;
 	luaState["HasTags"] = &rawHasTags;
@@ -290,6 +305,16 @@ string OsmLuaProcessing::Id() const {
 	return to_string(originalOsmID);
 }
 
+// Gets a table of all the OSM tags
+kaguya::LuaTable OsmLuaProcessing::AllTags(kaguya::State& luaState) {
+	// NOTE: this is only called in the PostScanRelation phase -- other phases are handled in rawAllTags
+	kaguya::LuaTable tagsTable = luaState.newTable();
+	for (const auto& kv: *currentPostScanTags) {
+		tagsTable[kv.first] = kv.second;
+	}
+	return tagsTable;
+}
+
 // Check if there's a value for a given key
 bool OsmLuaProcessing::Holds(const string& key) const {
 	// NOTE: this is only called in the PostScanRelation phase -- other phases are handled in rawHolds

from tilemaker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.