diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 8533183b..dd84a88d 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -151,6 +151,7 @@ To do that, you use these methods: * `Attribute(key,value,minzoom)`: add an attribute to the most recently written layer. Argument `minzoom` is optional, use it if you do not want to write the attribute on lower zoom levels. * `AttributeNumeric(key,value,minzoom)`, `AttributeBoolean(key,value,minzoom)`: for numeric/boolean columns. * `Id()`: get the OSM ID of the current object. +* `OsmType()`: get the OSM type of the current object. * `IsClosed()`: returns true if the current object is a closed area. * `IsMultiPolygon()`: returns true if the current object is a multipolygon. * `ZOrder(number)`: Set a numeric value (default 0) used to sort features within a layer. Use this feature to ensure a proper rendering order if the rendering engine itself does not support sorting. Sorting is not supported across layers merged with `write_to`. Features with different z-order are not merged if `combine_below` or `combine_polygons_below` is used. Use this in conjunction with `feature_limit` to only write the most important (highest z-order) features within a tile. (Values can be -50,000,000 to 50,000,000 and are lossy, particularly beyond -1000 to 1000.) diff --git a/include/osm_lua_processing.h b/include/osm_lua_processing.h index 72100635..0218a7de 100644 --- a/include/osm_lua_processing.h +++ b/include/osm_lua_processing.h @@ -115,6 +115,9 @@ class OsmLuaProcessing { // Get the ID of the current object std::string Id() const; + // Get the Type of the current object + std::string OsmType() const; + // Gets a table of all the keys of the OSM tags kaguya::LuaTable AllKeys(kaguya::State& luaState); diff --git a/src/osm_lua_processing.cpp b/src/osm_lua_processing.cpp index cba5948c..77490586 100644 --- a/src/osm_lua_processing.cpp +++ b/src/osm_lua_processing.cpp @@ -141,6 +141,7 @@ kaguya::LuaTable getAllTags(kaguya::State& luaState, const boost::container::fla } std::string rawId() { return osmLuaProcessing->Id(); } +std::string rawOsmType() { return osmLuaProcessing->OsmType(); } kaguya::LuaTable rawAllKeys() { if (osmLuaProcessing->isPostScanRelation) { return osmLuaProcessing->AllKeys(*g_luaState); @@ -247,6 +248,7 @@ OsmLuaProcessing::OsmLuaProcessing( osmLuaProcessing = this; luaState["Id"] = &rawId; + luaState["OsmType"] = &rawOsmType; luaState["AllKeys"] = &rawAllKeys; luaState["AllTags"] = &rawAllTags; luaState["Holds"] = &rawHolds; @@ -356,6 +358,11 @@ string OsmLuaProcessing::Id() const { return to_string(originalOsmID); } +// Get the Type of the current object +string OsmLuaProcessing::OsmType() const { + return (isRelation ? "relation" : isWay ? "way" : "node"); +} + // Gets a table of all the keys of the OSM tags kaguya::LuaTable OsmLuaProcessing::AllKeys(kaguya::State& luaState) { // NOTE: this is only called in the PostScanRelation phase -- other phases are handled in rawAllKeys