There are two main reasons as to why you would want to proxy the basemap, these are:
...
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.
Configuration
MapProxy uses a YAML configuration file to define the layers that are available in the service and also things like the caching used and the source for the cache.
There are four parts to the configuration
Layers
Code Block |
---|
- name: os_raster_road
title: os_raster_road
sources: [ "chc_os_raster_road" ] |
Caches
Code Block |
---|
chc_os_raster_road:
grids: [ "grd_os_raster_road" ]
sources: [ "src_os_raster_road"]
meta_buffer: 0
minimize_meta_requests: true |
Sources
Code Block |
---|
src_os_raster_road:
type: tile
grid: grd_os_raster_road
url: https://api.os.uk/maps/raster/v1/wmts?key=this_is_my_os_api_key&height=256&width=256&style=default&layer=Road_27700&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 |
Grids
Code Block |
---|
grd_os_raster_road:
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] |
Testing
Once these are incorporated into the main configuration file, you can then test it using the MapProxy demo site which should list the layer both in the WMS and WMTS sections. Clicking on the WMTS png
link will bring up an OpenLayers map which uses the specified basemap.
Configuring the WMTS Basemap in iShare Studio
...
Adding additional scales to a base map
The default scales may not cover the range of scales you wish to provide for your basemapbase 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.
...
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 infoinformation.
Code Block |
---|
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 |
...