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

mgrs-pole-test

v0.0.4

Published

Get MGRS coordinate for North Pole/South Pole

Downloads

8

Readme

These libraries ‘latitude/longitude’ decimal degree covering MGRS string and opposit converting.

How to use it

import MgrsPole from './node_modules/mgrs-pole/mgrs-pole.js';

const mgrsPole = new MgrsPole();
let lat = 89.4;
let lon = -124.54;
console.log(mgrsPole.toMgrs(lat, lon));

let mgrs ='ZAJ0193711009';
console.log(mgrsPole.toDegree(mgrs));

Run it

node app.js

Result

( 89.4 , -124.54 )  ==>  Y ZH 45127 37769
ZAJ0193711009  ==>  89.00000561585777 179.00034534622264
B AN 12345 67890  ==>  -89.3784881350407 10.305960479100179

How to data type file

npx -p typescript tsc *.js --declaration --allowJs --emitDeclarationOnly --outDir ./

How to test package

Once

npm install

After install dependencies

npm run test

In the package.json, make shure test script is exist.

  "type": "module",
  "scripts": {
    "test": "mocha --exit test/*.js",
    "type": "npx -p typescript tsc *.js --declaration --allowJs --emitDeclarationOnly --outDir types"
  },
  "devDependencies": {
    "@types/node": "^20.6.2",
    "chai": "^4.3.8",
    "mocha": "^10.2.0"
  }

Result of test

$npm run test

> [email protected] test
> mocha --exit test/*.js



  North Pole
    To MGRS
      ✔ input ( 89.4 , -124.54 ) => output Y ZH 45127 37769
      ✔ input ( 90.0 ,    0.0  ) => output Z AH 00000 00000
      ✔ input ( 85.49868, 180  ) => output Z AN 00000 00000
      ✔ input ( 84.974211, 174.289458 ) => output Z AN 55555 55555
      ✔ input ( 84.30793,  161.56511  ) => output Z BN 99999 99999
      ✔ input ( 85.4986848, 90 ) => output Z HH 00000 00000
      ✔ input ( 85.49868485,-90 ) => output Y TH 00000 00000
      ✔ input ( 84.92113141, -19.425812 ) => output Y YB 12345 67890
      ✔ input ( 84.30791588, -108.43483423 ) => output Y RJ 99999 99999
      ✔ input ( 84.525201427, 9.46230672 ) => output Z BA 00000 99999
      ✔ input ( 84.30791304032213, -18.434920175075227 ) => output Y YA 00000 99999
    To Degree
      ✔ input Y ZH 45127 37769 => output (89.4, -124.53958)
      ✔ input `Z AH 00000 00000` => output (90, 0)
      ✔ input `Z AN 00000 00000` => output (85.49868, 180)
      ✔ input `Z AN 55555 55555` => output (84.97421, 174.28946)
      ✔ input `Z HH 00000 00000` => output (85.4986848, 90)
      ✔ input `Z TH 00000 00000` => output (85.49868485, -90)
      ✔ input `Y YB 12345 67890` => output (84.92113141, -19.425812)
      ✔ input `Z JJ 00000 00000` => output (84.52521029, 99.46232221)
      ✔ input `Y RJ 99999 99999` => output (84.30791588, -108.43483423)
      ✔ input `Z BA 00000 99999` => output (84.52520142658405, 9.462306722704914)
      ✔ input `Z BN 99999 99999` => output (84.30793, 161.56511)
      ✔ input `Y YA 00000 99999` => output (84.30791304032213, -18.434920175075227)
      ✔ input `31U DQ 48251 11932` => output (48.858193837921434, 2.2944892452301553)
      ✔ input `Z AH 1 6` => output (89.45212493960805, 170.53767779197437)
      ✔ input `Z AH 12 67` => output (89.38692865323186, 169.84573341979976)
      ✔ input `Z AH 123 678` => output (89.37935813037085, 169.71746497072658)
      ✔ input `Z AH 1234 6789` => output (89.37849619026939, 169.698124263963)
      ✔ input `Z AH 12345 67890` => output (89.3784881350407, 169.69403952089982)
    Exception
      ✔ longitude `1000.0` out of range
      ✔ longitude `-375.0` out of range
      ✔ latitude `94.4` out of range
      ✔ latitude `-94.4` out of range
      ✔ wrong MGRS `Y XX 00000 00000`
      ✔ wrong MGRS `Z KH 12345 12345`
      ✔ wrong MGRS `Z ZP 12345 12345`
      ✔ wrong MGRS `Y BP 12345 12345`
      ✔ wrong MGRS `Z AH`
    Call getOnCirclePointY()
      ✔ input "Z AP 00000 00000" => output "Z AP 00000 66727"
      ✔ input "Z BP 00000 00000" => output "Z BP 00000 59185"
      ✔ input "Z CP 00000 00000" => output "Z CP 00000 36023"
      ✔ input "Z FN 00000 00000" => output "Z FN 00000 95420"
      ✔ input "Z GN 00000 00000" => output "Z GN 00000 33409"
      ✔ input "Z HM 00000 00000" => output "Z HM 00000 41050"
      ✔ input "Z JK 00000 00000" => output "Z JK 00000 90732"
      ✔ input "Y ZP 00000 00000" => output "Y ZP 00000 59185"
      ✔ input "Y YP 00000 00000" => output "Y YP 00000 36023"
      ✔ input "Y XN 00000 00000" => output "Y XN 00000 95420"
      ✔ input "Y UN 00000 00000" => output "Y UN 00000 33409"
      ✔ input "Y TM 00000 00000" => output "Y TM 00000 41050"
      ✔ input "Y SK 00000 00000" => output "Y SK 00000 90732"
      ✔ input "Z AA 00000 00000" => output "Z AA 00000 33273"
      ✔ input "Z BA 00000 00000" => output "Z BA 00000 40815"
      ✔ input "Z CA 00000 00000" => output "Z CA 00000 63977"
      ✔ input "Z FB 00000 00000" => output "Z FB 00000 04580"
      ✔ input "Z GB 00000 00000" => output "Z GB 00000 66591"
      ✔ input "Z HC 00000 00000" => output "Z HC 00000 58950"
      ✔ input "Z JE 00000 00000" => output "Z JE 00000 09268"
      ✔ input "Y ZA 00000 00000" => output "Y ZA 00000 40815"
      ✔ input "Y YA 00000 00000" => output "Y YA 00000 63977"
      ✔ input "Y XB 00000 00000" => output "Y XB 00000 04580"
      ✔ input "Y UB 00000 00000" => output "Y UB 00000 66591"
      ✔ input "Y TC 00000 00000" => output "Y TC 00000 58950"
      ✔ input "Y SE 00000 00000" => output "Y SE 00000 09268"
    Call getOnCirclePointX()
      ✔ input "Z JH 00000 00000" => output "Z JH 66727 00000"
      ✔ input "Z JJ 00000 00000" => output "Z JJ 59185 00000"
      ✔ input "Z JK 00000 00000" => output "Z JK 36023 00000"
      ✔ input "Z HL 00000 00000" => output "Z HL 95420 00000"
      ✔ input "Z HM 00000 00000" => output "Z HM 33409 00000"
      ✔ input "Z GN 00000 00000" => output "Z GN 41050 00000"
      ✔ input "Z CP 00000 00000" => output "Z CP 90732 00000"
      ✔ input "Y RH 00000 00000" => output "Y RH 33273 00000"
      ✔ input "Y RJ 00000 00000" => output "Y RJ 40815 00000"
      ✔ input "Y RK 00000 00000" => output "Y RK 63977 00000"
      ✔ input "Y SL 00000 00000" => output "Y SL 04580 00000"
      ✔ input "Y SM 00000 00000" => output "Y SM 66591 00000"
      ✔ input "Y TN 00000 00000" => output "Y TN 58950 00000"
      ✔ input "Y XP 00000 00000" => output "Y XP 09268 00000"
      ✔ input "Z JG 00000 00000" => output "Z JG 59185 00000"
      ✔ input "Z JF 00000 00000" => output "Z JF 36023 00000"
      ✔ input "Z HE 00000 00000" => output "Z HE 95420 00000"
      ✔ input "Z HD 00000 00000" => output "Z HD 33409 00000"
      ✔ input "Z GC 00000 00000" => output "Z GC 41050 00000"
      ✔ input "Z CB 00000 00000" => output "Z CB 90732 00000"
      ✔ input "Y RG 00000 00000" => output "Y RG 40815 00000"
      ✔ input "Y RF 00000 00000" => output "Y RF 63977 00000"
      ✔ input "Y SE 00000 00000" => output "Y SE 04580 00000"
      ✔ input "Y SD 00000 00000" => output "Y SD 66591 00000"
      ✔ input "Y TC 00000 00000" => output "Y TC 58950 00000"
      ✔ input "Y XB 00000 00000" => output "Y XB 09268 00000"

  South Pole
    To MGRS
      ✔ input (-89.4 , -124.54) => output A ZM 45127 62230
      ✔ input (-90.0 ,    0.0 ) => output B AN 00000 00000
    To Degree
      ✔ input B AN 00000 00000 => output (-90, 0)
      ✔ input A ZN 00000 00000 => output (-89.09931, -90)
      ✔ input B AB 00000 00000 => output (-80.11581108958083, 180)
      ✔ input B AY 00000 00000 => output (-81.01066338749857, 0)
      ✔ input B QN 00000 00000 => output (-81.01066338749857, 90)
      ✔ input A KN 00000 00000 => output (-80.11581108958083, -90)
      ✔ input B KV 00000 00000 => output (-81.10066069064223, 45)
      ✔ input A QV 00000 00000 => output (-80.44664636312663, -48.81407483429035)
      ✔ input B LF 00000 00000 => output (-80.44664636312663, 131.18592516570965)
      ✔ input A QF 00000 00000 => output (-80.44664636312663, -131.18592516570965)
      ✔ input B KW 00000 00000 => output (-80.44664636312663, 41.18592516570965)
      ✔ input B RW 00000 00000 => output (-80.44664636312663, -41.18592516570965)
      ✔ input `B AN 1 6` => output (-89.45212493960805, 9.462322208025617)
      ✔ input `B AN 12 67` => output (-89.38692865323186, 10.154266580200263)
      ✔ input `B AN 123 678` => output (-89.37935813037085, 10.282535029273433)
      ✔ input `B AN 1234 6789` => output (-89.37849619026939, 10.301875736036996)
      ✔ input `B AN 12345 67890` => output (-89.3784881350407, 10.305960479100179)
    Exception
      ✔ longitude out of range `1000.0`
      ✔ longitude out of range `-375.0`
      ✔ latitude out of range `-94.4`
      ✔ wrong MGRS `B SN 12345 12345`
      ✔ wrong MGRS `A HN 12345 12345`
      ✔ wrong MGRS `B ZY 12345 12345`
      ✔ wrong MGRS `A BY 12345 12345`
      ✔ wrong MGRS `A ZA`
    Call getOnCirclePointY()
      ✔ input "B AZ 00000 00000" => output "B AZ 00000 12951"
      ✔ input "B BZ 00000 00000" => output "B BZ 00000 08449"
      ✔ input "B CY 00000 00000" => output "B CY 00000 94833"
      ✔ input "B FY 00000 00000" => output "B FY 00000 71755"
      ✔ input "B GY 00000 00000" => output "B GY 00000 38585"
      ✔ input "B HX 00000 00000" => output "B HX 00000 94313"
      ✔ input "B JX 00000 00000" => output "B JX 00000 37368"
      ✔ input "B KW 00000 00000" => output "B KW 00000 65251"
      ✔ input "B LV 00000 00000" => output "B LV 00000 73731"
      ✔ input "B PU 00000 00000" => output "B PU 00000 54721"
      ✔ input "B QS 00000 00000" => output "B QS 00000 88528"
      ✔ input "B RP 00000 00000" => output "B RP 00000 69290"
      ✔ input "A ZZ 00000 00000" => output "A ZZ 00000 08449"
      ✔ input "A YY 00000 00000" => output "A YY 00000 94833"
      ✔ input "A XY 00000 00000" => output "A XY 00000 71755"
      ✔ input "A UY 00000 00000" => output "A UY 00000 38585"
      ✔ input "A TX 00000 00000" => output "A TX 00000 94313"
      ✔ input "A SX 00000 00000" => output "A SX 00000 37368"
      ✔ input "A RW 00000 00000" => output "A RW 00000 65251"
      ✔ input "A QV 00000 00000" => output "A QV 00000 73731"
      ✔ input "A PU 00000 00000" => output "A PU 00000 54721"
      ✔ input "A LS 00000 00000" => output "A LS 00000 88528"
      ✔ input "A KP 00000 00000" => output "A KP 00000 69290"
      ✔ input "B AA 00000 00000" => output "B AA 00000 87049"
      ✔ input "B BA 00000 00000" => output "B BA 00000 91551"
      ✔ input "B CB 00000 00000" => output "B CB 00000 05167"
      ✔ input "B FB 00000 00000" => output "B FB 00000 28245"
      ✔ input "B GB 00000 00000" => output "B GB 00000 61415"
      ✔ input "B HC 00000 00000" => output "B HC 00000 05687"
      ✔ input "B JC 00000 00000" => output "B JC 00000 62632"
      ✔ input "B KD 00000 00000" => output "B KD 00000 34749"
      ✔ input "B LE 00000 00000" => output "B LE 00000 26269"
      ✔ input "B PF 00000 00000" => output "B PF 00000 45279"
      ✔ input "B QH 00000 00000" => output "B QH 00000 11472"
      ✔ input "B RL 00000 00000" => output "B RL 00000 30710"
      ✔ input "A ZA 00000 00000" => output "A ZA 00000 91551"
      ✔ input "A YB 00000 00000" => output "A YB 00000 05167"
      ✔ input "A XB 00000 00000" => output "A XB 00000 28245"
      ✔ input "A UB 00000 00000" => output "A UB 00000 61415"
      ✔ input "A TC 00000 00000" => output "A TC 00000 05687"
      ✔ input "A SC 00000 00000" => output "A SC 00000 62632"
      ✔ input "A RD 00000 00000" => output "A RD 00000 34749"
      ✔ input "A QE 00000 00000" => output "A QE 00000 26269"
      ✔ input "A PF 00000 00000" => output "A PF 00000 45279"
      ✔ input "A LH 00000 00000" => output "A LH 00000 11472"
      ✔ input "A KL 00000 00000" => output "A KL 00000 30710"
    Call getOnCirclePointX()
      ✔ input "B RN 00000 00000" => output "B RN 12951 00000"
      ✔ input "B RP 00000 00000" => output "B RP 08449 00000"
      ✔ input "B QQ 00000 00000" => output "B QQ 94833 00000"
      ✔ input "B QR 00000 00000" => output "B QR 71755 00000"
      ✔ input "B QS 00000 00000" => output "B QS 38585 00000"
      ✔ input "B PT 00000 00000" => output "B PT 94313 00000"
      ✔ input "B PU 00000 00000" => output "B PU 37368 00000"
      ✔ input "B LV 00000 00000" => output "B LV 65251 00000"
      ✔ input "B KW 00000 00000" => output "B KW 73731 00000"
      ✔ input "B JX 00000 00000" => output "B JX 54721 00000"
      ✔ input "B GY 00000 00000" => output "B GY 88528 00000"
      ✔ input "B BZ 00000 00000" => output "B BZ 69290 00000"
      ✔ input "B RM 00000 00000" => output "B RM 08449 00000"
      ✔ input "B QL 00000 00000" => output "B QL 94833 00000"
      ✔ input "B QK 00000 00000" => output "B QK 71755 00000"
      ✔ input "B QJ 00000 00000" => output "B QJ 38585 00000"
      ✔ input "B PH 00000 00000" => output "B PH 94313 00000"
      ✔ input "B PG 00000 00000" => output "B PG 37368 00000"
      ✔ input "B LF 00000 00000" => output "B LF 65251 00000"
      ✔ input "B KE 00000 00000" => output "B KE 73731 00000"
      ✔ input "B JD 00000 00000" => output "B JD 54721 00000"
      ✔ input "B GC 00000 00000" => output "B GC 88528 00000"
      ✔ input "B BB 00000 00000" => output "B BB 69290 00000"
      ✔ input "A JN 00000 00000" => output "A JN 87049 00000"
      ✔ input "A JP 00000 00000" => output "A JP 91551 00000"
      ✔ input "A KQ 00000 00000" => output "A KQ 05167 00000"
      ✔ input "A KR 00000 00000" => output "A KR 28245 00000"
      ✔ input "A KS 00000 00000" => output "A KS 61415 00000"
      ✔ input "A LT 00000 00000" => output "A LT 05687 00000"
      ✔ input "A LU 00000 00000" => output "A LU 62632 00000"
      ✔ input "A PV 00000 00000" => output "A PV 34749 00000"
      ✔ input "A QW 00000 00000" => output "A QW 26269 00000"
      ✔ input "A RX 00000 00000" => output "A RX 45279 00000"
      ✔ input "A TY 00000 00000" => output "A TY 11472 00000"
      ✔ input "A YZ 00000 00000" => output "A YZ 30710 00000"
      ✔ input "A JM 00000 00000" => output "A JM 91551 00000"
      ✔ input "A KL 00000 00000" => output "A KL 05167 00000"
      ✔ input "A KK 00000 00000" => output "A KK 28245 00000"
      ✔ input "A KJ 00000 00000" => output "A KJ 61415 00000"
      ✔ input "A LH 00000 00000" => output "A LH 05687 00000"
      ✔ input "A LG 00000 00000" => output "A LG 62632 00000"
      ✔ input "A PF 00000 00000" => output "A PF 34749 00000"
      ✔ input "A QE 00000 00000" => output "A QE 26269 00000"
      ✔ input "A RD 00000 00000" => output "A RD 45279 00000"
      ✔ input "A TC 00000 00000" => output "A TC 11472 00000"
      ✔ input "A YB 00000 00000" => output "A YB 30710 00000"


  209 passing (33ms)