如何配置 mapcache 以缓存来自 tms 服务的切片

How to configure mapcache to cache tile from a tms service

我有一个带有地图缓存的地图服务器。

我知道如何配置 mapcache 以缓存来自 wms 服务的切片。

但我在任何地方都找不到如何配置地图缓存以缓存来自 TMS 服务的图块 (openstreetmap https://{s}.tile.openstreetmap.org/{z}/{x}/{y} .png)

在地图缓存页面上 https://mapserver.org/mapcache/index.html 据说 "services WMS, WMTS, TMS, VirtualEarth/Bing and Google Maps requests: Supported Tile Services"

我在 https://mapserver.org/mapcache/services.html#mapcache-services 上看到下面这行 “ 要激活 TMS 服务,请将这些行添加到 mapcache.xml 配置文件:

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

但它是供客户端从 mapcache 获取 tms tile,而不是 mapcache 从 tms 服务获取 tile

我不知道这是否可能,因为我没有找到例子。

要从 WMS 获取,我有上述内容

<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"/>

对于 TMS 我想要这种东西

<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"/>

谢谢

MapCache 不支持 TMS 作为源。参见 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).

您可以改用 MapProxy,它支持 TMS 源(图块)https://mapproxy.org/docs/nightly/sources.html