[gdal-dev] WMS Issues Two Requests

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Fri Feb 7 00:57:06 PST 2014


Martin Lewis <MLewis <at> ngms.eu.com> writes:

> 
> I need a little help on WMS, it appears to decide that my one request should
> be two and hence is slowing the whole thing up
> I create an XML file and it has the following attributes for DataWindow:
> 
>        UpperLeftX                       -10.2210525
>        UpperLeftY                        57.7424
>        LowerRightX                     4.88191
>        LowerRightY                     51.3579
>        SizeX                               1076
>        SizeY                                787
> 
> BlockSize is left at default of 1024 for X and Y
> 
> When the request is issued I am noticing in Wireshark TWO requests are sent
> that appear to have the following BBOX parameters:
> 
> Request 1
> ------------
> -10.2210525
> 49.43529033
> 4.15203
> 57.7424
> 
> Request 2
> ------------
> 4.15203
> 49.43529033
> 18.52511
> 57.7424
> 
> So a couple of questions:
> 1. Why the two requests?
> 2. Why is the area that ends up in the two requests a lot bigger than the
> size of the DataWindow that was requested?
> 3. What am I missing? Is it SizeX being slightly bigger than the block size
> causing the two fetches? How can it be optimised?

Hi,

You did not tell much details so I must be guessing. Was the request you
made something like "gdal_translate -of GTiff wms_test.xml test_out.tif"?

You have perhaps defined the extents and size what you want for the ouput
image in the DataWindow element of the XML window. It it better not to do it
that way. Think that in the XML file you are giving the limits for what is
possible to do with this WMS so you can decide later what you really want to
do just that time.

The extents of WMS source in the XML file should tell the largest extents
which are supported for that layer in the source SRS units. For a global
WMS84 service they are -180 -90 180 90 but if you know your coverage better,
use the real extents. That window is used as an output image extent too if
you do not give any other window with your request later with either -srcwin
or -prjwin parameters. If it is a WMS service then usually you do not want
always to get a map covering the whole area. Instead selecting a region of
interest with -prjwin is more like a standard usage. Same applies to to size
of the output image.

If I have understood right the meaning of SizeX and SizeY in XML is to tell
how large the whole coverage is expressed in pixels in native resolution.
Thus a WMS layer covering 100 by 100 km with 0,5 m resolution would have
200000 both as SizeX and SizeY.  However, I am not sure if the values need
to be correct and what happens if they are not. It is hard to know what the
right values should be if the WMS is not your own and it advertizes the
extents as -180 -90 180 90 because WMS does not advertize native resolution
anywhere. I can see values <SizeX>2949120</SizeX><SizeY>1474560</SizeY> in 
http://www.gdal.org/frmt_wms_onearth_global_mosaic.xml and values
<SizeX>65536</SizeX><SizeY>32768</SizeY> in
http://www.gdal.org/frmt_wms_tileservice_bmng.xml

Be aware that if SizeX and SizeY are used for output image size if it is not
set with -outsize. You may not want to get 2949120x1474569 sized image, so
use -outsize.

WMS servers have usually some limits for the size of an output image. For
example Mapserver has a default maxsize 2048x2048 pixels. Block size in the
XML file is for that and you were correct, because you have a block size
1024x1024 and you want a 1076 pixels wide image GDAL is making two requests
and merges and cuts them on the client side. Generally it is a good thing to
do, but you can increase the block size if the server allows it.

Thus the conclusion. What you wanted to hear is the advice to increase the
BlockSizeX and BlockSizeY values to for example 2048 and you will get rid of
the second WMS request. However, it would be good to think a little further,
edit your XML file to cover larger extents and announce more realistic size
in pixels and finally send a request like 

gdal_translate -of GTiff -outsize 1076 787 -prjwin  -10.2210525 57.7424 
4.88191  51.3579 input_wms.xml output.tif

-Jukka Rahkonen-



More information about the gdal-dev mailing list