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

Populate Node Position Label as appropriate #245

Merged
merged 2 commits into from
Nov 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ARKit+CoreLocation/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Tap a node to see location" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="b9i-TX-alA">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Tap a node to see location" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="b9i-TX-alA">
<rect key="frame" x="16" y="748" width="382" height="30"/>
<color key="backgroundColor" white="0.0" alpha="0.5" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
Expand Down
14 changes: 13 additions & 1 deletion ARKit+CoreLocation/POIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ extension POIViewController {
let applePark = buildViewNode(latitude: 37.334807, longitude: -122.009076, altitude: 100, text: "Apple Park")
nodes.append(applePark)

let theAlamo = buildViewNode(latitude: 29.4259671, longitude: -98.4861419, altitude: 300, text: "The Alamo")
nodes.append(theAlamo)

return nodes
}

Expand Down Expand Up @@ -362,11 +365,20 @@ extension POIViewController {
extension POIViewController: LNTouchDelegate {

func annotationNodeTouched(node: AnnotationNode) {
print("AnnotationNode touched \(node)")
if let node = node.parent as? LocationNode {
let coords = "\(node.location.coordinate.latitude.short)° \(node.location.coordinate.longitude.short)°"
let altitude = "\(node.location.altitude.short)m"
let tag = node.tag ?? ""
nodePositionLabel.text = " Annotation node at \(coords), \(altitude) - \(tag)"
}
}

func locationNodeTouched(node: LocationNode) {
print("Location node touched - tag: \(node.tag ?? "")")
let coords = "\(node.location.coordinate.latitude.short)° \(node.location.coordinate.longitude.short)°"
let altitude = "\(node.location.altitude.short)m"
let tag = node.tag ?? ""
nodePositionLabel.text = " Location node at \(coords), \(altitude) - \(tag)"
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public extension Double {
var metersToLongitude: Double {
return self / (6_356_752.3)
}

var short: String { return String(format: "%.02f", self) }

}

public extension Float {
Expand Down
4 changes: 2 additions & 2 deletions Sources/ARKit-CoreLocation/SceneLocationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ public extension SceneLocationView {
}

let coordinates = sender.location(in: touchedView)
let hitTest = touchedView.hitTest(coordinates)
let hitTests = touchedView.hitTest(coordinates)

guard let firstHitTest = hitTest.first else {
guard let firstHitTest = hitTests.first else {
return
}

Expand Down