I am using tilemaker to create contour tiles. I process some DEM data and use gdal to create shp contours. Each contour line has an elevation attribute. I want to show different contour lines on different zoom levels to reduce the tile size, eg.:
zoom 11: 50 m intervals
zoom 12: 20 m intervals
zoom 13: 10 m intervals
zoom 14: 5 m intervals
Based on the documentation in the Shapefiles and GeoJSON section, this should be possible with a following attribute_function():
function attribute_function(attr, layer)
if attr["elevation"] then
local table = {}
local elevation = math.floor(attr["elevation"])
local minzoom = 14
if elevation % 50 == 0 then
minzoom = 11
elseif elevation % 20 == 0 then
minzoom = 12
elseif elevation % 10 == 0 then
minzoom = 13
end
table["elevation"] = elevation
table["_minzoom"] = minzoom
return table
end
return attr
end
Unfortunately, this doesn't work. It seems that the _minzoom isn't applied per feature. Instead, the last _minzoom that is set is applied for the whole layer.
Hi,
I am using tilemaker to create contour tiles. I process some DEM data and use gdal to create shp contours. Each contour line has an
elevation
attribute. I want to show different contour lines on different zoom levels to reduce the tile size, eg.:zoom 11: 50 m intervals zoom 12: 20 m intervals zoom 13: 10 m intervals zoom 14: 5 m intervals
Based on the documentation in the Shapefiles and GeoJSON section, this should be possible with a following
attribute_function()
:This is my
config.json
file for reference.Unfortunately, this doesn't work. It seems that the
_minzoom
isn't applied per feature. Instead, the last_minzoom
that is set is applied for the whole layer.The code handling
_minzoom
is here (for shapefiles): https://github.com/systemed/tilemaker/blob/13b841d58f3f1bc1be6e4e7f86860e3eabfd91cf/src/shp_processor.cpp#L72-L74Am I missing something here or is it not working as expected?
Thanks for any input, Patrik