🎨 optimizing label/marker rendering

This commit is contained in:
Michael Straßburger 2016-09-29 01:24:00 +02:00
parent f493a48e34
commit bd83950eeb
5 changed files with 8 additions and 10 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules
bundle*
*.log
tmp

View File

@ -17,7 +17,7 @@ const Tile = require(__dirname+'/src/Tile')
termap = new Termap();
// TODO: abstracing this class, create loader class
data = fs.readFileSync(__dirname+"/tiles/world.pbf.gz");
data = fs.readFileSync(__dirname+"/tiles/regensburg.pbf.gz");
tile = new Tile(data);
termap.renderer.features = tile.layers
termap._draw();

View File

@ -40,7 +40,7 @@ module.exports = class Canvas
clear: ->
@buffer.clear()
text: (text, x, y, color, center = true) ->
text: (text, x, y, color, center = false) ->
position = @_project x, y
@buffer.writeText text, position[0], position[1], color, center

View File

@ -26,7 +26,6 @@ module.exports = class Renderer
"building"
"road"
"water_label"
"place_label"
"poi_label"
"housenum_label"
@ -147,7 +146,7 @@ module.exports = class Renderer
switch feature.type
when "LineString"
width = style.paint['line-width']?.base or 1
width = style.paint['line-width']?.base*1.4 or 1
@canvas.polyline points, colorCode, width for points in toDraw
when "Polygon"
@ -166,12 +165,10 @@ module.exports = class Renderer
x = point[0] - text.length
margin = @config.layers[layer]?.margin or @config.labelMargin
write = (text) => @canvas.text text, x, point[1], colorCode, false
if @labelBuffer.writeIfPossible text, x, point[1], margin
write text
else if @config.layers[layer]?.cluster and @labelBuffer.writeIfPossible "X", x, point[1], 3
write ""
@canvas.text text, x, point[1], colorCode
else if @config.layers[layer]?.cluster and @labelBuffer.writeIfPossible "X", point[0], point[1], 3
@canvas.text "", point[0], point[1], colorCode
_scaleAndReduce: (points, scale) ->
lastX = null

View File

@ -1799,7 +1799,7 @@
"type": "symbol",
"id": "housenum_label",
"paint": {
"text-color": "#333"
"text-color": "#444"
},
"source-layer": "housenum_label"
},