I´m looking for a solution to convert coordinates. Is there any pipe | service | function by which I am able to convert numbers to WGS84 format? Thank you very much for any help.
Longitude: 11.111111
Latitude: 22.22222
Example of converting to Degree, Minutes, Seconds (DMS). Once you have this you can then add the degree, minutes, and seconds signs if you prefer. You can also position the letters (NSWE) before or after the output string.
function toDMS(LAT,LNG) {
const toDMS=coord=>{min=~~(minA=((a=Math.abs(coord))-(deg=~~a))*60);
return deg+" "+min+" "+Math.ceil((minA-min)*60);
};
return `${toDMS(LAT)} ${LAT>=0?"N":"S"} / ${toDMS(LNG)} ${LNG>=0?"E":"W"}`;
}
// examples
console.log(toDMS( 22.22222, 11.11111));
console.log(toDMS( -22.22222, -11.11111));
function toDMS(LAT,LNG) {
const toDMS=coord=>{min=~~(minA=((a=Math.abs(coord))-(deg=~~a))*60);
return deg+"° "+min+"' "+Math.ceil((minA-min)*60)+'"';
};
return `${LAT>=0?"N":"S"} ${toDMS(LAT)} / ${LNG>=0?"E":"W"} ${toDMS(LNG)}`;
}
// examples
console.log(toDMS( 22.22222, 11.11111));
console.log(toDMS( -22.22222, -11.11111));