Hope to be useful to the developers, the test error is small
#pragma mark-German map GPS to coordinates//location lati, longi#define Pi 3.14159265358979324NSArray * TRANSFORMGPSTOMAMAP (NSString * Loc ation) {Nsarray * result = nil; A = 6378245.0, F = 298.3//b = A * (1-f)//ee = (a^2-b^2)/a^2; Const double A = 6378245.0; Const double EE = 0.00669342162296594323; Nsarray * Tmparr = [location componentsseparatedbystring:@ ","]; Double Wglat = [[Tmparr firstobject] doublevalue]; Double Wglon = [[Tmparr lastobject] doublevalue]; World Geodetic System ==> Mars Geodetic System if (Outofchina (Wglat, Wglon)) {result = @[[nsnumb ER Numberwithdouble:wglat], [NSNumber Numberwithdouble:wglon]]; return result; } Double Dlat = Transformlat (wgLon-105.0, wgLat-35.0); Double Dlon = Transformlon (wgLon-105.0, wgLat-35.0); Double Radlat = wglat/180.0 * PI; Double magic = sin (Radlat); Magic = 1-ee * Magic * MAGIC; Double sqrtmagic = sqrt (Magic); Dlat = (Dlat * 180.0)/((A * (1-ee))/(Magic * sqrtmagic) * pi); Dlon = (Dlon * 180.0)/(a/sqrtmagic * cos (radlat) * pi); Wglat = Wglat + Dlat; Wglon = Wglon + Dlon; result = @[[nsnumber Numberwithdouble:wglat], [NSNumber Numberwithdouble:wglon]]; return result;} static bool Outofchina (double lat, double lon) {if (Lon < 72.004 | | lon > 137.8347) return true; if (Lat < 0.8293 | | lat > 55.8271) return true; return false;} Static double Transformlat (double x, double y) {double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0 .2 * SQRT (ABS (x)); RET + = (20.0 * SIN (6.0 * x * pi) + 20.0 * SIN (2.0 * x * pi)) * 2.0/3.0; RET + = (20.0 * sin (y * pi) + 40.0 *sin (y/3.0 * pi)) * 2.0/3.0; RET + = (160.0 * sin (y/12.0 * pi) + * * sin (y * pi/30.0)) * 2.0/3.0; return ret;} Static double Transformlon (double x, double y) {double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * sqRT (ABS (x)); RET + = (20.0 * SIN (6.0 * x * pi) + 20.0 * SIN (2.0 * x * pi)) * 2.0/3.0; RET + = (20.0 * sin (x * pi) + 40.0 * sin (x/3.0 * pi)) * 2.0/3.0; RET + = (150.0 * sin (x/12.0 * pi) + 300.0 * sin (x/30.0 * pi)) * 2.0/3.0; return ret;}
Recently working on a map project, the algorithm for GPs to Mars gold coordinates is as follows