Skip to content

Commit 0506a9e

Browse files
committed
simplify how floor and ceiling altitudes are represented
1 parent d3a9e08 commit 0506a9e

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

Iguazu.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = "Iguazu"
11-
s.version = "1.2.1"
11+
s.version = "1.2.2"
1212
s.summary = "An aviation file format parser written in Swift"
1313
s.description = <<-DESC
1414
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.

Iguazu/AirSpace.swift

+12-8
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,20 @@ public extension AirSpace {
315315
}
316316

317317
extension AirSpaceAltitude {
318-
var asNSDictionary: NSDictionary {
318+
var geoJsonAltitude: Int {
319319
switch self {
320320
case .surface:
321-
return [ "type": "surface" ] as NSDictionary
322-
case .fl(let lvl):
323-
return [ "type": "fl", "value": lvl ] as NSDictionary
321+
return 0
322+
case .fl(let level):
323+
let flMeasure = Measurement(value: 100.0*Double(level), unit: UnitLength.feet).converted(to: .meters)
324+
let intMeters = Int(flMeasure.value.rounded())
325+
return intMeters
324326
case .agl(let alt):
325-
return [ "type": "agl", "value": alt.value, "unit": alt.unit.symbol ] as NSDictionary
327+
let intAGL = Int(alt.converted(to: .meters).value)
328+
return intAGL
326329
case .msl(let alt):
327-
return [ "type": "msl", "value": alt.value, "unit": alt.unit.symbol ] as NSDictionary
330+
let intMSL = Int(alt.converted(to: .meters).value)
331+
return intMSL
328332
}
329333
}
330334
}
@@ -338,8 +342,8 @@ extension AirSpace: GeoJsonEncodable {
338342
"properties": [
339343
"name": self.name as NSString,
340344
"type": self.class.rawValue as NSString,
341-
"floor": self.floor.asNSDictionary,
342-
"ceiling": self.ceiling.asNSDictionary,
345+
"floor": self.floor.geoJsonAltitude,
346+
"ceiling": self.ceiling.geoJsonAltitude,
343347
] as NSDictionary,
344348
"geometry": [
345349
"type": "Polygon" as NSString,

Iguazu/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.2.1</string>
18+
<string>1.2.2</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

IguazuTests/AirSpaceTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class AirSpaceTests : XCTestCase {
2727
XCTAssertNotNil(airSpaces)
2828
let asp = airSpaces![0]
2929
let geoJson = asp.geoJsonString
30-
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]]]}}")
30+
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]]]}}")
3131

3232
}
3333
}

0 commit comments

Comments
 (0)