Skip to content

Commit

Permalink
Provide a more fleshed out example config
Browse files Browse the repository at this point in the history
  • Loading branch information
systemed committed Jan 11, 2024
1 parent 5313711 commit d749f76
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 28 deletions.
22 changes: 9 additions & 13 deletions resources/config-example.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
{
"layers": {
"waterway": { "minzoom": 11, "maxzoom": 14 },
"transportation": { "minzoom": 12, "maxzoom": 14, "simplify_below": 13, "simplify_level": 0.0001, "simplify_ratio": 2.0 },
"building": { "minzoom": 14, "maxzoom": 14 },
"poi": { "minzoom": 13, "maxzoom": 14 }
"place": { "minzoom": 0, "maxzoom": 14 },
"poi": { "minzoom": 12, "maxzoom": 14 },
"transportation": { "minzoom": 4, "maxzoom": 14, "simplify_below": 13, "simplify_level": 0.0003, "simplify_ratio": 2.0 },
"transportation_name": { "minzoom": 10, "maxzoom": 14 },
"building": { "minzoom": 13, "maxzoom": 14 },
"water": { "minzoom": 6, "maxzoom": 14, "simplify_below": 12, "simplify_level": 0.0003, "simplify_ratio": 2.0 },
"waterway": { "minzoom": 6, "maxzoom": 14, "simplify_below": 12, "simplify_level": 0.0003, "simplify_ratio": 2.0 }
},
"settings": {
"minzoom": 12,
"minzoom": 4,
"maxzoom": 14,
"basezoom": 14,
"include_ids": false,
"name": "Tilemaker example",
"version": "0.1",
"description": "Sample vector tiles for Tilemaker",
"compress": "gzip",
"metadata": {
"json": { "vector_layers": [
{ "id": "transportation", "description": "transportation", "fields": {"class":"String"}},
{ "id": "waterway", "description": "waterway", "fields": {"class":"String"}},
{ "id": "building", "description": "building", "fields": {}}
] }
}
"compress": "gzip"
}
}
89 changes: 74 additions & 15 deletions resources/process-example.lua
Original file line number Diff line number Diff line change
@@ -1,45 +1,104 @@
-- Nodes will only be processed if one of these keys is present
--[[
node_keys = { "amenity", "shop" }
A simple example tilemaker configuration, intended to illustrate how it
works and to act as a starting point for your own configurations.
-- Initialize Lua logic
The basic principle is:
- read OSM tags with Find(key)
- write to vector tile layers with Layer(layer_name)
- add attributes with Attribute(field, value)
function init_function()
end
(This is a very basic subset of the OpenMapTiles schema. Don't take much
notice of the "class" attribute, that's an OMT implementation thing which
is just here to get them to show up with the default style.)
It doesn't do much filtering by zoom level - all the roads appear all the
time. If you want a practice project, try fixing that!
You can view your output with tilemaker-server:
tilemaker-server /path/to/your.mbtiles --static server/static
]]--


-- Nodes will only be processed if one of these keys is present

node_keys = { "amenity", "historic", "leisure", "place", "shop", "tourism" }

-- Finalize Lua logic()
function exit_function()
end

-- Assign nodes to a layer, and set attributes, based on OSM tags

function node_function(node)
-- POIs go to a "poi" layer (we just look for amenity and shop here)
local amenity = Find("amenity")
local shop = Find("shop")
if amenity~="" or shop~="" then
Layer("poi", false)
Layer("poi")
if amenity~="" then Attribute("class",amenity)
else Attribute("class",shop) end
Attribute("name", Find("name"))
Attribute("name:latin", Find("name"))
AttributeNumeric("rank", 3)
end

-- Places go to a "place" layer
local place = Find("place")
if place~="" then
Layer("place")
Attribute("class", place)
Attribute("name:latin", Find("name"))
if place=="city" then
AttributeNumeric("rank", 4)
MinZoom(3)
elseif place=="town" then
AttributeNumeric("rank", 6)
MinZoom(6)
else
AttributeNumeric("rank", 9)
MinZoom(10)
end
end
end

-- Similarly for ways

-- Assign ways to a layer, and set attributes, based on OSM tags

function way_function()
local highway = Find("highway")
local highway = Find("highway")
local waterway = Find("waterway")
local building = Find("building")

-- Roads
if highway~="" then
Layer("transportation", false)
if highway=="unclassified" or highway=="residential" then highway="minor" end
Attribute("class", highway)
-- Attribute("id",Id())
-- AttributeNumeric("area",37)
-- ...and road names
local name = Find("name")
if name~="" then
Layer("transportation_name", false)
Attribute("class", highway)
Attribute("name:latin", name)
end
end
if waterway~="" then

-- Rivers
if waterway=="stream" or waterway=="river" or waterway=="canal" then
Layer("waterway", false)
Attribute("class", waterway)
AttributeNumeric("intermittent", 0)
end

-- Lakes and other water polygons
if Find("natural")=="water" then
Layer("water", true)
if Find("water")=="river" then
Attribute("class", "river")
else
Attribute("class", "lake")
end
end
-- Buildings
if building~="" then
Layer("building", true)
end
Expand Down

0 comments on commit d749f76

Please sign in to comment.