Skip to content

Add support for bottomLeft cornerOfOrigin#173

Closed
gdh12 wants to merge 2 commits intodevelopmentseed:mainfrom
gdh12:bottomLeft-support
Closed

Add support for bottomLeft cornerOfOrigin#173
gdh12 wants to merge 2 commits intodevelopmentseed:mainfrom
gdh12:bottomLeft-support

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 🙏

top = origin_y + (t.y + 1) * matrix.cellSize * matrix.tileHeight
else:
top = origin_y - t.y * matrix.cellSize * matrix.tileHeight
bottom = origin_y - (t.y + 1) * matrix.cellSize * matrix.tileHeight
Copy link
Member

Choose a reason for hiding this comment

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

in #191 I didn't implement this because I'm not sure to understand why it was needed

@vincentsarago
Copy link
Member

done in #191 🙏

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