├── Test ├── .DS_Store ├── Test.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── project.pbxproj ├── Test │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ ├── AppDelegate.m │ └── ViewController.m └── TestTests │ ├── Info.plist │ └── TestTests.m ├── .gitignore ├── azure-pipelines.yml ├── TQLocationConverter.h ├── TQLocationConverter.podspec ├── README.md ├── LICENSE ├── README.en-US.md └── TQLocationConverter.m /Test/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TinyQ/TQLocationConverter/HEAD/Test/.DS_Store -------------------------------------------------------------------------------- /Test/Test.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Test/Test/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Test 4 | // 5 | // Created by qfu on 8/3/16. 6 | // Copyright © 2016 qfu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Test/Test/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Test 4 | // 5 | // Created by qfu on 8/3/16. 6 | // Copyright © 2016 qfu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Test/Test/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Test 4 | // 5 | // Created by qfu on 8/3/16. 6 | // Copyright © 2016 qfu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # Build, test, and archive an Xcode workspace on macOS. 3 | # Add steps that install certificates, test, sign, and distribute an app, save build artifacts, and more: 4 | # https://docs.microsoft.com/azure/devops/pipelines/languages/xcode 5 | 6 | trigger: 7 | - master 8 | 9 | pool: 10 | vmImage: 'macos-latest' 11 | 12 | steps: 13 | - task: Xcode@5 14 | inputs: 15 | actions: 'build' 16 | scheme: '' 17 | sdk: 'iphoneos' 18 | configuration: 'Release' 19 | xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace' 20 | xcodeVersion: 'default' # Options: 8, 9, 10, 11, 12, default, specifyPath 21 | -------------------------------------------------------------------------------- /Test/TestTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Test/Test/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /TQLocationConverter.h: -------------------------------------------------------------------------------- 1 | // 2 | // TQLocationConverter.h 3 | // 4 | // 5 | // Created by qfu on 9/16/14. 6 | // Copyright (c) 2014 tinyq. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface TQLocationConverter : NSObject 13 | 14 | /** 15 | * 判断是否在中国 16 | */ 17 | +(BOOL)isLocationOutOfChina:(CLLocationCoordinate2D)location; 18 | 19 | /** 20 | * 将WGS-84转为GCJ-02(火星坐标): 21 | */ 22 | +(CLLocationCoordinate2D)transformFromWGSToGCJ:(CLLocationCoordinate2D)wgsLoc; 23 | 24 | /** 25 | * 将GCJ-02(火星坐标)转为百度坐标: 26 | */ 27 | +(CLLocationCoordinate2D)transformFromGCJToBaidu:(CLLocationCoordinate2D)p; 28 | 29 | /** 30 | * 将百度坐标转为GCJ-02(火星坐标): 31 | */ 32 | +(CLLocationCoordinate2D)transformFromBaiduToGCJ:(CLLocationCoordinate2D)p; 33 | 34 | /** 35 | * 将GCJ-02(火星坐标)转为WGS-84: 36 | */ 37 | +(CLLocationCoordinate2D)transformFromGCJToWGS:(CLLocationCoordinate2D)p; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /TQLocationConverter.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint TQLocationConverter.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = "TQLocationConverter" 11 | s.version = "0.0.1" 12 | s.summary = "Converter CLLocation GCJ-02,WGS-84,Baidu." 13 | s.homepage = "https://github.com/TinyQ/TQLocationConverter" 14 | s.license = "MIT" 15 | s.author = { "qfu" => "tinyqf@gmail.com" } 16 | s.platform = :ios, "5.0" 17 | s.source = { :git => "https://github.com/TinyQ/TQLocationConverter.git", :tag => "v0.0.1" } 18 | s.source_files = "TQLocationConverter.{h,m}" 19 | s.frameworks = "CoreLocation" 20 | s.requires_arc = true 21 | end 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | TQLocationConverter 2 | =================== 3 | [English](README.en-US.md) 4 | 5 | ## Location converter 6 | 7 | 用来相互转换不同标准坐标系 8 | 9 | (GCJ-02火星坐标) 10 | 11 | (WGS-84 正常GPS坐标) 12 | 13 | (百度坐标) 14 | 15 | 16 | ## How to use 17 | 18 | 19 | ```objective-c 20 | 21 | //我是个经纬度 22 | CLLocationCoordinate2D location = (CLLocationCoordinate2D){ 23 | .latitude = 0.0, 24 | .longitude = 0.0 25 | }; 26 | 27 | //判断是否在中国 28 | if (![TQLocationConverter isLocationOutOfChina:location]) 29 | { 30 | //将WGS-84转为GCJ-02(火星坐标) 31 | location = [TQLocationConverter transformFromWGSToGCJ:location]; 32 | 33 | //将GCJ-02(火星坐标)转为百度坐标 34 | location = [TQLocationConverter transformFromGCJToBaidu:location]; 35 | 36 | //将百度坐标转为GCJ-02(火星坐标) 37 | location = [TQLocationConverter transformFromBaiduToGCJ:location]; 38 | 39 | //将GCJ-02(火星坐标)转为WGS-84 40 | location = [TQLocationConverter transformFromGCJToWGS:location]; 41 | } 42 | 43 | NSLog(@"%f,%f",location.latitude,location.longitude); 44 | 45 | ``` 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 TinyQ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.en-US.md: -------------------------------------------------------------------------------- 1 | TQLocationConverter 2 | =================== 3 | 4 | ## Location converter 5 | 6 | Used to convert different coordinate system standards to each other 7 | 8 | (GCJ-02 Mars coordinates) 9 | 10 | (WGS-84 normal GPS coordinates) 11 | 12 | (Baidu coordinates) 13 | 14 | 15 | ## How to use 16 | 17 | 18 | ```objective-c 19 | 20 | // latitiude and longitude 21 | CLLocationCoordinate2D location = (CLLocationCoordinate2D){ 22 | .latitude = 0.0, 23 | .longitude = 0.0 24 | }; 25 | 26 | // determine if in China 27 | if (![TQLocationConverter isLocationOutOfChina:location]) 28 | { 29 | // convert WGS-84 to GCJ-02 (Mars coordinates) 30 | location = [TQLocationConverter transformFromWGSToGCJ:location]; 31 | 32 | // convert GCJ-02 (Mars coordinates) into Baidu coordinates 33 | location = [TQLocationConverter transformFromGCJToBaidu:location]; 34 | 35 | // convert Baidu coordinates into GCJ-02 (Mars coordinates) 36 | location = [TQLocationConverter transformFromBaiduToGCJ:location]; 37 | 38 | // convert GCJ-02 (Mars coordinates) to WGS-84 (normal GPS coordinates) 39 | location = [TQLocationConverter transformFromGCJToWGS:location]; 40 | } 41 | 42 | NSLog(@"%f,%f",location.latitude,location.longitude); 43 | 44 | ``` 45 | -------------------------------------------------------------------------------- /Test/Test/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Test/Test/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Test/Test/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Test/Test/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Test 4 | // 5 | // Created by qfu on 8/3/16. 6 | // Copyright © 2016 qfu. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Test/Test/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Test 4 | // 5 | // Created by qfu on 8/3/16. 6 | // Copyright © 2016 qfu. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "TQLocationConverter.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | [self test1]; 22 | [self test2]; 23 | [self test3]; 24 | } 25 | 26 | - (void)test1 27 | { 28 | NSLog(@"Test1"); 29 | 30 | //我是个经纬度 31 | CLLocationCoordinate2D location = (CLLocationCoordinate2D){ 32 | .latitude = 39.7398995536, 33 | .longitude = 116.4761557871 34 | }; 35 | 36 | NSLog(@"原始坐标 %f,%f",location.latitude,location.longitude); 37 | 38 | CLLocationCoordinate2D result1; 39 | CLLocationCoordinate2D result2; 40 | 41 | //将WGS-84转为GCJ-02(火星坐标) 42 | result1 = [TQLocationConverter transformFromWGSToGCJ:location]; 43 | NSLog(@"WGS-84 to 火星 %f,%f,",result1.latitude,result1.longitude); 44 | //将GCJ-02(火星坐标)转为WGS-84 45 | result2 = [TQLocationConverter transformFromGCJToWGS:result1]; 46 | NSLog(@"火星 to WGS-84 %f,%f,",result2.latitude,result2.longitude); 47 | NSLog(@"\n"); 48 | } 49 | 50 | - (void)test2 51 | { 52 | NSLog(@"Test2"); 53 | 54 | //我是个经纬度 55 | CLLocationCoordinate2D location = (CLLocationCoordinate2D){ 56 | .latitude = 39.7398995536, 57 | .longitude = 116.4761557871 58 | }; 59 | 60 | NSLog(@"原始坐标 %f,%f",location.latitude,location.longitude); 61 | 62 | CLLocationCoordinate2D result1; 63 | CLLocationCoordinate2D result2; 64 | 65 | //将GCJ-02(火星坐标)转为百度坐标 66 | result1 = [TQLocationConverter transformFromGCJToBaidu:location]; 67 | NSLog(@"GCJ-02 to baidu %f,%f,",result1.latitude,result1.longitude); 68 | 69 | //将百度坐标转为GCJ-02(火星坐标) 70 | result2 = [TQLocationConverter transformFromBaiduToGCJ:result1]; 71 | NSLog(@"baidu to GCJ-02 %f,%f,",result2.latitude,result2.longitude); 72 | NSLog(@"\n"); 73 | } 74 | 75 | - (void)test3 76 | { 77 | NSLog(@"Test3"); 78 | 79 | //我是个经纬度 80 | CLLocationCoordinate2D location = (CLLocationCoordinate2D){ 81 | .latitude = 39.7398995536, 82 | .longitude = 116.4761557871 83 | }; 84 | 85 | NSLog(@"原始坐标 %f,%f",location.latitude,location.longitude); 86 | 87 | CLLocationCoordinate2D result1; 88 | CLLocationCoordinate2D result2; 89 | 90 | //将GCJ-02(火星坐标)转为WGS-84 91 | result1 = [TQLocationConverter transformFromGCJToWGS:location]; 92 | NSLog(@"GCJToWGS %f,%f,",result1.latitude,result1.longitude); 93 | 94 | //将WGS-84(火星坐标)转为GCJ-02 95 | result2 = [TQLocationConverter transformFromWGSToGCJ:result1]; 96 | NSLog(@"WGSToGCJ %f,%f,",result2.latitude,result2.longitude); 97 | NSLog(@"\n"); 98 | } 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /Test/TestTests/TestTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestTests.m 3 | // TestTests 4 | // 5 | // Created by 宋晓光 on 17/10/2016. 6 | // Copyright © 2016 qfu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "TQLocationConverter.h" 11 | 12 | @interface TestTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation TestTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | // Use XCTAssert and related functions to verify your tests produce the correct results. 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | -(void)testIsLocationOutOfChina{ 41 | 42 | BOOL isOutOfChina = NO; 43 | 44 | // Part 1 45 | isOutOfChina = [TQLocationConverter isLocationOutOfChina:CLLocationCoordinate2DMake(43.9391930000,105.1132810000)]; 46 | XCTAssertEqual(isOutOfChina, YES,@"Part 1 failed."); 47 | 48 | // Part 2 49 | isOutOfChina = [TQLocationConverter isLocationOutOfChina:CLLocationCoordinate2DMake(23.9423720000,121.0821340000)]; 50 | XCTAssertEqual(isOutOfChina, YES,@"Part 2 failed."); 51 | 52 | // Part 3 53 | isOutOfChina = [TQLocationConverter isLocationOutOfChina:CLLocationCoordinate2DMake(21.2779820000,105.407565000)]; 54 | XCTAssertEqual(isOutOfChina, YES,@"Part 3 failed."); 55 | 56 | // Part 4 57 | isOutOfChina = [TQLocationConverter isLocationOutOfChina:CLLocationCoordinate2DMake(40.6485130000,-109.9160210000)]; 58 | XCTAssertEqual(isOutOfChina, YES,@"Part 4 failed."); 59 | 60 | // Part 5 61 | isOutOfChina = [TQLocationConverter isLocationOutOfChina:CLLocationCoordinate2DMake(-23.4521890000,124.8351820000)]; 62 | XCTAssertEqual(isOutOfChina, YES,@"Part 5 failed."); 63 | 64 | // Part 6 65 | isOutOfChina = [TQLocationConverter isLocationOutOfChina:CLLocationCoordinate2DMake(52.3696860000,-0.8551500000)]; 66 | XCTAssertEqual(isOutOfChina, YES,@"Part 6 failed."); 67 | 68 | // Part 7 69 | isOutOfChina = [TQLocationConverter isLocationOutOfChina:CLLocationCoordinate2DMake(40.6424438827,114.3790442482)]; 70 | XCTAssertEqual(isOutOfChina, NO,@"Part 7 failed."); 71 | 72 | // Part 8 73 | isOutOfChina = [TQLocationConverter isLocationOutOfChina:CLLocationCoordinate2DMake(32.7132247538,119.3814515758)]; 74 | XCTAssertEqual(isOutOfChina, NO,@"Part 8 failed."); 75 | 76 | // Part 9 77 | isOutOfChina = [TQLocationConverter isLocationOutOfChina:CLLocationCoordinate2DMake(19.3281880801,109.9619378181)]; 78 | XCTAssertEqual(isOutOfChina, NO,@"Part 9 failed."); 79 | 80 | // Part 10 81 | isOutOfChina = [TQLocationConverter isLocationOutOfChina:CLLocationCoordinate2DMake(38.5939174139,76.1092626238)]; 82 | XCTAssertEqual(isOutOfChina, NO,@"Part 10 failed."); 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /TQLocationConverter.m: -------------------------------------------------------------------------------- 1 | // 2 | // TQLocationConverter.m 3 | // 4 | // 5 | // Created by qfu on 9/16/14. 6 | // Copyright (c) 2014 tinyq. All rights reserved. 7 | // 8 | 9 | #import "TQLocationConverter.h" 10 | #import 11 | #import 12 | 13 | static const double a = 6378245.0; 14 | static const double ee = 0.00669342162296594323; 15 | static const double pi = 3.14159265358979324; 16 | static const double xPi = M_PI * 3000.0 / 180.0; 17 | 18 | @implementation TQLocationConverter 19 | 20 | +(CLLocationCoordinate2D)transformFromWGSToGCJ:(CLLocationCoordinate2D)wgsLoc 21 | { 22 | CLLocationCoordinate2D adjustLoc; 23 | double adjustLat = [self transformLatWithX:wgsLoc.longitude - 105.0 withY:wgsLoc.latitude - 35.0]; 24 | double adjustLon = [self transformLonWithX:wgsLoc.longitude - 105.0 withY:wgsLoc.latitude - 35.0]; 25 | long double radLat = wgsLoc.latitude / 180.0 * pi; 26 | long double magic = sin(radLat); 27 | magic = 1 - ee * magic * magic; 28 | long double sqrtMagic = sqrt(magic); 29 | adjustLat = (adjustLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); 30 | adjustLon = (adjustLon * 180.0) / (a / sqrtMagic * cos(radLat) * pi); 31 | adjustLoc.latitude = wgsLoc.latitude + adjustLat; 32 | adjustLoc.longitude = wgsLoc.longitude + adjustLon; 33 | 34 | return adjustLoc; 35 | } 36 | 37 | + (double)transformLatWithX:(double)x withY:(double)y 38 | { 39 | double lat = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * sqrt(fabs(x)); 40 | 41 | lat += (20.0 * sin(6.0 * x * pi) + 20.0 *sin(2.0 * x * pi)) * 2.0 / 3.0; 42 | lat += (20.0 * sin(y * pi) + 40.0 * sin(y / 3.0 * pi)) * 2.0 / 3.0; 43 | lat += (160.0 * sin(y / 12.0 * pi) + 320 * sin(y * pi / 30.0)) * 2.0 / 3.0; 44 | return lat; 45 | } 46 | 47 | + (double)transformLonWithX:(double)x withY:(double)y 48 | { 49 | double lon = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * sqrt(fabs(x)); 50 | lon += (20.0 * sin(6.0 * x * pi) + 20.0 * sin(2.0 * x * pi)) * 2.0 / 3.0; 51 | lon += (20.0 * sin(x * pi) + 40.0 * sin(x / 3.0 * pi)) * 2.0 / 3.0; 52 | lon += (150.0 * sin(x / 12.0 * pi) + 300.0 * sin(x / 30.0 * pi)) * 2.0 / 3.0; 53 | return lon; 54 | } 55 | 56 | +(CLLocationCoordinate2D)transformFromGCJToBaidu:(CLLocationCoordinate2D)p 57 | { 58 | long double z = sqrt(p.longitude * p.longitude + p.latitude * p.latitude) + 0.00002 * sin(p.latitude * xPi); 59 | long double theta = atan2(p.latitude, p.longitude) + 0.000003 * cos(p.longitude * xPi); 60 | CLLocationCoordinate2D geoPoint; 61 | geoPoint.latitude = (z * sin(theta) + 0.006); 62 | geoPoint.longitude = (z * cos(theta) + 0.0065); 63 | return geoPoint; 64 | } 65 | 66 | +(CLLocationCoordinate2D)transformFromBaiduToGCJ:(CLLocationCoordinate2D)p 67 | { 68 | double x = p.longitude - 0.0065, y = p.latitude - 0.006; 69 | double z = sqrt(x * x + y * y) - 0.00002 * sin(y * xPi); 70 | double theta = atan2(y, x) - 0.000003 * cos(x * xPi); 71 | CLLocationCoordinate2D geoPoint; 72 | geoPoint.latitude = z * sin(theta); 73 | geoPoint.longitude = z * cos(theta); 74 | return geoPoint; 75 | } 76 | 77 | +(CLLocationCoordinate2D)transformFromGCJToWGS:(CLLocationCoordinate2D)p 78 | { 79 | double threshold = 0.00001; 80 | 81 | // The boundary 82 | double minLat = p.latitude - 0.5; 83 | double maxLat = p.latitude + 0.5; 84 | double minLng = p.longitude - 0.5; 85 | double maxLng = p.longitude + 0.5; 86 | 87 | double delta = 1; 88 | int maxIteration = 30; 89 | // Binary search 90 | while(true) 91 | { 92 | CLLocationCoordinate2D leftBottom = [[self class] transformFromWGSToGCJ:(CLLocationCoordinate2D){.latitude = minLat,.longitude = minLng}]; 93 | CLLocationCoordinate2D rightBottom = [[self class] transformFromWGSToGCJ:(CLLocationCoordinate2D){.latitude = minLat,.longitude = maxLng}]; 94 | CLLocationCoordinate2D leftUp = [[self class] transformFromWGSToGCJ:(CLLocationCoordinate2D){.latitude = maxLat,.longitude = minLng}]; 95 | CLLocationCoordinate2D midPoint = [[self class] transformFromWGSToGCJ:(CLLocationCoordinate2D){.latitude = ((minLat + maxLat) / 2),.longitude = ((minLng + maxLng) / 2)}]; 96 | delta = fabs(midPoint.latitude - p.latitude) + fabs(midPoint.longitude - p.longitude); 97 | 98 | if(maxIteration-- <= 0 || delta <= threshold) 99 | { 100 | return (CLLocationCoordinate2D){.latitude = ((minLat + maxLat) / 2),.longitude = ((minLng + maxLng) / 2)}; 101 | } 102 | 103 | if(isContains(p, leftBottom, midPoint)) 104 | { 105 | maxLat = (minLat + maxLat) / 2; 106 | maxLng = (minLng + maxLng) / 2; 107 | } 108 | else if(isContains(p, rightBottom, midPoint)) 109 | { 110 | maxLat = (minLat + maxLat) / 2; 111 | minLng = (minLng + maxLng) / 2; 112 | } 113 | else if(isContains(p, leftUp, midPoint)) 114 | { 115 | minLat = (minLat + maxLat) / 2; 116 | maxLng = (minLng + maxLng) / 2; 117 | } 118 | else 119 | { 120 | minLat = (minLat + maxLat) / 2; 121 | minLng = (minLng + maxLng) / 2; 122 | } 123 | } 124 | 125 | } 126 | 127 | static bool isContains(CLLocationCoordinate2D point, CLLocationCoordinate2D p1, CLLocationCoordinate2D p2) 128 | { 129 | return (point.latitude >= MIN(p1.latitude, p2.latitude) && point.latitude <= MAX(p1.latitude, p2.latitude)) && (point.longitude >= MIN(p1.longitude,p2.longitude) && point.longitude <= MAX(p1.longitude, p2.longitude)); 130 | } 131 | 132 | 133 | /** 134 | * 判断是不是在中国 135 | * 用引射线法判断 点是否在多边形内部 136 | * 算法参考:http://www.cnblogs.com/luxiaoxun/p/3722358.html 137 | */ 138 | + (BOOL)isLocationOutOfChina:(CLLocationCoordinate2D)location { 139 | CGPoint point = CGPointMake(location.latitude, location.longitude); 140 | BOOL oddFlag = NO; 141 | NSInteger j = [self polygonOfChina].count - 1; 142 | for (NSInteger i = 0; i < [self polygonOfChina].count; i++) { 143 | CGPoint polygonPointi = [[self polygonOfChina][i] CGPointValue]; 144 | CGPoint polygonPointj = [[self polygonOfChina][j] CGPointValue]; 145 | if (((polygonPointi.y < point.y && polygonPointj.y >= point.y) || 146 | (polygonPointj.y < point.y && polygonPointi.y >= point.y)) && 147 | (polygonPointi.x <= point.x || polygonPointj.x <= point.x)) { 148 | oddFlag ^= (polygonPointi.x + 149 | (point.y - polygonPointi.y) / 150 | (polygonPointj.y - polygonPointi.y) * 151 | (polygonPointj.x - polygonPointi.x) < 152 | point.x); 153 | } 154 | j = i; 155 | } 156 | return !oddFlag; 157 | } 158 | 159 | // 中国大陆多边形,用于判断坐标是否在中国 160 | // 因为港澳台地区使用WGS坐标,所以多边形不包含港澳台地区 161 | + (NSMutableArray *)polygonOfChina { 162 | static NSMutableArray *polygonOfChina = nil; 163 | static dispatch_once_t onceToken; 164 | dispatch_once(&onceToken, ^{ 165 | polygonOfChina = [[NSMutableArray alloc] init]; 166 | [polygonOfChina 167 | addObject:[NSValue valueWithCGPoint:CGPointMake(49.1506690000, 168 | 87.4150810000)]]; 169 | [polygonOfChina 170 | addObject:[NSValue valueWithCGPoint:CGPointMake(48.3664501790, 171 | 85.7527085300)]]; 172 | [polygonOfChina 173 | addObject:[NSValue valueWithCGPoint:CGPointMake(47.0253058185, 174 | 85.3847443554)]]; 175 | [polygonOfChina 176 | addObject:[NSValue valueWithCGPoint:CGPointMake(45.2406550000, 177 | 82.5214000000)]]; 178 | [polygonOfChina 179 | addObject:[NSValue valueWithCGPoint:CGPointMake(44.8957121295, 180 | 79.9392351487)]]; 181 | [polygonOfChina 182 | addObject:[NSValue valueWithCGPoint:CGPointMake(43.1166843846, 183 | 80.6751253982)]]; 184 | [polygonOfChina 185 | addObject:[NSValue valueWithCGPoint:CGPointMake(41.8701690000, 186 | 79.6882160000)]]; 187 | [polygonOfChina 188 | addObject:[NSValue valueWithCGPoint:CGPointMake(39.2896190000, 189 | 73.6171080000)]]; 190 | [polygonOfChina 191 | addObject:[NSValue valueWithCGPoint:CGPointMake(34.2303430000, 192 | 78.9155300000)]]; 193 | [polygonOfChina 194 | addObject:[NSValue valueWithCGPoint:CGPointMake(31.0238860000, 195 | 79.0627080000)]]; 196 | [polygonOfChina 197 | addObject:[NSValue valueWithCGPoint:CGPointMake(27.9989800000, 198 | 88.7028920000)]]; 199 | [polygonOfChina 200 | addObject:[NSValue valueWithCGPoint:CGPointMake(27.1793590000, 201 | 88.9972480000)]]; 202 | [polygonOfChina 203 | addObject:[NSValue valueWithCGPoint:CGPointMake(28.0969170000, 204 | 89.7331400000)]]; 205 | [polygonOfChina 206 | addObject:[NSValue valueWithCGPoint:CGPointMake(26.9157800000, 207 | 92.1615830000)]]; 208 | [polygonOfChina 209 | addObject:[NSValue valueWithCGPoint:CGPointMake(28.1947640000, 210 | 96.0986050000)]]; 211 | [polygonOfChina 212 | addObject:[NSValue valueWithCGPoint:CGPointMake(27.4094760000, 213 | 98.6742270000)]]; 214 | [polygonOfChina 215 | addObject:[NSValue valueWithCGPoint:CGPointMake(23.9085500000, 216 | 97.5703890000)]]; 217 | [polygonOfChina 218 | addObject:[NSValue valueWithCGPoint:CGPointMake(24.0775830000, 219 | 98.7846100000)]]; 220 | [polygonOfChina 221 | addObject:[NSValue valueWithCGPoint:CGPointMake(22.1375640000, 222 | 99.1893510000)]]; 223 | [polygonOfChina 224 | addObject:[NSValue valueWithCGPoint:CGPointMake(21.1398950000, 225 | 101.7649720000)]]; 226 | [polygonOfChina 227 | addObject:[NSValue valueWithCGPoint:CGPointMake(22.2746220000, 228 | 101.7281780000)]]; 229 | [polygonOfChina 230 | addObject:[NSValue valueWithCGPoint:CGPointMake(23.2641940000, 231 | 105.3708430000)]]; 232 | [polygonOfChina 233 | addObject:[NSValue valueWithCGPoint:CGPointMake(22.7191200000, 234 | 106.6954480000)]]; 235 | [polygonOfChina 236 | addObject:[NSValue valueWithCGPoint:CGPointMake(21.9945711661, 237 | 106.7256731791)]]; 238 | [polygonOfChina 239 | addObject:[NSValue valueWithCGPoint:CGPointMake(21.4847050000, 240 | 108.0200530000)]]; 241 | [polygonOfChina 242 | addObject:[NSValue valueWithCGPoint:CGPointMake(20.4478440000, 243 | 109.3814530000)]]; 244 | [polygonOfChina 245 | addObject:[NSValue valueWithCGPoint:CGPointMake(18.6689850000, 246 | 108.2408210000)]]; 247 | [polygonOfChina 248 | addObject:[NSValue valueWithCGPoint:CGPointMake(17.4017340000, 249 | 109.9333720000)]]; 250 | [polygonOfChina 251 | addObject:[NSValue valueWithCGPoint:CGPointMake(19.5085670000, 252 | 111.4051560000)]]; 253 | [polygonOfChina 254 | addObject:[NSValue valueWithCGPoint:CGPointMake(21.2716775175, 255 | 111.2514995205)]]; 256 | [polygonOfChina 257 | addObject:[NSValue valueWithCGPoint:CGPointMake(21.9936323233, 258 | 113.4625292629)]]; 259 | [polygonOfChina 260 | addObject:[NSValue valueWithCGPoint:CGPointMake(22.1818312942, 261 | 113.4258358111)]]; 262 | [polygonOfChina 263 | addObject:[NSValue valueWithCGPoint:CGPointMake(22.2249729295, 264 | 113.5913115000)]]; 265 | [polygonOfChina 266 | addObject:[NSValue valueWithCGPoint:CGPointMake(22.4501912753, 267 | 113.8946844490)]]; 268 | [polygonOfChina 269 | addObject:[NSValue valueWithCGPoint:CGPointMake(22.5959159322, 270 | 114.3623797842)]]; 271 | [polygonOfChina 272 | addObject:[NSValue valueWithCGPoint:CGPointMake(22.4334610000, 273 | 114.5194740000)]]; 274 | [polygonOfChina 275 | addObject:[NSValue valueWithCGPoint:CGPointMake(22.9680954377, 276 | 116.8326939975)]]; 277 | [polygonOfChina 278 | addObject:[NSValue valueWithCGPoint:CGPointMake(25.3788220000, 279 | 119.9667980000)]]; 280 | [polygonOfChina 281 | addObject:[NSValue valueWithCGPoint:CGPointMake(28.3261276204, 282 | 121.7724402562)]]; 283 | [polygonOfChina 284 | addObject:[NSValue valueWithCGPoint:CGPointMake(31.9883610000, 285 | 123.8808230000)]]; 286 | [polygonOfChina 287 | addObject:[NSValue valueWithCGPoint:CGPointMake(39.8759700000, 288 | 124.4695370000)]]; 289 | [polygonOfChina 290 | addObject:[NSValue valueWithCGPoint:CGPointMake(41.7350890000, 291 | 126.9531720000)]]; 292 | [polygonOfChina 293 | addObject:[NSValue valueWithCGPoint:CGPointMake(41.5142160000, 294 | 128.3145720000)]]; 295 | [polygonOfChina 296 | addObject:[NSValue valueWithCGPoint:CGPointMake(42.9842081790, 297 | 131.0676468344)]]; 298 | [polygonOfChina 299 | addObject:[NSValue valueWithCGPoint:CGPointMake(45.2690810000, 300 | 131.8468530000)]]; 301 | [polygonOfChina 302 | addObject:[NSValue valueWithCGPoint:CGPointMake(45.0608370000, 303 | 133.0610740000)]]; 304 | [polygonOfChina 305 | addObject:[NSValue valueWithCGPoint:CGPointMake(48.4480260000, 306 | 135.0111880000)]]; 307 | [polygonOfChina 308 | addObject:[NSValue valueWithCGPoint:CGPointMake(48.0054800000, 309 | 131.6628800000)]]; 310 | [polygonOfChina 311 | addObject:[NSValue valueWithCGPoint:CGPointMake(50.2270740000, 312 | 127.6890640000)]]; 313 | [polygonOfChina 314 | addObject:[NSValue valueWithCGPoint:CGPointMake(53.3516070000, 315 | 125.3710040000)]]; 316 | [polygonOfChina 317 | addObject:[NSValue valueWithCGPoint:CGPointMake(53.4176040000, 318 | 119.9254040000)]]; 319 | [polygonOfChina 320 | addObject:[NSValue valueWithCGPoint:CGPointMake(47.5590810000, 321 | 115.1421070000)]]; 322 | [polygonOfChina 323 | addObject:[NSValue valueWithCGPoint:CGPointMake(47.1339370000, 324 | 119.1159230000)]]; 325 | [polygonOfChina 326 | addObject:[NSValue valueWithCGPoint:CGPointMake(44.8256460000, 327 | 111.2786750000)]]; 328 | [polygonOfChina 329 | addObject:[NSValue valueWithCGPoint:CGPointMake(42.5293560000, 330 | 109.2549720000)]]; 331 | [polygonOfChina 332 | addObject:[NSValue valueWithCGPoint:CGPointMake(43.2598160000, 333 | 97.2967290000)]]; 334 | [polygonOfChina 335 | addObject:[NSValue valueWithCGPoint:CGPointMake(45.4247620000, 336 | 90.9680590000)]]; 337 | [polygonOfChina 338 | addObject:[NSValue valueWithCGPoint:CGPointMake(47.8075570000, 339 | 90.6737020000)]]; 340 | [polygonOfChina 341 | addObject:[NSValue valueWithCGPoint:CGPointMake(49.1506690000, 342 | 87.4150810000)]]; 343 | }); 344 | return polygonOfChina; 345 | } 346 | 347 | @end 348 | -------------------------------------------------------------------------------- /Test/Test.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A088585A1DB4B455004121FB /* TestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A08858591DB4B455004121FB /* TestTests.m */; }; 11 | E098D76E1D522BBA00F55BC1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E098D76D1D522BBA00F55BC1 /* main.m */; }; 12 | E098D7711D522BBA00F55BC1 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E098D7701D522BBA00F55BC1 /* AppDelegate.m */; }; 13 | E098D7741D522BBA00F55BC1 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E098D7731D522BBA00F55BC1 /* ViewController.m */; }; 14 | E098D7771D522BBA00F55BC1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E098D7751D522BBA00F55BC1 /* Main.storyboard */; }; 15 | E098D7791D522BBA00F55BC1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E098D7781D522BBA00F55BC1 /* Assets.xcassets */; }; 16 | E098D77C1D522BBA00F55BC1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E098D77A1D522BBA00F55BC1 /* LaunchScreen.storyboard */; }; 17 | E098D7851D522C1600F55BC1 /* TQLocationConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = E098D7841D522C1600F55BC1 /* TQLocationConverter.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | A088585C1DB4B455004121FB /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = E098D7611D522BBA00F55BC1 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = E098D7681D522BBA00F55BC1; 26 | remoteInfo = Test; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | A08858571DB4B455004121FB /* TestTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | A08858591DB4B455004121FB /* TestTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestTests.m; sourceTree = ""; }; 33 | A088585B1DB4B455004121FB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | E098D7691D522BBA00F55BC1 /* Test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Test.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | E098D76D1D522BBA00F55BC1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 36 | E098D76F1D522BBA00F55BC1 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 37 | E098D7701D522BBA00F55BC1 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 38 | E098D7721D522BBA00F55BC1 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 39 | E098D7731D522BBA00F55BC1 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 40 | E098D7761D522BBA00F55BC1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | E098D7781D522BBA00F55BC1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 42 | E098D77B1D522BBA00F55BC1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 43 | E098D77D1D522BBA00F55BC1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | E098D7831D522C1600F55BC1 /* TQLocationConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TQLocationConverter.h; path = ../TQLocationConverter.h; sourceTree = ""; }; 45 | E098D7841D522C1600F55BC1 /* TQLocationConverter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TQLocationConverter.m; path = ../TQLocationConverter.m; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | A08858541DB4B455004121FB /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | E098D7661D522BBA00F55BC1 /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | A08858581DB4B455004121FB /* TestTests */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | A08858591DB4B455004121FB /* TestTests.m */, 70 | A088585B1DB4B455004121FB /* Info.plist */, 71 | ); 72 | path = TestTests; 73 | sourceTree = ""; 74 | }; 75 | E098D7601D522BBA00F55BC1 = { 76 | isa = PBXGroup; 77 | children = ( 78 | E098D7831D522C1600F55BC1 /* TQLocationConverter.h */, 79 | E098D7841D522C1600F55BC1 /* TQLocationConverter.m */, 80 | E098D76B1D522BBA00F55BC1 /* Test */, 81 | A08858581DB4B455004121FB /* TestTests */, 82 | E098D76A1D522BBA00F55BC1 /* Products */, 83 | ); 84 | sourceTree = ""; 85 | }; 86 | E098D76A1D522BBA00F55BC1 /* Products */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | E098D7691D522BBA00F55BC1 /* Test.app */, 90 | A08858571DB4B455004121FB /* TestTests.xctest */, 91 | ); 92 | name = Products; 93 | sourceTree = ""; 94 | }; 95 | E098D76B1D522BBA00F55BC1 /* Test */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | E098D76F1D522BBA00F55BC1 /* AppDelegate.h */, 99 | E098D7701D522BBA00F55BC1 /* AppDelegate.m */, 100 | E098D7721D522BBA00F55BC1 /* ViewController.h */, 101 | E098D7731D522BBA00F55BC1 /* ViewController.m */, 102 | E098D7751D522BBA00F55BC1 /* Main.storyboard */, 103 | E098D7781D522BBA00F55BC1 /* Assets.xcassets */, 104 | E098D77A1D522BBA00F55BC1 /* LaunchScreen.storyboard */, 105 | E098D77D1D522BBA00F55BC1 /* Info.plist */, 106 | E098D76C1D522BBA00F55BC1 /* Supporting Files */, 107 | ); 108 | path = Test; 109 | sourceTree = ""; 110 | }; 111 | E098D76C1D522BBA00F55BC1 /* Supporting Files */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | E098D76D1D522BBA00F55BC1 /* main.m */, 115 | ); 116 | name = "Supporting Files"; 117 | sourceTree = ""; 118 | }; 119 | /* End PBXGroup section */ 120 | 121 | /* Begin PBXNativeTarget section */ 122 | A08858561DB4B455004121FB /* TestTests */ = { 123 | isa = PBXNativeTarget; 124 | buildConfigurationList = A08858601DB4B456004121FB /* Build configuration list for PBXNativeTarget "TestTests" */; 125 | buildPhases = ( 126 | A08858531DB4B455004121FB /* Sources */, 127 | A08858541DB4B455004121FB /* Frameworks */, 128 | A08858551DB4B455004121FB /* Resources */, 129 | ); 130 | buildRules = ( 131 | ); 132 | dependencies = ( 133 | A088585D1DB4B455004121FB /* PBXTargetDependency */, 134 | ); 135 | name = TestTests; 136 | productName = TestTests; 137 | productReference = A08858571DB4B455004121FB /* TestTests.xctest */; 138 | productType = "com.apple.product-type.bundle.unit-test"; 139 | }; 140 | E098D7681D522BBA00F55BC1 /* Test */ = { 141 | isa = PBXNativeTarget; 142 | buildConfigurationList = E098D7801D522BBA00F55BC1 /* Build configuration list for PBXNativeTarget "Test" */; 143 | buildPhases = ( 144 | E098D7651D522BBA00F55BC1 /* Sources */, 145 | E098D7661D522BBA00F55BC1 /* Frameworks */, 146 | E098D7671D522BBA00F55BC1 /* Resources */, 147 | ); 148 | buildRules = ( 149 | ); 150 | dependencies = ( 151 | ); 152 | name = Test; 153 | productName = Test; 154 | productReference = E098D7691D522BBA00F55BC1 /* Test.app */; 155 | productType = "com.apple.product-type.application"; 156 | }; 157 | /* End PBXNativeTarget section */ 158 | 159 | /* Begin PBXProject section */ 160 | E098D7611D522BBA00F55BC1 /* Project object */ = { 161 | isa = PBXProject; 162 | attributes = { 163 | LastUpgradeCheck = 0730; 164 | ORGANIZATIONNAME = qfu; 165 | TargetAttributes = { 166 | A08858561DB4B455004121FB = { 167 | CreatedOnToolsVersion = 8.0; 168 | ProvisioningStyle = Automatic; 169 | TestTargetID = E098D7681D522BBA00F55BC1; 170 | }; 171 | E098D7681D522BBA00F55BC1 = { 172 | CreatedOnToolsVersion = 7.3.1; 173 | }; 174 | }; 175 | }; 176 | buildConfigurationList = E098D7641D522BBA00F55BC1 /* Build configuration list for PBXProject "Test" */; 177 | compatibilityVersion = "Xcode 3.2"; 178 | developmentRegion = English; 179 | hasScannedForEncodings = 0; 180 | knownRegions = ( 181 | en, 182 | Base, 183 | ); 184 | mainGroup = E098D7601D522BBA00F55BC1; 185 | productRefGroup = E098D76A1D522BBA00F55BC1 /* Products */; 186 | projectDirPath = ""; 187 | projectRoot = ""; 188 | targets = ( 189 | E098D7681D522BBA00F55BC1 /* Test */, 190 | A08858561DB4B455004121FB /* TestTests */, 191 | ); 192 | }; 193 | /* End PBXProject section */ 194 | 195 | /* Begin PBXResourcesBuildPhase section */ 196 | A08858551DB4B455004121FB /* Resources */ = { 197 | isa = PBXResourcesBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | ); 201 | runOnlyForDeploymentPostprocessing = 0; 202 | }; 203 | E098D7671D522BBA00F55BC1 /* Resources */ = { 204 | isa = PBXResourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | E098D77C1D522BBA00F55BC1 /* LaunchScreen.storyboard in Resources */, 208 | E098D7791D522BBA00F55BC1 /* Assets.xcassets in Resources */, 209 | E098D7771D522BBA00F55BC1 /* Main.storyboard in Resources */, 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | }; 213 | /* End PBXResourcesBuildPhase section */ 214 | 215 | /* Begin PBXSourcesBuildPhase section */ 216 | A08858531DB4B455004121FB /* Sources */ = { 217 | isa = PBXSourcesBuildPhase; 218 | buildActionMask = 2147483647; 219 | files = ( 220 | A088585A1DB4B455004121FB /* TestTests.m in Sources */, 221 | ); 222 | runOnlyForDeploymentPostprocessing = 0; 223 | }; 224 | E098D7651D522BBA00F55BC1 /* Sources */ = { 225 | isa = PBXSourcesBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | E098D7741D522BBA00F55BC1 /* ViewController.m in Sources */, 229 | E098D7711D522BBA00F55BC1 /* AppDelegate.m in Sources */, 230 | E098D7851D522C1600F55BC1 /* TQLocationConverter.m in Sources */, 231 | E098D76E1D522BBA00F55BC1 /* main.m in Sources */, 232 | ); 233 | runOnlyForDeploymentPostprocessing = 0; 234 | }; 235 | /* End PBXSourcesBuildPhase section */ 236 | 237 | /* Begin PBXTargetDependency section */ 238 | A088585D1DB4B455004121FB /* PBXTargetDependency */ = { 239 | isa = PBXTargetDependency; 240 | target = E098D7681D522BBA00F55BC1 /* Test */; 241 | targetProxy = A088585C1DB4B455004121FB /* PBXContainerItemProxy */; 242 | }; 243 | /* End PBXTargetDependency section */ 244 | 245 | /* Begin PBXVariantGroup section */ 246 | E098D7751D522BBA00F55BC1 /* Main.storyboard */ = { 247 | isa = PBXVariantGroup; 248 | children = ( 249 | E098D7761D522BBA00F55BC1 /* Base */, 250 | ); 251 | name = Main.storyboard; 252 | sourceTree = ""; 253 | }; 254 | E098D77A1D522BBA00F55BC1 /* LaunchScreen.storyboard */ = { 255 | isa = PBXVariantGroup; 256 | children = ( 257 | E098D77B1D522BBA00F55BC1 /* Base */, 258 | ); 259 | name = LaunchScreen.storyboard; 260 | sourceTree = ""; 261 | }; 262 | /* End PBXVariantGroup section */ 263 | 264 | /* Begin XCBuildConfiguration section */ 265 | A088585E1DB4B456004121FB /* Debug */ = { 266 | isa = XCBuildConfiguration; 267 | buildSettings = { 268 | BUNDLE_LOADER = "$(TEST_HOST)"; 269 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 270 | CLANG_WARN_INFINITE_RECURSION = YES; 271 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 272 | INFOPLIST_FILE = TestTests/Info.plist; 273 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 274 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 275 | PRODUCT_BUNDLE_IDENTIFIER = com.mobvoi.TestTests; 276 | PRODUCT_NAME = "$(TARGET_NAME)"; 277 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Test.app/Test"; 278 | }; 279 | name = Debug; 280 | }; 281 | A088585F1DB4B456004121FB /* Release */ = { 282 | isa = XCBuildConfiguration; 283 | buildSettings = { 284 | BUNDLE_LOADER = "$(TEST_HOST)"; 285 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 286 | CLANG_WARN_INFINITE_RECURSION = YES; 287 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 288 | INFOPLIST_FILE = TestTests/Info.plist; 289 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 290 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 291 | PRODUCT_BUNDLE_IDENTIFIER = com.mobvoi.TestTests; 292 | PRODUCT_NAME = "$(TARGET_NAME)"; 293 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Test.app/Test"; 294 | }; 295 | name = Release; 296 | }; 297 | E098D77E1D522BBA00F55BC1 /* Debug */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ALWAYS_SEARCH_USER_PATHS = NO; 301 | CLANG_ANALYZER_NONNULL = YES; 302 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 303 | CLANG_CXX_LIBRARY = "libc++"; 304 | CLANG_ENABLE_MODULES = YES; 305 | CLANG_ENABLE_OBJC_ARC = YES; 306 | CLANG_WARN_BOOL_CONVERSION = YES; 307 | CLANG_WARN_CONSTANT_CONVERSION = YES; 308 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 309 | CLANG_WARN_EMPTY_BODY = YES; 310 | CLANG_WARN_ENUM_CONVERSION = YES; 311 | CLANG_WARN_INT_CONVERSION = YES; 312 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 313 | CLANG_WARN_UNREACHABLE_CODE = YES; 314 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 315 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 316 | COPY_PHASE_STRIP = NO; 317 | DEBUG_INFORMATION_FORMAT = dwarf; 318 | ENABLE_STRICT_OBJC_MSGSEND = YES; 319 | ENABLE_TESTABILITY = YES; 320 | GCC_C_LANGUAGE_STANDARD = gnu99; 321 | GCC_DYNAMIC_NO_PIC = NO; 322 | GCC_NO_COMMON_BLOCKS = YES; 323 | GCC_OPTIMIZATION_LEVEL = 0; 324 | GCC_PREPROCESSOR_DEFINITIONS = ( 325 | "DEBUG=1", 326 | "$(inherited)", 327 | ); 328 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 329 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 330 | GCC_WARN_UNDECLARED_SELECTOR = YES; 331 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 332 | GCC_WARN_UNUSED_FUNCTION = YES; 333 | GCC_WARN_UNUSED_VARIABLE = YES; 334 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 335 | MTL_ENABLE_DEBUG_INFO = YES; 336 | ONLY_ACTIVE_ARCH = YES; 337 | SDKROOT = iphoneos; 338 | }; 339 | name = Debug; 340 | }; 341 | E098D77F1D522BBA00F55BC1 /* Release */ = { 342 | isa = XCBuildConfiguration; 343 | buildSettings = { 344 | ALWAYS_SEARCH_USER_PATHS = NO; 345 | CLANG_ANALYZER_NONNULL = YES; 346 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 347 | CLANG_CXX_LIBRARY = "libc++"; 348 | CLANG_ENABLE_MODULES = YES; 349 | CLANG_ENABLE_OBJC_ARC = YES; 350 | CLANG_WARN_BOOL_CONVERSION = YES; 351 | CLANG_WARN_CONSTANT_CONVERSION = YES; 352 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 353 | CLANG_WARN_EMPTY_BODY = YES; 354 | CLANG_WARN_ENUM_CONVERSION = YES; 355 | CLANG_WARN_INT_CONVERSION = YES; 356 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 357 | CLANG_WARN_UNREACHABLE_CODE = YES; 358 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 359 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 360 | COPY_PHASE_STRIP = NO; 361 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 362 | ENABLE_NS_ASSERTIONS = NO; 363 | ENABLE_STRICT_OBJC_MSGSEND = YES; 364 | GCC_C_LANGUAGE_STANDARD = gnu99; 365 | GCC_NO_COMMON_BLOCKS = YES; 366 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 367 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 368 | GCC_WARN_UNDECLARED_SELECTOR = YES; 369 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 370 | GCC_WARN_UNUSED_FUNCTION = YES; 371 | GCC_WARN_UNUSED_VARIABLE = YES; 372 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 373 | MTL_ENABLE_DEBUG_INFO = NO; 374 | SDKROOT = iphoneos; 375 | VALIDATE_PRODUCT = YES; 376 | }; 377 | name = Release; 378 | }; 379 | E098D7811D522BBA00F55BC1 /* Debug */ = { 380 | isa = XCBuildConfiguration; 381 | buildSettings = { 382 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 383 | INFOPLIST_FILE = Test/Info.plist; 384 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 385 | PRODUCT_BUNDLE_IDENTIFIER = com.qfu.Test; 386 | PRODUCT_NAME = "$(TARGET_NAME)"; 387 | }; 388 | name = Debug; 389 | }; 390 | E098D7821D522BBA00F55BC1 /* Release */ = { 391 | isa = XCBuildConfiguration; 392 | buildSettings = { 393 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 394 | INFOPLIST_FILE = Test/Info.plist; 395 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 396 | PRODUCT_BUNDLE_IDENTIFIER = com.qfu.Test; 397 | PRODUCT_NAME = "$(TARGET_NAME)"; 398 | }; 399 | name = Release; 400 | }; 401 | /* End XCBuildConfiguration section */ 402 | 403 | /* Begin XCConfigurationList section */ 404 | A08858601DB4B456004121FB /* Build configuration list for PBXNativeTarget "TestTests" */ = { 405 | isa = XCConfigurationList; 406 | buildConfigurations = ( 407 | A088585E1DB4B456004121FB /* Debug */, 408 | A088585F1DB4B456004121FB /* Release */, 409 | ); 410 | defaultConfigurationIsVisible = 0; 411 | }; 412 | E098D7641D522BBA00F55BC1 /* Build configuration list for PBXProject "Test" */ = { 413 | isa = XCConfigurationList; 414 | buildConfigurations = ( 415 | E098D77E1D522BBA00F55BC1 /* Debug */, 416 | E098D77F1D522BBA00F55BC1 /* Release */, 417 | ); 418 | defaultConfigurationIsVisible = 0; 419 | defaultConfigurationName = Release; 420 | }; 421 | E098D7801D522BBA00F55BC1 /* Build configuration list for PBXNativeTarget "Test" */ = { 422 | isa = XCConfigurationList; 423 | buildConfigurations = ( 424 | E098D7811D522BBA00F55BC1 /* Debug */, 425 | E098D7821D522BBA00F55BC1 /* Release */, 426 | ); 427 | defaultConfigurationIsVisible = 0; 428 | defaultConfigurationName = Release; 429 | }; 430 | /* End XCConfigurationList section */ 431 | }; 432 | rootObject = E098D7611D522BBA00F55BC1 /* Project object */; 433 | } 434 | --------------------------------------------------------------------------------