Search code examples
configurationtms

How to configure mapcache to cache tile from a tms service


I have a mapserver with mapcache on a server.

I know how to configure mapcache to cache tile from a wms service.

But I can't find anywhere how to configure mapcache to cache tile from a TMS service (openstreetmap https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png)

On the mapcache page https://mapserver.org/mapcache/index.html it is said "services WMS, WMTS, TMS, VirtualEarth/Bing and Google Maps requests: Supported Tile Services"

I see the line below on https://mapserver.org/mapcache/services.html#mapcache-services " To activate the TMS service, add these lines to the mapcache.xml configuration file:

<service type="tms" enabled="true"/> "

but it's for a client to get tms tile from mapcache, not to mapcache to get the tile from a tms service

I Don't know if it is even possible, because I found no exemple.

To get from a WMS I had the above

<source name="name1" type="wms">
   <getmap>
      <params>
         <LAYERS>layer1</LAYERS>
      </params>
   </getmap>
   <http>
      <url>http://an_rul.com/ows/name1</url>
  </http>
</source>

<tileset name="name1">
   <source>name1</source>
   <cache>disk</cache>
   <grid>GoogleMapsCompatible</grid>

   <format>PNG</format>

   <metatile>5 5</metatile>
   <metabuffer>10</metabuffer>
   <expires>3600</expires>
</tileset>

<service type="wms" enabled="true">
   <full_wms>assemble</full_wms>
   <resample_mode>bilinear</resample_mode>
   <format>PNG</format>
   <maxsize>4096</maxsize>
   <forwarding_rule name="catch all">
   <http>
      <url>http://an_rul.com/ows/name1</url>
   </http>
   </forwarding_rule>
</service>

<service type="tms" enabled="true"/>

For a TMS i'd like to have this sort of thing

<source name="name1" type="tms">  <-- note the tms type i'd like
    <getmap>
       <params>
          <LAYERS>layer1 ?</LAYERS> <-- what layer can I put there  ?
       </params>
    </getmap>
    <http>
       <url>https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png ??</url> <-- which url should I write ??
   </http>
 </source>

 <tileset name="name1">
    <source>name1</source>
    <cache>disk</cache>
    <grid>GoogleMapsCompatible</grid>

    <format>PNG</format>

    <metatile>5 5</metatile>
    <metabuffer>10</metabuffer>
    <expires>3600</expires>
 </tileset>

 <service type="wms" enabled="true">
    <full_wms>assemble</full_wms>
    <resample_mode>bilinear</resample_mode>
    <format>PNG</format>
    <maxsize>4096</maxsize>
    <forwarding_rule name="catch all">
    <http>
       <url>http://an_rul.com/ows/name1</url>
    </http>
    </forwarding_rule>
 </service>

<service type="tms" enabled="true"/>

Thank You


Solution

  • MapCache does not support TMS as a source. See https://mapserver.org/mapcache/config.html

    A source is a service mod-mapcache can query to obtain image data. This is typically a WMS server accessible by a URL. (There are currently only WMS, WMTS and mapfile as sources, though others may be added later if the need arises, see Data Sources).

    You can use MapProxy instead, it supports TMS sources (tiles) https://mapproxy.org/docs/nightly/sources.html