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 support for variable TMS #131

Merged
merged 5 commits into from
Jul 24, 2023
Merged

add support for variable TMS #131

merged 5 commits into from
Jul 24, 2023

Conversation

vincentsarago
Copy link
Member

@vincentsarago vincentsarago commented Jul 20, 2023

closes #115

import morecantile
tms = morecantile.tms.get("GNOSISGlobalGrid")

tms.xy_bounds(0, 0, 1)
>> BoundingBox(left=-180.0, bottom=45.0, right=-135.0, top=90.0)

tms.xy_bounds(1, 0, 1)
>> BoundingBox(left=-180.0, bottom=45.0, right=-135.0, top=90.0)

tms.xy_bounds(4, 0, 1)
>> BoundingBox(left=-90.0, bottom=45.0, right=-45.0, top=90.0)

ToDo

  • add tests
  • add documentation

@vincentsarago vincentsarago marked this pull request as draft July 20, 2023 22:59
@cached_property
def is_quadtree(self) -> bool:
"""Check for quadtree support."""
return check_quadkey_support(self.tileMatrices)
Copy link
Member Author

Choose a reason for hiding this comment

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

using cached property is recommended by pydantic

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, this decorator requires that the dict attribute on each instance be a mutable mapping. This means it will not work with some types, such as metaclasses (since the dict attributes on type instances are read-only proxies for the class namespace), and those that specify slots without including dict as one of the defined slots (as such classes don’t provide a dict attribute at all).

Maybe we should check ☝️

origin_y = (
matrix.pointOfOrigin[0] if self._invert_axis else matrix.pointOfOrigin[1]
)
return Coords(origin_x, origin_y)
Copy link
Member Author

Choose a reason for hiding this comment

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

reduce code duplication

xcoord = origin_x + t.x * res * matrix.tileWidth
ycoord = origin_y - t.y * res * matrix.tileHeight
return Coords(xcoord, ycoord)
def _lr(self, *tile: Tile) -> Coords:
Copy link
Member Author

Choose a reason for hiding this comment

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

it's better to use lower-right coordinates than upper-right of tile + 1

morecantile/models.py Outdated Show resolved Hide resolved
@vincentsarago
Copy link
Member Author

cat morecantile/data/GNOSISGlobalGrid.json| morecantile tms-to-geojson --level 3 --collect > level3.geojson
Screenshot 2023-07-21 at 1 27 45 AM

@vincentsarago vincentsarago marked this pull request as ready for review July 21, 2023 16:21
@vincentsarago vincentsarago merged commit c3d7c62 into main Jul 24, 2023
5 checks passed
@vincentsarago vincentsarago deleted the variableWidth branch July 24, 2023 10:50
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.

enable Variable width tile matrices
1 participant