Using MapProxy in iShare
iShare v6 and later uses MapProxy to create and display cached map data, for example aerial or historic maps. MapProxy may also be useful in other circumstances, for example:
You may have to provide a customer API Key in the URL for each request, as in the case with the OS Maps API or Get Mapping Aerial Photography. If this were to be used directly in iShare, the key would have to be transferred to the client which could expose it to misuse.
Proxying the basemap through MapProxy allows us to also query it directly with WMS which then means that it should work seamlessly with printing.
Adding additional scales to a base map
The default scales may not cover the range of scales you wish to provide for your base map, and MapProxy can help with this. The cache upscale_tiles
as described in the cache documentation can scale tiles up depending on your requirements.
chc_my_basemap:
grids: [ "grd_my_basemap" ]
sources: [ "src_my_basemap"]
meta_buffer: 0
minimize_meta_requests: true
upscale_tiles: 1
cache_rescaled_tiles: true
This lets MapProxy know that any tiles that cannot be retrieved from the source should be rescaled from the next level up. Please note that this will not happen if there is an error returned from the source, just if the source is limited on what resolutions it can return. Again, please read the documentation for more information.
sources:
src_my_basemap:
type: tile
grid: grd_my_basemap
url: https://mymaps.com/maps/raster/v1/wmts?height=256&width=256&style=default&layer=My_Basemap&version=1.0.0&service=WMTS&Request=GetTile&format=image/png&TileMatrixSet=EPSG:27700&TileMatrix=EPSG:27700:%(z)s&TileRow=%(y)s&TileCol=%(x)s
max_res: 0.109375
min_res: 896.0
We need to set a max_res
and min_res
in the source to specify what resolutions the source supports returning.
grd_my_basemap:
origin: nw
srs: 'EPSG:27700'
bbox: [-238375.0,0.0,900000.0,1376256.0]
bbox_srs: 'EPSG:27700'
res: [896.0, 448.0, 224.0, 112.0, 56.0, 28.0, 14.0, 7.0, 3.5, 1.75, 0.875, 0.4375, 0.21875, 0.109375, 0.0546875, 0.02734375, 0.013671875, 0.0068359375]
The final step is to increase the number of resolutions that are available for the basemap so that the client will pick them up, just remember that any specific WMTS scale is the previous scale divided by two. In the example above, the following resolutions will be scaled as they are outside the source max/min res limits.
Â