Created
March 4, 2015 10:37
-
-
Save dedunumax/d22b060b1303ce6d6db7 to your computer and use it in GitHub Desktop.
KDTree example from NodeJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* You can download geo.txt from - https://github.com/Adslot/node-puzzle/blob/master/01-geo-lookup/data/geo.txt | |
*/ | |
var fs = require('fs'); | |
var kd = require('kdtree'); | |
var kdtree = new kd.KDTree(3); | |
//var kdtree = new kd.KDTree(4); | |
console.log('Preparing to load values...'); | |
fs.readFileSync('/home/dedunu/kdtree-sample/data/geo.txt').toString().split('\n').forEach(function (line) { | |
var record = line.split('\t'); | |
kdtree.insert(record[0], record[1], record[3]); | |
//kdtree.insert(record[0], record[1], record[3], record[4]); | |
}); | |
console.log('Values are loaded into tree...'); | |
var result = kdtree.nearest(100249600, 100253695); | |
console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment