支持的对象服务¶
- 作者
托马斯堡
- 联系方式
联系方式请见: terriscope.fr
- 作者
史蒂芬·伍德布里奇
mapcache能够使用各种不同的请求协议和tile命名约定为tile提供服务。本文件对此进行了说明。必须在mapcache.xml文件中打开各种服务,以便mapcache响应这些特定请求。
所有服务都可以在演示界面上使用,强烈建议您在创建自己的页面访问mapcache图块时复制/粘贴javascript代码以开始使用。
此页使用以下表示法,并引用mapcache.xml配置文件中的对象名。
<tileset_name>-配置的tileset的名称
<gridu name>-显式或隐式定义的网格的名称
<quadkey>-特定于Virtual Earth Tile服务
zxy命名方案中的缩放级别
zxy命名方案中的行号
zxy命名方案中的列号
TMS服务¶
TMS服务使用z/x/y图块命名方案,其中:
要激活TMS服务,请将这些行添加到mapcache.xml配置文件中:
<service type="tms" enabled="true"/>
“能力”文档可通过以下方式获取:
http://myhost.com/mapcache/tms/1.0.0/
使用此方案请求平铺:
http://myhost.com/mapcache/tms/1.0.0/<tileset_name>@<grid_name>/<z>/<x>/<y>.png
对于epsg:3857、epsg:900913或GoogleMapsCompatible网格,单元格为[z/x/y]:
z0:
[0/0/0]
z1:
[1/0/0][1/1/0]
[1/0/1][1/1/1]
z2:
[2/0/0][2/1/0][2/2/0][2/3/0]
[2/0/1][2/1/1][2/2/1][2/3/1]
[2/0/2]...
[2/0/3]...
等。。。
对于EPSG:4326或WGS84网格:
注解
OGC WMTS规范要求GoogleCRS84Quad WellKnownsCaleset具有0级,其范围是-180、-180180180。默认的“wgs84”mapcache网格支持这一点,这可能会导致与预期级别0为2x1、范围为-180、-90180、90的分片的软件不兼容
z0:
[0/0/0]
z1:
[1/0/0][1/1/0]
z2:
[2/0/0][2/1/0][2/2/0][2/3/0]
[2/0/1][2/1/1][2/2/1][2/3/1]
等。
KML服务¶
KML服务生产 Super-Overlays 对于与wgs84/epsg对齐的tileset:4326网格。超级覆盖是一个链接到图像URL的kml文件,以及与相邻分辨率相对应的一组其他kml URL。kml服务使用z/x/y图块命名方案,其中:
注解
为了使kml服务正常工作,还必须激活tms服务,因为kml超级叠加使用此规范链接到图像。
要激活kml服务,请将这些行添加到mapcache.xml配置文件中:
<service type="tms" enabled="true"/>
<service type="kml" enabled="true"/>
使用此方案请求平铺:
http://myhost.com/mapcache/kml/<tileset_name>@<grid_name>/<z>/<x>/<y>.kml
OGC WMTS服务¶
要激活WMTS服务,请将这些行添加到mapcache.xml配置文件中:
<service type="wmts" enabled="true"/>
此服务遵循标准的OGC WMTS请求,同时支持经典的OGC样式的键值对编码请求和REST样式请求。
http://myhost.com/mapcache/wmts?SERVICE=WMTS&VERSION=1.0.0&...
http://myhost.com/mapcache/wmts/1.0.0/....
这些能力是通过以下途径获得的:
http://myhost.com/mapcache/wmts?service=wmts&request=getcapabilities&version=1.0.0
http://myhost.com/mapcache/wmts/1.0.0/WMTSCapabilities.xml
参见
OWC WMS服务¶
MapCache响应WMS 1.1.1版请求,对1.3.0版请求的支持有限。
<service type="wms" enabled="true"/>
注解
请注意,WMS服务与其他mapcache服务稍有不同,因为它在已配置实例的根目录而不是其他终结点(即,服务在http://server/mapcache/上响应)上进行侦听。而不是在http://server/mapcache/wms?)。此行为是必需的,以便启用 proxying of unsupported requests 同时为所有OGC服务提供一个端点。
注解
MapCache主要支持1.1.1版WMS请求,但对较新版本1.3.0请求的支持有限。对于1.3.0请求,mapcache将确定 grid 通过使用crs=参数而不是srs=1来使用,并且将正确地遵守转换bbox参数的常规x/y顺序的epsg参考系统的轴顺序。
参见
参见
WMS请求遵循经典的键值对编码样式:
http://myhost.com/mapcache?SERVICE=WMS&VERSION=1.1.1&REQUEST=....
能力文件由以下人员返回:
http://myhost.com/mapcache?service=wms&request=getcapabilities
可选的WMS配置选项¶
未绑定的getmap支持¶
可以启用或禁用对untiled(非WMS-C)getmap请求的支持:
<service type="wms" enabled="true">
<!-- full_wms
Configure response to WMS requests that are not aligned to a tileset's grids.
Responding to requests that are not in the SRS of a configured grid is not supported, but
this should never happen as only the supported SRSs are publicized in the capabilities
document.
Allowed values are:
- error: return a 404 error (default)
- assemble: build the full image by assembling the tiles from the cache
- forward: forward the request to the configured source.
-->
<full_wms>assemble</full_wms>
</service>
获取地图图像格式¶
您可以显式地为一个未命名的WMS请求设置应返回给客户机的图像格式(即,当无法直接从缓存中提供分片数据,但需要经过解压/重新压缩阶段时)。
<service type="wms" enabled="true">
<format allow_client_override="true/false">myjpegformat</format>
</service>
如果 allow_client_override 属性设置为true,则mapcache将接受客户端发送的“format=…”参数。默认情况下,mapcache忽略此参数并使用其配置的图像格式。
图像重采样质量¶
<service type="wms" enabled="true">
<!-- resample mode
Filter applied when resampling tiles for full WMS requests.
Can be either:
- nearest : fastest, poor quality
- bilinear: slower, higher qulity
-->
<resample_mode>bilinear</resample_mode>
</service>
谷歌地图XYZ服务¶
<service type="gmaps" enabled="true"/>
前提条件:您的WMS应该能够在epsg:900913或epsg:3857 SRS中生成图像,即它应该引用“g”或“GoogleMapsCompatible”网格。
这是最基本的HTML页面。重要的位在urltemplate(for v2)和gettileurl(for v3)变量中:
/mapcache是mapcache处理请求的apache路径。
test@g是要使用的tileset和网格名称,由一个“@”连接,z/x/y应单独使用。
如果您在tileset中使用的是jpeg格式,那么最后的扩展名应该更改为“jpg”。
V2 API¶
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google/MapServer Tile Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAnfs7bKE82qgb3Zc2YyS-oBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSySz_REpPq-4WZA27OwgbtyR3VcA"
type="text/javascript"></script>
<script type="text/javascript">
function load() {
if (GBrowserIsCompatible()) {
var urlTemplate = '/mapcache/gmaps/test@g/{Z}/{X}/{Y}.png';
var myLayer = new GTileLayer(null,0,18,{
tileUrlTemplate:urlTemplate,
isPng:true,
opacity:0.8 });
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(0, 0), 1);
map.addOverlay(new GTileLayerOverlay(myLayer));
}
}
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 500px; height: 500px"></div>
</body>
</html>
V3 API¶
V2示例的前一个javascript应该稍微更改为:
var map = new google.maps.Map("<element-id>", { /*options*/ });
var layerOptions = {
getTileUrl: function(coord, zoom) {
return "/mapcache/gmaps/test@g/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
},
tileSize: new google.maps.Size(256,256) // or whatever
};
map.overlayMapTypes.insertAt(0, new google.maps.ImageMapType(layerOptions));
虚拟地砖服务¶
对象按照两种不同的布局之一进行排列,这取决于它们是使用球面墨卡托投影,如epsg:3857或epsg:900913,还是使用地理投影,如epsg:4326。
使用此方案请求平铺:
http://myhost.com/mapcache/ve?LAYER=<tileset_name>@<grid_name>&tile=<quadkey>
对于epsg:3857、epsg:900913或GoogleMapsCompatible网格,<QuadKey>排列:
z0:
[0]
http://myhost.com/mapcache/ve?LAYER=osm@GoogleMapsCompatible&tile=0
z1:
[00][01]
[02][03]
http://myhost.com/mapcache/ve?LAYER=osm@GoogleMapsCompatible&tile=00
http://myhost.com/mapcache/ve?LAYER=osm@GoogleMapsCompatible&tile=01
http://myhost.com/mapcache/ve?LAYER=osm@GoogleMapsCompatible&tile=02
http://myhost.com/mapcache/ve?LAYER=osm@GoogleMapsCompatible&tile=03
etc.
对于epsg:4326或wgs84网格,<quadkey>排列:
z1:
[0][1]
http://myhost.com/mapcache/ve?LAYER=osm@WGS84&tile=0
http://myhost.com/mapcache/ve?LAYER=osm@WGS84&tile=1
z2:
[00][01][10][11]
[02][03][12][13]
http://myhost.com/mapcache/ve?LAYER=osm@WGS84&tile=00
http://myhost.com/mapcache/ve?LAYER=osm@WGS84&tile=01
http://myhost.com/mapcache/ve?LAYER=osm@WGS84&tile=02
http://myhost.com/mapcache/ve?LAYER=osm@WGS84&tile=03
http://myhost.com/mapcache/ve?LAYER=osm@WGS84&tile=10
http://myhost.com/mapcache/ve?LAYER=osm@WGS84&tile=11
http://myhost.com/mapcache/ve?LAYER=osm@WGS84&tile=12
http://myhost.com/mapcache/ve?LAYER=osm@WGS84&tile=13
etc.