Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRS:84 Projection results in KeyError while retrieves tiles from Cache. #622

Open
U-Tyagi opened this issue Jan 18, 2023 · 2 comments
Open

Comments

@U-Tyagi
Copy link

U-Tyagi commented Jan 18, 2023

It seems its a bug though I am not sure.

Context

Used the config as follows:

<mapproxy.yaml>
layers: 
- name: truemarble
  title: True Marble
  sources: [truemarble_cache]
caches:
  truemarble_cache:
    sources:[truemarble_src]
    format:image/png
    grids:[GLOBAL_WEBMERCATOR, GLOBAL_GEODETIC,GLOBAL_MERCATOR]
sources:
  truemarble_src:
    type:wms
    wms_opts:
      featureinfo:true
      version:1.1.1
    req:
      url:<GeoserverURL>
      transparent:true
      layers:true_marble

Expected Behavior

DEMO app should work with all the SRS populated in ComboBox [Coordinate System]

Actual Behavior

  1. http://localhost:8080/demo produces coordinate system combo box with entries [EPSG:3857, EPSG:4326, EPSG:900913, EPSG:4258, CRS:84]. From where last two entries are coming though not specified in section of config.
  2. Further Selecting EPSG: 4258 load the wms layer as <srs.py> return best_srs as EPSG:4326 for the selected srs. As the condition .islatlong becomes true.
  3. But when I select CRS:84 it results in KEYERROR: as <available_srs> dictionary in <layers.py> doesn't have 'CRS:84' as a key. Though <srs.py> has returned best_srs as CRS:84. Because the condition is true
if target in available_src
    return target

It basically implies:

SRS CRS:84 ('epsg:4326') == SRS EPSG:4326 ('epsg:4326')
return SRS CRS:84 ('epsg:4326')

Possible Fix

Once the condition becomes true return the entry in available_src rather than supplied SRS (query_srs)
I changed the code as follows in srs.py:

if target in available_src
    for avail in available_src:
        if target == avail:
            return avail

It returns the correct entry of SRS to access CacheMap and no more KeyError.

Steps to Reproduce

  1. Configure with the mapproxy.yaml as provided above
  2. Select CRS:84 in demo app
  3. It results in KeyError.

Your Environment

  • Version used: 1.15.1
  • Python 3.9
  • Local development server
  • Operating System and version: RHEL 8

Kindly suggest on:

  1. How the SRS values are populated in ComboBox of DEMO app.
  2. If they are populated why the CRS:84 was resulting in an error and whether the approach to circumvent the error is Okay.
@weskamm
Copy link
Member

weskamm commented Jan 20, 2023

I will have a look at this in the next days, i also discovered that there appear unintended SRS, so this may need a fix

@landryb
Copy link

landryb commented Jul 17, 2023

i think i have a similar issue on a service but with EPSG:900913, using 1.13.0 on debian, the full traceback is:

CRITICAL - mapproxy.wsgiapp - fatal error in service for /service?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=275886.9870096099912%2C5507272.485068191774%2C812284.5106800451176%2C5894815.385318184271&CRS=EPSG%3A900913&WIDTH=1715&HEIGHT=1239&LAYERS=ortho&STYLES=&FORMAT=image%2Fjpeg&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi%3A96
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mapproxy/wsgiapp.py", line 141, in __call__
    resp = self.handlers[handler_name].handle(req)
  File "/usr/lib/python3/dist-packages/mapproxy/service/ows.py", line 38, in handle
    return self.services[service].handle(req)
  File "/usr/lib/python3/dist-packages/mapproxy/service/base.py", line 30, in handle
    return handler(parsed_req)
  File "/usr/lib/python3/dist-packages/mapproxy/service/wms.py", line 136, in map
    renderer.render(merger)
  File "/usr/lib/python3/dist-packages/mapproxy/service/wms.py", line 586, in render
    return self._render_capture_source_errors(async_pool, render_layers,
  File "/usr/lib/python3/dist-packages/mapproxy/service/wms.py", line 624, in _render_capture_source_errors
    reraise(ex)
  File "/usr/lib/python3/dist-packages/mapproxy/util/py.py", line 40, in reraise
    raise exc.with_traceback(tb)
  File "/usr/lib/python3/dist-packages/mapproxy/util/async_.py", line 105, in map_each
    yield func(*arg)
  File "/usr/lib/python3/dist-packages/mapproxy/service/wms.py", line 636, in _render_layer
    layer_img = layer.get_map(self.query)
  File "/usr/lib/python3/dist-packages/mapproxy/layer.py", line 347, in get_map
    layer = self._select_layer(query.srs)
  File "/usr/lib/python3/dist-packages/mapproxy/layer.py", line 352, in _select_layer
    return self.srs_map[srs]
KeyError: SRS('EPSG:900913')

the service config for wms has this:

  wms:
    srs: ['EPSG:2154', 'EPSG:4326', 'CRS:84', 'EPSG:4258', 'EPSG:900913', 'EPSG:3857', 'EPSG:3945', 'EPSG:3946']

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

No branches or pull requests

3 participants