🔍 using spatial indexing to determain which features to render

This commit is contained in:
Michael Straßburger 2016-09-27 14:53:47 +02:00
parent 06528f488d
commit cfe063cf2e
4 changed files with 14 additions and 14 deletions

View File

@ -27,7 +27,7 @@ No web browser around? No worries - discover the planet in your console!
## Behind the scenes
### Libraries
#### 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
* [`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] dynamic decluttering of labels
* [x] centering text labels
* [ ] clipping fix when x<0 after repositioning
* [x] clipping fix when x<0 after repositioning
* [ ] multi line label
* [ ] label margin to avoid POI overlap?
* [ ] 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] handle console resize
* [x] styling
* [ ] turn this into a [`blessed-contrib`](https://github.com/yaronn/blessed-contrib) widget
## License
#### The MIT License (MIT)

View File

@ -2,7 +2,7 @@
termap - Terminal Map Viewer
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)
* added support for filled polygons

View File

@ -41,14 +41,8 @@ module.exports = class Renderer
layers:
housenum_label: minZoom: 1.5
building: minZoom: 3.8
place_label: true
poi_label: minZoom: 3
road: true
water: true
admin: true
isDrawing: false
lastDrawAt: 0
@ -97,10 +91,17 @@ module.exports = class Renderer
@notify "rendering #{layer}..."
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
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, scale) ->

View File

@ -31,7 +31,7 @@ module.exports = class Termap
lng: 12.096956
zoom: 2
view: [0, 0]
view: [0, 100]
scale: 4
@ -66,7 +66,7 @@ module.exports = class Termap
_resizeRenderer: (cb) ->
@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