-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
113 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// CUPParser.swift | ||
// Iguazu | ||
// | ||
// Created by Engin Kurutepe on 01.03.20. | ||
// | ||
|
||
import Foundation | ||
|
||
public final class CUPParser { | ||
static public func pointOfInterest(from row: String) -> PointOfInterest? { | ||
let components = row.components(separatedBy: ",") | ||
// "001SPLuesse",,XX,5208.650N,01240.100E,66m,5,,,, | ||
guard | ||
components.count == 11, | ||
let latitude = Measurement<UnitAngle>(latitudeString: components[3]), | ||
let longitude = Measurement<UnitAngle>(longitudeString: components[4]), | ||
let elevation = Measurement<UnitLength>(components[5]) | ||
else { return nil } | ||
|
||
return PointOfInterest( | ||
title: components[0].replacingOccurrences(of: "\"", with: ""), | ||
code: components[1].replacingOccurrences(of: "\"", with: ""), | ||
country: components[2].replacingOccurrences(of: "\"", with: ""), | ||
latitude: latitude, | ||
longitude: longitude, | ||
elevation: elevation, | ||
style: PointOfInterest.Style(rawValue: Int(components[6]) ?? 0) ?? .unknown, | ||
direction: Int(components[7]), | ||
length: Measurement<UnitLength>(components[8]), | ||
frequency: components[9].replacingOccurrences(of: "\"", with: ""), | ||
description: components[10].replacingOccurrences(of: "\"", with: "")) | ||
} | ||
} | ||
|
||
public struct CUPFile { | ||
let name: String | ||
let points: [PointOfInterest] | ||
} | ||
|
||
public extension CUPFile { | ||
init?(name: String, fileURL: URL) { | ||
self.name = name | ||
guard let fileContents = try? String(contentsOf: fileURL) else { return nil } | ||
let lines = fileContents.components(separatedBy: .newlines) | ||
self.points = lines.concurrentMap { (line) -> PointOfInterest? in | ||
CUPParser.pointOfInterest(from: line) | ||
} | ||
.compactMap { $0 } | ||
} | ||
|
||
var airports: [Airport] { | ||
return points.filter { | ||
[PointOfInterest.Style.airfieldGliding, .airfieldGrass, .airfieldPaved].contains($0.style) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.