This is a Fastify-based web service that transforms WMTS tile requests from MapboxGL (Mercator projection) to CGCS2000 coordinate system, redraws PNG tiles and returns them to the MapboxGL frontend. Main features include:
这是一个基于Fastify的Web服务,用于将mapboxgl对墨卡托坐标系下wmts瓦片请求转化为对cgcs2000坐标系下的瓦片请求,重新绘制png瓦片后返回给mapboxgl前端。项目主要功能包括:
- 接收前端mapboxgl Mercator投影的瓦片请求 Receive tile requests from MapboxGL frontend in Mercator projection
- 将请求行列号转换为CGCS2000坐标系并计算瓦片四至坐标 Convert tile row/column numbers to CGCS2000 coordinate system and calculate tile bounds
- 从cgcs2000 的WMTS服务获取对应区域的瓦片 Fetch corresponding tiles from CGCS2000 WMTS service
- 合并多个瓦片并返回合成图像 Merge multiple tiles and return the composite image
- Ensure Node.js (recommended version 16+) and npm are installed 确保已安装Node.js (建议版本16+)和npm
- Clone this repository 克隆本项目
- Install dependencies: 安装依赖:
npm install- Start the service 启动服务:
npm start- 服务默认运行在:http://localhost:3000
- 请求格式:
/arcgis/rest/services/{folder}/{layer}/MapServer/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=imgmap&STYLE=default&TILEMATRIXSET=default028mm&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/png
前端mapboxgl示例代码:
map.addLayer({
id: "cgcs2000-img-layer",
type: "raster",
source: {
type: "raster",
tiles: [
"http://localhost:3000/arcgis/rest/services/zj_tdt/services/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=imgmap&STYLE=default&TILEMATRIXSET=default028mm&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image%2Fpng"
],
tileSize: 256
},
paint: {},
layout: { visibility: "visible" },
});- Modify the
target_wmts_urlvariable inapp.jsto configure your WMTS service URL - 修改
app.js中的target_wmts_url变量配置您的WMTS服务地址 - Adjust the resolution parameters in the
RESOLUTIONSarray as needed - 可根据需要调整
RESOLUTIONS数组中的分辨率参数
MIT License