Skip to content

Commit

Permalink
simplify how floor and ceiling altitudes are represented
Browse files Browse the repository at this point in the history
  • Loading branch information
ekurutepe committed May 28, 2018
1 parent d3a9e08 commit 0506a9e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Iguazu.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "Iguazu"
s.version = "1.2.1"
s.version = "1.2.2"
s.summary = "An aviation file format parser written in Swift"
s.description = <<-DESC
Iguazu is a new project and still work in progress. The goal is to have a Swift framework with support for various popular aviation file formats to facilitate development of apps for pilots on the iOS platform.
Expand Down
20 changes: 12 additions & 8 deletions Iguazu/AirSpace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,20 @@ public extension AirSpace {
}

extension AirSpaceAltitude {
var asNSDictionary: NSDictionary {
var geoJsonAltitude: Int {
switch self {
case .surface:
return [ "type": "surface" ] as NSDictionary
case .fl(let lvl):
return [ "type": "fl", "value": lvl ] as NSDictionary
return 0
case .fl(let level):
let flMeasure = Measurement(value: 100.0*Double(level), unit: UnitLength.feet).converted(to: .meters)
let intMeters = Int(flMeasure.value.rounded())
return intMeters
case .agl(let alt):
return [ "type": "agl", "value": alt.value, "unit": alt.unit.symbol ] as NSDictionary
let intAGL = Int(alt.converted(to: .meters).value)
return intAGL
case .msl(let alt):
return [ "type": "msl", "value": alt.value, "unit": alt.unit.symbol ] as NSDictionary
let intMSL = Int(alt.converted(to: .meters).value)
return intMSL
}
}
}
Expand All @@ -338,8 +342,8 @@ extension AirSpace: GeoJsonEncodable {
"properties": [
"name": self.name as NSString,
"type": self.class.rawValue as NSString,
"floor": self.floor.asNSDictionary,
"ceiling": self.ceiling.asNSDictionary,
"floor": self.floor.geoJsonAltitude,
"ceiling": self.ceiling.geoJsonAltitude,
] as NSDictionary,
"geometry": [
"type": "Polygon" as NSString,
Expand Down
2 changes: 1 addition & 1 deletion Iguazu/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.2.1</string>
<string>1.2.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion IguazuTests/AirSpaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AirSpaceTests : XCTestCase {
XCTAssertNotNil(airSpaces)
let asp = airSpaces![0]
let geoJson = asp.geoJsonString
XCTAssertEqual(geoJson, "{\"type\":\"Feature\",\"properties\":{\"ceiling\":{\"type\":\"fl\",\"value\":65},\"name\":\"TMZ-EDLW 129.875\",\"type\":\"TMZ\",\"floor\":{\"type\":\"msl\",\"value\":4500,\"unit\":\"ft\"}},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[7.3055555555555554,51.516666666666666],[7.3055555555555554,51.516666666666666],[7.3433333333333328,51.423888888888889],[7.4625000000000004,51.31305555555555],[7.4519444444444449,51.408333333333331],[7.3741666666666665,51.493055555555557],[7.3055555555555554,51.516666666666666]]]}}")
XCTAssertEqual(geoJson, "{\"type\":\"Feature\",\"properties\":{\"ceiling\":1981,\"name\":\"TMZ-EDLW 129.875\",\"type\":\"TMZ\",\"floor\":1371},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[7.3055555555555554,51.516666666666666],[7.3055555555555554,51.516666666666666],[7.3433333333333328,51.423888888888889],[7.4625000000000004,51.31305555555555],[7.4519444444444449,51.408333333333331],[7.3741666666666665,51.493055555555557],[7.3055555555555554,51.516666666666666]]]}}")

}
}

0 comments on commit 0506a9e

Please sign in to comment.