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

dms2dec

v1.1.0

Published

GPS degrees, minutes, seconds coordinates to decimal

Downloads

7,237

Readme

dms2dec.js

Build status NPM downloads NPM version Node version Dependency status

Degrees, minutes, seconds (sexagesimal) to decimal GPS positions. Useful for parsing PGS exif tags in geotagged images.

Install

Node.JS

npm install dms2dec --save
var dms2dec = require('dms2dec');

Web

<script language="JavaScript" src="/dms2dec.js"></script>

Usage

[latDec, lonDec] = dms2dec(String lat, String latRef, String lon, String lonRef);

Params

  • lat – latitude in "degrees, minutes, seconds" format
  • lagRef – latitude hemisphere reference (N or S)
  • lon – longitude in "degrees, minutes, seconds" format
  • lonRef – longitude hemisphere reference (E or W)

Return

  • latDec – latitude converted into decimal format
  • lonDec – longitude converted into decimal format

Parse dms strings

var dec = dms2dec("60/1, 21/1, 4045/100", "N", "5/1, 22/1, 1555/100", "E");
// dec[0] == 60.36123611111111, dec[1] == 5.370986111111111

// without spaces or commas in the dms strings are also supported
var dec = dms2dec("60/1,21/1,4045/100", "N", "5/1,22/1,1555/100", "E");
var dec = dms2dec("60/1 21/1 4045/100", "N", "5/1 22/1 1555/100", "E");

Parse dms arrays

var dec = dms2dec(["60/1", "21/1", "4045/100"], "N", ["5/1", "22/1", "1555/100"], "E");
// dec[0] == 60.36123611111111, dec[1] == 5.370986111111111

dms arrays as decimal

var dec = dms2dec([60, 21, 40.45], "N", [5, 22, 15.55], "E");
// dec[0] == 60.36123611111111, dec[1] == 5.370986111111111

GeoJSON

NB! Remember that GeoJSON stores coordinates in reversed order (longitude, latitude) which means you have to reverse the order of the coordinates returned from dms2dec().

var geojson = {
  type: 'Point',
  coordinates: dms2dec(lat, latRef, lon, lonRef).reverse()
};