This is the essence of what I attempting: a way to change sign to negative for the southern hemisphere, see commented code at bottom. Obviously, I'm just learning Cocoa/ObjC.
The lat/lon are in an SQLite database.
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *stringLat1 = @"N37-21.2"; //string: sample latitude from database
NSString *hemi = [stringLat1 substringWithRange:NSMakeRange( 0, 1) ]; // string: Hemisphere
NSString *degLat1 = [stringLat1 substringWithRange:NSMakeRange( 1, 2) ]; // string: degree of latitude
NSString *minLat1 = [stringLat1 substringWithRange:NSMakeRange( 4, 4) ]; // string: minute of latitude
float intMinLat1 = [minLat1 floatValue]/60; // int: minute of latitude
float intDegLat1 = [degLat1 floatValue]; //int: degree of latitude
float intPt1 = intMinLat1 + intDegLat1; // int: complete latitude
float point1Lat;
point1Lat = intPt1; /* the completed latitude (37.353333) for the northern hemisphere, a positive number vice a negative number for the southern hemi. */
NSLog(@"Pt1 hemisphere is %@, lat is %@ degrees, lon is %@ minutes, a %f decimal value. The point1Lat is %f",hemi,degLat1, minLat1, intMinLat1, point1Lat);
[pool drain];
return 0;
}
/*
if (hemi == @"N")
{
point1Lat = intPt1;
}
else if (hemi == @"S")
{
point1Lat = intPt1 - 2 * intPt1;
}
*/
The lat/lon are in an SQLite database.
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *stringLat1 = @"N37-21.2"; //string: sample latitude from database
NSString *hemi = [stringLat1 substringWithRange:NSMakeRange( 0, 1) ]; // string: Hemisphere
NSString *degLat1 = [stringLat1 substringWithRange:NSMakeRange( 1, 2) ]; // string: degree of latitude
NSString *minLat1 = [stringLat1 substringWithRange:NSMakeRange( 4, 4) ]; // string: minute of latitude
float intMinLat1 = [minLat1 floatValue]/60; // int: minute of latitude
float intDegLat1 = [degLat1 floatValue]; //int: degree of latitude
float intPt1 = intMinLat1 + intDegLat1; // int: complete latitude
float point1Lat;
point1Lat = intPt1; /* the completed latitude (37.353333) for the northern hemisphere, a positive number vice a negative number for the southern hemi. */
NSLog(@"Pt1 hemisphere is %@, lat is %@ degrees, lon is %@ minutes, a %f decimal value. The point1Lat is %f",hemi,degLat1, minLat1, intMinLat1, point1Lat);
[pool drain];
return 0;
}
/*
if (hemi == @"N")
{
point1Lat = intPt1;
}
else if (hemi == @"S")
{
point1Lat = intPt1 - 2 * intPt1;
}
*/