1.2.0 • Published 11 months ago

geo-coord-utils v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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.

1.2.0

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago