Я пытаюсь получить доступ к координатам в полученном GEO Json. Я создал Codable Structs
.
Моя GEOJson
codable
Geometry
структура выглядит так:
struct ServiceArea : Codable {
let area : [Area]?
let vehicleType : String?
enum CodingKeys: String, CodingKey {
case area = "area"
case vehicleType = "vehicle_type"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
area = try values.decodeIfPresent([Area].self, forKey: .area)
vehicleType = try values.decodeIfPresent(String.self, forKey: .vehicleType)
}
}
struct Area : Codable {
let geometry : Geometry?
let properties : Property?
let type : String?
enum CodingKeys: String, CodingKey {
case geometry
case properties
case type = "type"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
geometry = try Geometry(from: decoder)
properties = try Property(from: decoder)
type = try values.decodeIfPresent(String.self, forKey: .type)
}
}
struct Geometry : Codable {
let coordinates : [[[Float]]]?
let type : String?
enum CodingKeys: String, CodingKey {
case coordinates = "coordinates"
case type = "type"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
coordinates = try values.decodeIfPresent([[[Float]]].self, forKey: .coordinates)
type = try values.decodeIfPresent(String.self, forKey: .type)
}
}
Но когда я пытаюсь получить доступ к .coordinates, это всегда ноль.