fix(qgis): preserve XYZ tile URL templates and refresh canvas#92
Merged
Conversation
QGIS's XYZ datasource needs the tile URL template (with {z}/{x}/{y}
placeholders) to remain readable, so percent-encoding the entire URL
broke standard tile providers. Move URI assembly into a helper, only
encode characters that actually need escaping, drop the bogus
attribution-as-referer mapping, and refresh the canvas plus set the
new layer active so it shows immediately.
|
🚀 Deployed on https://6a0003d076ca2200fee07c2f--opengeos.netlify.app |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the QGIS add_xyz_tile_layer tool so standard XYZ tile URL templates (e.g., {z}/{x}/{y}) are preserved in the datasource URI, and newly added XYZ layers render immediately by activating the layer and refreshing the canvas.
Changes:
- Added
_xyz_tile_uri()to build QGIS XYZ datasource URIs while preserving{z}/{x}/{y}placeholders and avoiding over-encoding. - Removed the attribution→HTTP referer mapping from XYZ layer URIs.
- After adding an XYZ tile layer, sets it as the active layer and refreshes the map canvas; updated/added tests to validate URI formatting and refresh behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
geoagent/tools/qgis.py |
Introduces _xyz_tile_uri(), uses it in add_xyz_tile_layer, and refreshes/activates the added layer. |
tests/test_qgis_tools.py |
Adds coverage for the URI helper and asserts active-layer + canvas refresh behavior when adding XYZ layers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1119
to
+1124
| uri = _xyz_tile_uri( | ||
| url, | ||
| zmin=zmin, | ||
| zmax=zmax, | ||
| attribution=attribution, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_xyz_tile_urihelper that keeps{z}/{x}/{y}placeholders and other URL-template characters unescaped, so QGIS's XYZ provider accepts standard tile URLs (OSM, etc.) instead of the over-encoded form.Test plan
pre-commit run --all-filespytest tests/test_qgis_tools.py -q