ubilabs/kd-tree-javascript — pull request #4 by russfrank (2013-08-06 20:06:46+00:00)
Title: Adding serialization capability

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:

```javascript
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']);
```