From 233b118dd60495e8ba012ec96903441af05e4b15 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Wed, 8 Jan 2020 17:45:54 -0500 Subject: added search.update, integrating rasterization --- tools/search.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tools') diff --git a/tools/search.js b/tools/search.js index fc9817a..38a1124 100644 --- a/tools/search.js +++ b/tools/search.js @@ -6,6 +6,7 @@ const bs = require('binary-search'); const Space = require('../space'); const comb = require('../utils/comb') const vec = require('../utils/vec'); +const raster = require('../utils/raster'); function getComp(index){ return (element,needle) => (element[index] - needle[index] || element[1-index] - needle[1-index]) @@ -75,6 +76,14 @@ function Search(searchBlock){ // searchBlock should be a Space object. // bs returns negative if not found. else return true; } + + this.update = function(space){ // Must be a space w/ valid loc; allows overlay of some arbitrary text (in the space) mostly for recording updates from the server without directly cataloguing them + let tiles = raster(space); // Returns a this.tiles-style binding: {'2,-3':Space object} + for (tile in tiles){ + if (this.tiles[tile]) this.tiles[tile].comb(tiles[tile], comb.flip(comb.add)); + else this.add(tile, tiles[tile]); + } + } } module.exports = Search; -- cgit