I've added the ability to serialize a tree and restore it from the serialization. This way, a tree can be generated on a server and then pulled to a client where it is loaded and used. Example:
var tree = new kdTree(stops, haversine, ['x', 'y']);
fs.writeFileSync('kdtree.json', JSON.stringify(tree, false, 4));
// Later ...
var treeData = JSON.parse(fs.readFileSync('kdtree.json', 'utf8'));
var newTree = new kdTree(treeData, haversine, ['x', 'y']);
Hi,
I've added the ability to serialize a tree and restore it from the serialization. This way, a tree can be generated on a server and then pulled to a client where it is loaded and used. Example: