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

location-utilities

v1.0.3

Published

Coordinate formatting, location calculation utilities, and NMEA sentence parser.

Downloads

58

Readme

location-utilities

Coordinate formatting, location calculation utilities, and NMEA sentence parser.

This module provides many useful functions:

  • Formats ddmm.mmmmm or degrees minutes as DD or decimal degrees.
  • Formats decimal degrees or DD as degrees minutes seconds or DMS.
  • Formats DMS or degrees minutes seconds as DD or decimal degrees.
  • Calculates horizontal accuracy which is the accuracy output on most GPS devices.
  • Calculates the distance between two points.
  • Parses all standard sentences of the NMEA protocol which includes $GPDTM, $GPGBS, $GPGGA, $GPGLL, $GPGLQ, $GPGNQ, $GPGNS, $GPGPQ, $GPGRS, $GPGSA, $GPGST, $GPGSV, $GPRMC, $GPVTG, and $GPZDA.
  • Supports metric and imperial units.

Love my modules?

  • Support my continued creation of important modules. Buy me a glass of bourbon! https://www.paypal.me/buymebourbon

Installation

npm install location-utilities --save

Node usage

var LocationUtility =  require('path-to-module-index-file/index.js');

Angular usage

import { LocationUtility } from 'location-utilities';

Current module functions

Returned Unit of Measure

// Pass 'imp' for imperial and 'm' for metric

Parse NMEA sentence

// Returns an object with the parsed data
// Unit is either m for metric or imp for imperial
// Measurements are returned in meters or feet
// Longitude and latitude are returned in decimal degrees
LocationUtility.parseNMEA(NMEASentence, unit);
Parse NMEA sentence with an interface
// Returns an object with the parsed data and casts it to a NMEA sentence interface
LocationUtility.parseNMEA(NMEASentence, 'imp') as LocationUtility.GGA;

Parse specific NMEA sentence

// Supports all standard NMEA sentences as parse functions
// Replace GGA with the name of the sentence you are trying to parse
// Measurements are returned in meters or feet
// Longitude and latitude are returned in decimal degrees
LocationUtility.parseGGA(NMEASentence, 'imp');

Calculate horizontal accuracy

// Returns horizontal accuracy as a number
// Unit is either m for metric or imp for imperial
// Measurements are returned in meters or feet
  let parsedGST = LocationUtility.parseGST(NMEAGSTSentence, 'imp');
  LocationUtility.horizontalAccuracy(parsedGST.stdLatitudeError, parsedGST.stdLongitudeError, 'imp');

Format degrees minutes as decimal degrees

// Returns an object containing decimal degrees for both latitude and longitude
// Latitude direction is either N for North or S for South
// Longitude direction is either E for East or W for west
  LocationUtility.DMToDD(latitudeDirection, latitude, longitudeDirection, longitude);

Format latitude degrees minutes as decimal degrees

// Returns decimal degrees for latitude as a number
// Latitude direction is either N for North or S for South
  LocationUtility.DMLatToDD(latitudeDirection, latitude);

Format longitude degrees minutes as decimal degrees

// Returns decimal degrees for longitude as a number
// Longitude direction is either E for East or W for west
  LocationUtility.DMLongToDD(longitudeDirection, longitude);

Format latitude decimal degrees as degrees minutes seconds

// Returns degrees minutes seconds for latitude as a string
  LocationUtility.DDLatToDMS(latitude);

Format longitude decimal degrees as degrees minutes seconds

// Returns degrees minutes seconds for longitude as a string
  LocationUtility.DDLongToDMS(longitude);

Format degrees minutes seconds as decimal degrees

// Returns decimal degrees as a number
// Looks for strings in this format: 138° 31' 50" E
  LocationUtility.DMSToDD(longitude);

Calculate distance between two points

// Returns the distance in the desired unit
// Unit is either m for metric or imp for imperial
// Longitude points and latitude points must be in decimal degrees
// Measurements are returned in kilometers or miles
  LocationUtility.calculateDistance(point1Latitude, point1Longitude, point2Latitude, point2Longitude, unit);