mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add reverse geocoding service (#1085)
* add Geocoding service * move url session extension
This commit is contained in:
+6
@@ -21,3 +21,9 @@ extension MapTilerStyleBuilder {
|
||||
self.init(lightURL: appSettings.lightTileMapStyleURL, darkURL: appSettings.darkTileMapStyleURL, key: appSettings.mapTilerApiKey)
|
||||
}
|
||||
}
|
||||
|
||||
extension MapTilerGeoCodingService {
|
||||
init(session: URLSession = .shared, appSettings: AppSettings) {
|
||||
self.init(session: session, key: appSettings.mapTilerApiKey, geocodingURL: appSettings.geocodingURLFormatString)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright 2023 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension URLSession {
|
||||
/// The same as `data(for:delegate:)` but with an additional immediate retry if the first attempt fails.
|
||||
func dataWithRetry(for request: URLRequest, delegate: URLSessionTaskDelegate? = nil) async throws -> (Data, URLResponse) {
|
||||
if let firstTryResult = try? await data(for: request, delegate: delegate) {
|
||||
return firstTryResult
|
||||
}
|
||||
|
||||
return try await data(for: request, delegate: delegate)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user