Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dms2dec

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dms2dec

GPS degrees, minutes, seconds coordinates to decimal

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1K
increased by96.31%
Maintainers
1
Weekly downloads
 
Created
Source

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()
};

Keywords

FAQs

Package last updated on 30 Jul 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc