Parsing of NavData implemented, lookup of Waypoints implemented as testbed
This commit is contained in:
parent
e7f105091b
commit
a70df29f40
7
About.rtf
Normal file
7
About.rtf
Normal file
@ -0,0 +1,7 @@
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460
|
||||
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw12240\paperh15840\margl1440\margr1440\vieww9000\viewh8400\viewkind0
|
||||
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
|
||||
|
||||
\f0\fs24 \cf0 SWTableViewCell by Chris Wendel: https://github.com/CEWendel/SWTableViewCell}
|
||||
@ -7,6 +7,8 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
E20D7B501CBE807700FF3C70 /* NavDataParser.m in Sources */ = {isa = PBXBuildFile; fileRef = E20D7B4F1CBE807700FF3C70 /* NavDataParser.m */; };
|
||||
E20D7B521CBE87A800FF3C70 /* About.rtf in Resources */ = {isa = PBXBuildFile; fileRef = E20D7B511CBE87A800FF3C70 /* About.rtf */; };
|
||||
E227C7831C9F42AB00DE0CA4 /* ViewControllerKeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = E227C7821C9F42AB00DE0CA4 /* ViewControllerKeyboard.m */; };
|
||||
E227C7861C9F474100DE0CA4 /* ViewControllerScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = E227C7851C9F474100DE0CA4 /* ViewControllerScreen.m */; };
|
||||
E22E0B561CAD655D00B71EE5 /* libPods-FMC Planner 2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E22E0B551CAD655D00B71EE5 /* libPods-FMC Planner 2.a */; };
|
||||
@ -57,6 +59,9 @@
|
||||
7001889F24BA85C99E7B33D5 /* Pods-FMC Planner 2Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FMC Planner 2Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-FMC Planner 2Tests/Pods-FMC Planner 2Tests.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
7D8EFDFEC3DAB0323BA29ECE /* Pods-FMC Planner 2.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FMC Planner 2.debug.xcconfig"; path = "Pods/Target Support Files/Pods-FMC Planner 2/Pods-FMC Planner 2.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
C9A81E1FC84665AB5255ECFC /* Pods-FMC Planner 2UITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FMC Planner 2UITests.release.xcconfig"; path = "Pods/Target Support Files/Pods-FMC Planner 2UITests/Pods-FMC Planner 2UITests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
E20D7B4E1CBE807700FF3C70 /* NavDataParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavDataParser.h; sourceTree = "<group>"; };
|
||||
E20D7B4F1CBE807700FF3C70 /* NavDataParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavDataParser.m; sourceTree = "<group>"; };
|
||||
E20D7B511CBE87A800FF3C70 /* About.rtf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.rtf; path = About.rtf; sourceTree = "<group>"; };
|
||||
E227C7811C9F42AB00DE0CA4 /* ViewControllerKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewControllerKeyboard.h; sourceTree = "<group>"; };
|
||||
E227C7821C9F42AB00DE0CA4 /* ViewControllerKeyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerKeyboard.m; sourceTree = "<group>"; };
|
||||
E227C7841C9F474100DE0CA4 /* ViewControllerScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewControllerScreen.h; sourceTree = "<group>"; };
|
||||
@ -157,6 +162,7 @@
|
||||
E22EE9C31C9DB7B3001F5BC0 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E20D7B511CBE87A800FF3C70 /* About.rtf */,
|
||||
E22EE9CE1C9DB7B3001F5BC0 /* FMC Planner 2 */,
|
||||
E22EE9E81C9DB7B4001F5BC0 /* FMC Planner 2Tests */,
|
||||
E22EE9F31C9DB7B4001F5BC0 /* FMC Planner 2UITests */,
|
||||
@ -194,6 +200,8 @@
|
||||
E2A9270E1CA2FE5200606E07 /* Header */,
|
||||
E22EE9DB1C9DB7B3001F5BC0 /* Assets.xcassets */,
|
||||
E22EE9E01C9DB7B3001F5BC0 /* Info.plist */,
|
||||
E20D7B4E1CBE807700FF3C70 /* NavDataParser.h */,
|
||||
E20D7B4F1CBE807700FF3C70 /* NavDataParser.m */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
@ -410,6 +418,7 @@
|
||||
E29391CE1CA444F4008EB590 /* LaunchScreen.storyboard in Resources */,
|
||||
E28E10731CA0375F006E2C6B /* ROUTE.plist in Resources */,
|
||||
E22EE9DA1C9DB7B3001F5BC0 /* Main.storyboard in Resources */,
|
||||
E20D7B521CBE87A800FF3C70 /* About.rtf in Resources */,
|
||||
E2763C721CA6C8AE001E4EDA /* LSKs.plist in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@ -566,6 +575,7 @@
|
||||
E227C7831C9F42AB00DE0CA4 /* ViewControllerKeyboard.m in Sources */,
|
||||
E2763C751CA6E777001E4EDA /* ViewControllerServiceMenu.m in Sources */,
|
||||
E227C7861C9F474100DE0CA4 /* ViewControllerScreen.m in Sources */,
|
||||
E20D7B501CBE807700FF3C70 /* NavDataParser.m in Sources */,
|
||||
E280F3A41CA7C71500DF2A05 /* TableViewController.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
//
|
||||
|
||||
#import "DropboxV2ObjC.h"
|
||||
#import "NavDataParser.h"
|
||||
#import "ViewController.h"
|
||||
#import "ViewControllerServiceMenu.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@ -14,9 +16,9 @@
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
#pragma mark - Shared Dropbox client
|
||||
/// Shared Dropbox client
|
||||
@property (strong, nonatomic) DropboxV2ObjC *dbClient;
|
||||
#pragma mark - Refrence to other views in app
|
||||
|
||||
@property (strong, nonatomic) ViewController *main;
|
||||
|
||||
#pragma mark - Refrence to authentication web view in order to dismiss it
|
||||
|
||||
|
||||
@ -15,18 +15,8 @@
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
// Override point for customization after application launch.
|
||||
_dbClient = [[DropboxV2ObjC alloc] init];
|
||||
NSDictionary *credentials =
|
||||
[[NSURLCredentialStorage sharedCredentialStorage]
|
||||
credentialsForProtectionSpace:_dbClient.kDropboxProtectionSpace];
|
||||
NSURLCredential *credential = [credentials.objectEnumerator nextObject];
|
||||
_dbClient.token = credential.password;
|
||||
// Reset if user changed it
|
||||
[_dbClient setupDropboxWithHandler:^{
|
||||
}
|
||||
presenter:nil];
|
||||
[self setup];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@ -74,15 +64,16 @@
|
||||
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
|
||||
{
|
||||
// Display text
|
||||
[_dbClient authorizeUserWithToke:url
|
||||
completion:^(void) {
|
||||
[_smWebView.navigationController
|
||||
popViewControllerAnimated:YES];
|
||||
[_dbClient setupDropboxWithHandler:^{
|
||||
}
|
||||
presenter:_smMenu];
|
||||
}
|
||||
presenter:_smMenu];
|
||||
[_main.dbClient authorizeUserWithToke:url
|
||||
completion:^(void) {
|
||||
[_smWebView.navigationController
|
||||
popViewControllerAnimated:YES];
|
||||
[_main.dbClient
|
||||
setupDropboxWithHandler:^{
|
||||
}
|
||||
presenter:_smMenu];
|
||||
}
|
||||
presenter:_smMenu];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
@ -116,7 +115,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="MYC-QY-v42">
|
||||
<rect key="frame" x="73" y="72" width="176" height="30"/>
|
||||
<rect key="frame" x="72" y="72" width="176" height="30"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="30" id="2iN-qg-kf5"/>
|
||||
<constraint firstAttribute="width" constant="176" id="30a-wW-H5A"/>
|
||||
@ -127,9 +126,9 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fft-ba-oCA">
|
||||
<rect key="frame" x="112" y="224" width="97" height="30"/>
|
||||
<rect key="frame" x="107" y="224" width="107" height="30"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="97" id="1fV-Ks-aH1"/>
|
||||
<constraint firstAttribute="width" constant="107" id="1fV-Ks-aH1"/>
|
||||
<constraint firstAttribute="height" constant="30" id="WLI-4o-ris"/>
|
||||
</constraints>
|
||||
<state key="normal" title="Load NavData"/>
|
||||
@ -143,11 +142,11 @@
|
||||
<constraint firstItem="n9p-C2-IND" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="91" id="3OR-Oa-8cl"/>
|
||||
<constraint firstAttribute="trailing" secondItem="n9p-C2-IND" secondAttribute="trailing" constant="91" id="6nb-b2-JUb"/>
|
||||
<constraint firstItem="MYC-QY-v42" firstAttribute="top" secondItem="ggM-lD-yT2" secondAttribute="bottom" constant="8" id="7Aw-oA-8DT"/>
|
||||
<constraint firstAttribute="trailing" secondItem="fft-ba-oCA" secondAttribute="trailing" constant="111" id="8mU-OF-jU7"/>
|
||||
<constraint firstAttribute="trailing" secondItem="MYC-QY-v42" secondAttribute="trailing" constant="71" id="9o7-P0-T70"/>
|
||||
<constraint firstItem="MYC-QY-v42" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="73" id="Clk-jD-xRP"/>
|
||||
<constraint firstAttribute="trailing" secondItem="fft-ba-oCA" secondAttribute="trailing" constant="106" id="8mU-OF-jU7"/>
|
||||
<constraint firstAttribute="trailing" secondItem="MYC-QY-v42" secondAttribute="trailing" constant="72" id="9o7-P0-T70"/>
|
||||
<constraint firstItem="MYC-QY-v42" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="72" id="Clk-jD-xRP"/>
|
||||
<constraint firstItem="V5o-Hb-Mk0" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="73" id="ISQ-lm-JNH"/>
|
||||
<constraint firstItem="fft-ba-oCA" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="112" id="LEy-ig-Kbg"/>
|
||||
<constraint firstItem="fft-ba-oCA" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="107" id="LEy-ig-Kbg"/>
|
||||
<constraint firstItem="xba-tH-5D0" firstAttribute="top" secondItem="V5o-Hb-Mk0" secondAttribute="bottom" constant="8" id="UcB-x5-idK"/>
|
||||
<constraint firstItem="fft-ba-oCA" firstAttribute="top" secondItem="xba-tH-5D0" secondAttribute="bottom" constant="8" id="cfI-Sc-hrE"/>
|
||||
<constraint firstItem="n9p-C2-IND" firstAttribute="top" secondItem="MYC-QY-v42" secondAttribute="bottom" constant="8" id="fvc-m1-XMt"/>
|
||||
@ -842,7 +841,6 @@
|
||||
<constraint firstAttribute="trailing" secondItem="sro-Ep-8wL" secondAttribute="trailing" constant="10" id="1Th-Lj-0rz"/>
|
||||
<constraint firstAttribute="trailing" secondItem="mXy-bk-ceo" secondAttribute="trailing" constant="10" id="1Vv-tc-eER"/>
|
||||
<constraint firstItem="do1-lk-i4d" firstAttribute="height" secondItem="Loy-Fk-sOd" secondAttribute="height" id="1rI-kB-WIo"/>
|
||||
<constraint firstItem="Loy-Fk-sOd" firstAttribute="top" secondItem="2YN-Dg-9F2" secondAttribute="topMargin" constant="1" id="2AI-CS-ecI"/>
|
||||
<constraint firstItem="DKU-Ht-Zkn" firstAttribute="height" secondItem="Loy-Fk-sOd" secondAttribute="height" id="2E0-GI-3WL"/>
|
||||
<constraint firstItem="k64-uO-je8" firstAttribute="leading" secondItem="2YN-Dg-9F2" secondAttribute="leading" constant="10" id="2JU-4a-rdl"/>
|
||||
<constraint firstItem="BXf-ft-vHl" firstAttribute="height" secondItem="Loy-Fk-sOd" secondAttribute="height" id="2Yp-AR-BNB"/>
|
||||
@ -864,6 +862,7 @@
|
||||
<constraint firstItem="8LD-xq-b8N" firstAttribute="leading" secondItem="f2v-9B-nOm" secondAttribute="trailing" id="7ie-Gv-rWl"/>
|
||||
<constraint firstItem="LPI-AA-rrg" firstAttribute="height" secondItem="Loy-Fk-sOd" secondAttribute="height" id="7nh-EX-nEn"/>
|
||||
<constraint firstItem="5g4-VN-3D0" firstAttribute="leading" secondItem="2YN-Dg-9F2" secondAttribute="leading" constant="10" id="81d-Gh-AB9"/>
|
||||
<constraint firstItem="Loy-Fk-sOd" firstAttribute="top" secondItem="bgX-Bo-CkS" secondAttribute="bottom" constant="1" id="8Bq-II-XC6"/>
|
||||
<constraint firstItem="Sdv-Fw-LQq" firstAttribute="leading" secondItem="Z4K-ej-cbf" secondAttribute="trailing" id="8aa-6a-4Qb"/>
|
||||
<constraint firstItem="DKU-Ht-Zkn" firstAttribute="leading" secondItem="2YN-Dg-9F2" secondAttribute="leading" constant="1" id="8rF-0n-Wz1"/>
|
||||
<constraint firstItem="fxC-LW-Dp9" firstAttribute="height" secondItem="Loy-Fk-sOd" secondAttribute="height" id="93b-ex-ETS"/>
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
@property (strong, nonatomic) NSString *rootDirectory;
|
||||
@property (strong, nonatomic) NSData *kJSONNullObject;
|
||||
@property (strong, nonatomic) NSURLProtectionSpace *kDropboxProtectionSpace;
|
||||
@property (strong, nonatomic) NSError *dbError;
|
||||
|
||||
#pragma mark - Authorization methods
|
||||
|
||||
|
||||
25
FMC Planner 2/NavDataParser.h
Normal file
25
FMC Planner 2/NavDataParser.h
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// NavDataParser.h
|
||||
// FMC Planner 2
|
||||
//
|
||||
// Created by Kilian Hofmann on 13.04.16.
|
||||
// Copyright © 2016 Kilian Hofmann. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SharedDeclerations.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@interface NavDataParser : NSObject
|
||||
|
||||
@property (strong, nonatomic) NSMutableDictionary *intersections;
|
||||
@property (strong, nonatomic) NSMutableDictionary *navaids;
|
||||
@property (strong, nonatomic) NSMutableDictionary *airways;
|
||||
@property (nonatomic) BOOL parserReady;
|
||||
|
||||
#pragma mark - Search for elements in normal route entry
|
||||
|
||||
- (NSArray *)findWaypoint:(NSString *)waypoint;
|
||||
- (NSArray *)findAirway:(NSString *)airway;
|
||||
|
||||
@end
|
||||
168
FMC Planner 2/NavDataParser.m
Normal file
168
FMC Planner 2/NavDataParser.m
Normal file
@ -0,0 +1,168 @@
|
||||
//
|
||||
// NavDataParser.m
|
||||
// FMC Planner 2
|
||||
//
|
||||
// Created by Kilian Hofmann on 13.04.16.
|
||||
// Copyright © 2016 Kilian Hofmann. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NavDataParser.h"
|
||||
|
||||
@implementation NavDataParser
|
||||
|
||||
NSString *const Airways = @"NAVDATA/awys.txt";
|
||||
NSString *const Intersections = @"NAVDATA/ints.txt";
|
||||
NSString *const Navaids = @"NAVDATA/navs.txt";
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self.parserReady = false;
|
||||
// Load Navaids
|
||||
NSArray *temp = [[NSString
|
||||
stringWithContentsOfFile:[SharedDeclerations savePathForFile:Navaids]
|
||||
encoding:NSASCIIStringEncoding
|
||||
error:nil] componentsSeparatedByString:@"\r\n"];
|
||||
self.navaids = [[NSMutableDictionary alloc] init];
|
||||
for (NSString *str in temp) {
|
||||
if (str.length > 0 &&
|
||||
![[str substringToIndex:1] isEqualToString:@";"]) {
|
||||
if ([self.navaids objectForKey:[str substringToIndex:5]] != nil) {
|
||||
// Item exists, make array and set that.
|
||||
NSMutableArray *temp2 = [[NSMutableArray alloc] init];
|
||||
[temp2 addObject:[str substringFromIndex:10]];
|
||||
if ([[self.navaids objectForKey:[str substringToIndex:5]]
|
||||
isKindOfClass:[NSArray class]]) {
|
||||
[temp2 addObjectsFromArray:
|
||||
[self.navaids
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
else {
|
||||
[temp2
|
||||
addObject:[self.navaids
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
[self.navaids setValue:temp2 forKey:[str substringToIndex:5]];
|
||||
}
|
||||
else {
|
||||
[self.navaids setValue:[str substringFromIndex:10]
|
||||
forKey:[str substringToIndex:5]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load Intersections
|
||||
temp = [[NSString
|
||||
stringWithContentsOfFile:[SharedDeclerations
|
||||
savePathForFile:Intersections]
|
||||
encoding:NSASCIIStringEncoding
|
||||
error:nil] componentsSeparatedByString:@"\r\n"];
|
||||
self.intersections = [[NSMutableDictionary alloc] init];
|
||||
for (NSString *str in temp) {
|
||||
if (str.length > 0 &&
|
||||
![[str substringToIndex:1] isEqualToString:@";"]) {
|
||||
if ([self.intersections objectForKey:[str substringToIndex:5]] !=
|
||||
nil) {
|
||||
// Item exists, make array and set that.
|
||||
NSMutableArray *temp2 = [[NSMutableArray alloc] init];
|
||||
[temp2 addObject:[str substringFromIndex:10]];
|
||||
if ([[self.intersections objectForKey:[str substringToIndex:5]]
|
||||
isKindOfClass:[NSArray class]]) {
|
||||
[temp2 addObjectsFromArray:
|
||||
[self.intersections
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
else {
|
||||
[temp2
|
||||
addObject:[self.intersections
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
[self.intersections setValue:temp2
|
||||
forKey:[str substringToIndex:5]];
|
||||
}
|
||||
else {
|
||||
[self.intersections setValue:[str substringFromIndex:10]
|
||||
forKey:[str substringToIndex:5]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load Airways
|
||||
temp = [[NSString
|
||||
stringWithContentsOfFile:[SharedDeclerations savePathForFile:Airways]
|
||||
encoding:NSASCIIStringEncoding
|
||||
error:nil] componentsSeparatedByString:@"\r\n"];
|
||||
self.airways = [[NSMutableDictionary alloc] init];
|
||||
for (NSString *str in temp) {
|
||||
if (str.length > 0 &&
|
||||
![[str substringToIndex:1] isEqualToString:@";"]) {
|
||||
if ([self.airways objectForKey:[str substringToIndex:5]] != nil) {
|
||||
// Item exists, make array and set that.
|
||||
NSMutableArray *temp2 = [[NSMutableArray alloc] init];
|
||||
[temp2 addObject:[str substringFromIndex:10]];
|
||||
if ([[self.airways objectForKey:[str substringToIndex:5]]
|
||||
isKindOfClass:[NSArray class]]) {
|
||||
[temp2 addObjectsFromArray:
|
||||
[self.airways
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
else {
|
||||
[temp2
|
||||
addObject:[self.airways
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
[self.airways setValue:temp2 forKey:[str substringToIndex:5]];
|
||||
}
|
||||
else {
|
||||
[self.airways setValue:[str substringFromIndex:10]
|
||||
forKey:[str substringToIndex:5]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.parserReady = true;
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Search for elements in normal route entry
|
||||
|
||||
- (NSArray *)findAirway:(NSString *)airway
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the given waypoint in both files, returns Array so user can select
|
||||
* @param waypoint
|
||||
*/
|
||||
- (NSArray *)findWaypoint:(NSString *)waypoint
|
||||
{
|
||||
NSMutableArray *array = [[NSMutableArray alloc] init];
|
||||
for (int i = (int)waypoint.length; i < 5; i++) {
|
||||
waypoint = [waypoint stringByAppendingString:@" "];
|
||||
}
|
||||
|
||||
id navaids = [_navaids objectForKey:waypoint];
|
||||
id intersections = [_intersections objectForKey:waypoint];
|
||||
|
||||
if (navaids != nil) {
|
||||
if ([navaids isKindOfClass:[NSArray class]]) {
|
||||
[array addObjectsFromArray:navaids];
|
||||
}
|
||||
else {
|
||||
[array addObject:navaids];
|
||||
}
|
||||
}
|
||||
|
||||
if (intersections != nil) {
|
||||
if ([intersections isKindOfClass:[NSArray class]]) {
|
||||
[array addObjectsFromArray:intersections];
|
||||
}
|
||||
else {
|
||||
[array addObject:intersections];
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -14,6 +14,14 @@
|
||||
|
||||
extern NSString *const FMCNEXTRTEPAGE;
|
||||
extern NSString *const FMCFIRSTRTEPAGE;
|
||||
|
||||
#pragma mark - FMC Error messages
|
||||
|
||||
extern NSString *const INVALID;
|
||||
extern NSString *const NOTREADY;
|
||||
|
||||
#pragma mark - Dropbox constants
|
||||
|
||||
extern NSString *const DropboxErrorDomain;
|
||||
extern NSString *const DropboxErrorUserInfo;
|
||||
|
||||
|
||||
@ -12,6 +12,10 @@
|
||||
|
||||
NSString *const FMCNEXTRTEPAGE = @"NEXTRTEPAGE";
|
||||
NSString *const FMCFIRSTRTEPAGE = @"FIRSTRTEPAGE";
|
||||
|
||||
NSString *const INVALID = @"INVALID ENTRY";
|
||||
NSString *const NOTREADY = @"NAV DATA NOT READY";
|
||||
|
||||
NSString *const DropboxErrorDomain = @"com.weebly.alikja.FMC";
|
||||
NSString *const DropboxErrorUserInfo = @"error_summary";
|
||||
|
||||
@ -75,27 +79,29 @@ NSString *const DropboxErrorUserInfo = @"error_summary";
|
||||
+ (void)presentErrorAlert:(NSError *)error
|
||||
presenter:(UIViewController *)presenter
|
||||
{
|
||||
if ([UIAlertController class]) {
|
||||
UIAlertController *alert = [UIAlertController
|
||||
alertControllerWithTitle:@"Error"
|
||||
message:error.localizedDescription
|
||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
UIAlertAction *defaultAction =
|
||||
[UIAlertAction actionWithTitle:@"OK"
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:nil];
|
||||
[alert addAction:defaultAction];
|
||||
if (presenter != nil) {
|
||||
if ([UIAlertController class]) {
|
||||
UIAlertController *alert = [UIAlertController
|
||||
alertControllerWithTitle:@"Error"
|
||||
message:error.localizedDescription
|
||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
UIAlertAction *defaultAction =
|
||||
[UIAlertAction actionWithTitle:@"OK"
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:nil];
|
||||
[alert addAction:defaultAction];
|
||||
|
||||
[presenter presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
else {
|
||||
UIAlertView *alert =
|
||||
[[UIAlertView alloc] initWithTitle:@"Error"
|
||||
message:error.localizedDescription
|
||||
delegate:nil
|
||||
cancelButtonTitle:@"Cancel"
|
||||
otherButtonTitles:nil];
|
||||
[alert show];
|
||||
[presenter presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
else {
|
||||
UIAlertView *alert =
|
||||
[[UIAlertView alloc] initWithTitle:@"Error"
|
||||
message:error.localizedDescription
|
||||
delegate:nil
|
||||
cancelButtonTitle:@"Cancel"
|
||||
otherButtonTitles:nil];
|
||||
[alert show];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,10 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class ViewControllerServiceMenu;
|
||||
@interface TableViewController : UITableViewController <SWTableViewCellDelegate>
|
||||
@interface TableViewController
|
||||
: UITableViewController <SWTableViewCellDelegate> {
|
||||
DropboxV2ObjC *dbClient;
|
||||
}
|
||||
|
||||
#pragma mark - Refrence to other views in app
|
||||
|
||||
|
||||
@ -10,8 +10,6 @@
|
||||
|
||||
@implementation TableViewController
|
||||
|
||||
DropboxV2ObjC *dbClient = nil;
|
||||
|
||||
#pragma mark - View management and navigation
|
||||
|
||||
- (void)viewDidLoad
|
||||
@ -26,8 +24,7 @@ DropboxV2ObjC *dbClient = nil;
|
||||
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
||||
self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
||||
_markList = [[NSMutableArray alloc] init];
|
||||
dbClient =
|
||||
((AppDelegate *)[UIApplication sharedApplication].delegate).dbClient;
|
||||
dbClient = _main.dbClient;
|
||||
|
||||
if ([self.title isEqualToString:@"Manage"] ||
|
||||
[self.title isEqualToString:@"Upload"]) {
|
||||
@ -46,19 +43,20 @@ DropboxV2ObjC *dbClient = nil;
|
||||
contentsOfPath:@"SAVES"
|
||||
completion:^(NSArray *data) {
|
||||
NSMutableArray *temp = [[NSMutableArray alloc] init];
|
||||
if (data != nil) {
|
||||
for (NSDictionary *dict in data) {
|
||||
[temp addObject:[dict valueForKey:@"name"]];
|
||||
}
|
||||
|
||||
for (NSDictionary *dict in data) {
|
||||
[temp addObject:[dict valueForKey:@"name"]];
|
||||
_dataSource = [[temp
|
||||
filteredArrayUsingPredicate:
|
||||
[NSPredicate predicateWithFormat:
|
||||
@"NOT (SELF BEGINSWITH %@)",
|
||||
@"."]] mutableCopy];
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
[self.tableView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
_dataSource = [[temp
|
||||
filteredArrayUsingPredicate:
|
||||
[NSPredicate
|
||||
predicateWithFormat:@"NOT (SELF BEGINSWITH %@)",
|
||||
@"."]] mutableCopy];
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
[self.tableView reloadData];
|
||||
}];
|
||||
}
|
||||
presenter:self];
|
||||
}
|
||||
@ -112,13 +110,17 @@ DropboxV2ObjC *dbClient = nil;
|
||||
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if ([self.title isEqualToString:@"Manage"]) {
|
||||
[self dismissViewControllerAnimated:YES
|
||||
completion:^(void) {
|
||||
[_main loadSave:[tableView
|
||||
cellForRowAtIndexPath:
|
||||
indexPath]
|
||||
.textLabel.text];
|
||||
}];
|
||||
[self
|
||||
dismissViewControllerAnimated:YES
|
||||
completion:^(void) {
|
||||
[_main loadSave:
|
||||
[@"SAVES/"
|
||||
stringByAppendingString:
|
||||
[tableView
|
||||
cellForRowAtIndexPath:
|
||||
indexPath]
|
||||
.textLabel.text]];
|
||||
}];
|
||||
}
|
||||
else {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
@ -262,7 +264,10 @@ DropboxV2ObjC *dbClient = nil;
|
||||
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
|
||||
[[NSFileManager defaultManager]
|
||||
removeItemAtPath:[SharedDeclerations
|
||||
savePathForFile:_dataSource[indexPath.row]]
|
||||
savePathForFile:[@"SAVES/"
|
||||
stringByAppendingString:
|
||||
_dataSource[indexPath
|
||||
.row]]]
|
||||
error:nil];
|
||||
[_dataSource removeObjectAtIndex:indexPath.row];
|
||||
[self.tableView deleteRowsAtIndexPaths:@[ indexPath ]
|
||||
|
||||
@ -14,6 +14,14 @@
|
||||
|
||||
@interface ViewController : UIViewController <UIAlertViewDelegate>
|
||||
|
||||
#pragma mark - Shared nav data parser
|
||||
|
||||
@property (strong, nonatomic) NavDataParser *navDataParser;
|
||||
|
||||
#pragma mark - Shared Dropbox client
|
||||
/// Shared Dropbox client
|
||||
@property (strong, nonatomic) DropboxV2ObjC *dbClient;
|
||||
|
||||
#pragma mark - Refrence to other views in app
|
||||
|
||||
@property (strong, nonatomic) ViewControllerScreen *screen;
|
||||
|
||||
@ -25,6 +25,23 @@
|
||||
_save = [[NSMutableDictionary alloc] init];
|
||||
_firstLoad = true;
|
||||
self.title = @"FMC";
|
||||
|
||||
// Override point for customization after application launch._dbClient =
|
||||
// [[DropboxV2ObjC alloc] init];
|
||||
NSDictionary *credentials =
|
||||
[[NSURLCredentialStorage sharedCredentialStorage]
|
||||
credentialsForProtectionSpace:_dbClient.kDropboxProtectionSpace];
|
||||
NSURLCredential *credential = [credentials.objectEnumerator nextObject];
|
||||
_dbClient.token = credential.password;
|
||||
// Reset if user changed it
|
||||
[_dbClient setupDropboxWithHandler:^{
|
||||
}
|
||||
presenter:self];
|
||||
|
||||
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
|
||||
[queue addOperationWithBlock:^{
|
||||
_navDataParser = [[NavDataParser alloc] init];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
|
||||
@ -44,8 +61,12 @@
|
||||
|
||||
- (void)saveToFile:(NSDictionary *)save
|
||||
{
|
||||
NSString *file =
|
||||
[SharedDeclerations savePathForFile:[_save valueForKey:@"MENU@LSKR1"]];
|
||||
NSString *file = [[NSString alloc] init];
|
||||
if ([_save valueForKey:@"MENU@LSKR1"] != nil) {
|
||||
file = [SharedDeclerations
|
||||
savePathForFile:[@"SAVES/" stringByAppendingString:
|
||||
[_save valueForKey:@"MENU@LSKR1"]]];
|
||||
}
|
||||
if (_firstLoad) {
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:file]) {
|
||||
[self alertViewiOS7:file];
|
||||
@ -79,7 +100,8 @@
|
||||
clickedButtonAtIndex:(NSInteger)buttonIndex
|
||||
{
|
||||
if (buttonIndex == 1) {
|
||||
[self loadSave:[_save valueForKey:@"MENU@LSKR1"]];
|
||||
[self loadSave:[@"SAVES/" stringByAppendingString:
|
||||
[_save valueForKey:@"MENU@LSKR1"]]];
|
||||
}
|
||||
else if (buttonIndex == 2) {
|
||||
[_save
|
||||
|
||||
@ -110,7 +110,9 @@
|
||||
[_main.screen.Scratchpad.text stringByAppendingString:@" "];
|
||||
}
|
||||
else if ([sender.restorationIdentifier isEqualToString:@"Clear"]) {
|
||||
if ([_main.screen.Scratchpad.text isEqualToString:@"DELETE"]) {
|
||||
if ([_main.screen.Scratchpad.text isEqualToString:@"DELETE"] ||
|
||||
[_main.screen.Scratchpad.text isEqualToString:INVALID] ||
|
||||
[_main.screen.Scratchpad.text isEqualToString:NOTREADY]) {
|
||||
_main.screen.Scratchpad.text = @"";
|
||||
}
|
||||
else if (_main.screen.Scratchpad.text.length > 0) {
|
||||
@ -139,7 +141,8 @@
|
||||
}
|
||||
else {
|
||||
_main.screen.Scratchpad.text = [_main.screen.Scratchpad.text
|
||||
stringByAppendingString:sender.titleLabel.text];
|
||||
stringByAppendingString:[sender
|
||||
titleForState:UIControlStateNormal]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
// Copyright © 2016 Kilian Hofmann. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NavDataParser.h"
|
||||
#import "SharedDeclerations.h"
|
||||
#import "ViewController.h"
|
||||
#import "ViewControllerServiceMenu.h"
|
||||
|
||||
@ -11,6 +11,8 @@
|
||||
|
||||
@implementation ViewControllerScreen
|
||||
|
||||
NavDataParser *parser = nil;
|
||||
|
||||
#pragma mark - View management and navigation
|
||||
|
||||
- (void)viewDidLoad
|
||||
@ -37,6 +39,8 @@
|
||||
reg.numberOfTouchesRequired = 1;
|
||||
[label addGestureRecognizer:reg];
|
||||
}
|
||||
|
||||
parser = _main.navDataParser;
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
@ -71,8 +75,13 @@
|
||||
|
||||
- (void)enterLSK:(UITapGestureRecognizer *)tapReg
|
||||
{
|
||||
if ([_Scratchpad.text isEqualToString:@"DELETE"]) {
|
||||
if ([_Scratchpad.text isEqualToString:INVALID] ||
|
||||
[_Scratchpad.text isEqualToString:NOTREADY]) {
|
||||
// DO NOTHING AS OF YET
|
||||
}
|
||||
else if ([_Scratchpad.text isEqualToString:@"DELETE"]) {
|
||||
((UILabel *)tapReg.view).text = @"";
|
||||
_Scratchpad.text = @"";
|
||||
}
|
||||
else if ([_Header.text isEqualToString:@"MENU"]) {
|
||||
if ([((UILabel *)tapReg.view)
|
||||
@ -86,6 +95,7 @@
|
||||
}
|
||||
_main.backupCoRte = ((UILabel *)tapReg.view).text;
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
_Scratchpad.text = @"";
|
||||
}
|
||||
else if ([((UILabel *)tapReg.view)
|
||||
.restorationIdentifier isEqualToString:@"LSKR4"]) {
|
||||
@ -122,33 +132,52 @@
|
||||
}
|
||||
else {
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
_Scratchpad.text = @"";
|
||||
}
|
||||
}
|
||||
else if ([[_Header.text substringToIndex:3] isEqualToString:@"ROU"]) {
|
||||
|
||||
#warning TEST BED for NOW
|
||||
if (parser.parserReady) {
|
||||
NSArray *finds = [parser findWaypoint:_Scratchpad.text];
|
||||
|
||||
if (finds.count != 0) {
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
_Scratchpad.text = @"";
|
||||
}
|
||||
else {
|
||||
_Scratchpad.text = INVALID;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_Scratchpad.text = NOTREADY;
|
||||
}
|
||||
if ([((UILabel *)tapReg.view)
|
||||
.restorationIdentifier isEqualToString:@"LSKR6"] &&
|
||||
_numRoutePage == _maxNumRoutePages) {
|
||||
_maxNumRoutePages += 1;
|
||||
NSRange indexSlash = [_Header.text rangeOfString:@"/"];
|
||||
_Header.text = [_Header.text
|
||||
stringByReplacingCharactersInRange:NSMakeRange(
|
||||
indexSlash.location,
|
||||
_Header.text.length -
|
||||
indexSlash.location)
|
||||
withString:
|
||||
[NSString
|
||||
stringWithFormat:
|
||||
@"/%lu",
|
||||
(unsigned long)
|
||||
_maxNumRoutePages]];
|
||||
}
|
||||
}
|
||||
else {
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
}
|
||||
if ([((UILabel *)tapReg.view)
|
||||
.restorationIdentifier isEqualToString:@"LSKR6"] &&
|
||||
_numRoutePage == _maxNumRoutePages &&
|
||||
[[_Header.text substringToIndex:3] isEqualToString:@"ROU"]) {
|
||||
_maxNumRoutePages += 1;
|
||||
NSRange indexSlash = [_Header.text rangeOfString:@"/"];
|
||||
_Header.text = [_Header.text
|
||||
stringByReplacingCharactersInRange:NSMakeRange(
|
||||
indexSlash.location,
|
||||
_Header.text.length -
|
||||
indexSlash.location)
|
||||
withString:[NSString
|
||||
stringWithFormat:
|
||||
@"/%lu",
|
||||
(unsigned long)
|
||||
_maxNumRoutePages]];
|
||||
_Scratchpad.text = @"";
|
||||
}
|
||||
(_main.save)[[NSString
|
||||
stringWithFormat:@"%@@%@", _Header.text,
|
||||
((UILabel *)tapReg.view).restorationIdentifier]] =
|
||||
((UILabel *)tapReg.view).text;
|
||||
_Scratchpad.text = @"";
|
||||
[_main saveToFile:_main.save];
|
||||
}
|
||||
|
||||
|
||||
@ -13,7 +13,9 @@
|
||||
#import "ViewController.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface ViewControllerServiceMenu : UIViewController <UIAlertViewDelegate>
|
||||
@interface ViewControllerServiceMenu : UIViewController <UIAlertViewDelegate> {
|
||||
DropboxV2ObjC *dbClient;
|
||||
}
|
||||
|
||||
#pragma mark - Refrence to other views in app
|
||||
|
||||
|
||||
@ -20,13 +20,12 @@
|
||||
style:UIBarButtonItemStyleDone
|
||||
target:self
|
||||
action:@selector(back)];
|
||||
dbClient = _main.dbClient;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
DropboxV2ObjC *dbClient =
|
||||
((AppDelegate *)[UIApplication sharedApplication].delegate).dbClient;
|
||||
if (dbClient.token != nil) {
|
||||
[_dbConnectButton setTitle:@"Disconnect from Dropbox"
|
||||
forState:UIControlStateNormal];
|
||||
@ -97,8 +96,6 @@
|
||||
// Dynamically set and unset
|
||||
- (IBAction)dbDisconnect:(UIButton *)sender
|
||||
{
|
||||
DropboxV2ObjC *dbClient =
|
||||
((AppDelegate *)[UIApplication sharedApplication].delegate).dbClient;
|
||||
[dbClient deauthorizeUserWithPresenter:self];
|
||||
[_dbConnectButton setTitle:@"Connect to Dropbox"
|
||||
forState:UIControlStateNormal];
|
||||
@ -122,9 +119,6 @@
|
||||
_dbNavData.alpha = 0.5;
|
||||
_main.navDataActive = true;
|
||||
[queue addOperationWithBlock:^{
|
||||
DropboxV2ObjC *dbClient =
|
||||
((AppDelegate *)[UIApplication sharedApplication].delegate)
|
||||
.dbClient;
|
||||
[dbClient
|
||||
contentsOfPath:@"NAVDATA"
|
||||
completion:^(NSArray *files) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user