47 lines
927 B
Swift
47 lines
927 B
Swift
|
//
|
||
|
// Location+URLs.swift
|
||
|
// Locations
|
||
|
//
|
||
|
// Created by Javier Cicchelli on 13/04/2023.
|
||
|
// Copyright © 2023 Röck+Cöde. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import Foundation
|
||
|
import Persistence
|
||
|
|
||
|
extension Location {
|
||
|
|
||
|
var wikipediaPlacesURL: URL? {
|
||
|
var urlComponents = URLComponents()
|
||
|
|
||
|
urlComponents.scheme = .Scheme.wikipedia
|
||
|
urlComponents.host = .Host.places
|
||
|
urlComponents.queryItems = [
|
||
|
.init(
|
||
|
name: .Query.key,
|
||
|
value: .init(format: .Query.value, latitude, longitude)
|
||
|
)
|
||
|
]
|
||
|
|
||
|
return urlComponents.url
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
// MARK: - String+Constants
|
||
|
|
||
|
private extension String {
|
||
|
enum Scheme {
|
||
|
static let wikipedia = "wikipedia"
|
||
|
}
|
||
|
|
||
|
enum Host {
|
||
|
static let places = "places"
|
||
|
}
|
||
|
|
||
|
enum Query {
|
||
|
static let key = "coordinates"
|
||
|
static let value = "%f,%f"
|
||
|
}
|
||
|
}
|