Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#3997 closed enhancement (fixed)

Field "Referer" required in WMS service description XML files

Reported by: jcrepetto Owned by: warmerdam
Priority: normal Milestone: 1.9.0
Component: GDAL_Raster Version: svn-trunk
Severity: normal Keywords:
Cc: nowakpl

Description

Some TMS servers require a special "Referer" in HTTP headers. For example, http://map.geo.admin.ch/ .

The attached patch adds support for a "Referer" field to the WMS driver.

The patch contains a configuration file for this service, that you can test with the command :

gdal_translate -projwin 737440 275760 740000 273200 frmts/wms/frmt_wms_swissgeo_tms.xml test.tif

Attachments (2)

gdal_referer.patch (3.7 KB ) - added by jcrepetto 13 years ago.
Configuration file for Swiss Topo
three-digits.patch (2.9 KB ) - added by jcrepetto 13 years ago.
Patch to split tile numbers into three groups of three digits

Download all attachments as: .zip

Change History (11)

by jcrepetto, 13 years ago

Attachment: gdal_referer.patch added

Configuration file for Swiss Topo

comment:1 by Even Rouault, 13 years ago

Cc: nowakpl added
Milestone: 1.8.11.9.0

r21966 /trunk/gdal/frmts/wms/ (7 files): WMS: add capability to set Referer http header; TMS-specific hack for some servers that require tile numbers to have exactly 3 characters (#3997)

While playing with the example file for Swiss topo, I have discovered the following issues I've noted in the xml file I've commited :

<!-- Caution : currently the georeferencing only works properly for the lowest-resolution level (base band). Some overviews levels are not exactly at half resolution of the neighbouring overview level, and the extent might also be slightly different... -->

comment:2 by jcrepetto, 13 years ago

The "TMS-hack" you added is not correct. I suggest something like :

  URLSearchAndReplace(url, "${xxx}", "%03d/%03d/%03d", tiri.m_x / 1000000, (tiri.m_x / 1000) % 1000, tiri.m_x % 1000); 
  URLSearchAndReplace(url, "${yyy}", "%03d/%03d/%03d", tms_y / 1000000, (tms_y / 1000) % 1000, tms_y % 1000); 

My plan was to submit a patch to address this problem after the "referer" patch has been accepted, but you went too fast :-)

You are right about the overviews, only the first three ones are valid. I'll file another ticket for this problem.

comment:3 by Even Rouault, 13 years ago

Will you attach a patch for a more correct version of the TMS hack (and the adaptation of the XML) ? Thanks

comment:4 by jcrepetto, 13 years ago

The tile numbers must be split in three groups of three digits (millions, thousands, units). I attach a patch to fix your previous patch. I have also updated the configuration file, you can use it at levels 20, 21 and 22 (2 overviews). Examples :

gdal_translate -projwin 549280 102960 590240 62000 frmt_wms_swissgeo_tms.xml level22.tif
gdal_translate -outsize 8192 8192 -projwin 549280 102960 590240 62000 frmt_wms_swissgeo_tms.xml level21.tif
gdal_translate -outsize 4096 4096 -projwin 549280 102960 590240 62000 frmt_wms_swissgeo_tms.xml level20.tif

by jcrepetto, 13 years ago

Attachment: three-digits.patch added

Patch to split tile numbers into three groups of three digits

comment:5 by Even Rouault, 13 years ago

Resolution: fixed
Status: newclosed

three-digits.patch applied in r22021 with an extra warning in the .xml file

comment:6 by jcrepetto, 13 years ago

The documentation page at http://www.gdal.org/frmt_wms.html needs to be updated to describe the new variables ${xxx} and ${yyy}.

comment:7 by Even Rouault, 13 years ago

Yeah, but I'm not too sure that this hack is under its final form and really deserves publicity... Do you now if it is used by other servers than this swisstopo one ?

Adam also suggested on IRC that we should perhaps have a more general way of formatting the x and y with some form of expression evaluation, but this is a non-trivial thing to implement. And I'm not sure than his proposal of doing it with reversed polish notation would be the most intuitive way for the user ;-)

comment:8 by jcrepetto, 13 years ago

I know these ones : http://map.geoportail.lu/ (Luxembourg) http://map.globe.admin.ch/ (Switzerland)

comment:9 by Even Rouault, 11 years ago

The example has been removed per #5022

Note: See TracTickets for help on using tickets.