Skip to content

fix(qgis): preserve XYZ tile URL templates and refresh canvas#92

Merged
giswqs merged 1 commit into
mainfrom
fix/qgis-xyz-tile-url
May 10, 2026
Merged

fix(qgis): preserve XYZ tile URL templates and refresh canvas#92
giswqs merged 1 commit into
mainfrom
fix/qgis-xyz-tile-url

Conversation

@giswqs

@giswqs giswqs commented May 10, 2026

Copy link
Copy Markdown
Member

Summary

  • Extract a _xyz_tile_uri helper 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.
  • Drop the attribution-as-referer mapping (attribution is a display credit, not an HTTP referer) and document the reasoning in the helper.
  • After adding an XYZ tile layer, set it as the active layer and refresh the map canvas so the tiles render immediately.

Test plan

  • pre-commit run --all-files
  • pytest tests/test_qgis_tools.py -q

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.
Copilot AI review requested due to automatic review settings May 10, 2026 04:03
@github-actions

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request May 10, 2026 04:04 Inactive
@giswqs giswqs linked an issue May 10, 2026 that may be closed by this pull request
@giswqs giswqs merged commit f105c6d into main May 10, 2026
11 checks passed
@giswqs giswqs deleted the fix/qgis-xyz-tile-url branch May 10, 2026 04:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 thread geoagent/tools/qgis.py
Comment on lines +1119 to +1124
uri = _xyz_tile_uri(
url,
zmin=zmin,
zmax=zmax,
attribution=attribution,
)
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.

QGIS plugin: xyz tiles url is encoded

2 participants