Skip to content

map providers can sometimes be passed incorrect bbox-crs value #2443

Open

Description

@ricardogsilva

when preparing a response for a static map request, pygeoapi does some pre-processing of inputs and then passes them to a map provider for rendering the image.

After initial parsing, if bbox-crs is different from crs, pygeoapi transforms the bbox parameter to the crs specified in crs, as can be seen in:

if query_args['bbox-crs'] != query_args['crs']:
bbox = transform_bbox(bbox, query_args['bbox-crs'],
query_args['crs'], always_xy=True)
LOGGER.debug(f'Transformed bbox: {bbox}')
query_args['bbox'] = bbox

The result of this coordinate transformation is then used to replace the value of query_args['bbox']. However, the value of query_args['bbox_crs'] is never updated to match the CRS of the newly transformed bbox.

This means that when the map provider is given the query_args dict, it can sometimes contain an incorrect value for the bbox-crs key.

As an example, I'm seeing these as the input parameters to my custom map provider's query() method:

{
    'self': <BaseProvider> map, 
    'style': None, 
    'bbox': [-20037508.342789244, -20037471.205137063, 20037508.342789244, 20037471.205137063], 
    'width': 500, 
    'height': 300, 
    'crs': 'http://www.opengis.net/def/crs/EPSG/0/3857', 
    'transparent': True, 
    'format_': 'png', 
    'kwargs': {
        'bbox-crs': 'http://www.opengis.net/def/crs/OGC/1.3/CRS84', 'datetime_': None
    }
}

It can be seen that even though the contents of bbox is in 3857, the bbox-crs is still set to CRS84.

Activity

  1. ricardogsilva commented on Oct 23, 2026

    @ricardogsilva
    MemberAuthor

    An additional issue I've noted with the bbox-crs key of the query_args dict is that this uses a dash in its name, which cannot be used when creating Python identifiers.

    This is not a problem per se, but makes the API for downstream map providers more awkward than it needs to be, as it means all map providers are thus forced to accept a **kwargs argument in their respective query() methods because bbox-crs would not be a valid name in a Python function signature.

  2. amantebriwal4321 commented on Nov 3, 2026

    @amantebriwal4321

    Hi, I'd like to take this one. The fix is to set bbox-crs to crs right after the bbox is transformed in get_collection_map, plus a test that checks what the provider receives. I see #2446 tried this and was closed, so let me know if you'd rather handle it differently or if it should wait for #2475.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions