Skip to content

Instantly share code, notes, and snippets.

View dougmulley's full-sized avatar

Doug Mulley dougmulley

View GitHub Profile
@dougmulley
dougmulley / maidenhead-to-lat_long
Created August 9, 2022 15:40
Convert 4- or 6-character Maidenhead grid square to latitude and longitude
#!/usr/bin/env node
// Usage: maidenhead-to-lat_long <maidenhead-grid-square>
// Credit: Using the conversion method describe here at
// https://www.m0nwk.co.uk/how-to-convert-maidenhead-locator-to-latitude-and-longitude/
const mhGridSquare = process.argv[2];
console.log(`Maidenhead grid square: ${mhGridSquare}`);
const latitudePart1 = (mhGridSquare.charCodeAt(1) - 65) * 10;