🎨 adding support for style.constants

pull/7/head
Michael Straßburger 2016-10-03 05:29:40 +02:00
rodzic afe7a53009
commit 89f4521251
1 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -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]