这是indexloc提供的服务,不要输入任何密码
Skip to content

Potential Service Initialization Race Condition #1246

@malakaispann

Description

@malakaispann

Hello!

When porting an older app (Mapproxy v1.12 , Python 2.7) to a more modern version (Mapproxy v3.1.1, Python 3.12), I noticed that the Coordinate-System Picker for a given WMS layer wasn't respecting what I had set in my YAML.

Somewhat minimal YAML to reproduce:

services:
  demo:
  wms:
    md: 
      title: "foo"
      abstract: "bar"
      online_resource: https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9
    srs: 
      - "EPSG:3857"
    image_formats: 
      - "image/jpeg"
  wmts:
    restful: true
    kvp: true
    restful_template: /{Layer}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.{InfoFormat}

sources:
  esri_world_imagery:
    type: tile
    grid: default
    url: https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/WMTS/tile/1.0.0/World_Imagery/default/default/%(z)s/%(y)s/%(x)s.%(format)s
        
caches:
  esri_cache:
    sources: [esri_world_imagery]
    grids: [default]
    cache:
      type: file

layers:
  - name: '0'
    title: World Imagery
    sources: [esri_cache]

grids:
  default:
    base: GLOBAL_WEBMERCATOR
    bbox: [-19971868.8804, -20037507.0672, 19971868.8804, 20037507.0672]

Produces a Demo Page with the following CRS options:

  • EPSG:3857
  • EPSG:4258
  • EPSG:4326
  • EPSG:900913
  • CRS:84

The WMS capabilities doc and actual WMS server seem correct in only listing/allowing CRS:84 & EPSG:3857.

After a good bit of digging, I tracked down where I think the issue is occurring in ServiceConfiguration.services of "mapproxy/config/loader.py". The Demo service gets initialized before the WMS service and srs = self.context.globals.get_value('srs', ...) ends up getting set to the defaults defined in "mapproxy/config/defaults.py"

When placing the the Demo Service somewhere after WMS in the YAML, the options work as expected. i.e.

services:
  wms:
    md: 
      title: "foo"
      abstract: "bar"
      online_resource: https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9
    srs: 
      - "EPSG:3857"
    image_formats: 
      - "image/jpeg"
  wmts:
    restful: true
    kvp: true
    restful_template: /{Layer}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.{InfoFormat}
  demo:

# ...

I'm not sure if this oddity happens in the newer versions or if it even is a "bug" rather than user-error, but I though I'd mention it here just in case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions