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

Add conversions between enumerations and associated values #159

Merged
merged 3 commits into from
Oct 6, 2021

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Sep 30, 2021

Added protocol-based initializers to Geometry and GeoJSONObject that accept each case’s associated value as an initializer argument. This makes the enumerations more consistent with the JSONValue and FeatureIdentifier enumerations and simplifies some common workflows.

JSONValue and FeatureIdentifier now conform to the Hashable protocol. These types are likely to be used as dictionary keys or set members, and it’s pretty easy to make them hashable.

Fixes #158.

/cc @mapbox/navigation-ios @mapbox/maps-ios

@1ec5 1ec5 added the improvement Improvement for an existing feature. label Sep 30, 2021
@1ec5 1ec5 added this to the v2.0.0 (GA) milestone Sep 30, 2021
@1ec5 1ec5 self-assigned this Sep 30, 2021
@1ec5 1ec5 requested a review from macdrevx September 30, 2021 06:51
@1ec5

This comment has been minimized.

Sources/Turf/JSON.swift Outdated Show resolved Hide resolved
Sources/Turf/JSON.swift Outdated Show resolved Hide resolved
Sources/Turf/JSON.swift Outdated Show resolved Hide resolved
Copy link
Contributor

@macdrevx macdrevx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel really comfortable with the GeometryConvertible and GeoJSONObjectConvertible portions of this PR. It's less obvious whether the JSONValueConvertible portions are what we want. If there's a way to defer those parts, I think it'd be worth taking the extra time.

@1ec5 1ec5 force-pushed the 1ec5-geojson-convertible-158 branch from 16fa18c to 53910de Compare October 6, 2021 00:04
@1ec5
Copy link
Contributor Author

1ec5 commented Oct 6, 2021

I split out the JSONValueConvertible changes as #164, since there are still open questions about the extra syntactic sugar it would introduce.

@1ec5 1ec5 requested a review from macdrevx October 6, 2021 00:24
@1ec5 1ec5 merged commit ce7cc2f into main Oct 6, 2021
@1ec5 1ec5 deleted the 1ec5-geojson-convertible-158 branch October 6, 2021 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement for an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Geometric types should conform to common protocol that converts to Geometry
2 participants