mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Reduced precision map circles for the node map
This commit is contained in:
parent
5a0f180acf
commit
e462055ad7
4 changed files with 17 additions and 3 deletions
|
|
@ -214,6 +214,7 @@ func deviceMetadataPacket (metadata: DeviceMetadata, fromNum: Int64, context: NS
|
|||
if fetchedNode.count > 0 {
|
||||
fetchedNode[0].metadata = newMetadata
|
||||
} else {
|
||||
|
||||
let newNode = createNodeInfo(num: Int64(fromNum), context: context)
|
||||
newNode.metadata = newMetadata
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,11 +265,14 @@ func upsertPositionPacket (packet: MeshPacket, context: NSManagedObjectContext)
|
|||
return
|
||||
}
|
||||
/// Don't save nearly the same position over and over. If the next position is less than 10 meters from the new position, delete the previous position and save the new one.
|
||||
if mutablePositions.count > 0 {
|
||||
if mutablePositions.count > 0 && position.precisionBits == 32 {
|
||||
let mostRecent = mutablePositions.lastObject as! PositionEntity
|
||||
if mostRecent.coordinate.distance(from: position.coordinate) < 10 {
|
||||
if mostRecent.coordinate.distance(from: position.coordinate) < 15 {
|
||||
mutablePositions.remove(mostRecent)
|
||||
}
|
||||
} else if mutablePositions.count > 0 && 11...16 ~= position.precisionBits {
|
||||
/// Don't store any history for reduced accuracy positions, we will just show a circle
|
||||
mutablePositions.removeAllObjects()
|
||||
}
|
||||
mutablePositions.add(position)
|
||||
fetchedNode[0].id = Int64(packet.from)
|
||||
|
|
|
|||
|
|
@ -116,6 +116,15 @@ struct MeshMap: View {
|
|||
selectedPosition = (selectedPosition == position ? nil : position)
|
||||
}
|
||||
}
|
||||
/// Reduced Precision Map Circles
|
||||
if 11...16 ~= position.precisionBits {
|
||||
let pp = PositionPrecision(rawValue: Int(position.precisionBits))
|
||||
let radius : CLLocationDistance = pp?.precisionMeters ?? 0
|
||||
if radius > 0.0 {
|
||||
MapCircle(center: position.coordinate, radius: radius)
|
||||
.foregroundStyle(Color(nodeColor).opacity(0.60))
|
||||
}
|
||||
}
|
||||
/// Routes
|
||||
ForEach(Array(routes), id: \.id) { route in
|
||||
let routeLocations = Array(route.locations!) as! [LocationEntity]
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ struct Channels: View {
|
|||
@State private var positionsEnabled = true
|
||||
|
||||
/// Minimum Version for granular position configuration
|
||||
@State var minimumVersion = "2.2.20"
|
||||
@State var minimumVersion = "2.2.24"
|
||||
|
||||
|
||||
var body: some View {
|
||||
|
|
@ -424,6 +424,7 @@ struct Channels: View {
|
|||
channelRole = 2
|
||||
channelKey = key
|
||||
positionsEnabled = false
|
||||
preciseLocation = false
|
||||
positionPrecision = 0
|
||||
uplink = false
|
||||
downlink = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue