diff --git a/.gitignore b/.gitignore index ec839c0..34c6c44 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,12 @@ # Xcode # +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated build/ +DerivedData/ + +## Various settings *.pbxuser !default.pbxuser *.mode1v3 @@ -9,10 +15,19 @@ build/ !default.mode2v3 *.perspectivev3 !default.perspectivev3 -xcuserdata -*.xccheckout +xcuserdata/* +*.xcuserdatad + +## Other *.moved-aside -DerivedData -*.hmap -*.ipa -*.xcuserstate +*.xccheckout +*.xcscmblueprint + +## SJT - do we need this still, given above lines? +# *.xcuserstate + +## Cocoapods +Pods + +## Subversion +.svn \ No newline at end of file diff --git a/ObjectiveWMM.xcodeproj/project.pbxproj b/ObjectiveWMM.xcodeproj/project.pbxproj index 40504c4..c1743fa 100644 --- a/ObjectiveWMM.xcodeproj/project.pbxproj +++ b/ObjectiveWMM.xcodeproj/project.pbxproj @@ -217,7 +217,7 @@ DC71D8C8197E067F00C665CB /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0600; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = "Crookneck Consulting LLC"; TargetAttributes = { DC71D8D0197E067F00C665CB = { @@ -226,6 +226,7 @@ }; DC71D8DB197E067F00C665CB = { CreatedOnToolsVersion = 6.0; + DevelopmentTeam = RMH7P6Q49N; }; }; }; @@ -305,21 +306,33 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -332,7 +345,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; METAL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -350,13 +363,23 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; @@ -365,13 +388,14 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; METAL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -384,22 +408,21 @@ DC71D8E8197E067F00C665CB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/ObjectiveWMM", - ); + FRAMEWORK_SEARCH_PATHS = ""; INFOPLIST_FILE = "$(SRCROOT)/ObjectiveWMM/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACH_O_TYPE = mh_dylib; ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = "com.crookneckconsulting.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = ObjectiveWMM; PROVISIONING_PROFILE = ""; SKIP_INSTALL = YES; @@ -409,22 +432,20 @@ DC71D8E9197E067F00C665CB /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/ObjectiveWMM", - ); + FRAMEWORK_SEARCH_PATHS = ""; INFOPLIST_FILE = "$(SRCROOT)/ObjectiveWMM/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACH_O_TYPE = mh_dylib; ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = "com.crookneckconsulting.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = ObjectiveWMM; PROVISIONING_PROFILE = ""; SKIP_INSTALL = YES; @@ -434,6 +455,7 @@ DC71D8EB197E067F00C665CB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + DEVELOPMENT_TEAM = RMH7P6Q49N; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", @@ -445,6 +467,7 @@ INFOPLIST_FILE = ObjectiveWMMTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; METAL_ENABLE_DEBUG_INFO = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.crookneckconsulting.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = ObjectiveWMMTests; }; name = Debug; @@ -452,6 +475,7 @@ DC71D8EC197E067F00C665CB /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + DEVELOPMENT_TEAM = RMH7P6Q49N; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", @@ -459,6 +483,7 @@ INFOPLIST_FILE = ObjectiveWMMTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; METAL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "com.crookneckconsulting.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = ObjectiveWMMTests; }; name = Release; diff --git a/ObjectiveWMM.xcodeproj/xcuserdata/stephen.xcuserdatad/xcschemes/xcschememanagement.plist b/ObjectiveWMM.xcodeproj/xcuserdata/stephen.xcuserdatad/xcschemes/xcschememanagement.plist index 3304ad5..922586a 100644 --- a/ObjectiveWMM.xcodeproj/xcuserdata/stephen.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/ObjectiveWMM.xcodeproj/xcuserdata/stephen.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ ObjectiveWMM.xcscheme orderHint - 0 + 2 SuppressBuildableAutocreation diff --git a/ObjectiveWMM/CCMagneticDeclination.h b/ObjectiveWMM/CCMagneticDeclination.h index a2eed41..7096d4e 100644 --- a/ObjectiveWMM/CCMagneticDeclination.h +++ b/ObjectiveWMM/CCMagneticDeclination.h @@ -11,12 +11,13 @@ @interface CCMagneticDeclination : NSObject -- (id) initWithCoordinate:(CLLocationCoordinate2D)coordinate elevation:(CLLocationDistance)elevation date:(NSDate *)date magneticDeclination:(CLLocationDirection)magneticDeclination; +- (id) initWithCoordinate:(CLLocationCoordinate2D)coordinate elevation:(CLLocationDistance)elevation date:(NSDate *)date magneticDeclination:(CLLocationDirection)magneticDeclination fieldStrength:(double)fieldStrength; @property (readonly, nonatomic) CLLocationCoordinate2D coordinate; @property (readonly, nonatomic) CLLocationDistance elevation; @property (readonly, nonatomic, strong) NSDate *date; @property (readonly, nonatomic) CLLocationDirection magneticDeclination; +@property (readonly, nonatomic) double fieldStrength; // in μT - (CLLocationDirection) trueHeadingFromMagneticHeading:(CLLocationDirection)magneticHeading; - (CLLocationDirection) magneticHeadingFromTrueHeading:(CLLocationDirection)trueHeading; diff --git a/ObjectiveWMM/CCMagneticDeclination.m b/ObjectiveWMM/CCMagneticDeclination.m index 3010455..64344f5 100644 --- a/ObjectiveWMM/CCMagneticDeclination.m +++ b/ObjectiveWMM/CCMagneticDeclination.m @@ -18,29 +18,38 @@ @interface CCMagneticDeclination() @property (readwrite, nonatomic) CLLocationDistance elevation; @property (readwrite, nonatomic, strong) NSDate *date; @property (readwrite, nonatomic) CLLocationDirection magneticDeclination; +@property (readwrite, nonatomic) double fieldStrength; @end @implementation CCMagneticDeclination -- (id) initWithCoordinate:(CLLocationCoordinate2D)coordinate elevation:(CLLocationDistance)elevation date:(NSDate *)date magneticDeclination:(CLLocationDirection)magneticDeclination { +- (id) initWithCoordinate:(CLLocationCoordinate2D)coordinate elevation:(CLLocationDistance)elevation date:(NSDate *)date magneticDeclination:(CLLocationDirection)magneticDeclination fieldStrength:(double)fieldStrength { self = [super init]; if (self) { - self.coordinate = coordinate; - self.elevation = elevation; - self.date = date; - self.magneticDeclination = magneticDeclination; + _coordinate = coordinate; + _elevation = elevation; + _date = date; + _magneticDeclination = magneticDeclination; + _fieldStrength = fieldStrength; } return self; } +- (NSString *) description { + + NSString *desc = [NSString stringWithFormat:@"%1.3f°,%1.3f° / %1.2fm at %@: decl: %1.2f° F: %1.2fμT", self.coordinate.latitude, self.coordinate.longitude, self.elevation, self.date.description, self.magneticDeclination, self.fieldStrength]; + + return desc; +} + #pragma mark - NSCopying - (id)copyWithZone:(NSZone *)zone { - CCMagneticDeclination *magneticDeclination = [[CCMagneticDeclination allocWithZone:zone] initWithCoordinate:self.coordinate elevation:self.elevation date:self.date magneticDeclination:self.magneticDeclination]; + CCMagneticDeclination *magneticDeclination = [[CCMagneticDeclination allocWithZone:zone] initWithCoordinate:self.coordinate elevation:self.elevation date:self.date magneticDeclination:self.magneticDeclination fieldStrength:self.fieldStrength]; return magneticDeclination; } @@ -53,8 +62,9 @@ - (id)initWithCoder:(NSCoder *)aDecoder { CLLocationDistance elevation = [aDecoder decodeDoubleForKey:@"elevation"]; NSDate *date = [aDecoder decodeObjectForKey:@"date"]; CLLocationDirection magneticDeclination = [aDecoder decodeDoubleForKey:@"magneticDeclination"]; + double fieldStrength = [aDecoder decodeDoubleForKey:@"fieldStrength"]; - self = [self initWithCoordinate:coord elevation:elevation date:date magneticDeclination:magneticDeclination]; + self = [self initWithCoordinate:coord elevation:elevation date:date magneticDeclination:magneticDeclination fieldStrength:fieldStrength]; if (!self) { return nil; } @@ -69,6 +79,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeDouble:self.elevation forKey:@"elevation"]; [aCoder encodeObject:self.date forKey:@"date"]; [aCoder encodeDouble:self.magneticDeclination forKey:@"magneticDeclination"]; + [aCoder encodeDouble:self.fieldStrength forKey:@"fieldStrength"]; } #pragma mark - Public diff --git a/ObjectiveWMM/CCMagneticModel.m b/ObjectiveWMM/CCMagneticModel.m index f6d85be..37ab591 100644 --- a/ObjectiveWMM/CCMagneticModel.m +++ b/ObjectiveWMM/CCMagneticModel.m @@ -64,10 +64,7 @@ - (id) init { int epochs = 1; int numTerms, nMax = 0; - NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.crookneckconsulting.ObjectiveWMM"]; - NSString *path = [bundle pathForResource:@"WMM" ofType:@"COF"]; - - char *filename = (char *) [path cStringUsingEncoding:NSUTF8StringEncoding]; + char *filename = (char *) getPathForResource("WMM", "COF"); MAG_robustReadMagModels(filename, &_magneticModels, epochs); @@ -139,7 +136,7 @@ - (CCMagneticDeclination *) declinationForCoordinate:(CLLocationCoordinate2D)coo MAG_CalculateGridVariation(coordGeodetic, &geoMagneticElements); - CCMagneticDeclination *result = [[CCMagneticDeclination alloc] initWithCoordinate:coordinate elevation:elevation date:date magneticDeclination:geoMagneticElements.Decl]; + CCMagneticDeclination *result = [[CCMagneticDeclination alloc] initWithCoordinate:coordinate elevation:elevation date:date magneticDeclination:geoMagneticElements.Decl fieldStrength:geoMagneticElements.F/1000.0]; return result; } diff --git a/ObjectiveWMM/Info.plist b/ObjectiveWMM/Info.plist index 2b1cc0f..778f82f 100644 --- a/ObjectiveWMM/Info.plist +++ b/ObjectiveWMM/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.crookneckconsulting.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/ObjectiveWMM/WMM/GeomagnetismLibrary.c b/ObjectiveWMM/WMM/GeomagnetismLibrary.c index de9d6f3..0e8536d 100644 --- a/ObjectiveWMM/WMM/GeomagnetismLibrary.c +++ b/ObjectiveWMM/WMM/GeomagnetismLibrary.c @@ -1208,7 +1208,7 @@ CALLS: MAG_DMSstringToDegree(buffer, &CoordGeodetic->lambda); (The program uses sscanf(buffer, "%d/%d/%d", &MagneticDate->Month, &MagneticDate->Day, &MagneticDate->Year); if(!MAG_DateToYear(MagneticDate, Error_Message)) { - printf(Error_Message); + printf("%s", Error_Message); printf("\nPlease re-enter Date in MM/DD/YYYY or MM DD YYYY format, or as a decimal year\n"); fgets(buffer, 40, stdin); i = 0; @@ -1232,7 +1232,7 @@ CALLS: MAG_DMSstringToDegree(buffer, &CoordGeodetic->lambda); (The program uses { if(!MAG_DateToYear(MagneticDate, Error_Message)) { - printf(Error_Message); + printf("%s", Error_Message); strcpy(buffer, ""); printf("\nError encountered, please re-enter Date in MM/DD/YYYY or MM DD YYYY format, or as a decimal year\n"); fgets(buffer, 40, stdin); @@ -1660,19 +1660,19 @@ CALLS : none if(!LegendreFunction) { MAG_Error(1); - return FALSE; + return (MAGtype_LegendreFunction *) FALSE; } LegendreFunction->Pcup = (double *) malloc((NumTerms + 1) * sizeof ( double)); if(LegendreFunction->Pcup == 0) { MAG_Error(1); - return FALSE; + return (MAGtype_LegendreFunction *) FALSE; } LegendreFunction->dPcup = (double *) malloc((NumTerms + 1) * sizeof ( double)); if(LegendreFunction->dPcup == 0) { MAG_Error(1); - return FALSE; + return (MAGtype_LegendreFunction *) FALSE; } return LegendreFunction; } /*MAGtype_LegendreFunction*/ @@ -1710,7 +1710,7 @@ CALLS : none if(MagneticModel == NULL) { MAG_Error(2); - return FALSE; + return (MAGtype_MagneticModel *) FALSE; } MagneticModel->Main_Field_Coeff_G = (double *) malloc((NumTerms + 1) * sizeof ( double)); @@ -1718,7 +1718,7 @@ CALLS : none if(MagneticModel->Main_Field_Coeff_G == NULL) { MAG_Error(2); - return FALSE; + return (MAGtype_MagneticModel *) FALSE; } MagneticModel->Main_Field_Coeff_H = (double *) malloc((NumTerms + 1) * sizeof ( double)); @@ -1726,19 +1726,19 @@ CALLS : none if(MagneticModel->Main_Field_Coeff_H == NULL) { MAG_Error(2); - return FALSE; + return (MAGtype_MagneticModel *) FALSE; } MagneticModel->Secular_Var_Coeff_G = (double *) malloc((NumTerms + 1) * sizeof ( double)); if(MagneticModel->Secular_Var_Coeff_G == NULL) { MAG_Error(2); - return FALSE; + return (MAGtype_MagneticModel *) FALSE; } MagneticModel->Secular_Var_Coeff_H = (double *) malloc((NumTerms + 1) * sizeof ( double)); if(MagneticModel->Secular_Var_Coeff_H == NULL) { MAG_Error(2); - return FALSE; + return (MAGtype_MagneticModel *) FALSE; } MagneticModel->CoefficientFileEndDate = 0; MagneticModel->EditionDate = 0; diff --git a/ObjectiveWMMTests/Info.plist b/ObjectiveWMMTests/Info.plist index 4ee8cde..dd37a8e 100644 --- a/ObjectiveWMMTests/Info.plist +++ b/ObjectiveWMMTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.crookneckconsulting.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName