Skip to content

Commit

Permalink
Merge pull request stephent#14 from stephent/development/WMM2015
Browse files Browse the repository at this point in the history
Development/wmm2015
  • Loading branch information
stephent committed Nov 17, 2015
2 parents d965df8 + 260a1e2 commit e6c676d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
15 changes: 10 additions & 5 deletions ObjectiveWMM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
DC71D8C8197E067F00C665CB /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
LastUpgradeCheck = 0710;
ORGANIZATIONNAME = "Crookneck Consulting LLC";
TargetAttributes = {
DC71D8D0197E067F00C665CB = {
Expand Down Expand Up @@ -318,6 +318,7 @@
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_OPTIMIZATION_LEVEL = 0;
Expand All @@ -332,7 +333,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 = 8.1;
METAL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -371,7 +372,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 = 8.1;
METAL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -396,10 +397,11 @@
);
INFOPLIST_FILE = "$(SRCROOT)/ObjectiveWMM/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACH_O_TYPE = mh_dylib;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.crookneckconsulting.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = ObjectiveWMM;
PROVISIONING_PROFILE = "";
SKIP_INSTALL = YES;
Expand All @@ -421,10 +423,11 @@
);
INFOPLIST_FILE = "$(SRCROOT)/ObjectiveWMM/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACH_O_TYPE = mh_dylib;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.crookneckconsulting.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = ObjectiveWMM;
PROVISIONING_PROFILE = "";
SKIP_INSTALL = YES;
Expand All @@ -445,6 +448,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;
Expand All @@ -459,6 +463,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;
Expand Down
3 changes: 2 additions & 1 deletion ObjectiveWMM/CCMagneticDeclination.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

@interface CCMagneticDeclination : NSObject <NSCopying, NSCoding>

- (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;
Expand Down
25 changes: 18 additions & 7 deletions ObjectiveWMM/CCMagneticDeclination.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveWMM/CCMagneticModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,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;
}
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveWMM/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.crookneckconsulting.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
4 changes: 2 additions & 2 deletions ObjectiveWMM/WMM/GeomagnetismLibrary.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveWMMTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.crookneckconsulting.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down

0 comments on commit e6c676d

Please sign in to comment.