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():
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
This is my config.json file for reference.
{
"layers": {
"contour": { "minzoom": 11, "maxzoom": 14, "source": "contours/part1.shp", "source_columns": ["elevation"] },
"contour_2": { "minzoom": 11, "maxzoom": 14, "source": "contours/part2.shp", "source_columns": ["elevation"], "write_to": "contour" },
"contour_3": { "minzoom": 11, "maxzoom": 14, "source": "contours/part3.shp", "source_columns": ["elevation"], "write_to": "contour" }
},
"settings": {
"minzoom": 11,
"maxzoom": 14,
"basezoom": 14,
"include_ids": false,
"bounding_box": [-180, -85, 180, 85]
}
}
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):
|
if (key=="_minzoom") { minzoom=val; continue; } |
|
attributeStore.addAttribute(attributes, key, (float)val, 0); |
|
layer.attributeMap[key] = 1; |
Am I missing something here or is it not working as expected?
Thanks for any input,
Patrik
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
elevationattribute. 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.jsonfile for reference.{ "layers": { "contour": { "minzoom": 11, "maxzoom": 14, "source": "contours/part1.shp", "source_columns": ["elevation"] }, "contour_2": { "minzoom": 11, "maxzoom": 14, "source": "contours/part2.shp", "source_columns": ["elevation"], "write_to": "contour" }, "contour_3": { "minzoom": 11, "maxzoom": 14, "source": "contours/part3.shp", "source_columns": ["elevation"], "write_to": "contour" } }, "settings": { "minzoom": 11, "maxzoom": 14, "basezoom": 14, "include_ids": false, "bounding_box": [-180, -85, 180, 85] } }Unfortunately, this doesn't work. It seems that the
_minzoomisn't applied per feature. Instead, the last_minzoomthat is set is applied for the whole layer.The code handling
_minzoomis here (for shapefiles):tilemaker/src/shp_processor.cpp
Lines 72 to 74 in 13b841d
Am I missing something here or is it not working as expected?
Thanks for any input,
Patrik