注意:此库已转换为 Swift 3 并作为 pod发布!要查看旧样式,请查看 objectivec 或 swift2 分支。
这是一个全球机场的 mac 和 iOS 数据库。它使用一个 Cocoa 框架 Core Data 模型和配套的 Swift 类。还包括跑道和频率信息。
将此行添加到你的 Podfile 中
pod 'iAirportsDB', :git => 'https://github.com/ckhsponge/iairportsdb.git'
重要:该 pod 现在仅包含一个空数据库。请使用以下命令下载完整数据库。
curl -O https://raw.githubusercontent.com/ckhsponge/iairportsdb/master/Example/data/iAirportsDBExample.sqlite
将下载的文件添加到你的 Xcode 项目中,然后使用以下方法配置 IADB 以使用它:
IADBModel.setPersistence(path: Bundle.main.path(forResource: "iAirportsDBExample", ofType: "sqlite")!)
此数据库被广泛流行的NRST: Descent Rate & Airport Finder for iOS 所使用。
以下是你获得的一些数据示例
class IADBAirport {
var identifier: String // gps code
var latitude: Double
var longitude: Double
var name: String
var type: String
var elevationFeet: NSNumber? // for objc compatibility Int32? is not allowed, -1 is a valid elevation
var code: String // iata code e.g. ICN, this is what is printed on boarding passes
var municipality: String /// Normally the nearby city e.g. Seoul
var runways:[IADBRunway]
var frequencies:[IADBFrequency]
}
class IADBRunway {
var closed: Bool
var lighted: Bool
var headingTrue: Float // runway 12 will have a magnetic heading of ~120
var identifierA: String // e.g. 12
var identifierB: String // e.g. 30
var lengthFeet: Int32
var surface: String // e.g. TURF
var widthFeet: Int32
}
class IADBFrequency {
var mhz: Float
var name: String // e.g. APP
var type: String // e.g. NORCAL APP
}
使用以下方法查找机场
- IADBAirport.findNear(CLLocation, withinNM:CLLocationDistance)
- IADBAirport.findNear(CLLocation, withinNM:CLLocationDistance, types:[IADBAirport.AirportType]?)
- IADBAirport.findAllByIdentifier(String)
或者用 Objective C 写
- [IADBAirport findNear:(CLLocation *) location withinNM:(CLLocationDistance) distance]
- [IADBAirport findAllByIdentifier:(NSString *) identifier]
- [IADBNavigationAid findNear:(CLLocation *) location withinNM:(CLLocationDistance) distance]
- [IADBNavigationAid findAllByIdentifier:(NSString *) identifier]
- [IADBLocation findNear:(CLLocation *) location withinNM:(CLLocationDistance) distance]
- [IADBLocation findAllByIdentifier:(NSString *) identifier]