-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from intere/polylines
Directions (Routes) and AR Polylines
- Loading branch information
Showing
57 changed files
with
3,488 additions
and
1,132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,9 @@ Pod::Spec.new do |s| | |
s.license = { :type => 'MIT', :file => 'LICENSE' } | ||
s.source = { :git => "https://[email protected]/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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.