Skip to content

Instantly share code, notes, and snippets.

View valeriyvan's full-sized avatar
🇺🇦
in Armed Forces of Ukraine since 3 of March 2022

Valeriy Van valeriyvan

🇺🇦
in Armed Forces of Ukraine since 3 of March 2022
  • B̵e̵r̵l̵i̵n̵/̵O̵d̵e̵s̵a̵ somewhere in Ukraine
View GitHub Profile
@valeriyvan
valeriyvan / DMSToDecimal
Last active August 19, 2019 12:35
Geographic coordinate conversion from NSString in DMS format into decimal in CLLocationDegrees (aka double).http://en.wikipedia.org/wiki/Geographic_coordinate_conversion43° 36' 15.894" N => 43.60442
// http://en.wikipedia.org/wiki/Geographic_coordinate_conversion
// 43° 36' 15.894" N => 43.60442
#import "DMSToDecimal.h"
BOOL DMSToDecimal(NSString* dms, CLLocationDegrees *decimal) {
CLLocationDegrees degres=0, minutes=0, seconds=0;
NSScanner *scanner = [NSScanner scannerWithString:dms];
scanner.charactersToBeSkipped = [NSCharacterSet whitespaceAndNewlineCharacterSet];
if (![scanner scanDouble:&degres]) {