Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the gridZone letter? #3

Open
nnhubbard opened this issue May 2, 2017 · 8 comments
Open

How to get the gridZone letter? #3

nnhubbard opened this issue May 2, 2017 · 8 comments

Comments

@nnhubbard
Copy link

Is there a way to calculate what the grideZone letter would be? E.g. 32U or 10T. How can we get the U or T?

@palmerc
Copy link
Owner

palmerc commented May 2, 2017 via email

@nnhubbard
Copy link
Author

I guess my question should have been. How are other UTM converters doing it?

@palmerc
Copy link
Owner

palmerc commented May 2, 2017 via email

@nnhubbard
Copy link
Author

I wrote this up and seems to be what I am needing:

+ (NSString *)UTMlatZoneForCoordinates:(CLLocationCoordinate2D)coordinate {
    
    NSString *DigraphLetrsE = @"ABCDEFGHJKLMNPQRSTUVWXYZ";
    int latz = 0;//Latitude zone: A-B S of -80, C-W -80 to +72, X 72-84, Y,Z N of 84
    double latd = coordinate.latitude;
    
    if (latd > -80 && latd < 72) {
        latz = floor((latd + 80)/8)+2;
    }
    if (latd > 72 && latd < 84) {
        latz = 21;
    }
    if (latd > 84){
        latz = 23;
    }
    
    char letter = [DigraphLetrsE characterAtIndex:latz];
    return [NSString stringWithFormat:@"%c", letter];
    
}

@palmerc
Copy link
Owner

palmerc commented May 2, 2017 via email

@nnhubbard
Copy link
Author

Norway is 32V and that seems to be working correctly. What should I be doing different?

@palmerc
Copy link
Owner

palmerc commented May 3, 2017 via email

@palmerc
Copy link
Owner

palmerc commented May 3, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants