Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

There are two main reasons as to why you would want to proxy the basemap, these are:

  1. You have to provide a customer API Key in the URL for each request, as in the case with the OS Maps API. 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.

  2. 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

  - name: os_raster_road
    title: os_raster_road
    sources: [ "chc_os_raster_road" ]

Caches

  chc_os_raster_road:
    grids: [ "grd_os_raster_road" ]
    sources: [ "src_os_raster_road"]
    meta_buffer: 0
    minimize_meta_requests: true

Sources

  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

  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

Configuring your WMTS basemap for use in iShare is done via iShare Studio and is covered in the following pages:

Increasing the number of Scales for the Basemap

The default scales may not cover the range of scales you wish to provide for your basemap, 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.

0.0546875, 0.02734375, 0.013671875, 0.0068359375
  • No labels