mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-21 23:53:08 +01:00
🔍 using spatial indexing to determain which features to render
This commit is contained in:
parent
06528f488d
commit
cfe063cf2e
@ -27,7 +27,7 @@ No web browser around? No worries - discover the planet in your console!
|
|||||||
## Behind the scenes
|
## Behind the scenes
|
||||||
### Libraries
|
### Libraries
|
||||||
#### Mastering the console
|
#### Mastering the console
|
||||||
* [`x256`](https://github.com/substack/node-x256) for finding nearest xterm-256 [color codes](https://en.wikipedia.org/wiki/File:Xterm_256color_chart.svg)
|
* [`x256`](https://github.com/substack/node-x256) for converting RGB values to closest xterm-256 [color code](https://en.wikipedia.org/wiki/File:Xterm_256color_chart.svg)
|
||||||
* [`term-mouse`](https://github.com/CoderPuppy/term-mouse) for mouse handling
|
* [`term-mouse`](https://github.com/CoderPuppy/term-mouse) for mouse handling
|
||||||
* [`keypress`](https://github.com/TooTallNate/keypress) for input handling
|
* [`keypress`](https://github.com/TooTallNate/keypress) for input handling
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ No web browser around? No worries - discover the planet in your console!
|
|||||||
* [x] support for point labels
|
* [x] support for point labels
|
||||||
* [x] dynamic decluttering of labels
|
* [x] dynamic decluttering of labels
|
||||||
* [x] centering text labels
|
* [x] centering text labels
|
||||||
* [ ] clipping fix when x<0 after repositioning
|
* [x] clipping fix when x<0 after repositioning
|
||||||
* [ ] multi line label
|
* [ ] multi line label
|
||||||
* [ ] label margin to avoid POI overlap?
|
* [ ] label margin to avoid POI overlap?
|
||||||
* [ ] translatable raster fonts
|
* [ ] translatable raster fonts
|
||||||
@ -81,7 +81,6 @@ No web browser around? No worries - discover the planet in your console!
|
|||||||
* [x] accurate mouse drag&drop
|
* [x] accurate mouse drag&drop
|
||||||
* [x] handle console resize
|
* [x] handle console resize
|
||||||
* [x] styling
|
* [x] styling
|
||||||
* [ ] turn this into a [`blessed-contrib`](https://github.com/yaronn/blessed-contrib) widget
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
#### The MIT License (MIT)
|
#### The MIT License (MIT)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
termap - Terminal Map Viewer
|
termap - Terminal Map Viewer
|
||||||
by Michael Strassburger <codepoet@cpan.org>
|
by Michael Strassburger <codepoet@cpan.org>
|
||||||
|
|
||||||
Simple pixel to barille character mapper
|
Canvas-like painting abstraction for BrailleBuffer
|
||||||
|
|
||||||
Implementation inspired by node-drawille-canvas (https://github.com/madbence/node-drawille-canvas)
|
Implementation inspired by node-drawille-canvas (https://github.com/madbence/node-drawille-canvas)
|
||||||
* added support for filled polygons
|
* added support for filled polygons
|
||||||
|
@ -41,14 +41,8 @@ module.exports = class Renderer
|
|||||||
layers:
|
layers:
|
||||||
housenum_label: minZoom: 1.5
|
housenum_label: minZoom: 1.5
|
||||||
building: minZoom: 3.8
|
building: minZoom: 3.8
|
||||||
|
|
||||||
place_label: true
|
|
||||||
poi_label: minZoom: 3
|
poi_label: minZoom: 3
|
||||||
|
|
||||||
road: true
|
|
||||||
water: true
|
|
||||||
admin: true
|
|
||||||
|
|
||||||
isDrawing: false
|
isDrawing: false
|
||||||
lastDrawAt: 0
|
lastDrawAt: 0
|
||||||
|
|
||||||
@ -97,10 +91,17 @@ module.exports = class Renderer
|
|||||||
@notify "rendering #{layer}..."
|
@notify "rendering #{layer}..."
|
||||||
scale = Math.pow 2, @zoom
|
scale = Math.pow 2, @zoom
|
||||||
|
|
||||||
if @config.layers[layer].minZoom and @zoom > @config.layers[layer].minZoom
|
if @config.layers[layer]?.minZoom and @zoom > @config.layers[layer].minZoom
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for feature in @features[layer].tree.search(minX: 0, minY: 0, maxX: 4096, maxY: 4096)
|
box =
|
||||||
|
minX: -@view[0]*scale
|
||||||
|
minY: -@view[1]*scale
|
||||||
|
maxX: (@width-@view[0])*scale
|
||||||
|
maxY: (@height-@view[1])*scale
|
||||||
|
|
||||||
|
for feature in @features[layer].tree.search box
|
||||||
|
#@notify "rendering #{feature.data.id}"
|
||||||
@_drawFeature layer, feature.data, scale
|
@_drawFeature layer, feature.data, scale
|
||||||
|
|
||||||
_drawFeature: (layer, feature, scale) ->
|
_drawFeature: (layer, feature, scale) ->
|
||||||
|
@ -31,7 +31,7 @@ module.exports = class Termap
|
|||||||
lng: 12.096956
|
lng: 12.096956
|
||||||
|
|
||||||
zoom: 2
|
zoom: 2
|
||||||
view: [0, 0]
|
view: [0, 100]
|
||||||
|
|
||||||
scale: 4
|
scale: 4
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ module.exports = class Termap
|
|||||||
|
|
||||||
_resizeRenderer: (cb) ->
|
_resizeRenderer: (cb) ->
|
||||||
@width = (process.stdout.columns-1) >> 1 << 2
|
@width = (process.stdout.columns-1) >> 1 << 2
|
||||||
@height = process.stdout.rows >> 2 << 4
|
@height = Math.ceil(process.stdout.rows/2) << 4
|
||||||
|
|
||||||
@renderer.setSize @width, @height
|
@renderer.setSize @width, @height
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user