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 internal map delegates, create platform Projection class #390

Merged
merged 8 commits into from
May 25, 2021

Conversation

julianrex
Copy link
Contributor

@julianrex julianrex commented May 25, 2021

PRs must be submitted under the terms of our Contributor License Agreement CLA.

Pull request checklist:

  • Briefly describe the changes in this PR.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality. If tests were not written, please explain why.
  • Add example if relevant.
  • Document any changes to public APIs.
  • Apply changelog label ('breaking change', 'bug 🪲', 'build', 'docs', 'feature 🍏', 'performance ⚡', 'testing 💯') or use the label 'skip changelog'
  • Add an entry inside this element for inclusion in the mapbox-maps-ios changelog: <changelog></changelog>.
  • Update the migration guide, API Docs, Markdown files - Readme, Developing, etc

Summary of changes

This PR:

  • Introduces MapTransformDelegate and MapProjectionDelegate protocols, both currently internal
  • Creates a platform specific Projection class that implements MapProjectionDelegate, shadowing the one from MapboxCoreMaps.
  • Fixes a minor TileStore bug with tileRegionGeometry

The two protocols match Android, except for getMetersPerPixelAtLatitude(latitude: Double). Also on Android MapboxMap conforms to MapProjectionDelegate, for iOS it's a new platform Projection

Developer impact

Developers will need to update any existing use of Projection in their code.

@julianrex julianrex added the breaking change ⚠️ If your pull request introduces a breaking change and updates are required when version is published label May 25, 2021
@julianrex julianrex marked this pull request as ready for review May 25, 2021 16:18
Copy link
Contributor

@neelmistry94 neelmistry94 left a comment

Choose a reason for hiding this comment

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

Seems like a trivial change. Could we add some testing around these new protocols though? Seems like the projection delegate could be mocked for a series of unit tests

@julianrex
Copy link
Contributor Author

Not sure what testing the protocol will give us, but will add a couple of small tests to test some assumptions (e.g. conformance)

@neelmistry94
Copy link
Contributor

Not sure what testing the protocol will give us, but will add a couple of small tests to test some assumptions (e.g. conformance)

They are simple pass through functions, but unit tests for those will help us Catch any breaking changes upstream from Core. It will be a nice catch all

static func unproject(_ mercatorCoordinate: MercatorCoordinate, zoomScale: CGFloat) -> CLLocationCoordinate2D
}

public class Projection: MapProjectionDelegate {
Copy link
Member

@pengdev pengdev May 25, 2021

Choose a reason for hiding this comment

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

On Android the MapboxMap : MapProjectionDelegate to be more discoverable, where the functions inside MapProjectionDelegate are not static.

gl-native exposed generated static APIs can be directly used as Projection.project(point, zoomScale).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's leave this as a point of difference? At the moment there's no need on iOS because of the lack of plugins. /cc @tobrun

_ = map as CameraManagerProtocol
_ = map as MapFeatureQueryable
_ = map as ObservableProtocol
_ = map as MapEventsObservable
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, this is an interesting concept as a test I like it

@julianrex julianrex merged commit 1c06e45 into main May 25, 2021
@julianrex julianrex deleted the jrex/map-delegates branch May 25, 2021 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change ⚠️ If your pull request introduces a breaking change and updates are required when version is published
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants