Created
June 9, 2017 07:37
-
-
Save pawankmrai/ff502861fce79e5a35a2b02d2aff3af7 to your computer and use it in GitHub Desktop.
Mardinate-China Map Coordinate Fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const double x_pi = 3.14159265358979324 * 3000.0 / 180.0; | |
| -(CLLocationCoordinate2D)bd_encryptWithCoordinate:(CLLocationCoordinate2D)coordinate{ | |
| double x = coordinate.longitude; | |
| double y = coordinate.latitude; | |
| double z = sqrt (x * x + y * y) + 0.00002 * sin (y * x_pi); | |
| double theta = atan2 (y, x) + 0.000003 * cos (x * x_pi); | |
| double bd_lon = z * cos (theta) + 0.0065; | |
| double bd_lat = z * sin (theta) + 0.006; | |
| return [self bd_decryptWithCoordinate:CLLocationCoordinate2DMake(bd_lat, bd_lon)]; | |
| } | |
| -(CLLocationCoordinate2D)bd_decryptWithCoordinate:(CLLocationCoordinate2D)coordinate{ | |
| double bd_lon = coordinate.longitude; | |
| double bd_lat = coordinate.latitude; | |
| double x = bd_lon - 0.0065, y = bd_lat - 0.006; | |
| double z = sqrt (x * x + y * y) - 0.00002 * sin (y * x_pi); | |
| double theta = atan2 (y, x) - 0.000003 * cos (x * x_pi); | |
| double gg_lon = z * cos (theta); | |
| double gg_lat = z * sin (theta); | |
| return CLLocationCoordinate2DMake(gg_lat, gg_lon); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment