Hamtools.js - Javascript lib for several ham related stuff

For my project repeatermap.de I need several Javascript functions for several calculations. So I decided to write a small library or toolbox. Maybe it's useful for somebody else. There is not so much so far, but I will extend it whenever I need something else.

The library can be found at github: https://github.com/lnitram/hamtools.js

Here are some examples how it can be used

Calculate wavelength from frequency

Calculate wavelength in meter from frequency in MHz

var wavelength = Hamtools.f2l(freq);
Frequency: MHz
Wavelength: m

Calculate frequency from wavelength

Calculate frequency in MHz from wavelength in meters

var freq = Hamtools.f2l(wavelength);
Wavelength: m
Frequency: MHz

Parse position to lonLat

On aprs.fi the positions are shown in degrees and minutes. If you want to work with positions, just decimal would be much better. Here you can just paste a position from aprs.fi and you will get it in decimal degrees only. Also the maidenhead locator is calculated

     var s = "53°35.86' N 9°56.87' E";
     var pos = Hamtools.parsePosition(s);
     var lon = pos["lon"];
     var lat = pos["lat"];
     var loc = Hamtools.pos2loc(lon,lat,3);

Calculate distance between 2 lon/lat

     var lon1 = -74.0; var lat1 = 40.8; // New York
     var lon2 =  10.0; var lat2 = 53.6; // Hamburg
     var distance = Hamtools.distance(lat1,lon1,lat2,lon2);
     // => 6128.78 km
Location 1
Location 2