-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turf update #426
Turf update #426
Conversation
southWest = try container.decode(CLLocationCoordinate2D.self, forKey: .southWest) | ||
northEast = try container.decode(CLLocationCoordinate2D.self, forKey: .northEast) | ||
southWest = try container.decode(CLLocationCoordinate2DCodable.self, forKey: .southWest).decodedCoordinates | ||
northEast = try container.decode(CLLocationCoordinate2DCodable.self, forKey: .northEast).decodedCoordinates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be tempting to remove CoordinateBounds
in favor of the BoundingBox
struct in Turf. Unfortunately, it looks like BoundingBox
was copied from CoordinateBounds
back before we fixed #348, so we’ll have to fix mapbox/turf-swift#102 before we can rely on BoundingBox
.
init(from decoder: Decoder) throws { | ||
let container = try decoder.singleValueContainer() | ||
let options = decoder.userInfo[.options] as? DirectionsOptions | ||
switch options?.shapeFormat ?? .default { | ||
case .geoJSON: | ||
self = .lineString(try container.decode(LineString.self)) | ||
let lineStringContainer = try decoder.container(keyedBy: LineStringCodingKeys.self) | ||
let coordinates = try lineStringContainer.decode([CLLocationCoordinate2DCodable].self, forKey: .coordinates).map { $0.decodedCoordinates } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to manually decode the LineString here? Can we continue to rely on Turf’s implementation of LineString’s Codable conformance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turf
does not provide LineString
Codable
conformance. So I decided we should not add it in Directions
either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that’s a little bit awkward. But Geometry is codable, so we can continue to wrap the LineString in a Geometry and decode that, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it could work for decoding, but encoding Geometry
will also serialize it's type
, which is undesired.
@@ -519,7 +519,7 @@ open class RouteStep: Codable { | |||
try maneuver.encode(instructions, forKey: .instruction) | |||
try maneuver.encode(maneuverType, forKey: .type) | |||
try maneuver.encodeIfPresent(maneuverDirection, forKey: .direction) | |||
try maneuver.encodeIfPresent(maneuverLocation, forKey: .location) | |||
try maneuver.encode(CLLocationCoordinate2DCodable(maneuverLocation), forKey: .location) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any maneuver types for which there’s no maneuverLocation
present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand what Maneuver
is, it always has a location where it "occurs" or "vocalized". Also, in the code, maneuverLocation
is non-nil.
Resolves #423
Bumbed Turf version to
0.4.0
. Implemented now hiddenCodable
conformances, refined importing conflicts betweenTurf
andPolyline
.