{"id":13907504,"url":"https://github.com/mourner/geokdbush","last_synced_at":"2025-09-14T21:33:06.485Z","repository":{"id":47189265,"uuid":"85291666","full_name":"mourner/geokdbush","owner":"mourner","description":"The fastest spatial index for geographic locations in JavaScript","archived":false,"fork":false,"pushed_at":"2024-07-29T17:53:50.000Z","size":62,"stargazers_count":347,"open_issues_count":1,"forks_count":36,"subscribers_count":13,"default_branch":"main","last_synced_at":"2024-12-19T01:42:06.630Z","etag":null,"topics":["algorithm","awesome","computational-geometry","earth","fast","javascript","spatial-index"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mourner.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-17T09:02:55.000Z","updated_at":"2024-12-16T02:50:24.000Z","dependencies_parsed_at":"2024-07-29T22:56:47.489Z","dependency_job_id":null,"html_url":"https://github.com/mourner/geokdbush","commit_stats":{"total_commits":35,"total_committers":7,"mean_commits":5.0,"dds":"0.17142857142857137","last_synced_commit":"19331e1b781d091fd4a1de87d19910acf7e9cd64"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Fgeokdbush","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Fgeokdbush/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Fgeokdbush/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Fgeokdbush/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mourner","download_url":"https://codeload.github.com/mourner/geokdbush/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233034806,"owners_count":18614891,"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":["algorithm","awesome","computational-geometry","earth","fast","javascript","spatial-index"],"created_at":"2024-08-06T23:01:58.182Z","updated_at":"2025-01-08T13:23:12.983Z","avatar_url":"https://github.com/mourner.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"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 =\u003e 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmourner%2Fgeokdbush","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmourner%2Fgeokdbush","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmourner%2Fgeokdbush/lists"}