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

Expose coveringTiles() in transform objects #5239

Closed

Conversation

jonathanlurie
Copy link
Contributor

@jonathanlurie jonathanlurie commented Dec 18, 2024

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Add an entry to CHANGELOG.md under the ## main section.

Description

Before the work on globe, the function .coveringTiles() used to be a method of the Transform object, it was very convenient to access the list of tiles (with z, x and y indices) that were currently displayed. This PR aims at bringing this function back to the map.transform object.

Motivations

We (at MapTiler but we are not the only ones) are creating tiled layers to display raster data. These tiles are WebGL polygons with the same footprints as regular raster tiles, just with custom shaders. When only using Mercator it was fairly easy to figure out the math to know what tile should be displayed, but with the globe view, it is much more difficult. Since the list of tiles is computed internally in Maplibre, it would be great to expose it so that third-party plugins can use it.

Contrary to a previous PR I submitted (#5158), this one does not add any function or object to the official public API.

Usage

const tileList = map.transform.coveringTiles({tileSize: 512});

The tileSize attribute is the only one mandatory (as in the internal coveringTiles() function). Since it's the default size is always 512, we could make it the default value if not provided.

@jonathanlurie jonathanlurie changed the title Expose coveringTiles() Expose coveringTiles() in transform objects Dec 18, 2024
@jonathanlurie jonathanlurie marked this pull request as ready for review December 18, 2024 14:18
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.82%. Comparing base (5d5a2cd) to head (2101b45).
Report is 49 commits behind head on main.

Files with missing lines Patch % Lines
src/geo/projection/globe_transform.ts 80.00% 1 Missing ⚠️
src/geo/projection/mercator_transform.ts 75.00% 1 Missing ⚠️
...c/geo/projection/vertical_perspective_transform.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5239      +/-   ##
==========================================
- Coverage   91.83%   91.82%   -0.02%     
==========================================
  Files         281      281              
  Lines       38833    38845      +12     
  Branches     6779     6821      +42     
==========================================
+ Hits        35661    35668       +7     
- Misses       3044     3048       +4     
- Partials      128      129       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HarelM
Copy link
Collaborator

HarelM commented Dec 18, 2024

This is a change in the opposite direction of what we are looking to do.
Please also read the following PR comments and problems:

I would advise to think of a better way to expose this.
The transform class is not an external API nor we are planning for it to be so.

Copy link
Collaborator

@HarelM HarelM left a comment

Choose a reason for hiding this comment

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

See my previous comment.

@HarelM
Copy link
Collaborator

HarelM commented Jan 12, 2025

Closing this for now as there was no response, if this is still relevant please let me know and I'll reopen.

@HarelM HarelM closed this Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants