Skip to content

WMS: add buildGetMapURL() - #1051

Open
michaeldavie wants to merge 3 commits into
geopython:masterfrom
michaeldavie:wms-getmap-url
Open

michaeldavie wants to merge 3 commits into
geopython:masterfrom
michaeldavie:wms-getmap-url

Conversation

@michaeldavie

@michaeldavie michaeldavie commented Nov 1, 2026 •

Copy link
Copy Markdown

Why

I maintain env_canada, which feeds the Environment Canada integration in Home Assistant and fetches MSC GeoMet radar frames over WMS. I'd like to use OWSLib for this rather than maintain my own WMS code, but Home Assistant runs on asyncio and doesn't allow blocking I/O in the event loop, so env_canada uses aiohttp and can't currently call getmap(). OWSLib already parses a capabilities document passed with xml=, so the missing piece is building the GetMap URL without sending it. Right now that logic is in the private __build_getmap_request.

What

This PR adds buildGetMapURL(**kwargs) to WebMapService_1_1_1 and WebMapService_1_3_0. It takes the same parameters as getmap() (without method and timeout), passes them to the existing private builder with getmap()'s defaults, and returns the URL that getmap(method='Get') would request. The name follows WMTS's buildTileRequest(). Existing methods are unchanged. A short note is added to usage.rst.

Tests

One offline test, parametrized over 1.3.0 and 1.1.1 using the existing Mesonet capabilities documents, checks that buildGetMapURL() returns exactly what getmap() sets as self.request.

Return the URL that getmap()/getfeatureinfo() would request, without
sending it, so callers can fetch with their own HTTP client (for example
aiohttp). Together with the existing xml= constructor argument, this lets
WMS be used without blocking I/O. The names follow WMTS's
buildTileRequest() and buildTileResource().

The operation URL lookup and GetFeatureInfo parameter building move into
private helpers shared by the request and URL methods; behaviour of
getmap() and getfeatureinfo() is unchanged.
@JakobMiksch

Copy link
Copy Markdown
Contributor

@michaeldavie I guess you have read the contribution guide: https://github.com/geopython/OWSLib/blob/master/CONTRIBUTING.md#by-humans-for-humans-bhfh

have you used AI for the creation of this PR, if yes how much?

@JakobMiksch

Copy link
Copy Markdown
Contributor

There is a lot of code changes only to expose two internal functions. I guess the maintainers should decide if this justifies the created benefit. Also I am wondering, if the same functionality (including proper tests) could be done shorter with less code generated.

Address review: drop buildGetFeatureInfoURL() and the refactor of
getmap()/getfeatureinfo(), pass getmap()'s parameters straight through
to the existing private builder, and test against the existing Mesonet
capabilities documents instead of adding a new fixture.
@michaeldavie michaeldavie changed the title WMS: add buildGetMapURL() and buildGetFeatureInfoURL() WMS: add buildGetMapURL() Nov 1, 2026
@michaeldavie

Copy link
Copy Markdown
Author

have you used AI for the creation of this PR, if yes how much?

Yes, I've used Claude Code and Claude Opus 5.5 to work on this.

There is a lot of code changes only to expose two internal functions. I guess the maintainers should decide if this justifies the created benefit. Also I am wondering, if the same functionality (including proper tests) could be done shorter with less code generated.

Thanks for the feedback, I've added a commit that trims the changes down significantly.

Comment thread owslib/map/wms130.py Resolved
Comment thread owslib/map/wms130.py Resolved
Comment thread docs/source/usage.rst Resolved
…add GeoMet example

Moves the base URL lookup and request encoding into a private __build_getmap_url() used by both getmap() and buildGetMapURL(), gives buildGetMapURL() the same explicit parameters as getmap(), and adds an aiohttp example against MSC GeoMet to usage.rst.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants