// // LocationService.swift // AutoCatCore // // Created by Selim Mustafaev on 31.07.2024. // Copyright © 2024 Selim Mustafaev. All rights reserved. // import CoreLocation @MainActor public final class LocationService: LocationServiceProtocol { private var geocoder: GeocoderProtocol public init(geocoder: GeocoderProtocol) { self.geocoder = geocoder } public func getAddressForLocation(latitude: Double, longitude: Double) async throws -> String { let location = CLLocation(latitude: latitude, longitude: longitude) let placemarks = try await geocoder.reverseGeocodeLocation(location) if let name = placemarks.first?.name { return name } else { throw LocationError.reverseGeocode } } }