{"id":21323643,"url":"https://github.com/justinethier/node-kdtree","last_synced_at":"2025-06-28T17:04:03.997Z","repository":{"id":57144228,"uuid":"1475263","full_name":"justinethier/node-kdtree","owner":"justinethier","description":"A node.js add-on for performing efficient Nearest Neighbor searches using libkdtree.","archived":false,"fork":false,"pushed_at":"2018-07-17T09:41:02.000Z","size":116,"stargazers_count":56,"open_issues_count":3,"forks_count":60,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-24T04:44:30.507Z","etag":null,"topics":["c","kd-tree","nodejs"],"latest_commit_sha":null,"homepage":"http://justinethier.github.com/node-kdtree","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justinethier.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-03-13T18:27:51.000Z","updated_at":"2024-12-13T08:43:57.000Z","dependencies_parsed_at":"2022-09-06T08:53:46.587Z","dependency_job_id":null,"html_url":"https://github.com/justinethier/node-kdtree","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/justinethier/node-kdtree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinethier%2Fnode-kdtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinethier%2Fnode-kdtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinethier%2Fnode-kdtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinethier%2Fnode-kdtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justinethier","download_url":"https://codeload.github.com/justinethier/node-kdtree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinethier%2Fnode-kdtree/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262465670,"owners_count":23315636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","kd-tree","nodejs"],"created_at":"2024-11-21T20:26:02.804Z","updated_at":"2025-06-28T17:04:03.956Z","avatar_url":"https://github.com/justinethier.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg src=\"https://raw.githubusercontent.com/justinethier/node-kdtree/master/doc/node-kdtree-logo.png\" alt=\"\"\u003e](https://github.com/justinethier/node-kdtree) \n#node-kdtree\n\nnode-kdtree is a node.js addon that defines a wrapper to libkdtree, allowing one to work with KD trees directly in node. A [KD tree](http://en.wikipedia.org/wiki/Kd-tree) is a data structure that organizes points in a multi-dimensional space, and in particular is useful for performing efficient nearest neighbor searches.\n\n## Dependencies\nThe [kdtree](https://github.com/jtsiomb/kdtree) C library is required. In order to install, get the latest version from [here](https://github.com/jtsiomb/kdtree/releases) and run the following commands:\n\n    ./configure\n    make\n    sudo make install PREFIX=/usr \n\n## Installation\nThe easiest way to install node-kdtree is to use the [npm](https://github.com/isaacs/npm) package manager:\n\n    npm install kdtree\n\n## Usage\n\n###Creating a tree\nYou may create a tree by instantiating a new `KDTree` object:\n\n    var kd = require('kdtree');\n    var tree = new kd.KDTree(3); // A new tree for 3-dimensional points\n\nWhen creating a new tree we can specify the dimensions of the data. For example, a three-dimensional tree will contain points of the form (x, y, z). If a dimension is not specified, the tree defaults to three dimensions.\n\n###Adding data to a tree\nData may be added to the tree using the `insert` method:\n\n    tree.insert(1, 2, 3);\n    tree.insert(10, 20, 30);\n\nThere must be one argument for each dimension of the data - for example, a three dimensional tree would have three arguments to `insert`. An optional data parameter may also be specified to store a data value alongside the point data:\n\n    tree.insert(39.285785, -76.610262, \"USS Constellation\");\n\n###Nearest neighbor searches\nThe `nearest` method is used to find the point in the tree that is closest to a target point. For example:\n\n    \u003e tree.nearest(39.273889, -76.738056);\n    [39.272051, -76.731917, \"Bill's Music, Inc.\"]\n\n`nearest` will return an array containing closest point, or an empty array if no points were found. As shown above, if the point contains a data value, that value will also be returned at the end of the array.\n\n\nA `nearestRange` method is also provided, which allows us to find all of the points within a given range. For example:\n\n    \u003e tree.nearestRange(0, 0, 3);\n    [ [ 1, 1 ],\n      [ 0, 2 ],\n      [ 2, 0 ],\n      [ 1, 0 ],\n      [ 0, 1 ],\n      [ 0, 0 ] ]\n\nThe first arguments to `nearestRange` are the components of the point to begin searching at. The last argument is the search range.\n\n##API\n\n[API documentation](https://github.com/justinethier/node-kdtree/blob/master/doc/API.markdown)\n\n##Credits\n\nnode-kdtree is developed by [Justin Ethier](http://github.com/justinethier).\n\nThanks to John Tsiombikas for developing libkdtree!\n\nPatches are welcome; please send via pull request on github.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinethier%2Fnode-kdtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinethier%2Fnode-kdtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinethier%2Fnode-kdtree/lists"}