mirror of
https://github.com/rastapasta/mapscii.git
synced 2025-03-27 13:56:02 +01:00
🎨 adding support for style.constants
This commit is contained in:
parent
afe7a53009
commit
89f4521251
@ -19,6 +19,8 @@ module.exports = class Styler
|
||||
json = JSON.parse fs.readFileSync(file).toString()
|
||||
@styleName = json.name
|
||||
|
||||
@_replaceConstants json.constants, json.layers if json.constants
|
||||
|
||||
for style in json.layers
|
||||
continue if style.ref
|
||||
|
||||
@ -37,7 +39,19 @@ module.exports = class Styler
|
||||
if style.appliesTo(feature) and ((layer is "road") or (not style.minzoom) or style.minzoom <= zoom)
|
||||
return style
|
||||
|
||||
false
|
||||
return false
|
||||
|
||||
_replaceConstants: (constants, tree) ->
|
||||
for id, node of tree
|
||||
switch typeof node
|
||||
when 'object'
|
||||
continue if node.constructor.name.match /Stream/
|
||||
@_replaceConstants constants, node
|
||||
|
||||
when 'string'
|
||||
if node.charAt(0) is '@'
|
||||
tree[id] = constants[node]
|
||||
null
|
||||
|
||||
_compileFilter: (filter) ->
|
||||
switch filter?[0]
|
||||
|
Loading…
Reference in New Issue
Block a user