Opened 7 years ago

Closed 7 years ago

Last modified 5 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 7 years ago.
Configuration file for Swiss Topo
three-digits.patch (2.9 KB) - added by jcrepetto 7 years ago.
Patch to split tile numbers into three groups of three digits

Download all attachments as: .zip

Change History (11)

Changed 7 years ago by jcrepetto

Attachment: gdal_referer.patch added

Configuration file for Swiss Topo

comment:1 Changed 7 years ago by Even Rouault

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 Changed 7 years ago by jcrepetto

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 Changed 7 years ago by Even Rouault

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

comment:4 Changed 7 years ago by jcrepetto

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

Changed 7 years ago by jcrepetto

Attachment: three-digits.patch added

Patch to split tile numbers into three groups of three digits

comment:5 Changed 7 years ago by Even Rouault

Resolution: fixed
Status: newclosed

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

comment:6 Changed 7 years ago by jcrepetto

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 Changed 7 years ago by Even Rouault

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 Changed 7 years ago by jcrepetto

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

comment:9 Changed 5 years ago by Even Rouault

The example has been removed per #5022

Note: See TracTickets for help on using tickets.