
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
geokdbush-tk
Advanced tools
**Note 1:** This fork works with `kdbush 4.x`, which doesn't store the whole objects, but only ids, so you have to keep the id-to-object lookup by yourself, and the `.around` method returns just ids.
Note 1: This fork works with kdbush 4.x
, which doesn't store the whole objects, but only ids, so you have to keep the id-to-object lookup by yourself, and the .around
method returns just ids.
Note 2: With geokdbush 2.x
, this module is obsolete, as geokdbush 2.x is updated to work with kdbush 4.x and uses the exact same API as this module (which is no longer updated).
A geographic extension for kdbush, the fastest static spatial index for points in JavaScript.
It implements fast nearest neighbors queries for locations on Earth, taking Earth curvature and date line wrapping into account. Inspired by sphere-knn, but uses a different algorithm.
import KDBush from 'kdbush'
import * as geokdbush from 'geokdbush'
// create a point array
const points = [
{ lat: 12.345, lon: 123.456 } // , ...
]
// create kdbush index of given length
let index = new KDBush(points.length)
// add locations
for (const point of points) {
index.add(point.lon, point.lat)
}
// perform the indexing
index.finish()
// look up ids ...
const nearestIds = geokdbush.around(index, -119.7051, 34.4363, 1000)
// ... and optionally convert to points
const nearestPoints = nearestIds.map((id) => points[id])
Returns an array of the closest ids (indices) of points from a given location in order of increasing distance.
index
: kdbush index.longitude
: query point longitude.latitude
: query point latitude.maxResults
: (optional) maximum number of points to return (Infinity
by default).maxDistance
: (optional) maximum distance in kilometers to search within (Infinity
by default).filterFn
: (optional) a function to filter the results (ids) with.Returns great circle distance between two locations in kilometers.
This library is incredibly fast.
The results below were obtained with npm run bench
(Node v7.7.2, Macbook Pro 15 mid-2012).
benchmark | geokdbush | sphere-knn | naive |
---|---|---|---|
index 138398 points | 69ms | 967ms | n/a |
query 1000 closest | 4ms | 4ms | 155ms |
query 50000 closest | 31ms | 368ms | 155ms |
query all 138398 | 80ms | 29.7s | 155ms |
1000 queries of 1 | 55ms | 165ms | 18.4s |
FAQs
**Note 1:** This fork works with `kdbush 4.x`, which doesn't store the whole objects, but only ids, so you have to keep the id-to-object lookup by yourself, and the `.around` method returns just ids.
The npm package geokdbush-tk receives a total of 0 weekly downloads. As such, geokdbush-tk popularity was classified as not popular.
We found that geokdbush-tk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.