Meshtastic-Apple/Meshtastic/Extensions/CLLocationCoordinate2D.swift
2023-04-25 17:56:57 -07:00

20 lines
582 B
Swift

//
// CLLocationCoordinate2D.swift
// Meshtastic
//
// Copyright(c) Garth Vander Houwen 4/25/23.
//
import Foundation
import MapKit
extension CLLocationCoordinate2D {
/// Returns distance from coordianate in meters.
/// - Parameter from: coordinate which will be used as end point.
/// - Returns: distance in meters.
func distance(from: CLLocationCoordinate2D) -> CLLocationDistance {
let from = CLLocation(latitude: from.latitude, longitude: from.longitude)
let to = CLLocation(latitude: self.latitude, longitude: self.longitude)
return from.distance(from: to)
}
}