3

I'm having problems making MapProxy render a Mapserver WMS layer. My configuration file looks like this:

services:
 wms:
   srs: ['EPSG:3785', 'EPSG:4326', 'EPSG:23028']
   image_formats: ['image/jpg', 'image/png']

layers:
 name: mylayer
 title: My layer
 sources: [my_wms_source]

sources:
 my_wms_source:
   type:wms
   req:
     url: http://mydomain/cgi-bin/mapserv?
     layers: mylayer_in_mapserver
     map: /path/to/my/mapfile.map

Direct queries to mapserver work fine. So, a query like this works:

http://mydomain/cgi-bin/mapserv?styles=&map=/path/to/my/mapfile.map&format=image/png&width=800&height=600&bbox=-18.4267,27.3264,-13.0047,29.5457&layers=mylayer_in_mapserver&service=WMS&request=GetMap&srs=EPSG:4326&version=1.1.1

The key, I think, is in the bounding box. If I deploy MapProxy with debug activated and try to see my WMS source through the demo app, queries like these are raised:

http://mydomain/cgi-bin/mapserv?styles=&map=map=/path/to/my/mapfile.map&format=image%2Fpng&width=800&height=600&bbox=-506.77734375,-266.8359375,370.01953125,190.1953125&layers=mylayer_in_mapserver&service=WMS&request=GetMap&srs=EPSG:4326&version=1.1.1

And that query doesn't work, because the bounding box is in a different coordinate system (I guess epsg:3785).

How could I control that? The bbox is used for WMS queries. I've tried the 'srs' parameter in the wms option of the 'services' section, but it doesn't work. Any clues?

Thanks in advance, and best regards

3
  • The bounding box in the second query looks like it's in screen pixels. Notice, too, that each one of those coordinates is a whole multiple of 1/128. Evidently you need to apply a screen-to-world transformation to execute this query.
    – whuber
    Nov 14, 2011 at 18:46
  • Thanks for the tip, whuber. But the second query is automatically generated by MapProxy. I saw it activating the debug. So, I think I need to change a configuration parameter, but I don't know what parameter... Nov 14, 2011 at 22:05
  • I don't have the answer, Jorge, but I offered that observation in the hope that perhaps it might help someone get closer to a solution for you.
    – whuber
    Nov 14, 2011 at 22:31

2 Answers 2

2

Solved. With this configuration in the MapProxy yaml file:

services:
  wms:
    srs: ['EPSG:3785', 'EPSG:4326', 'EPSG:23028']
    image_formats: ['image/jpg', 'image/png']

layers:
  name: mylayer
  title: My layer
  sources: [my_cache]

caches:
  my_cache:
   grids: [GLOBAL_MERCATOR]
   sources: [my_wms_source]
   format: image/png
   request_format: image/png

sources:
  my_wms_source:
   type:wms
   req:
     url: http://ip_of_my_mapserver_machine/cgi-bin/mapserv?
     layers: mylayer_in_mapserver
     map: /path/to/my/mapfile.map
   supported_srs:['EPSG:3785', 'EPSG:4326', 'EPSG:23028']
1

The BBOX (-506.77734375,-266.8359375,370.01953125,190.1953125) is in EPSG:4326. You are just a bit too far zoomed out and the OpenLayers demo client will request that BBOX without any clipping. MapProxy doesn't know the extent of the cascaded service with your first configuration and forwards the requested BBOX to Mapserver. The second configuration (from your answer) contains an extent from the GLOBAL_MERCATOR grid and MapProxy can clip the BBOX.

You can get the first example to work if you add a coverage to your source.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.