A Swift wrapper for the original WMM_Tiny library.
- Calculate magnetic variation (declination) for any location, altitude, and date.
- Lightweight and easy to use.
- Uses the latest World Magnetic Model (WMM 2025).
let wmm = WMMTiny.shared
let magVar = wmm.magneticVariation(
coordinate: CLLocationCoordinate2D(
latitude: 37.7749,
longitude: -122.4194
),
altitudeKm: 10,
date: Date()
)
This package uses wmm.c
and wmm.h
from the original WMM_Tiny, with a slight modification to include altitude as an input parameter:
// include altitude above ellipsoid
r += height_km;
d += height_km;
To re-generate the WMM_COF.c file from a WMM.COF model file, run:
swift run WWMConverter WMM.COF
See MIT License for details.