mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-21 15:43:08 +01:00
🔍 adapting label decluttering to centered labels
This commit is contained in:
parent
d3e2961184
commit
1effed33d9
@ -38,8 +38,9 @@ No web browser around? No worries - discover the planet in your console!
|
||||
* [`vector-tile-js`](https://github.com/mapbox/vector-tile-js) for [VectorTile](https://github.com/mapbox/vector-tile-spec/tree/master/2.1) parsing
|
||||
|
||||
#### Juggling the vectors and numbers
|
||||
* [`pnltri`](https://github.com/jahting/pnltri.js) for polygon triangulation to draw them filled
|
||||
* [`pnltri`](https://github.com/jahting/pnltri.js) for polygon triangulation to draw 'em filled
|
||||
* [`rbush`](https://github.com/mourner/rbush) for 2D spatial indexing based label and mouse collision detection
|
||||
* [`gl-matrix`](https://github.com/toji/gl-matrix) for vector and matrix operations
|
||||
* [`sphericalmercator`](https://github.com/mapbox/node-sphericalmercator) for [EPSG:3857](http://spatialreference.org/ref/sr-org/6864/) <> [WGS84](http://spatialreference.org/ref/epsg/wgs-84/) conversions
|
||||
|
||||
### TODOs
|
||||
@ -51,12 +52,14 @@ No web browser around? No worries - discover the planet in your console!
|
||||
* [x] support for point labels
|
||||
* [x] dynamic decluttering of labels
|
||||
* [x] centering text labels
|
||||
* [ ] clipping fix when x<0 after repositioning
|
||||
* [ ] multi line label
|
||||
* [ ] label margin to avoid POI overlap?
|
||||
* [ ] translatable raster fonts
|
||||
* [x] filled polygons
|
||||
* [x] convert polygons to triangles
|
||||
* [x] implement fillTriangle into drawille-canvas-blessed-contrib
|
||||
* [ ] respect fill/line style file based setting
|
||||
* [ ] lat/lng-center + zoom based viewport
|
||||
* [ ] bbox awareness
|
||||
* [ ] zoom -> scale calculation
|
||||
|
@ -22,6 +22,7 @@
|
||||
"dependencies": {
|
||||
"coffee-script": "^1.10.0",
|
||||
"drawille-canvas-blessed-contrib": "git+https://github.com/rastapasta/drawille-canvas-blessed-contrib.git",
|
||||
"gl-matrix": "^2.3.2",
|
||||
"keypress": "^0.2.1",
|
||||
"pbf": "^3.0.0",
|
||||
"pnltri": "^2.1.1",
|
||||
|
@ -7,7 +7,35 @@
|
||||
###
|
||||
|
||||
BlessedCanvas = require 'drawille-canvas-blessed-contrib'
|
||||
vec2 = require('gl-matrix').vec2
|
||||
|
||||
module.exports = class Canvas extends BlessedCanvas
|
||||
fillText: (text, x, y, size=1) ->
|
||||
super text, x-text.length, y
|
||||
|
||||
# bresenham: (from, to) ->
|
||||
# points = []
|
||||
# adx = Math.abs dx = to.x - from.x
|
||||
# ady = Math.abs dy = to.y - from.y
|
||||
# eps = 0
|
||||
# sx = if dx > 0 then 1 else -1
|
||||
# sy = if dy > 0 then 1 else -1
|
||||
#
|
||||
# [x, y] = from
|
||||
# if adx > ady
|
||||
# while if sx < 0 then x >= x1 else x <= x1
|
||||
# points.add x:, y: y
|
||||
# eps += ady
|
||||
# if eps<<1 >= adx
|
||||
# y += sy
|
||||
# eps -= adx
|
||||
#
|
||||
# x += sx
|
||||
# else
|
||||
# while if sy < 0 then y >= y1 else y <= y1
|
||||
# fn(x, y);
|
||||
# eps += adx;
|
||||
# if eps<<1 >= ady
|
||||
# x += sx;
|
||||
# eps -= ady;
|
||||
#
|
||||
# y += sy
|
||||
# arr
|
||||
|
@ -296,8 +296,9 @@ class Termap
|
||||
# TODO: check in definition if points can actually own multiple geometries
|
||||
for points in toDraw
|
||||
for point in points
|
||||
if @labelBuffer.writeIfPossible text, point.x, point.y
|
||||
@canvas.fillText text, point.x, point.y
|
||||
x = point.x - text.length
|
||||
if @labelBuffer.writeIfPossible text, x, point.y
|
||||
@canvas.fillText text, x, point.y
|
||||
wasDrawn = true
|
||||
|
||||
wasDrawn
|
||||
|
Loading…
Reference in New Issue
Block a user