Skip to content
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

Merged
merged 2 commits into from
Jun 10, 2020
Merged

Turf update #426

merged 2 commits into from
Jun 10, 2020

Conversation

Udumft
Copy link
Contributor

@Udumft Udumft commented Jun 5, 2020

Resolves #423

Bumbed Turf version to 0.4.0. Implemented now hidden Codable conformances, refined importing conflicts between Turf and Polyline.

@Udumft Udumft added the build label Jun 5, 2020
@Udumft Udumft self-assigned this Jun 5, 2020
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
Copy link
Contributor

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 }
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@Udumft Udumft requested a review from 1ec5 June 9, 2020 14:08
@Udumft Udumft merged commit 1ff08cb into master Jun 10, 2020
@Udumft Udumft deleted the vk-turf-update branch June 11, 2020 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to Turf v0.4.0
2 participants