By default zoom map to show all nodes, with names and icons.

This commit is contained in:
geeksville 2020-04-05 12:33:23 -07:00
parent 2f556b6dc9
commit 743316d421
3 changed files with 41 additions and 21 deletions

View file

@ -111,11 +111,17 @@ data class NodeInfo(
return (now - lastSeen <= timeout) || lastSeen == 0
}
/// return the position if it is valid, else null
val validPosition: Position?
get() {
return position?.takeIf { it.latitude != 0.0 || it.longitude != 0.0 }
}
/// @return distance in meters to some other node (or null if unknown)
fun distance(o: NodeInfo?): Int? {
val p = position
val op = o?.position
return if (p != null && op != null && p.latitude != 0.0 && op.longitude != 0.0)
val p = validPosition
val op = o?.validPosition
return if (p != null && op != null)
p.distance(op).toInt()
else
null