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

geo-coord-utils

v1.2.0

Published

This library provides functions to convert coordinates between DMS (Degrees, Minutes, Seconds), Latitude-Longitude and UTM (Universal Transverse Mercator) formats in JavaScript.

Downloads

353

Readme

Geo-Coord-Utils

Installation

You can install this library using npm:

npm install geo-coord-utils

Usage

Importing the Library

const { UTMToDMS, UTMToLatLon, LatLonToUTM, LatLonToDMS, DMSToLatLon, DMSToUTM } = require('geo-coord-utils');

Converting UTM to Lat/Lon

To convert coordinates from UTM to longitude/longitude:

const utmCoords = {
  easting: 567047.1966208686,
  northern: 4478055.059933961,
  zoneNum: 17,
  zoneLetter: 'T'
};

const latLonCoords = UTMToLatLon(utmCoords);
console.log('UTM to Lat/Lon:', latLonCoords);

Converting UTM to DMS

To convert coordinates from UTM to DMS:

const dmsCoords = UTMToDMS(utmCoords);
console.log('UTM to DMS:', dmsCoords);

Converting DMS to UTM

To convert coordinates from DMS to UTM:

const dmsToUtmExample = {
  latD: 40,
  latM: 26,
  latS: 46,
  latDir: 'N',
  lonD: 79,
  lonM: 58,
  lonS: 56,
  lonDir: 'W'
};

const utmCoords = DMSToUTM(dmsToUtmExample);
console.log('DMS to UTM:', utmCoords);

Converting DMS to Lat/Lon

To convert coordinates from DMS to longitude/longitude:

const dmsToLatLonExample = {
  latD: 40,
  latM: 26,
  latS: 46,
  latDir: 'N',
  lonD: 79,
  lonM: 58,
  lonS: 56,
  lonDir: 'W'
};

const latLonCoords = DMSToLatLon(dmsToLatLonExample);
console.log('DMS to Lat/Lon:', latLonCoords);

Converting Lat/Lon to UTM

To convert coordinates from longitude/longitude to UTM:

const lat = 40.446195;
const lon = -79.982222;

const utmCoords = LatLonToUTM(lat, lon);
console.log('Lat/Lon to UTM:', utmCoords);

Converting Lat/Lon to DMS

To convert coordinates from longitude/longitude to DMS:

const lat = 40.446195;
const lon = -79.982222;

const dmsCoords = LatLonToDMS(lat, lon);
console.log('Lat/Lon to DMS:', dmsCoords);

Functions

DMSToUTM(latDeg, latMin, latSec, latDir, lonDeg, lonMin, lonSec, lonDir)

Converts DMS coordinates to UTM coordinates.

Parameters:

  • latD: Latitude degrees
  • latM: Latitude minutes
  • latS: Latitude seconds
  • latDir: Latitude direction ('N' or 'S')
  • lonD: Longitude degrees
  • lonM: Longitude minutes
  • lonS: Longitude seconds
  • lonDir: Longitude direction ('E' or 'W')

Returns:

  • An object containing UTM coordinates (easting, northern, zoneNum, zoneLetter).

UTMToDMS(easting, northern, zoneNum, zoneLetter)

Converts UTM coordinates to DMS coordinates.

Parameters:

  • easting: Easting value
  • northern: Northing value
  • zoneNum: UTM zone number
  • zoneLetter: UTM zone letter

Returns:

  • An object containing DMS coordinates (lat, lon).

UTMToLatLon(easting, northern, zoneNum, zoneLetter)

Converts UTM coordinates to longitude/longitude coordinates.

Parameters:

  • easting: Easting value
  • northern: Northing value
  • zoneNum: UTM zone number
  • zoneLetter: UTM zone letter

Returns:

  • An object containing longitude/longitude coordinates (longitude, longitude).

LatLonToUTM(lat, lon)

Converts longitude/longitude coordinates to UTM coordinates.

Parameters:

  • lat: Latitude value
  • lon: Longitude value

Returns:

  • An object containing UTM coordinates (easting, northern, zoneNum, zoneLetter).

LatLonToDMS(lat, lon)

Converts longitude/longitude coordinates to DMS coordinates.

Parameters:

  • lat: Latitude value
  • lon: Longitude value

Returns:

  • An object containing DMS coordinates (lat, lon).

DMSToLatLon(latDeg, latMin, latSec, latDir, lonDeg, lonMin, lonSec, lonDir)

Converts DMS coordinates to longitude/longitude coordinates.

Parameters:

  • latD: Latitude degrees
  • latM: Latitude minutes
  • latS: Latitude seconds
  • latDir: Latitude direction ('N' or 'S')
  • lonD: Longitude degrees
  • lonM: Longitude minutes
  • lonS: Longitude seconds
  • lonDir: Longitude direction ('E' or 'W')

Returns:

  • An object containing longitude/longitude coordinates (lat, lon).

License

This project is licensed under the MIT License - see the LICENSE file for details.