mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-21 23:53:08 +01:00
🎨 optimizing label/marker rendering
This commit is contained in:
parent
f493a48e34
commit
bd83950eeb
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
node_modules
|
||||
bundle*
|
||||
*.log
|
||||
tmp
|
||||
|
2
main.js
2
main.js
@ -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();
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -1799,7 +1799,7 @@
|
||||
"type": "symbol",
|
||||
"id": "housenum_label",
|
||||
"paint": {
|
||||
"text-color": "#333"
|
||||
"text-color": "#444"
|
||||
},
|
||||
"source-layer": "housenum_label"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user