mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-22 08:03:07 +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
|
node_modules
|
||||||
bundle*
|
bundle*
|
||||||
*.log
|
*.log
|
||||||
|
tmp
|
||||||
|
2
main.js
2
main.js
@ -17,7 +17,7 @@ const Tile = require(__dirname+'/src/Tile')
|
|||||||
termap = new Termap();
|
termap = new Termap();
|
||||||
|
|
||||||
// TODO: abstracing this class, create loader class
|
// 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);
|
tile = new Tile(data);
|
||||||
termap.renderer.features = tile.layers
|
termap.renderer.features = tile.layers
|
||||||
termap._draw();
|
termap._draw();
|
||||||
|
@ -40,7 +40,7 @@ module.exports = class Canvas
|
|||||||
clear: ->
|
clear: ->
|
||||||
@buffer.clear()
|
@buffer.clear()
|
||||||
|
|
||||||
text: (text, x, y, color, center = true) ->
|
text: (text, x, y, color, center = false) ->
|
||||||
position = @_project x, y
|
position = @_project x, y
|
||||||
@buffer.writeText text, position[0], position[1], color, center
|
@buffer.writeText text, position[0], position[1], color, center
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ module.exports = class Renderer
|
|||||||
"building"
|
"building"
|
||||||
"road"
|
"road"
|
||||||
|
|
||||||
"water_label"
|
|
||||||
"place_label"
|
"place_label"
|
||||||
"poi_label"
|
"poi_label"
|
||||||
"housenum_label"
|
"housenum_label"
|
||||||
@ -147,7 +146,7 @@ module.exports = class Renderer
|
|||||||
|
|
||||||
switch feature.type
|
switch feature.type
|
||||||
when "LineString"
|
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
|
@canvas.polyline points, colorCode, width for points in toDraw
|
||||||
|
|
||||||
when "Polygon"
|
when "Polygon"
|
||||||
@ -166,12 +165,10 @@ module.exports = class Renderer
|
|||||||
x = point[0] - text.length
|
x = point[0] - text.length
|
||||||
margin = @config.layers[layer]?.margin or @config.labelMargin
|
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
|
if @labelBuffer.writeIfPossible text, x, point[1], margin
|
||||||
write text
|
@canvas.text text, x, point[1], colorCode
|
||||||
else if @config.layers[layer]?.cluster and @labelBuffer.writeIfPossible "X", x, point[1], 3
|
else if @config.layers[layer]?.cluster and @labelBuffer.writeIfPossible "X", point[0], point[1], 3
|
||||||
write "◉"
|
@canvas.text "◉", point[0], point[1], colorCode
|
||||||
|
|
||||||
_scaleAndReduce: (points, scale) ->
|
_scaleAndReduce: (points, scale) ->
|
||||||
lastX = null
|
lastX = null
|
||||||
|
@ -1799,7 +1799,7 @@
|
|||||||
"type": "symbol",
|
"type": "symbol",
|
||||||
"id": "housenum_label",
|
"id": "housenum_label",
|
||||||
"paint": {
|
"paint": {
|
||||||
"text-color": "#333"
|
"text-color": "#444"
|
||||||
},
|
},
|
||||||
"source-layer": "housenum_label"
|
"source-layer": "housenum_label"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user