🔍 adding house numbers and custom label margin per layer

This commit is contained in:
Michael Straßburger 2016-09-27 23:45:26 +02:00
parent 6fbd676a2e
commit 64b03e3422
3 changed files with 12 additions and 4 deletions

View File

@ -21,18 +21,18 @@ module.exports = class LabelBuffer
project: (x, y) ->
[Math.floor(x/2), Math.floor(y/4)]
writeIfPossible: (text, x, y) ->
writeIfPossible: (text, x, y, margin = @margin) ->
point = @project x, y
if @_hasSpace text, point[0], point[1]
@tree.insert @_calculateArea text, point[0], point[1]
@tree.insert @_calculateArea text, point[0], point[1], margin
else
false
_hasSpace: (text, x, y) ->
not @tree.collides @_calculateArea text, x, y, 0
_calculateArea: (text, x, y, margin = @margin) ->
_calculateArea: (text, x, y, margin) ->
minX: x-margin
minY: y-margin
maxX: x+margin+text.length

View File

@ -66,7 +66,7 @@ module.exports = class Termap
_resizeRenderer: (cb) ->
@width = (process.stdout.columns-1) >> 1 << 2
@height = process.stdout.rows >> 2 << 4
@height = process.stdout.rows * 4 - 8
@renderer.setSize @width, @height

View File

@ -1150,6 +1150,14 @@
}
}
},
{
"type": "symbol",
"id": "housenum_label",
"paint": {
"text-color": "#333"
},
"source-layer": "housenum_label"
},
{
"type": "symbol",
"id": "place_label_other",