Skip to content

Add support for bottomLeft cornerOfOrigin #173

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gdh12
Copy link

@gdh12 gdh12 commented Apr 17, 2025

This PR adds support for bottomLeft cornerOfOrigin.

cornerOfOrigin is specified in the OGC Two Dimensional Tile Matrix Set 2.0 specification and within the TileMatrix object model but is not currently handled anywhere in the morecantile code. This could be supported potentially "better" by through a refactor of the code that takes into account direction the matrix is heading instead of using if statements everywhere but instead I opted to add onto the API instead of introducing breaking changes.

This is tested by adding a bunch of unit tests for various zoom levels and tiles but also by creating a new TileMatrixSet I called "WebMercatorQuadBottomLeft" which is just WebMercatorQuad but starts bottom left. WebMercatorQuadBottomLeft is loaded automatically using a session autouse=True fixture to load it into the tms registry. Testing this required adding arguments a bunch of tests to taken in the tile identifier as an pytest argument so as not to duplicate code too much.

I would not consider myself an expert on the OGC tile specification so any feedback or concerns would be appreciated.

Functions added

  • ur, _ur, ll, and _ll
    • These functions were added to help with getting the TMS and geographic coordinates of the tile since ul and lr since those are new origin points.
  • origin_coords _origin_coords, origin_coords_across, and _origin_coords_across
    • These functions were added to help with getting the origin coordinates for a tile without the user having to guess the read the cornerOfOrigin themselves. This can be useful as a replacement for various usages of ul for any code that makes use of morecantile when figuring out where to start their tile placement from
  • translate_cornerOfOrigin_Tile to TileMatrix
    • More of a utility function but adding this to utils.py with type hints will cause a circular import. This will translate a Tile object from one cornerOfOrigin to another. Mostly useful when testing

Functions api changed

  • TileMatrixSet.custom
    • Added point_of_origin and corner_of_origin as optional kwargs which were previously being ignored

@vincentsarago
Copy link
Member

Hi @gdh12
Thanks for the PR, Sadly I do not have time to review right now because it does a lot of important changes (necessary).
I'll try to give it some time in the next few weeks.

I hope you understand 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants