Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ Note that this is not compatible with the `combine_xxx` settings to reduce tiles

If you need to include OSM object types as well, you can use the `OsmType()` function in your `process.lua` script.

It is possible to override the original OSM ID using the function `ModifyId(newId)`.

## Lua processing reference

Your Lua file can supply these functions for tilemaker to call:
Expand Down Expand Up @@ -163,6 +165,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)`, `AttributeInteger(key,value,minzoom)`, `AttributeBoolean(key,value,minzoom)`: for numeric (floating-point), integer and boolean columns.
* `Id()`: get the OSM ID of the current object.
* `ModifyId(newId)`: replace the ID of the current object with newId.
* `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.
Expand Down
1 change: 1 addition & 0 deletions include/osm_lua_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class OsmLuaProcessing {
void LayerAsCentroid(const std::string &layerName, kaguya::VariadicArgType nodeSources);

// Set attributes in a vector tile's Attributes table
void ModifyId(const int newId);
void Attribute(const std::string &key, const protozero::data_view val, const char minzoom);
void AttributeNumeric(const std::string &key, const double val, const char minzoom);
void AttributeBoolean(const std::string &key, const bool val, const char minzoom);
Expand Down
7 changes: 7 additions & 0 deletions src/osm_lua_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ bool rawIsMultiPolygon() { return osmLuaProcessing->IsMultiPolygon(); }
double rawArea() { return osmLuaProcessing->Area(); }
double rawLength() { return osmLuaProcessing->Length(); }
kaguya::optional<std::vector<double>> rawCentroid(kaguya::VariadicArgType algorithm) { return osmLuaProcessing->Centroid(algorithm); }
void rawModifyId(const int newId) { return osmLuaProcessing->ModifyId(newId); }
void rawLayer(const std::string& layerName, bool area) { return osmLuaProcessing->Layer(layerName, area); }
void rawLayerAsCentroid(const std::string &layerName, kaguya::VariadicArgType nodeSources) { return osmLuaProcessing->LayerAsCentroid(layerName, nodeSources); }
void rawMinZoom(const double z) { return osmLuaProcessing->MinZoom(z); }
Expand Down Expand Up @@ -267,6 +268,7 @@ OsmLuaProcessing::OsmLuaProcessing(
luaState["Centroid"] = &rawCentroid;
luaState["Layer"] = &rawLayer;
luaState["LayerAsCentroid"] = &rawLayerAsCentroid;
luaState["ModifyId"] = &rawModifyId;
luaState["Attribute"] = kaguya::overload(
[](const std::string &key, const protozero::data_view val) { osmLuaProcessing->Attribute(key, val, 0); },
[](const std::string &key, const protozero::data_view val, const char minzoom) { osmLuaProcessing->Attribute(key, val, minzoom); }
Expand Down Expand Up @@ -922,6 +924,11 @@ void OsmLuaProcessing::removeAttributeIfNeeded(const string& key) {
outputKeys.push_back(key);
}

// Force a new ID
void OsmLuaProcessing::ModifyId(const int newId) {
originalOsmID = static_cast<int64_t>(newId);
}

// Set attributes in a vector tile's Attributes table
void OsmLuaProcessing::Attribute(const string &key, const protozero::data_view val, const char minzoom) {
if (outputs.size()==0) { ProcessingError("Can't add Attribute if no Layer set"); return; }
Expand Down
Loading