{"name":"geokdbush","version":"2.0.0","author":{"name":"Vladimir Agafonkin","email":"agafonkin@gmail.com"},"license":"ISC","_id":"geokdbush@2.0.0","homepage":"https://github.com/mourner/geokdbush#readme","bugs":{"url":"https://github.com/mourner/geokdbush/issues"},"dist":{"shasum":"8dddb1b5a5fb06bf4b69f86e008b38678f9a3f19","tarball":"http://registry-npm.ywwl.com/geokdbush/download/geokdbush-2.0.0.tgz","fileCount":11,"integrity":"sha512-6vxU1wd61uC5VIA1F195N5b1Czx7JVilIYVPvkAWvBkdFdlgZ/xbIeqCWDQMczyzH0mpDsuzMRBpdfILyZe1/Q==","signatures":[{"sig":"MEYCIQCfvWFG+pFShliQod4ZgxcalUONzgI9AJuwB4LwiKdikAIhALX0ayb8cMOAF2n6U4f7gwcLmi4gJbl5J9xHG9dXheZQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17017,"size":5441,"noattachment":false,"key":"/geokdbush/-/geokdbush-2.0.0.tgz"},"main":"index.js","type":"module","gitHead":"4d8a55f4f8c6d7e284e56158452dc346382ec261","scripts":{"test":"node test.js","bench":"cd bench && node bench-geokdbush && node bench-sphere-knn && node bench-naive && node bench-vptree","pretest":"eslint index.js test.js bench"},"_npmUser":{"name":"mourner","email":"agafonkin@gmail.com"},"repository":{"url":"git+https://github.com/mourner/geokdbush.git","type":"git"},"_npmVersion":"10.8.0","description":"A geographic extension for [KDBush](https://github.com/mourner/kdbush), the fastest static spatial index for points in JavaScript.","directories":{},"_nodeVersion":"20.14.0","dependencies":{"tinyqueue":"^2.0.3"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.6.0","kdbush":"^4.0.2","vptree":"^1.0.0","sphere-knn":"^1.4.0","all-the-cities":"3.1.0","eslint-config-mourner":"^4.0.1"},"_npmOperationalInternal":{"tmp":"tmp/geokdbush_2.0.0_1719825504532_0.16069797106905148","host":"s3://npm-registry-packages"},"readme":"## geokdbush [![Node](https://github.com/mourner/geokdbush/actions/workflows/node.yml/badge.svg)](https://github.com/mourner/geokdbush/actions/workflows/node.yml) [![Simply Awesome](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects)\n\nA geographic extension for [KDBush](https://github.com/mourner/kdbush),\nthe fastest static spatial index for points in JavaScript.\n\nIt implements fast [nearest neighbors](https://en.wikipedia.org/wiki/Nearest_neighbor_search) queries\nfor locations on Earth, taking Earth curvature and date line wrapping into account.\nInspired by [sphere-knn](https://github.com/darkskyapp/sphere-knn), but uses a different algorithm.\n\n### Example\n\n```js\nimport KDBush from 'kdbush';\nimport * as geokdbush from 'geokdbush';\n\nconst index = new KDBush(points.length);\nfor (const {lon, lat} of points) index.add(lon, lat);\nindex.finish();\n\nconst nearestIds = geokdbush.around(index, -119.7051, 34.4363, 1000);\n\nconst nearest = nearestIds.map(id => points[id]);\n```\n\n### API\n\n#### geokdbush.around(index, longitude, latitude[, maxResults, maxDistance, filterFn])\n\nReturns an array of the closest points from a given location in order of increasing distance.\n\n- `index`: [kdbush](https://github.com/mourner/kdbush) index.\n- `longitude`: query point longitude.\n- `latitude`: query point latitude.\n- `maxResults`: (optional) maximum number of points to return (`Infinity` by default).\n- `maxDistance`: (optional) maximum distance in kilometers to search within (`Infinity` by default).\n- `filterFn`: (optional) a function to filter the results with.\n\n#### geokdbush.distance(longitude1, latitude1, longitude2, latitude2)\n\nReturns great circle distance between two locations in kilometers.\n\n### Performance\n\nThis library is incredibly fast.\nThe results below were obtained with `npm run bench`\n(Node v20, Macbook Pro 2020 M1 Pro).\n\nbenchmark | geokdbush | sphere-knn | naive\n--- | ---: | ---: | ---:\nindex 138398 points | 57.6ms | 408ms | n/a\nquery 1000 closest | 1.6ms | 1.8ms | 72ms\nquery 50000 closest | 14.7ms | 91.5ms | 72ms\nquery all 138398 | 33.7ms | 500ms | 72ms\n1000 queries of 1 | 24.7ms | 27.5ms | 11.1s\n","publish_time":1719825504695,"maintainers":[{"name":"mourner","email":"agafonkin@gmail.com"}],"_cnpm_publish_time":1719825504695,"dist-tags":{"latest":"2.1.0"}}