Skip to content

Commit 80f53f3

Browse files
authored
create function to get OSM type (#834)
1 parent aa00786 commit 80f53f3

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

docs/CONFIGURATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ To do that, you use these methods:
160160
* `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.
161161
* `AttributeNumeric(key,value,minzoom)`, `AttributeInteger(key,value,minzoom)`, `AttributeBoolean(key,value,minzoom)`: for numeric (floating-point), integer and boolean columns.
162162
* `Id()`: get the OSM ID of the current object.
163+
* `OsmType()`: get the OSM type of the current object.
163164
* `IsClosed()`: returns true if the current object is a closed area.
164165
* `IsMultiPolygon()`: returns true if the current object is a multipolygon.
165166
* `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.)

include/osm_lua_processing.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ class OsmLuaProcessing {
115115
// Get the ID of the current object
116116
std::string Id() const;
117117

118+
// Get the Type of the current object
119+
std::string OsmType() const;
120+
118121
// Gets a table of all the keys of the OSM tags
119122
kaguya::LuaTable AllKeys(kaguya::State& luaState);
120123

src/osm_lua_processing.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ kaguya::LuaTable getAllTags(kaguya::State& luaState, const boost::container::fla
141141
}
142142

143143
std::string rawId() { return osmLuaProcessing->Id(); }
144+
std::string rawOsmType() { return osmLuaProcessing->OsmType(); }
144145
kaguya::LuaTable rawAllKeys() {
145146
if (osmLuaProcessing->isPostScanRelation) {
146147
return osmLuaProcessing->AllKeys(*g_luaState);
@@ -247,6 +248,7 @@ OsmLuaProcessing::OsmLuaProcessing(
247248

248249
osmLuaProcessing = this;
249250
luaState["Id"] = &rawId;
251+
luaState["OsmType"] = &rawOsmType;
250252
luaState["AllKeys"] = &rawAllKeys;
251253
luaState["AllTags"] = &rawAllTags;
252254
luaState["Holds"] = &rawHolds;
@@ -360,6 +362,11 @@ string OsmLuaProcessing::Id() const {
360362
return to_string(originalOsmID);
361363
}
362364

365+
// Get the Type of the current object
366+
string OsmLuaProcessing::OsmType() const {
367+
return (isRelation ? "relation" : isWay ? "way" : "node");
368+
}
369+
363370
// Gets a table of all the keys of the OSM tags
364371
kaguya::LuaTable OsmLuaProcessing::AllKeys(kaguya::State& luaState) {
365372
// NOTE: this is only called in the PostScanRelation phase -- other phases are handled in rawAllKeys

0 commit comments

Comments
 (0)