npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

geodesy-js

v1.0.4

Published

A lightweight library represents a location with an easy to use API (using [unitsnet-js](https://www.npmjs.com/package/unitsnet-js) units structs).

Downloads

286

Readme

geodesy-js

A lightweight library represents a location with an easy to use API (using unitsnet-js units structs).

Supports getting the curve between two locations and getting a destination location based on curve data.

The calculations is from the great Geodesy project.

CI CD Status Tests Coverage Status

Install via NPM:


npm install geodesy-js

Using examples

Example with the class driven API

import { GeoLocation } from 'geodesy-js';
import { Angle, Length } from 'unitsnet-js';

// Create a world location
const location = new GeoLocation({
    Latitude: Angle.FromDegrees(32),
    Longitude: Angle.FromDegrees(35),
});

// Get a location based on the curve from the location
const destinationLocation = location.destination(Angle.FromDegrees(10), Length.FromMeters(3000));

console.log(`The destination coordinates:`);
console.log(`Latitude: ${destinationLocation.Latitude.toString()}`); // Latitude: 32.026643406143805 °
console.log(`Longitude: ${destinationLocation.Longitude.toString()}`); // Longitude: 35.005514633016986 °


// Get the distance between the location and the destinationLocation.
const distance = location.distance(destinationLocation);
console.log(`The distance: ${distance.toString()}`); // The distance: 2999.998518387958 m


// Get the curve (distance & azimuth) between the location and the destinationLocation.
const curve = location.curve(destinationLocation);
console.log(`The curve:`);
console.log(`Distance: ${curve.Distance.toString()}`); // Distance: 2999.998518387958 m
console.log(`Azimuth: ${curve.Azimuth.toString()}`); // Azimuth: 9.999999999995072 °

Example with the methods driven API


import { GeoPoint, getDestinationGeoPoint, getDistance, getGeoPointsCurve } from 'geodesy-js';
import { Angle, Length } from 'unitsnet-js';

// Create a world location
const location: GeoPoint = {
    Latitude: Angle.FromDegrees(32),
    Longitude: Angle.FromDegrees(35),
};

// Get a location based on the curve from the location
const destinationLocation = getDestinationGeoPoint(location, Angle.FromDegrees(10), Length.FromMeters(3000));

console.log(`The destination coordinates:`);
console.log(`Latitude: ${destinationLocation.Latitude.toString()}`); // Latitude: 32.026643406143805 °
console.log(`Longitude: ${destinationLocation.Longitude.toString()}`); // Longitude: 35.005514633016986 °


// Get the distance between the location and the destinationLocation.
const distance = getDistance(location, destinationLocation);
console.log(`The distance: ${distance.toString()}`); // The distance: 2999.998518387958 m


// Get the curve (distance & azimuth) between the location and the destinationLocation.
const curve = getGeoPointsCurve(location, destinationLocation);
console.log(`The curve:`);
console.log(`Distance: ${curve.Distance.toString()}`); // Distance: 2999.998518387958 m
console.log(`Azimuth: ${curve.Azimuth.toString()}`); // Azimuth: 9.999999999995072 °

Currently the library supports only WGS84 datum.