Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
sphere-knn
Advanced tools
Readme
sphere-knn
is a Node.JS module that provides fast nearest-neighbor lookups on
a sphere. This is useful if, for example, you have a database of geographic
points (latitude, longitude) and want to swiftly look up which of those points
are near a given latitude, longitude pair. It came out of a need to do such
lookups in the Dark Sky API, but all
existing libraries either threw scary runtime flags, were too slow, broke at
the International Date Line, or didn't have tests.
So anyway, this one is well-tested and works correctly regardless of where on the earth things are located. It's been in production use at Dark Sky since Oct 2012.
To install:
npm install sphere-knn
To use:
var sphereKnn = require("sphere-knn"),
lookup = sphereKnn([
/* This array needs to be full of objects that have latitudes and
* longitudes. Accepted property names are "lat", "latitude", "lon",
* "lng", "long", "longitude". */
{lat: ..., lon: ...},
/* You can also use an array. */
[my_lat, my_lon],
...
])
var points = lookup(someLatitude, someLongitude, maxResults, maxDistance)
The points
array consists of objects that were in the array passed to
sphereKnn()
, ordered from nearest to furthest. The maxResults
value is the
maximum size of the returned array, and is mandatory. (Often, you'll just want
it set to 1, but there are use-cases for more points.) The maxDistance
value
is the maximum distance away we should look up for in meters. This is handy if
you want to find, say, any points within 200 kilometers of a given point.
maxDistance
is optional and defaults to Infinity. (Please note that since our
backing earth model is a sphere, all distances given to this function are
approximate. If it matters that much to you, add a few meters of padding and
check the results with some very accurate (and complex) distance function.)
To the extend possible by law, The Dark Sky Company, LLC has waived all copyright and related or neighboring rights to this library.
FAQs
search for k nearest neighbors on a sphere
The npm package sphere-knn receives a total of 8,866 weekly downloads. As such, sphere-knn popularity was classified as popular.
We found that sphere-knn demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.