mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Reciprical extension for measurement angles (headings)
This commit is contained in:
parent
e2ce6bff07
commit
e4ba47abc2
6 changed files with 15 additions and 9 deletions
|
|
@ -297,6 +297,7 @@
|
|||
}
|
||||
},
|
||||
"%@ hPa" : {
|
||||
"extractionState" : "stale",
|
||||
"localizations" : {
|
||||
"sr" : {
|
||||
"stringUnit" : {
|
||||
|
|
@ -9252,9 +9253,6 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Done" : {
|
||||
|
||||
},
|
||||
"Double Tap as Button" : {
|
||||
"localizations" : {
|
||||
|
|
@ -29835,8 +29833,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
"Trace route received directly by %@ with a SNR of %@ dB" : {
|
||||
"extractionState" : "stale",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,14 @@
|
|||
import Foundation
|
||||
import Charts
|
||||
|
||||
extension Measurement where UnitType == UnitAngle {
|
||||
func reciprocal() -> Measurement {
|
||||
var recip = self.converted(to: .degrees)
|
||||
recip.value = (recip.value + 180).truncatingRemainder(dividingBy: 360)
|
||||
return recip.converted(to: self.unit)
|
||||
}
|
||||
}
|
||||
|
||||
struct PlottableMeasurement<UnitType: Unit> {
|
||||
var measurement: Measurement<UnitType>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ struct PositionPopover: View {
|
|||
/// Heading
|
||||
let degrees = Angle.degrees(Double(position.heading))
|
||||
Label {
|
||||
let heading = Measurement(value: degrees.degrees, unit: UnitAngle.degrees)
|
||||
let heading = Measurement(value: degrees.degrees, unit: UnitAngle.degrees).reciprocal()
|
||||
Text("Heading: \(heading.formatted(.measurement(width: .narrow, numberFormatStyle: .number.precision(.fractionLength(0)))))")
|
||||
} icon: {
|
||||
Image(systemName: "location.north")
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ struct NodeListItem: View {
|
|||
.symbolRenderingMode(.multicolor)
|
||||
.clipShape(Circle())
|
||||
.rotationEffect(headingDegrees)
|
||||
let heading = Measurement(value: trueBearing, unit: UnitAngle.degrees)
|
||||
let heading = Measurement(value: trueBearing, unit: UnitAngle.degrees).reciprocal()
|
||||
Text("\(heading.formatted(.measurement(width: .narrow, numberFormatStyle: .number.precision(.fractionLength(0)))))")
|
||||
.font(UIDevice.current.userInterfaceIdiom == .phone ? .callout : .caption)
|
||||
.foregroundColor(.gray)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ struct PositionLog: View {
|
|||
}
|
||||
TableColumn("Heading") { position in
|
||||
let degrees = Angle.degrees(Double(position.heading))
|
||||
let heading = Measurement(value: degrees.degrees, unit: UnitAngle.degrees)
|
||||
let heading = Measurement(value: degrees.degrees, unit: UnitAngle.degrees).reciprocal()
|
||||
Text(heading.formatted(.measurement(width: .narrow, numberFormatStyle: .number.precision(.fractionLength(0)))))
|
||||
}
|
||||
TableColumn("SNR") { position in
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ struct GPSStatus: View {
|
|||
let altitiude = Measurement(value: newLocation.altitude, unit: UnitLength.meters)
|
||||
let speed = Measurement(value: newLocation.speed, unit: UnitSpeed.kilometersPerHour)
|
||||
let speedAccuracy = Measurement(value: newLocation.speedAccuracy, unit: UnitSpeed.metersPerSecond)
|
||||
let courseAccuracy = Measurement(value: newLocation.courseAccuracy, unit: UnitAngle.degrees)
|
||||
let courseAccuracy = Measurement(value: newLocation.courseAccuracy, unit: UnitAngle.degrees).reciprocal()
|
||||
|
||||
Label("Coordinate \(String(format: "%.5f", newLocation.coordinate.latitude)), \(String(format: "%.5f", newLocation.coordinate.longitude))", systemImage: "mappin")
|
||||
.font(largeFont)
|
||||
|
|
@ -45,7 +45,7 @@ struct GPSStatus: View {
|
|||
HStack {
|
||||
let degrees = Angle.degrees(newLocation.course)
|
||||
Label {
|
||||
let heading = Measurement(value: degrees.degrees, unit: UnitAngle.degrees)
|
||||
let heading = Measurement(value: degrees.degrees, unit: UnitAngle.degrees).reciprocal()
|
||||
Text("Heading: \(heading.formatted(.measurement(width: .narrow, numberFormatStyle: .number.precision(.fractionLength(0)))))")
|
||||
} icon: {
|
||||
Image(systemName: "location.north")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue