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

WMTSCapabilitiesGenerator (fix for various CRS default values) #39

Merged
merged 6 commits into from
Jan 27, 2025

Conversation

alonakos
Copy link
Contributor

switched wellKnownScaleSet and crs_url from defaults to morecantile values

@alonakos alonakos requested a review from robyngit January 18, 2025 02:41
Copy link
Member

@robyngit robyngit left a comment

Choose a reason for hiding this comment

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

This is looking great @alonakos ! I couldn't getting it working with either of the following tests:

generator = WMTSCapabilitiesGenerator(
    title="This is the title",
    base_url="https://example.com",
    doi="doi:10.0000/00000000",
    layer_title="layer_title",
    layer_identifier="layer_identifier",
    bounding_box=None,
    tile_format=".png",
    tile_matrix_set_id="WorldCRS84Quad",
    tile_width=128,
    tile_height=128,
    max_z_level=3
)
generator = WMTSCapabilitiesGenerator(
    title="This is the title",
    base_url="https://example.com",
    doi="doi:10.5066/F7VQ30RM",
    layer_title="layer_title",
    layer_identifier="layer_identifier",
    bounding_box=None,
    tile_format=".png",
    tile_matrix_set_id="WorldCRS84Quad",
    tile_width=128,
    tile_height=128,
    max_z_level=3
)

I see the error:

Traceback (most recent call last):
  File "/Users/robyn/.vscode/extensions/ms-python.python-2024.22.2-darwin-arm64/python_files/python_server.py", line 133, in exec_user_input
    retval = callable_(user_input, user_globals)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 1, in <module>
  File "<string>", line 99, in __init__
  File "/Users/robyn/code/viz-raster/.venv/lib/python3.12/site-packages/pydantic/main.py", line 891, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'TileMatrixSet' object has no attribute 'supportedCRS'

Is there something I'm doing wrong?

Comment on lines 38 to 39
tile_width=128,
tile_height=128,
Copy link
Member

Choose a reason for hiding this comment

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

I think we decided that tile width and height should come from the TMS definition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, thank you! I updated it to use morecantile tms values

Comment on lines 30 to 35
title="This is the title",
base_url="https://example.com",
doi="doi:10.5066/F7VQ30RM",
layer_title="layer_title",
layer_identifier="layer_identifier",
bounding_box=None,
Copy link
Member

Choose a reason for hiding this comment

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

I like that you changed the example to hard-coded values 👍🏻 ! Makes it much more useful for people reading the docs.

@alonakos
Copy link
Contributor Author

This is looking great @alonakos ! I couldn't getting it working with either of the following tests:

generator = WMTSCapabilitiesGenerator(
    title="This is the title",
    base_url="https://example.com",
    doi="doi:10.0000/00000000",
    layer_title="layer_title",
    layer_identifier="layer_identifier",
    bounding_box=None,
    tile_format=".png",
    tile_matrix_set_id="WorldCRS84Quad",
    tile_width=128,
    tile_height=128,
    max_z_level=3
)
generator = WMTSCapabilitiesGenerator(
    title="This is the title",
    base_url="https://example.com",
    doi="doi:10.5066/F7VQ30RM",
    layer_title="layer_title",
    layer_identifier="layer_identifier",
    bounding_box=None,
    tile_format=".png",
    tile_matrix_set_id="WorldCRS84Quad",
    tile_width=128,
    tile_height=128,
    max_z_level=3
)

I see the error:

Traceback (most recent call last):
  File "/Users/robyn/.vscode/extensions/ms-python.python-2024.22.2-darwin-arm64/python_files/python_server.py", line 133, in exec_user_input
    retval = callable_(user_input, user_globals)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 1, in <module>
  File "<string>", line 99, in __init__
  File "/Users/robyn/code/viz-raster/.venv/lib/python3.12/site-packages/pydantic/main.py", line 891, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'TileMatrixSet' object has no attribute 'supportedCRS'

Is there something I'm doing wrong?

This is the morecantile version issue. Dmed you about which version do we want ti honor/support

@alonakos
Copy link
Contributor Author

updated the code for the latest morecantile version

Copy link
Member

@robyngit robyngit left a comment

Choose a reason for hiding this comment

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

Going to make a couple follow-up issues for some potential improvements but otherwise LGTM! 👍🏻

@alonakos alonakos merged commit 41f76ce into main Jan 27, 2025
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