1

I have an array containing the names of the cities of a particular country and each town has a longitude and latitude I have a longitude and latitude and I want to know which of the countries is closer to this longitude and latitude

this is city object :

struct Cities: Codable {
    let id, code, name: String?
    let location: Location?

    enum CodingKeys: String, CodingKey {
        case id = "_id"
        case code, name, location
    }
}


struct Location: Codable {
    let longitude, latitude, locationDescription: String?

    enum CodingKeys: String, CodingKey {
        case longitude, latitude
        case locationDescription = "description"
    }
}

this is array of object :

var citiesArr = [Cities]()

How can I get closer (city object Array) from some long and lat?

0 Answers0