Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directions (Routes) and AR Polylines #159

Merged
merged 33 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ac1e88e
added swiftlint
Aug 8, 2017
fb25f0f
Leftovers from cherry-pick.
intere Feb 18, 2019
b9ed5f6
Added missing file.
intere Feb 18, 2019
2056f02
code style fixes
Aug 8, 2017
0d2c37b
fix code style
Aug 8, 2017
ba93b98
default implementations for delegate functions
Aug 9, 2017
a901a49
default implementations for delegate functions
Aug 9, 2017
48f7341
move SceneLocationViewDelegate to dedicated file
Aug 9, 2017
45ca2a3
add/remove arrays of nodes
Aug 9, 2017
a28b50a
Nuked the orig file.
intere Feb 18, 2019
4614baa
use storyboard instead of hardcoding UI for demo app
Aug 9, 2017
1812794
More updates.
intere Feb 18, 2019
cef8bb8
code refactoring
Aug 10, 2017
9743ac4
Updates to let the app run.
intere Feb 18, 2019
41c90db
code refactoring
Aug 10, 2017
5701493
fix podspec
Aug 10, 2017
053be5d
Updates to address pod linting and ensuring things compile propertly.
intere Feb 18, 2019
f835243
fix func/variables access levels
Aug 10, 2017
fc67e61
draw routs in scene
Aug 11, 2017
63e010f
remove routes
Aug 11, 2017
b3cb308
Fixed the podspec and updated the PolylineNode so that everything com…
intere Feb 18, 2019
85ded70
Refactored the Podfile to use the local pod source and updated the pr…
intere Feb 18, 2019
c65b6d1
Merge remote-tracking branch 'upstream/master' into polylines
intere Feb 18, 2019
39ac915
Some cleanup.
intere Feb 18, 2019
43c9216
Exposing some properties that should be public.
intere Feb 19, 2019
ba41ccb
PR feedback updates and hooked the debugging function back up (using …
intere Feb 20, 2019
7079a47
I've got a weak UI that barely works for getting directions and showi…
intere Feb 20, 2019
d2738fb
I'm closing in on a working demo for Points of Interest and directions.
intere Feb 21, 2019
8945a4f
I've completed the demo and added soome comments. I'll update the PR…
intere Feb 22, 2019
d1fc4c4
Added a PR template.
intere Feb 22, 2019
3c1565f
Added a changelog and update the PR template to include updating this…
intere Feb 22, 2019
a500958
Added a travis config that just does a pod lib lint (to let us know i…
intere Feb 22, 2019
cb7df11
Added 2 UX improvements: 1. hitting enter on the keyboard executes a …
intere Feb 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### Background

Describe the purpose of this pull request.

### Breaking Changes
Describe any breaking changes that this pull request will introduce.

### Meta
- Tied to Version Release(s):

### Checklist

- [ ] Appropriate label has been added to this PR (i.e., Bug, Enhancement, etc.).
- [ ] Documentation has been added to all `open`, and `public` scoped methods and properties.
- [ ] Changelog has been updated
- [ ] Tests have have been added to all new features. (not a requirement, but helpful)
- [ ] Image/GIFs have been added for all UI related changed.

<!--- For UI Changes, please upload a GIF or Image of the feature in action --->
<!--- https://www.cockos.com/licecap/ Is a great tool to create quick and easy gifs --->

### Screenshots
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

15 changes: 9 additions & 6 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
line_length: 130

disabled_rules:
- file_length
- identifier_name
- line_length
- shorthand_operator
- type_body_length
function_body_length: 70
- variable_name
- todo
- valid_docs

excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: objective-c
osx_image: xcode10.1

script:
- pod lib lint

notifications:
email: false
3 changes: 2 additions & 1 deletion ARCL.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ Pod::Spec.new do |s|
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.source = { :git => "https://ProjectDent@github.com/ProjectDent/ARKit-CoreLocation.git", :tag => s.version.to_s, :submodules => false }
s.platform = :ios, '9.0'
s.swift_version = "4.2"
s.requires_arc = true
s.source_files = 'ARCL/Source/*.swift'
s.source_files = 'ARCL/Source/**/*.{swift}'
s.frameworks = 'Foundation', 'UIKit', 'ARKit', 'CoreLocation', 'MapKit', 'SceneKit'
s.ios.deployment_target = '9.0'
end
107 changes: 0 additions & 107 deletions ARCL/Source/CLLocation+Extensions.swift

This file was deleted.

29 changes: 29 additions & 0 deletions ARCL/Source/Extensions/BaseTypes+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// BaseTypes+Extensions.swift
// ARKit+CoreLocation
//
// Created by Ilya Seliverstov on 08/08/2017.
// Copyright © 2017 Project Dent. All rights reserved.
//

import Foundation

public extension Double {

var metersToLatitude: Double {
return self / (6_360_500.0)
}

var metersToLongitude: Double {
return self / (5_602_900.0)
}
}

public extension Float {
var short: String { return String(format: "%.2f", self) }
}

public extension Int {
var short: String { return String(format: "%02d", self) }
var short3: String { return String(format: "%03d", self / 1_000_000) }
}
102 changes: 102 additions & 0 deletions ARCL/Source/Extensions/CLLocation+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//
// CLLocation+Extensions.swift
// ARKit+CoreLocation
//
// Created by Andrew Hart on 02/07/2017.
// Copyright © 2017 Project Dent. All rights reserved.
//

import Foundation
import CoreLocation

///Translation in meters between 2 locations
public struct LocationTranslation {
public var latitudeTranslation: Double
public var longitudeTranslation: Double
public var altitudeTranslation: Double
}

public extension CLLocation {
public convenience init(coordinate: CLLocationCoordinate2D, altitude: CLLocationDistance) {
self.init(coordinate: coordinate, altitude: altitude, horizontalAccuracy: 0, verticalAccuracy: 0, timestamp: Date())
}

///Translates distance in meters between two locations.
///Returns the result as the distance in latitude and distance in longitude.
public func translation(toLocation location: CLLocation) -> LocationTranslation {
let inbetweenLocation = CLLocation(latitude: self.coordinate.latitude, longitude: location.coordinate.longitude)

let distanceLatitude = location.distance(from: inbetweenLocation)

let latitudeTranslation = location.coordinate.latitude > inbetweenLocation.coordinate.latitude ? distanceLatitude
: -distanceLatitude

let distanceLongitude = distance(from: inbetweenLocation)

let longitudeTranslation = coordinate.longitude > inbetweenLocation.coordinate.longitude ? -distanceLongitude
: distanceLongitude

let altitudeTranslation = location.altitude - self.altitude

return LocationTranslation( latitudeTranslation: latitudeTranslation,
longitudeTranslation: longitudeTranslation,
altitudeTranslation: altitudeTranslation)
}

public func translatedLocation(with translation: LocationTranslation) -> CLLocation {
let latitudeCoordinate = self.coordinate.coordinateWithBearing(bearing: 0,
distanceMeters: translation.latitudeTranslation)

let longitudeCoordinate = self.coordinate.coordinateWithBearing(bearing: 90,
distanceMeters: translation.longitudeTranslation)

let coordinate = CLLocationCoordinate2D( latitude: latitudeCoordinate.latitude, longitude: longitudeCoordinate.longitude)

let altitude = self.altitude + translation.altitudeTranslation

return CLLocation(coordinate: coordinate,
altitude: altitude,
horizontalAccuracy: self.horizontalAccuracy,
verticalAccuracy: self.verticalAccuracy,
timestamp: self.timestamp)
}

func bearing(between point: CLLocation) -> Double {
let lat1 = self.coordinate.latitude.degreesToRadians
let lon1 = self.coordinate.longitude.degreesToRadians

let lat2 = point.coordinate.latitude.degreesToRadians
let lon2 = point.coordinate.longitude.degreesToRadians

let dLon = lon2 - lon1

let y = sin(dLon) * cos(lat2)
let x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon)
return atan2(y, x).radiansToDegrees
}
}

public extension CLLocation {
var debugLog: String {
return "location: \(self.coordinate), accuracy: \(self.horizontalAccuracy), date: \(self.timestamp)"
}
}

public extension CLLocationCoordinate2D {

func coordinateWithBearing(bearing: Double, distanceMeters: Double) -> CLLocationCoordinate2D {
//The numbers for earth radius may be _off_ here
//but this gives a reasonably accurate result..
//Any correction here is welcome.
let distRadiansLat = distanceMeters.metersToLatitude // earth radius in meters latitude
let distRadiansLong = distanceMeters.metersToLongitude // earth radius in meters longitude

let lat1 = self.latitude * Double.pi / 180
let lon1 = self.longitude * Double.pi / 180

let lat2 = asin(sin(lat1) * cos(distRadiansLat) + cos(lat1) * sin(distRadiansLat) * cos(bearing))
let lon2 = lon1 + atan2(sin(bearing) * sin(distRadiansLong) * cos(lat1), cos(distRadiansLong) - sin(lat1) * sin(lat2))

return CLLocationCoordinate2D(latitude: lat2 * 180 / Double.pi, longitude: lon2 * 180 / Double.pi)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@ extension SCNNode {
let quiverThickness = (quiverLength / 50.0) * quiverThickness
let chamferRadius = quiverThickness / 2.0

let xQuiverBox = SCNBox(width: quiverLength, height: quiverThickness, length: quiverThickness, chamferRadius: chamferRadius)
let xQuiverBox = SCNBox(width: quiverLength,
height: quiverThickness,
length: quiverThickness,
chamferRadius: chamferRadius)
xQuiverBox.firstMaterial?.diffuse.contents = UIColor.red
let xQuiverNode = SCNNode(geometry: xQuiverBox)
xQuiverNode.position = SCNVector3Make(Float(quiverLength / 2.0), 0.0, 0.0)

let yQuiverBox = SCNBox(width: quiverThickness, height: quiverLength, length: quiverThickness, chamferRadius: chamferRadius)
let yQuiverBox = SCNBox(width: quiverThickness,
height: quiverLength,
length: quiverThickness,
chamferRadius: chamferRadius)
yQuiverBox.firstMaterial?.diffuse.contents = UIColor.green
let yQuiverNode = SCNNode(geometry: yQuiverBox)
yQuiverNode.position = SCNVector3Make(0.0, Float(quiverLength / 2.0), 0.0)

let zQuiverBox = SCNBox(width: quiverThickness, height: quiverThickness, length: quiverLength, chamferRadius: chamferRadius)
let zQuiverBox = SCNBox(width: quiverThickness,
height: quiverThickness,
length: quiverLength,
chamferRadius: chamferRadius)
zQuiverBox.firstMaterial?.diffuse.contents = UIColor.blue
let zQuiverNode = SCNNode(geometry: zQuiverBox)
zQuiverNode.position = SCNVector3Make(0.0, 0.0, Float(quiverLength / 2.0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SceneKit

extension SCNVector3 {
public extension SCNVector3 {
///Calculates distance between vectors
///Doesn't include the y axis, matches functionality of CLLocation 'distance' function.
func distance(to anotherVector: SCNVector3) -> Float {
Expand Down
Loading