├── .gitignore ├── .swift-version ├── .travis.yml ├── ARNavigation.podspec ├── ARNavigation.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata ├── xcshareddata │ └── xcschemes │ │ └── ARNavigation.xcscheme └── xcuserdata │ └── ChrisWebb.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── ARNavigation ├── ARNavigation.h ├── Annotation.swift ├── AnnotationService.swift ├── BaseNode.swift ├── CLLocation+Extension.swift ├── CLLocationCoordinate2D+Extension.swift ├── Double+Extension.swift ├── Info.plist ├── LocationConstants.swift ├── LocationService.swift ├── LocationServiceDelegate.swift ├── LocationTranslation.swift ├── MappingService.swift ├── MatrixHelper.swift ├── NavigationService.swift ├── SCNVector3+Extension.swift └── TapMap.swift ├── ARNavigationTests ├── ARNavigationTests.swift └── Info.plist ├── CODE_OF_CONDUCT.md ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 4.0 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode9.0.1 3 | script: 4 | - xcodebuild clean test -project ARNavigation.xcodeproj -scheme ARNavigation -destination 'platform=iOS Simulator,name=iPhone 7,OS=11.1' -------------------------------------------------------------------------------- /ARNavigation.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'ARNavigation' 3 | s.version = '0.1.2' 4 | s.summary = 'Navigation in Augmented reality.' 5 | 6 | s.description = <<-DESC 7 | The tools to setup navigation in augmented reality for iOS 11 ARKit. 8 | DESC 9 | 10 | s.homepage = 'https://github.com/chriswebb09/ARNavigation' 11 | s.license = { :type => 'MIT', :file => 'LICENSE' } 12 | s.author = { 'Christopher Webb' => 'chris.webb5249@gmail.com' } 13 | s.source = { :git => 'https://github.com/chriswebb09/ARNavigation.git', :tag => '0.1.2' } 14 | 15 | s.ios.deployment_target = '11.0' 16 | s.source_files = 'ARNavigation/*.swift' 17 | 18 | end -------------------------------------------------------------------------------- /ARNavigation.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A7025D4E1F98A3070059A05C /* LocationServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7025D4D1F98A3070059A05C /* LocationServiceDelegate.swift */; }; 11 | A7025D501F98A43C0059A05C /* LocationConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7025D4F1F98A43C0059A05C /* LocationConstants.swift */; }; 12 | A7025D521F98A45B0059A05C /* LocationTranslation.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7025D511F98A45B0059A05C /* LocationTranslation.swift */; }; 13 | A752AB081F98AE6F00D82000 /* BaseNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = A752AB071F98AE6F00D82000 /* BaseNode.swift */; }; 14 | A752AB0A1F98AEAB00D82000 /* Annotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = A752AB091F98AEAB00D82000 /* Annotation.swift */; }; 15 | A752AB0C1F98B06000D82000 /* MappingService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A752AB0B1F98B06000D82000 /* MappingService.swift */; }; 16 | A752AB0E1F98B06B00D82000 /* AnnotationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A752AB0D1F98B06B00D82000 /* AnnotationService.swift */; }; 17 | A752AB101F98B56800D82000 /* TapMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = A752AB0F1F98B56800D82000 /* TapMap.swift */; }; 18 | A77EB11C1F98056E004E0161 /* ARNavigation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A77EB1121F98056E004E0161 /* ARNavigation.framework */; }; 19 | A77EB1211F98056E004E0161 /* ARNavigationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77EB1201F98056E004E0161 /* ARNavigationTests.swift */; }; 20 | A77EB1231F98056E004E0161 /* ARNavigation.h in Headers */ = {isa = PBXBuildFile; fileRef = A77EB1151F98056E004E0161 /* ARNavigation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 21 | A77EB12F1F9805A5004E0161 /* Double+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77EB12C1F9805A5004E0161 /* Double+Extension.swift */; }; 22 | A77EB1301F9805A5004E0161 /* CLLocation+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77EB12D1F9805A5004E0161 /* CLLocation+Extension.swift */; }; 23 | A77EB1311F9805A5004E0161 /* CLLocationCoordinate2D+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77EB12E1F9805A5004E0161 /* CLLocationCoordinate2D+Extension.swift */; }; 24 | A77EB1361F9805AB004E0161 /* LocationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77EB1321F9805AB004E0161 /* LocationService.swift */; }; 25 | A77EB1371F9805AB004E0161 /* MatrixHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77EB1331F9805AB004E0161 /* MatrixHelper.swift */; }; 26 | A77EB1381F9805AB004E0161 /* NavigationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77EB1341F9805AB004E0161 /* NavigationService.swift */; }; 27 | A77EB1391F9805AB004E0161 /* SCNVector3+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77EB1351F9805AB004E0161 /* SCNVector3+Extension.swift */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXContainerItemProxy section */ 31 | A77EB11D1F98056E004E0161 /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = A77EB1091F98056E004E0161 /* Project object */; 34 | proxyType = 1; 35 | remoteGlobalIDString = A77EB1111F98056E004E0161; 36 | remoteInfo = ARNavigation; 37 | }; 38 | /* End PBXContainerItemProxy section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | A7025D4D1F98A3070059A05C /* LocationServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationServiceDelegate.swift; sourceTree = ""; }; 42 | A7025D4F1F98A43C0059A05C /* LocationConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationConstants.swift; sourceTree = ""; }; 43 | A7025D511F98A45B0059A05C /* LocationTranslation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationTranslation.swift; sourceTree = ""; }; 44 | A752AB071F98AE6F00D82000 /* BaseNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseNode.swift; sourceTree = ""; }; 45 | A752AB091F98AEAB00D82000 /* Annotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Annotation.swift; sourceTree = ""; }; 46 | A752AB0B1F98B06000D82000 /* MappingService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MappingService.swift; sourceTree = ""; }; 47 | A752AB0D1F98B06B00D82000 /* AnnotationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnnotationService.swift; sourceTree = ""; }; 48 | A752AB0F1F98B56800D82000 /* TapMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TapMap.swift; sourceTree = ""; }; 49 | A77EB1121F98056E004E0161 /* ARNavigation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ARNavigation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | A77EB1151F98056E004E0161 /* ARNavigation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ARNavigation.h; sourceTree = ""; }; 51 | A77EB1161F98056E004E0161 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | A77EB11B1F98056E004E0161 /* ARNavigationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ARNavigationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | A77EB1201F98056E004E0161 /* ARNavigationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ARNavigationTests.swift; sourceTree = ""; }; 54 | A77EB1221F98056E004E0161 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | A77EB12C1F9805A5004E0161 /* Double+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Double+Extension.swift"; sourceTree = ""; }; 56 | A77EB12D1F9805A5004E0161 /* CLLocation+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CLLocation+Extension.swift"; sourceTree = ""; }; 57 | A77EB12E1F9805A5004E0161 /* CLLocationCoordinate2D+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CLLocationCoordinate2D+Extension.swift"; sourceTree = ""; }; 58 | A77EB1321F9805AB004E0161 /* LocationService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocationService.swift; sourceTree = ""; }; 59 | A77EB1331F9805AB004E0161 /* MatrixHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MatrixHelper.swift; sourceTree = ""; }; 60 | A77EB1341F9805AB004E0161 /* NavigationService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationService.swift; sourceTree = ""; }; 61 | A77EB1351F9805AB004E0161 /* SCNVector3+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SCNVector3+Extension.swift"; sourceTree = ""; }; 62 | /* End PBXFileReference section */ 63 | 64 | /* Begin PBXFrameworksBuildPhase section */ 65 | A77EB10E1F98056E004E0161 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | A77EB1181F98056E004E0161 /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | A77EB11C1F98056E004E0161 /* ARNavigation.framework in Frameworks */, 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXFrameworksBuildPhase section */ 81 | 82 | /* Begin PBXGroup section */ 83 | A77EB1081F98056E004E0161 = { 84 | isa = PBXGroup; 85 | children = ( 86 | A77EB1141F98056E004E0161 /* ARNavigation */, 87 | A77EB11F1F98056E004E0161 /* ARNavigationTests */, 88 | A77EB1131F98056E004E0161 /* Products */, 89 | ); 90 | sourceTree = ""; 91 | }; 92 | A77EB1131F98056E004E0161 /* Products */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | A77EB1121F98056E004E0161 /* ARNavigation.framework */, 96 | A77EB11B1F98056E004E0161 /* ARNavigationTests.xctest */, 97 | ); 98 | name = Products; 99 | sourceTree = ""; 100 | }; 101 | A77EB1141F98056E004E0161 /* ARNavigation */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | A77EB1321F9805AB004E0161 /* LocationService.swift */, 105 | A7025D4D1F98A3070059A05C /* LocationServiceDelegate.swift */, 106 | A77EB1331F9805AB004E0161 /* MatrixHelper.swift */, 107 | A77EB1341F9805AB004E0161 /* NavigationService.swift */, 108 | A77EB1351F9805AB004E0161 /* SCNVector3+Extension.swift */, 109 | A77EB12D1F9805A5004E0161 /* CLLocation+Extension.swift */, 110 | A77EB12E1F9805A5004E0161 /* CLLocationCoordinate2D+Extension.swift */, 111 | A77EB12C1F9805A5004E0161 /* Double+Extension.swift */, 112 | A77EB1151F98056E004E0161 /* ARNavigation.h */, 113 | A77EB1161F98056E004E0161 /* Info.plist */, 114 | A7025D4F1F98A43C0059A05C /* LocationConstants.swift */, 115 | A7025D511F98A45B0059A05C /* LocationTranslation.swift */, 116 | A752AB071F98AE6F00D82000 /* BaseNode.swift */, 117 | A752AB091F98AEAB00D82000 /* Annotation.swift */, 118 | A752AB0B1F98B06000D82000 /* MappingService.swift */, 119 | A752AB0D1F98B06B00D82000 /* AnnotationService.swift */, 120 | A752AB0F1F98B56800D82000 /* TapMap.swift */, 121 | ); 122 | path = ARNavigation; 123 | sourceTree = ""; 124 | }; 125 | A77EB11F1F98056E004E0161 /* ARNavigationTests */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | A77EB1201F98056E004E0161 /* ARNavigationTests.swift */, 129 | A77EB1221F98056E004E0161 /* Info.plist */, 130 | ); 131 | path = ARNavigationTests; 132 | sourceTree = ""; 133 | }; 134 | /* End PBXGroup section */ 135 | 136 | /* Begin PBXHeadersBuildPhase section */ 137 | A77EB10F1F98056E004E0161 /* Headers */ = { 138 | isa = PBXHeadersBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | A77EB1231F98056E004E0161 /* ARNavigation.h in Headers */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXHeadersBuildPhase section */ 146 | 147 | /* Begin PBXNativeTarget section */ 148 | A77EB1111F98056E004E0161 /* ARNavigation */ = { 149 | isa = PBXNativeTarget; 150 | buildConfigurationList = A77EB1261F98056E004E0161 /* Build configuration list for PBXNativeTarget "ARNavigation" */; 151 | buildPhases = ( 152 | A77EB10D1F98056E004E0161 /* Sources */, 153 | A77EB10E1F98056E004E0161 /* Frameworks */, 154 | A77EB10F1F98056E004E0161 /* Headers */, 155 | A77EB1101F98056E004E0161 /* Resources */, 156 | ); 157 | buildRules = ( 158 | ); 159 | dependencies = ( 160 | ); 161 | name = ARNavigation; 162 | productName = ARNavigation; 163 | productReference = A77EB1121F98056E004E0161 /* ARNavigation.framework */; 164 | productType = "com.apple.product-type.framework"; 165 | }; 166 | A77EB11A1F98056E004E0161 /* ARNavigationTests */ = { 167 | isa = PBXNativeTarget; 168 | buildConfigurationList = A77EB1291F98056E004E0161 /* Build configuration list for PBXNativeTarget "ARNavigationTests" */; 169 | buildPhases = ( 170 | A77EB1171F98056E004E0161 /* Sources */, 171 | A77EB1181F98056E004E0161 /* Frameworks */, 172 | A77EB1191F98056E004E0161 /* Resources */, 173 | ); 174 | buildRules = ( 175 | ); 176 | dependencies = ( 177 | A77EB11E1F98056E004E0161 /* PBXTargetDependency */, 178 | ); 179 | name = ARNavigationTests; 180 | productName = ARNavigationTests; 181 | productReference = A77EB11B1F98056E004E0161 /* ARNavigationTests.xctest */; 182 | productType = "com.apple.product-type.bundle.unit-test"; 183 | }; 184 | /* End PBXNativeTarget section */ 185 | 186 | /* Begin PBXProject section */ 187 | A77EB1091F98056E004E0161 /* Project object */ = { 188 | isa = PBXProject; 189 | attributes = { 190 | LastSwiftUpdateCheck = 0900; 191 | LastUpgradeCheck = 0900; 192 | ORGANIZATIONNAME = "Christopher Webb-Orenstein"; 193 | TargetAttributes = { 194 | A77EB1111F98056E004E0161 = { 195 | CreatedOnToolsVersion = 9.0.1; 196 | LastSwiftMigration = 0900; 197 | ProvisioningStyle = Automatic; 198 | }; 199 | A77EB11A1F98056E004E0161 = { 200 | CreatedOnToolsVersion = 9.0.1; 201 | ProvisioningStyle = Automatic; 202 | }; 203 | }; 204 | }; 205 | buildConfigurationList = A77EB10C1F98056E004E0161 /* Build configuration list for PBXProject "ARNavigation" */; 206 | compatibilityVersion = "Xcode 8.0"; 207 | developmentRegion = en; 208 | hasScannedForEncodings = 0; 209 | knownRegions = ( 210 | en, 211 | ); 212 | mainGroup = A77EB1081F98056E004E0161; 213 | productRefGroup = A77EB1131F98056E004E0161 /* Products */; 214 | projectDirPath = ""; 215 | projectRoot = ""; 216 | targets = ( 217 | A77EB1111F98056E004E0161 /* ARNavigation */, 218 | A77EB11A1F98056E004E0161 /* ARNavigationTests */, 219 | ); 220 | }; 221 | /* End PBXProject section */ 222 | 223 | /* Begin PBXResourcesBuildPhase section */ 224 | A77EB1101F98056E004E0161 /* Resources */ = { 225 | isa = PBXResourcesBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | ); 229 | runOnlyForDeploymentPostprocessing = 0; 230 | }; 231 | A77EB1191F98056E004E0161 /* Resources */ = { 232 | isa = PBXResourcesBuildPhase; 233 | buildActionMask = 2147483647; 234 | files = ( 235 | ); 236 | runOnlyForDeploymentPostprocessing = 0; 237 | }; 238 | /* End PBXResourcesBuildPhase section */ 239 | 240 | /* Begin PBXSourcesBuildPhase section */ 241 | A77EB10D1F98056E004E0161 /* Sources */ = { 242 | isa = PBXSourcesBuildPhase; 243 | buildActionMask = 2147483647; 244 | files = ( 245 | A77EB12F1F9805A5004E0161 /* Double+Extension.swift in Sources */, 246 | A752AB101F98B56800D82000 /* TapMap.swift in Sources */, 247 | A77EB1381F9805AB004E0161 /* NavigationService.swift in Sources */, 248 | A7025D521F98A45B0059A05C /* LocationTranslation.swift in Sources */, 249 | A77EB1391F9805AB004E0161 /* SCNVector3+Extension.swift in Sources */, 250 | A752AB0E1F98B06B00D82000 /* AnnotationService.swift in Sources */, 251 | A7025D501F98A43C0059A05C /* LocationConstants.swift in Sources */, 252 | A77EB1301F9805A5004E0161 /* CLLocation+Extension.swift in Sources */, 253 | A752AB081F98AE6F00D82000 /* BaseNode.swift in Sources */, 254 | A77EB1361F9805AB004E0161 /* LocationService.swift in Sources */, 255 | A7025D4E1F98A3070059A05C /* LocationServiceDelegate.swift in Sources */, 256 | A77EB1311F9805A5004E0161 /* CLLocationCoordinate2D+Extension.swift in Sources */, 257 | A752AB0C1F98B06000D82000 /* MappingService.swift in Sources */, 258 | A752AB0A1F98AEAB00D82000 /* Annotation.swift in Sources */, 259 | A77EB1371F9805AB004E0161 /* MatrixHelper.swift in Sources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | A77EB1171F98056E004E0161 /* Sources */ = { 264 | isa = PBXSourcesBuildPhase; 265 | buildActionMask = 2147483647; 266 | files = ( 267 | A77EB1211F98056E004E0161 /* ARNavigationTests.swift in Sources */, 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | /* End PBXSourcesBuildPhase section */ 272 | 273 | /* Begin PBXTargetDependency section */ 274 | A77EB11E1F98056E004E0161 /* PBXTargetDependency */ = { 275 | isa = PBXTargetDependency; 276 | target = A77EB1111F98056E004E0161 /* ARNavigation */; 277 | targetProxy = A77EB11D1F98056E004E0161 /* PBXContainerItemProxy */; 278 | }; 279 | /* End PBXTargetDependency section */ 280 | 281 | /* Begin XCBuildConfiguration section */ 282 | A77EB1241F98056E004E0161 /* Debug */ = { 283 | isa = XCBuildConfiguration; 284 | buildSettings = { 285 | ALWAYS_SEARCH_USER_PATHS = NO; 286 | CLANG_ANALYZER_NONNULL = YES; 287 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 288 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 289 | CLANG_CXX_LIBRARY = "libc++"; 290 | CLANG_ENABLE_MODULES = YES; 291 | CLANG_ENABLE_OBJC_ARC = YES; 292 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 293 | CLANG_WARN_BOOL_CONVERSION = YES; 294 | CLANG_WARN_COMMA = YES; 295 | CLANG_WARN_CONSTANT_CONVERSION = YES; 296 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 297 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 298 | CLANG_WARN_EMPTY_BODY = YES; 299 | CLANG_WARN_ENUM_CONVERSION = YES; 300 | CLANG_WARN_INFINITE_RECURSION = YES; 301 | CLANG_WARN_INT_CONVERSION = YES; 302 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 303 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 304 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 305 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 306 | CLANG_WARN_STRICT_PROTOTYPES = YES; 307 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 308 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 309 | CLANG_WARN_UNREACHABLE_CODE = YES; 310 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 311 | CODE_SIGN_IDENTITY = "iPhone Developer"; 312 | COPY_PHASE_STRIP = NO; 313 | CURRENT_PROJECT_VERSION = 1; 314 | DEBUG_INFORMATION_FORMAT = dwarf; 315 | ENABLE_STRICT_OBJC_MSGSEND = YES; 316 | ENABLE_TESTABILITY = YES; 317 | GCC_C_LANGUAGE_STANDARD = gnu11; 318 | GCC_DYNAMIC_NO_PIC = NO; 319 | GCC_NO_COMMON_BLOCKS = YES; 320 | GCC_OPTIMIZATION_LEVEL = 0; 321 | GCC_PREPROCESSOR_DEFINITIONS = ( 322 | "DEBUG=1", 323 | "$(inherited)", 324 | ); 325 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 326 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 327 | GCC_WARN_UNDECLARED_SELECTOR = YES; 328 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 329 | GCC_WARN_UNUSED_FUNCTION = YES; 330 | GCC_WARN_UNUSED_VARIABLE = YES; 331 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 332 | MTL_ENABLE_DEBUG_INFO = YES; 333 | ONLY_ACTIVE_ARCH = YES; 334 | SDKROOT = iphoneos; 335 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 336 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 337 | VERSIONING_SYSTEM = "apple-generic"; 338 | VERSION_INFO_PREFIX = ""; 339 | }; 340 | name = Debug; 341 | }; 342 | A77EB1251F98056E004E0161 /* Release */ = { 343 | isa = XCBuildConfiguration; 344 | buildSettings = { 345 | ALWAYS_SEARCH_USER_PATHS = NO; 346 | CLANG_ANALYZER_NONNULL = YES; 347 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 348 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 349 | CLANG_CXX_LIBRARY = "libc++"; 350 | CLANG_ENABLE_MODULES = YES; 351 | CLANG_ENABLE_OBJC_ARC = YES; 352 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 353 | CLANG_WARN_BOOL_CONVERSION = YES; 354 | CLANG_WARN_COMMA = YES; 355 | CLANG_WARN_CONSTANT_CONVERSION = YES; 356 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 357 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 358 | CLANG_WARN_EMPTY_BODY = YES; 359 | CLANG_WARN_ENUM_CONVERSION = YES; 360 | CLANG_WARN_INFINITE_RECURSION = YES; 361 | CLANG_WARN_INT_CONVERSION = YES; 362 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 363 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 364 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 365 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 366 | CLANG_WARN_STRICT_PROTOTYPES = YES; 367 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 368 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 369 | CLANG_WARN_UNREACHABLE_CODE = YES; 370 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 371 | CODE_SIGN_IDENTITY = "iPhone Developer"; 372 | COPY_PHASE_STRIP = NO; 373 | CURRENT_PROJECT_VERSION = 1; 374 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 375 | ENABLE_NS_ASSERTIONS = NO; 376 | ENABLE_STRICT_OBJC_MSGSEND = YES; 377 | GCC_C_LANGUAGE_STANDARD = gnu11; 378 | GCC_NO_COMMON_BLOCKS = YES; 379 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 380 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 381 | GCC_WARN_UNDECLARED_SELECTOR = YES; 382 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 383 | GCC_WARN_UNUSED_FUNCTION = YES; 384 | GCC_WARN_UNUSED_VARIABLE = YES; 385 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 386 | MTL_ENABLE_DEBUG_INFO = NO; 387 | SDKROOT = iphoneos; 388 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 389 | VALIDATE_PRODUCT = YES; 390 | VERSIONING_SYSTEM = "apple-generic"; 391 | VERSION_INFO_PREFIX = ""; 392 | }; 393 | name = Release; 394 | }; 395 | A77EB1271F98056E004E0161 /* Debug */ = { 396 | isa = XCBuildConfiguration; 397 | buildSettings = { 398 | CLANG_ENABLE_MODULES = YES; 399 | CODE_SIGN_IDENTITY = ""; 400 | CODE_SIGN_STYLE = Automatic; 401 | DEFINES_MODULE = YES; 402 | DEVELOPMENT_TEAM = 4SZP4Q326F; 403 | DYLIB_COMPATIBILITY_VERSION = 1; 404 | DYLIB_CURRENT_VERSION = 1; 405 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 406 | INFOPLIST_FILE = ARNavigation/Info.plist; 407 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 409 | PRODUCT_BUNDLE_IDENTIFIER = com.froleeyo.ARNavigation; 410 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 411 | SKIP_INSTALL = YES; 412 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 413 | SWIFT_VERSION = 4.0; 414 | TARGETED_DEVICE_FAMILY = "1,2"; 415 | }; 416 | name = Debug; 417 | }; 418 | A77EB1281F98056E004E0161 /* Release */ = { 419 | isa = XCBuildConfiguration; 420 | buildSettings = { 421 | CLANG_ENABLE_MODULES = YES; 422 | CODE_SIGN_IDENTITY = ""; 423 | CODE_SIGN_STYLE = Automatic; 424 | DEFINES_MODULE = YES; 425 | DEVELOPMENT_TEAM = 4SZP4Q326F; 426 | DYLIB_COMPATIBILITY_VERSION = 1; 427 | DYLIB_CURRENT_VERSION = 1; 428 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 429 | INFOPLIST_FILE = ARNavigation/Info.plist; 430 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 431 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 432 | PRODUCT_BUNDLE_IDENTIFIER = com.froleeyo.ARNavigation; 433 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 434 | SKIP_INSTALL = YES; 435 | SWIFT_VERSION = 4.0; 436 | TARGETED_DEVICE_FAMILY = "1,2"; 437 | }; 438 | name = Release; 439 | }; 440 | A77EB12A1F98056E004E0161 /* Debug */ = { 441 | isa = XCBuildConfiguration; 442 | buildSettings = { 443 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 444 | CODE_SIGN_STYLE = Automatic; 445 | DEVELOPMENT_TEAM = 4SZP4Q326F; 446 | INFOPLIST_FILE = ARNavigationTests/Info.plist; 447 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 448 | PRODUCT_BUNDLE_IDENTIFIER = com.froleeyo.ARNavigationTests; 449 | PRODUCT_NAME = "$(TARGET_NAME)"; 450 | SWIFT_VERSION = 4.0; 451 | TARGETED_DEVICE_FAMILY = "1,2"; 452 | }; 453 | name = Debug; 454 | }; 455 | A77EB12B1F98056E004E0161 /* Release */ = { 456 | isa = XCBuildConfiguration; 457 | buildSettings = { 458 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 459 | CODE_SIGN_STYLE = Automatic; 460 | DEVELOPMENT_TEAM = 4SZP4Q326F; 461 | INFOPLIST_FILE = ARNavigationTests/Info.plist; 462 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 463 | PRODUCT_BUNDLE_IDENTIFIER = com.froleeyo.ARNavigationTests; 464 | PRODUCT_NAME = "$(TARGET_NAME)"; 465 | SWIFT_VERSION = 4.0; 466 | TARGETED_DEVICE_FAMILY = "1,2"; 467 | }; 468 | name = Release; 469 | }; 470 | /* End XCBuildConfiguration section */ 471 | 472 | /* Begin XCConfigurationList section */ 473 | A77EB10C1F98056E004E0161 /* Build configuration list for PBXProject "ARNavigation" */ = { 474 | isa = XCConfigurationList; 475 | buildConfigurations = ( 476 | A77EB1241F98056E004E0161 /* Debug */, 477 | A77EB1251F98056E004E0161 /* Release */, 478 | ); 479 | defaultConfigurationIsVisible = 0; 480 | defaultConfigurationName = Release; 481 | }; 482 | A77EB1261F98056E004E0161 /* Build configuration list for PBXNativeTarget "ARNavigation" */ = { 483 | isa = XCConfigurationList; 484 | buildConfigurations = ( 485 | A77EB1271F98056E004E0161 /* Debug */, 486 | A77EB1281F98056E004E0161 /* Release */, 487 | ); 488 | defaultConfigurationIsVisible = 0; 489 | defaultConfigurationName = Release; 490 | }; 491 | A77EB1291F98056E004E0161 /* Build configuration list for PBXNativeTarget "ARNavigationTests" */ = { 492 | isa = XCConfigurationList; 493 | buildConfigurations = ( 494 | A77EB12A1F98056E004E0161 /* Debug */, 495 | A77EB12B1F98056E004E0161 /* Release */, 496 | ); 497 | defaultConfigurationIsVisible = 0; 498 | defaultConfigurationName = Release; 499 | }; 500 | /* End XCConfigurationList section */ 501 | }; 502 | rootObject = A77EB1091F98056E004E0161 /* Project object */; 503 | } 504 | -------------------------------------------------------------------------------- /ARNavigation.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ARNavigation.xcodeproj/xcshareddata/xcschemes/ARNavigation.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 66 | 67 | 73 | 74 | 75 | 76 | 77 | 78 | 84 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /ARNavigation.xcodeproj/xcuserdata/ChrisWebb.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ARNavigation.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | A77EB1111F98056E004E0161 16 | 17 | primary 18 | 19 | 20 | A77EB11A1F98056E004E0161 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ARNavigation/ARNavigation.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARNavigation.h 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/18/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for ARNavigation. 12 | FOUNDATION_EXPORT double ARNavigationVersionNumber; 13 | 14 | //! Project version string for ARNavigation. 15 | FOUNDATION_EXPORT const unsigned char ARNavigationVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /ARNavigation/Annotation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Annotation.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/19/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import MapKit 11 | 12 | open class Annotation: NSObject, MKAnnotation { 13 | 14 | public var coordinate: CLLocationCoordinate2D 15 | 16 | public var title: String? 17 | 18 | public var subtitle: String? 19 | 20 | public init(coordinate: CLLocationCoordinate2D, name: String) { 21 | self.coordinate = coordinate 22 | self.title = name 23 | self.subtitle = "(\(coordinate.latitude),\(coordinate.longitude))" 24 | super.init() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ARNavigation/AnnotationService.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnnotationService.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/19/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MapKit 11 | import CoreLocation 12 | import ARKit 13 | 14 | open class AnnotationService { 15 | 16 | var startingLocation: CLLocation! 17 | var sceneView: ARSCNView! 18 | var nodes: [BaseNode]! 19 | var anchors: [ARAnchor]! 20 | var updateNodes: Bool! 21 | var locationUpdates: Int = 0 22 | var updatedLocations: [CLLocation]! 23 | 24 | private func addSphere(for step: MKRouteStep) { 25 | DispatchQueue.main.async { 26 | let stepLocation = step.getLocation() 27 | let locationTransform = MatrixHelper.transformMatrix(for: matrix_identity_float4x4, originLocation: self.startingLocation, location: stepLocation) 28 | let stepAnchor = ARAnchor(transform: locationTransform) 29 | let sphere = BaseNode(title: step.instructions, location: stepLocation) 30 | self.anchors.append(stepAnchor) 31 | 32 | sphere.addNode(with: 0.3, and: .green, and: step.instructions) 33 | sphere.location = stepLocation 34 | sphere.anchor = stepAnchor 35 | self.sceneView.session.add(anchor: stepAnchor) 36 | self.sceneView.scene.rootNode.addChildNode(sphere) 37 | self.nodes.append(sphere) 38 | } 39 | 40 | } 41 | 42 | // For intermediary locations - CLLocation - add sphere 43 | 44 | private func addSphere(for location: CLLocation) { 45 | DispatchQueue.main.async { 46 | let locationTransform = MatrixHelper.transformMatrix(for: matrix_identity_float4x4, originLocation: self.startingLocation, location: location) 47 | let stepAnchor = ARAnchor(transform: locationTransform) 48 | let sphere = BaseNode(title: "Title", location: location) 49 | 50 | sphere.addSphere(with: 0.25, and: .blue) 51 | self.anchors.append(stepAnchor) 52 | sphere.location = location 53 | self.sceneView.session.add(anchor: stepAnchor) 54 | self.sceneView.scene.rootNode.addChildNode(sphere) 55 | sphere.anchor = stepAnchor 56 | self.nodes.append(sphere) 57 | } 58 | } 59 | 60 | 61 | private func updateNodePosition() { 62 | if updateNodes { 63 | locationUpdates += 1 64 | SCNTransaction.begin() 65 | SCNTransaction.animationDuration = 0.5 66 | if updatedLocations.count > 0 { 67 | startingLocation = CLLocation.bestLocationEstimate(locations: updatedLocations) 68 | for baseNode in nodes { 69 | let translation = MatrixHelper.transformMatrix(for: matrix_identity_float4x4, originLocation: startingLocation, location: baseNode.location) 70 | let position = SCNVector3.positionFrom(translation) 71 | let distance = baseNode.location.distance(from: startingLocation) 72 | DispatchQueue.main.async { 73 | let scale = 100 / Float(distance) 74 | baseNode.scale = SCNVector3(x: scale, y: scale, z: scale) 75 | baseNode.anchor = ARAnchor(transform: translation) 76 | baseNode.position = position 77 | } 78 | } 79 | } 80 | SCNTransaction.commit() 81 | } 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /ARNavigation/BaseNode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BaseNode.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/19/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import SceneKit 10 | import UIKit 11 | import ARKit 12 | import CoreLocation 13 | 14 | open class BaseNode: SCNNode { 15 | 16 | public let title: String 17 | public var anchor: ARAnchor? 18 | public var location: CLLocation! 19 | 20 | public init(title: String, location: CLLocation) { 21 | self.title = title 22 | super.init() 23 | let billboardConstraint = SCNBillboardConstraint() 24 | billboardConstraint.freeAxes = SCNBillboardAxis.Y 25 | constraints = [billboardConstraint] 26 | } 27 | 28 | required public init?(coder aDecoder: NSCoder) { 29 | fatalError("init(coder:) has not been implemented") 30 | } 31 | 32 | public func createSphereNode(with radius: CGFloat, color: UIColor) -> SCNNode { 33 | let geometry = SCNSphere(radius: radius) 34 | geometry.firstMaterial?.diffuse.contents = color 35 | let sphereNode = SCNNode(geometry: geometry) 36 | return sphereNode 37 | } 38 | 39 | public func addSphere(with radius: CGFloat, and color: UIColor) { 40 | let sphereNode = createSphereNode(with: radius, color: color) 41 | addChildNode(sphereNode) 42 | } 43 | 44 | public func addNode(with radius: CGFloat, and color: UIColor, and text: String) { 45 | let sphereNode = createSphereNode(with: radius, color: color) 46 | let newText = SCNText(string: title, extrusionDepth: 0.05) 47 | newText.font = UIFont (name: "AvenirNext-Medium", size: 1) 48 | newText.firstMaterial?.diffuse.contents = UIColor.red 49 | let _textNode = SCNNode(geometry: newText) 50 | let annotationNode = SCNNode() 51 | annotationNode.addChildNode(_textNode) 52 | annotationNode.position = sphereNode.position 53 | addChildNode(sphereNode) 54 | addChildNode(annotationNode) 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /ARNavigation/CLLocation+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CLLocation+Extension.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/18/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreLocation 11 | import GLKit 12 | import SceneKit 13 | 14 | public func -(left: CLLocationCoordinate2D, right: CLLocationCoordinate2D) -> CLLocationDistance { 15 | 16 | let leftLatRadian = left.latitude.toRadians() 17 | let leftLonRadian = left.longitude.toRadians() 18 | 19 | let rightLatRadian = right.latitude.toRadians() 20 | let rightLonRadian = right.longitude.toRadians() 21 | 22 | let a = pow(sin((rightLatRadian - leftLatRadian) / 2), 2) 23 | + pow(sin((rightLonRadian - leftLonRadian) / 2), 2) * cos(leftLatRadian) * cos(rightLatRadian) 24 | return 2 * atan2(sqrt(a), sqrt(1 - a)) 25 | } 26 | 27 | extension CLLocation { 28 | 29 | public func bearingToLocationRadian(_ destinationLocation: CLLocation) -> Double { 30 | 31 | let lat1 = self.coordinate.latitude.toRadians() 32 | let lon1 = self.coordinate.longitude.toRadians() 33 | 34 | let lat2 = destinationLocation.coordinate.latitude.toRadians() 35 | let lon2 = destinationLocation.coordinate.longitude.toRadians() 36 | let dLon = lon2 - lon1 37 | let y = sin(dLon) * cos(lat2); 38 | let x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon); 39 | let radiansBearing = atan2(y, x) 40 | return radiansBearing 41 | } 42 | 43 | public func translatedLocation(with latitudeTranslation: Double, longitudeTranslation: Double, altitudeTranslation: Double) -> CLLocation { 44 | let latitudeCoordinate = self.coordinate.coordinate(with: 0, and: latitudeTranslation) 45 | let longitudeCoordinate = self.coordinate.coordinate(with: 90, and: longitudeTranslation) 46 | let coordinate = CLLocationCoordinate2D( 47 | latitude: latitudeCoordinate.latitude, 48 | longitude: longitudeCoordinate.longitude) 49 | let altitude = self.altitude + altitudeTranslation 50 | return CLLocation(coordinate: coordinate, altitude: altitude, horizontalAccuracy: self.horizontalAccuracy, verticalAccuracy: self.verticalAccuracy, timestamp: self.timestamp) 51 | } 52 | 53 | public func translation(toLocation location: CLLocation) -> LocationTranslation { 54 | let inbetweenLocation = CLLocation(latitude: self.coordinate.latitude, longitude: location.coordinate.longitude) 55 | let distanceLatitude = location.distance(from: inbetweenLocation) 56 | let latitudeTranslation: Double 57 | if location.coordinate.latitude > inbetweenLocation.coordinate.latitude { 58 | latitudeTranslation = distanceLatitude 59 | } else { 60 | latitudeTranslation = 0 - distanceLatitude 61 | } 62 | let distanceLongitude = self.distance(from: inbetweenLocation) 63 | let longitudeTranslation: Double 64 | if self.coordinate.longitude > inbetweenLocation.coordinate.longitude { 65 | longitudeTranslation = 0 - distanceLongitude 66 | } else { 67 | longitudeTranslation = distanceLongitude 68 | } 69 | let altitudeTranslation = location.altitude - self.altitude 70 | return LocationTranslation( 71 | latitudeTranslation: latitudeTranslation, 72 | longitudeTranslation: longitudeTranslation, 73 | altitudeTranslation: altitudeTranslation) 74 | } 75 | 76 | public static func bestLocationEstimate(locations: [CLLocation]) -> CLLocation { 77 | let sortedLocationEstimates = locations.sorted(by: { 78 | if $0.horizontalAccuracy == $1.horizontalAccuracy { 79 | return $0.timestamp > $1.timestamp 80 | } 81 | return $0.horizontalAccuracy < $1.horizontalAccuracy 82 | }) 83 | return sortedLocationEstimates.first! 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /ARNavigation/CLLocationCoordinate2D+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CLLocationCoordinate2D+Extension.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/18/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreLocation 11 | 12 | extension CLLocationCoordinate2D: Equatable { 13 | 14 | public static func ==(lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool { 15 | return lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude 16 | } 17 | 18 | public func bearingToLocationRadian(_ destinationLocation: CLLocationCoordinate2D) -> Double { 19 | 20 | let lat1 = latitude.toRadians() 21 | let lon1 = longitude.toRadians() 22 | let lat2 = destinationLocation.latitude.toRadians() 23 | let lon2 = destinationLocation.longitude.toRadians() 24 | 25 | let dLon = lon2 - lon1 26 | let y = sin(dLon) * cos(lat2) 27 | let x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon) 28 | let radiansBearing = atan2(y, x) 29 | return radiansBearing 30 | } 31 | 32 | public func calculateDirection(to coordinate: CLLocationCoordinate2D) -> Double { 33 | let a = sin(coordinate.longitude.toRadians() - longitude.toRadians()) * cos(coordinate.latitude.toRadians()) 34 | let dLat = cos(latitude.toRadians()) * sin(coordinate.latitude.toRadians()) - sin(latitude.toRadians()) 35 | let dLon = cos(coordinate.latitude.toRadians()) * cos(coordinate.longitude.toRadians() - longitude.toRadians()) 36 | let b = dLat * dLon 37 | return atan2(a, b) 38 | } 39 | 40 | public func direction(to coordinate: CLLocationCoordinate2D) -> CLLocationDirection { 41 | return self.calculateDirection(to: coordinate).toDegrees() 42 | } 43 | 44 | public func coordinate(with bearing: Double, and distance: Double) -> CLLocationCoordinate2D { 45 | let distRadiansLat = distance / LocationConstants.metersPerRadianLat // earth radius in meters latitude 46 | let distRadiansLong = distance / LocationConstants.metersPerRadianLon // earth radius in meters longitude 47 | let lat1 = self.latitude.toRadians() 48 | let lon1 = self.longitude.toRadians() 49 | let lat2 = asin(sin(lat1) * cos(distRadiansLat) + cos(lat1) * sin(distRadiansLat) * cos(bearing)) 50 | let lon2 = lon1 + atan2(sin(bearing) * sin(distRadiansLong) * cos(lat1), cos(distRadiansLong) - sin(lat1) * sin(lat2)) 51 | return CLLocationCoordinate2D(latitude: lat2.toDegrees(), longitude: lon2.toDegrees()) 52 | } 53 | 54 | public static func getIntermediaryLocations(currentLocation: CLLocation, destinationLocation: CLLocation) -> [CLLocationCoordinate2D] { 55 | var distances = [CLLocationCoordinate2D]() 56 | let metersIntervalPerNode: Float = 10 57 | var distance = Float(destinationLocation.distance(from: currentLocation)) 58 | let bearing = currentLocation.bearingToLocationRadian(destinationLocation) 59 | while distance > 10 { 60 | distance -= metersIntervalPerNode 61 | let newLocation = currentLocation.coordinate.coordinate(with: Double(bearing), and: Double(distance)) 62 | if !distances.contains(newLocation) { 63 | distances.append(newLocation) 64 | } 65 | } 66 | return distances 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ARNavigation/Double+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Double+Extension.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/18/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public extension Double { 12 | 13 | public func metersToLatitude() -> Double { 14 | return self / (6373000.0) 15 | } 16 | 17 | public func metersToLongitude() -> Double { 18 | return self / (5602900.0) 19 | } 20 | 21 | public func toRadians() -> Double { 22 | return self * .pi / 180.0 23 | } 24 | 25 | public func toDegrees() -> Double { 26 | return self * 180.0 / .pi 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ARNavigation/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /ARNavigation/LocationConstants.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LocationConstants.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/19/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct LocationConstants { 12 | public static let metersPerRadianLat: Double = 6373000.0 13 | public static let metersPerRadianLon: Double = 5602900.0 14 | } 15 | -------------------------------------------------------------------------------- /ARNavigation/LocationService.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LocationService.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/18/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreLocation 11 | 12 | open class LocationService: NSObject, CLLocationManagerDelegate { 13 | 14 | var locationManager: CLLocationManager? 15 | var lastLocation: CLLocation? 16 | var delegate: LocationServiceDelegate? 17 | var currentLocation: CLLocation? 18 | var initial: Bool = true 19 | var userHeading: CLLocationDirection! 20 | var locations: [CLLocation] = [] 21 | 22 | public override init() { 23 | super.init() 24 | locationManager = CLLocationManager() 25 | guard let locationManager = locationManager else { return } 26 | requestAuthorization(locationManager: locationManager) 27 | locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation 28 | locationManager.distanceFilter = kCLDistanceFilterNone 29 | locationManager.headingFilter = kCLHeadingFilterNone 30 | locationManager.pausesLocationUpdatesAutomatically = false 31 | locationManager.delegate = self 32 | } 33 | 34 | public func requestAuthorization(locationManager: CLLocationManager) { 35 | locationManager.requestWhenInUseAuthorization() 36 | switch(CLLocationManager.authorizationStatus()) { 37 | case .authorizedAlways, .authorizedWhenInUse: 38 | startUpdatingLocation(locationManager: locationManager) 39 | case .denied, .notDetermined, .restricted: 40 | stopUpdatingLocation(locationManager: locationManager) 41 | } 42 | } 43 | 44 | public func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) { 45 | if newHeading.headingAccuracy < 0 { return } 46 | 47 | let heading = newHeading.trueHeading > 0 ? newHeading.trueHeading : newHeading.magneticHeading 48 | userHeading = heading 49 | NotificationCenter.default.post(name: Notification.Name(rawValue:"myNotificationName"), object: self, userInfo: nil) 50 | } 51 | 52 | public func startUpdatingLocation(locationManager: CLLocationManager) { 53 | locationManager.startUpdatingLocation() 54 | locationManager.startUpdatingHeading() 55 | } 56 | 57 | public func stopUpdatingLocation(locationManager: CLLocationManager) { 58 | locationManager.stopUpdatingLocation() 59 | locationManager.stopUpdatingHeading() 60 | } 61 | 62 | public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 63 | for location in locations { 64 | delegate?.trackingLocation(for: location) 65 | } 66 | currentLocation = manager.location 67 | } 68 | 69 | public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { 70 | updateLocationDidFailWithError(error: error as NSError) 71 | } 72 | 73 | public func updateLocation(currentLocation: CLLocation) { 74 | guard let delegate = delegate else { return } 75 | delegate.trackingLocation(for: currentLocation) 76 | } 77 | 78 | public func updateLocationDidFailWithError(error: Error) { 79 | guard let delegate = delegate else { return } 80 | delegate.trackingLocationDidFail(with: error) 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /ARNavigation/LocationServiceDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LocationServiceDelegate.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/19/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreLocation 11 | 12 | protocol LocationServiceDelegate: class { 13 | func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) 14 | func trackingLocation(for currentLocation: CLLocation) 15 | func trackingLocationDidFail(with error: Error) 16 | } 17 | 18 | -------------------------------------------------------------------------------- /ARNavigation/LocationTranslation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LocationTranslation.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/19/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct LocationTranslation { 12 | 13 | public var latitudeTranslation: Double 14 | public var longitudeTranslation: Double 15 | public var altitudeTranslation: Double 16 | 17 | public init(latitudeTranslation: Double, longitudeTranslation: Double, altitudeTranslation: Double) { 18 | self.latitudeTranslation = latitudeTranslation 19 | self.longitudeTranslation = longitudeTranslation 20 | self.altitudeTranslation = altitudeTranslation 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ARNavigation/MappingService.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MappingService.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/19/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MapKit 11 | import CoreLocation 12 | import ARKit 13 | 14 | open class MappingService { 15 | 16 | public var startingLocation: CLLocation! 17 | 18 | public var destinationLocation: CLLocationCoordinate2D! { 19 | didSet { 20 | setupNavigation() 21 | } 22 | } 23 | 24 | public var annotationColor = UIColor.blue 25 | 26 | public var mapView: MKMapView! 27 | public var annotations: [Annotation] = [] 28 | 29 | public var navigationService: NavigationService = NavigationService() 30 | 31 | public var steps: [MKRouteStep] = [] 32 | public var currentTripLegs: [[CLLocationCoordinate2D]] = [] 33 | public var locations: [CLLocation] = [] 34 | 35 | public init() { 36 | 37 | } 38 | 39 | public func setupNavigation() { 40 | 41 | let group = DispatchGroup() 42 | group.enter() 43 | 44 | DispatchQueue.global(qos: .default).async { 45 | 46 | if self.destinationLocation != nil { 47 | self.navigationService.getDirections(destinationLocation: self.destinationLocation, request: MKDirectionsRequest()) { steps in 48 | for step in steps { 49 | self.annotations.append(Annotation(coordinate: step.getLocation().coordinate, name: "N " + step.instructions)) 50 | } 51 | self.steps.append(contentsOf: steps) 52 | group.leave() 53 | } 54 | } 55 | 56 | // All steps must be added before moving to next step 57 | 58 | group.wait() 59 | 60 | self.getLocationData() 61 | } 62 | } 63 | 64 | public func getLocationData() { 65 | 66 | for (index, step) in steps.enumerated() { 67 | setTripLegFromStep(step, and: index) 68 | } 69 | 70 | for leg in currentTripLegs { 71 | update(intermediary: leg) 72 | } 73 | 74 | centerMapInInitialCoordinates() 75 | showPointsOfInterestInMap(currentTripLegs: currentTripLegs) 76 | addMapAnnotations() 77 | } 78 | 79 | public func setTripLegFromStep(_ tripStep: MKRouteStep, and index: Int) { 80 | if index > 0 { 81 | getTripLeg(for: index, and: tripStep) 82 | } else { 83 | getInitialLeg(for: tripStep) 84 | } 85 | } 86 | 87 | 88 | public func getInitialLeg(for tripStep: MKRouteStep) { 89 | let nextLocation = CLLocation(latitude: tripStep.polyline.coordinate.latitude, longitude: tripStep.polyline.coordinate.longitude) 90 | let intermediaries = CLLocationCoordinate2D.getIntermediaryLocations(currentLocation: startingLocation, destinationLocation: nextLocation) 91 | currentTripLegs.append(intermediaries) 92 | } 93 | 94 | public func getTripLeg(for index: Int, and tripStep: MKRouteStep) { 95 | let previousIndex = index - 1 96 | let previousStep = steps[previousIndex] 97 | let previousLocation = CLLocation(latitude: previousStep.polyline.coordinate.latitude, longitude: previousStep.polyline.coordinate.longitude) 98 | let nextLocation = CLLocation(latitude: tripStep.polyline.coordinate.latitude, longitude: tripStep.polyline.coordinate.longitude) 99 | let intermediarySteps = CLLocationCoordinate2D.getIntermediaryLocations(currentLocation: previousLocation, destinationLocation: nextLocation) 100 | currentTripLegs.append(intermediarySteps) 101 | } 102 | 103 | public func update(intermediary locations: [CLLocationCoordinate2D]) { 104 | for intermediaryLocation in locations { 105 | annotations.append(Annotation(coordinate: intermediaryLocation, name: String(describing:intermediaryLocation))) 106 | self.locations.append(CLLocation(latitude: intermediaryLocation.latitude, longitude: intermediaryLocation.longitude)) 107 | } 108 | } 109 | 110 | public func showPointsOfInterestInMap(currentTripLegs: [[CLLocationCoordinate2D]]) { 111 | mapView.removeAnnotations(mapView.annotations) 112 | for tripLeg in currentTripLegs { 113 | for coordinate in tripLeg { 114 | let poi = Annotation(coordinate: coordinate, name: String(describing: coordinate)) 115 | mapView.addAnnotation(poi) 116 | } 117 | } 118 | } 119 | 120 | public func centerMapInInitialCoordinates() { 121 | if startingLocation != nil { 122 | DispatchQueue.main.async { 123 | self.mapView.setCenter(self.startingLocation.coordinate, animated: true) 124 | let latDelta: CLLocationDegrees = 0.004 125 | let lonDelta: CLLocationDegrees = 0.004 126 | let span = MKCoordinateSpanMake(latDelta, lonDelta) 127 | let region = MKCoordinateRegionMake(self.startingLocation.coordinate, span) 128 | self.mapView.setRegion(region, animated: false) 129 | } 130 | } 131 | } 132 | 133 | public func addMapAnnotations() { 134 | 135 | annotations.forEach { annotation in 136 | 137 | // Step annotations are green, intermediary are blue 138 | DispatchQueue.main.async { 139 | if let title = annotation.title, title.hasPrefix("N") { 140 | self.annotationColor = .green 141 | } else { 142 | self.annotationColor = .blue 143 | } 144 | self.mapView?.addAnnotation(annotation) 145 | self.mapView.add(MKCircle(center: annotation.coordinate, radius: 0.2)) 146 | } 147 | } 148 | } 149 | } 150 | 151 | -------------------------------------------------------------------------------- /ARNavigation/MatrixHelper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MatrixHelper.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/18/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreLocation 11 | import SceneKit 12 | 13 | public class MatrixHelper { 14 | 15 | // column 0 column 1 column 2 column 3 16 | //  1 0 0 X   x   x + X*w  17 | //  0 1 0 Y  x  y  =  y + Y*w  18 | //  0 0 1 Z   z   z + Z*w  19 | //  0 0 0 1   w   w  20 | 21 | public static func translationMatrix(with matrix: matrix_float4x4, for translation : vector_float4) -> matrix_float4x4 { 22 | var matrix = matrix 23 | matrix.columns.3 = translation 24 | return matrix 25 | } 26 | 27 | // column 0 column 1 column 2 column 3 28 | //  cosθ 0 sinθ 0  29 | //  0 1 0 0  30 | //  −sinθ 0 cosθ 0  31 | //  0 0 0 1  32 | 33 | public static func rotateAroundY(with matrix: matrix_float4x4, for degrees: Float) -> matrix_float4x4 { 34 | var matrix : matrix_float4x4 = matrix 35 | 36 | matrix.columns.0.x = cos(degrees) 37 | matrix.columns.0.z = -sin(degrees) 38 | 39 | matrix.columns.2.x = sin(degrees) 40 | matrix.columns.2.z = cos(degrees) 41 | return matrix.inverse 42 | } 43 | 44 | public static func transformMatrix(for matrix: simd_float4x4, originLocation: CLLocation, location: CLLocation) -> simd_float4x4 { 45 | let distance = Float(location.distance(from: originLocation)) 46 | let bearing = originLocation.bearingToLocationRadian(location) 47 | let position = vector_float4(0.0, 0.0, -distance, 0.0) 48 | let translationMatrix = MatrixHelper.translationMatrix(with: matrix_identity_float4x4, for: position) 49 | let rotationMatrix = MatrixHelper.rotateAroundY(with: matrix_identity_float4x4, for: Float(bearing)) 50 | let transformMatrix = simd_mul(rotationMatrix, translationMatrix) 51 | return simd_mul(matrix, transformMatrix) 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /ARNavigation/NavigationService.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationService.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/18/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import MapKit 10 | 11 | public struct NavigationService { 12 | 13 | public func getDirections(destinationLocation: CLLocationCoordinate2D, request: MKDirectionsRequest, completion: @escaping ([MKRouteStep]) -> Void) { 14 | var steps: [MKRouteStep] = [] 15 | 16 | let placeMark = MKPlacemark(coordinate: destinationLocation) 17 | 18 | request.destination = MKMapItem.init(placemark: placeMark) 19 | request.source = MKMapItem.forCurrentLocation() 20 | request.requestsAlternateRoutes = false 21 | request.transportType = .walking 22 | 23 | let directions = MKDirections(request: request) 24 | 25 | directions.calculate { response, error in 26 | if error != nil { 27 | print("Error getting directions") 28 | } else { 29 | guard let response = response else { return } 30 | for route in response.routes { 31 | steps.append(contentsOf: route.steps) 32 | } 33 | completion(steps) 34 | } 35 | } 36 | } 37 | } 38 | 39 | extension MKRouteStep { 40 | public func getLocation() -> CLLocation { 41 | return CLLocation(latitude: polyline.coordinate.latitude, longitude: polyline.coordinate.longitude) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ARNavigation/SCNVector3+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SCNVector3+Extension.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/18/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import SceneKit 11 | 12 | extension SCNVector3 { 13 | 14 | public func distance(to vector: SCNVector3) -> Float { 15 | return sqrt(pow(vector.x - x, 2) + pow(vector.z - z, 2)) 16 | } 17 | 18 | public static func positionFrom(_ transform: matrix_float4x4) -> SCNVector3 { 19 | return SCNVector3Make(transform.columns.3.x, transform.columns.3.y, transform.columns.3.z) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ARNavigation/TapMap.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TapMap.swift 3 | // ARNavigation 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/19/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import MapKit 10 | 11 | open class TapMap: MKMapView { 12 | 13 | private var press: UILongPressGestureRecognizer! 14 | 15 | public var destinationLocation: CLLocationCoordinate2D! 16 | 17 | public init() { 18 | super.init(frame: CGRect.zero) 19 | setup() 20 | } 21 | 22 | required public init?(coder aDecoder: NSCoder) { 23 | fatalError("init(coder:) has not been implemented") 24 | } 25 | 26 | private func setup() { 27 | press = UILongPressGestureRecognizer(target: self, action: #selector(handleMapTap(gesture:))) 28 | press.minimumPressDuration = 0.35 29 | addGestureRecognizer(press) 30 | } 31 | 32 | @objc private func handleMapTap(gesture: UIGestureRecognizer) { 33 | if gesture.state != UIGestureRecognizerState.began { 34 | return 35 | } 36 | // Get tap point on map 37 | let touchPoint = gesture.location(in: self) 38 | 39 | // Convert map tap point to coordinate 40 | let coord: CLLocationCoordinate2D = convert(touchPoint, toCoordinateFrom: self) 41 | 42 | destinationLocation = coord 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ARNavigationTests/ARNavigationTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ARNavigationTests.swift 3 | // ARNavigationTests 4 | // 5 | // Created by Christopher Webb-Orenstein on 10/18/17. 6 | // Copyright © 2017 Christopher Webb-Orenstein. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import ARNavigation 11 | 12 | class ARNavigationTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ARNavigationTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at chris.webb5249@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Christopher Webb 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.md: -------------------------------------------------------------------------------- 1 | # ARNavigation 2 | 3 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) 4 | [![Platform](http://img.shields.io/badge/platform-ios-lightgrey.svg?style=flat)](https://developer.apple.com/resources/) 5 | [![Platform](https://img.shields.io/badge/swift-4.0-orange.svg?style=flat)](hhttps://swift.org/blog/swift-4-0-released/) 6 | 7 | 8 | - ARKit 9 | 10 | - MapKit 11 | 12 | - CoreLocation 13 | 14 | Use location and MapKit's navigation API to navigate in augmented reality. 15 | 16 | [Proof of concept](https://github.com/chriswebb09/ARKitNavigationDemo) 17 | 18 | ## Related Tutorial 19 | 20 | [ARKit and Core Location - Part One](https://medium.com/journey-of-one-thousand-apps/arkit-and-corelocation-part-one-fc7cb2fa0150) 21 | 22 | [ARKit and Core Location - Part Two](https://medium.com/journey-of-one-thousand-apps/arkit-and-corelocation-part-two-7b045fb1d7a1) 23 | 24 | [ARKit and Core Location - Part Three](https://medium.com/journey-of-one-thousand-apps/arkit-and-corelocation-part-three-98b1d51e2eac) 25 | --------------------------------------------------------------------------------