Repository navigation
WMS: add buildGetMapURL() - #1051
michaeldavie wants to merge 3 commits into
Conversation
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.
|
@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? |
|
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.
Yes, I've used Claude Code and Claude Opus 5.5 to work on this.
Thanks for the feedback, I've added a commit that trims the changes down significantly. |
…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.
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 onasyncioand doesn't allow blocking I/O in the event loop, soenv_canadausesaiohttpand can't currently callgetmap(). OWSLib already parses a capabilities document passed withxml=, so the missing piece is building theGetMapURL without sending it. Right now that logic is in the private__build_getmap_request.What
This PR adds
buildGetMapURL(**kwargs)toWebMapService_1_1_1andWebMapService_1_3_0. It takes the same parameters asgetmap()(withoutmethodandtimeout), passes them to the existing private builder withgetmap()'s defaults, and returns the URL thatgetmap(method='Get')would request. The name follows WMTS'sbuildTileRequest(). Existing methods are unchanged. A short note is added tousage.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 whatgetmap()sets asself.request.