Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
geo-distance
Advanced tools
A common JS module for calculating and converting Earth distances using correct great-circle distance formula.
Common JS module for calculating and converting Earth distances using correct great-circle distance formula.
npm install geo-distance
The lat/lon coordinates were flipped until v0.1.2. This is fixed in v0.2.0. Please be aware, when updating. Discussion here.
For JavaScripters:
var Distance = require('geo-distance');
console.log('' + Distance('50 km').human_readable('customary'));
// https://www.latlong.net/place/oslo-norway-14195.html: Oslo, Norway, Latitude and longitude coordinates are: 59.911491, 10.757933
var Oslo = {
lat: 59.914,
lon: 10.752
};
var Berlin = {
lat: 52.523,
lon: 13.412
};
var OsloToBerlin = Distance.between(Oslo, Berlin);
console.log('' + OsloToBerlin.human_readable());
if (OsloToBerlin > Distance('800 km')) {
console.log('Nice journey!');
}
For CoffeeScripters:
Distance = require 'geo-distance'
console.log "#{ Distance('50 km').human_readable 'customary' }"
Oslo =
lat: 59.914
lon: 10.752
Berlin =
lat: 52.523
lon: 13.412
OsloToBerlin = Distance.between Oslo, Berlin
console.log "#{ OsloToBerlin.human_readable() }"
console.log 'Nice journey!' if OsloToBerlin > Distance '800 km'
If you want to work with GeoJSON or maybe just want to calculate distance as a number (fx. kilometers or miles), it is possible to use the @turf/distance npm module.
The image example/earth.jpg
is a rescaled version of a NASA image in the
public domain. All other files are released under the MIT license:
Copyright (c) 2011 Bjarke Walling <bwp@bwp.dk>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
FAQs
A common JS module for calculating and converting Earth distances using correct great-circle distance formula.
The npm package geo-distance receives a total of 0 weekly downloads. As such, geo-distance popularity was classified as not popular.
We found that geo-distance demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.