WorldMagneticModel 1.0.5

WorldMagneticModel 1.0.5

Paul Calnan 维护。



  • Bose Corporation

World Magnetic Model

此项目提供了一个封装了 World Magnetic Model 的原生 iOS 框架。

World Magnetic Model 是美国国家地理空间情报局 (NGA) 和英国国防地理中心 (DGC) 的联合产品。WMM 是由国家地球物理数据中心 (NGDC, 博尔德科罗拉多州,美国)(现为国家环境信息中心 (NCEI))和英国地质调查局 (BGS, 爱丁堡,苏格兰) 联合开发的。

World Magnetic Model 是美国国防部、英国国防部、北大西洋公约组织 (NATO) 和国际水文组织 (IHO) 用于使用地磁场进行导航、姿态和方向参照系统的标准模型。它也广泛应用于民用导航和方向系统。模型、相关软件和文档由 NCEI 代表 NGA 发布。该模型每 5 年制作一次,当前模型于 2019 年 12 月 31 日到期。

有关 World Magnetic Model 的更多信息,请访问 这里

从 WMM 网站下载的 WMM 源和系数分布包含在 WMM2015v2 目录中。这些仅用于参考。iOS 包装库使用的任何文件也提交在 Source/WMM 目录下。

安装

此框架可以通过 CocoaPods 安装。在你的 Podfile 中添加以下内容

pod 'WorldMagneticModel', '~> 1'

用法

import CoreLocation
import WorldMagneticModel

// Step 1: Create the model.
let model = try? WMMModel()

// Step 2: Get the current location of the device. This is left as an exercise
// for the reader.
let location: CLLocation = getCurrentLocation()

// Step 3: Compute the magnetic field elements for the current location at the
// current time.
let elements = model?.elements(for: location)

// Step 4: Get the current heading of the device. This is left as an exercise
// for the reader. The value should be in degrees as the declination value
// (found in WMMElements.decl) is in degrees.
let magneticHeading: Double = getCurrentMagneticHeading()

// Step 5: Use the declination (found in WMMElements.decl) to convert the
// magnetic heading (relative to magnetic north) into a true heading (relative
// to the geographic north).
let trueHeading = magneticHeading + elements.decl