Make CLLocationCoordinate2D implement Equatable
This commit is contained in:
parent
9a1c070e3e
commit
a8b55ba005
|
@ -0,0 +1,16 @@
|
||||||
|
//
|
||||||
|
// CLLocationCoordinate2D+Equatable.swift
|
||||||
|
// SwiftKit
|
||||||
|
//
|
||||||
|
// Created by Daniel Saidi on 2021-09-08.
|
||||||
|
// Copyright © 2021 Daniel Saidi. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import CoreLocation
|
||||||
|
|
||||||
|
extension CLLocationCoordinate2D: Equatable {
|
||||||
|
|
||||||
|
public static func == (lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool {
|
||||||
|
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ import CoreLocation
|
||||||
it simplifies extending it with new coordinates in any apps
|
it simplifies extending it with new coordinates in any apps
|
||||||
that use custom coordinates.
|
that use custom coordinates.
|
||||||
*/
|
*/
|
||||||
public struct WorldCoordinate: Identifiable, Hashable {
|
public struct WorldCoordinate: Hashable, Equatable, Identifiable {
|
||||||
|
|
||||||
public var id: String { name }
|
public var id: String { name }
|
||||||
|
|
||||||
|
@ -30,12 +30,6 @@ public struct WorldCoordinate: Identifiable, Hashable {
|
||||||
*/
|
*/
|
||||||
public let coordinate: CLLocationCoordinate2D
|
public let coordinate: CLLocationCoordinate2D
|
||||||
|
|
||||||
public static func == (lhs: WorldCoordinate, rhs: WorldCoordinate) -> Bool {
|
|
||||||
lhs.name == rhs.name
|
|
||||||
&& lhs.coordinate.latitude == rhs.coordinate.latitude
|
|
||||||
&& lhs.coordinate.longitude == rhs.coordinate.longitude
|
|
||||||
}
|
|
||||||
|
|
||||||
public func hash(into hasher: inout Hasher) {
|
public func hash(into hasher: inout Hasher) {
|
||||||
hasher.combine(id)
|
hasher.combine(id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue