# tilefuser-server **Repository Path**: geoair/tilefuser-server ## Basic Information - **Project Name**: tilefuser-server - **Description**: 谷歌服务瓦片转换4490瓦片服务解决方案 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-17 - **Last Updated**: 2026-07-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: 3857转4490, 谷歌网格转换, 4490瓦片服务, 谷歌瓦片服务 ## README # 瓦片融合服务 (TileFuser) 使用文档 ## 1. 项目概述 ### 1.1 简介 瓦片融合服务(TileFuser)是一个基于 Spring Boot 的 GIS 瓦片服务中间件,提供多种坐标系之间的瓦片转换、图层代理和预缓存功能。 ### 1.2 核心功能 - **坐标系转换**:支持 EPSG:3857(Web Mercator)与 EPSG:4326(WGS84)之间的瓦片实时转换 - **图层代理**:支持网络(HTTP)和本地文件两种瓦片数据源 - **网络代理**:支持通过代理服务器访问外部瓦片服务 - **预缓存**:支持按地理范围和层级预生成瓦片,提升访问性能 - **多格式支持**:支持 PNG、JPG、WebP 等图片格式 ### 1.3 转换示例 #### 示例一:3857 → 4490 坐标系转换 将 Web Mercator(EPSG:3857)网格的 OSM 地图转换为 CGCS2000(EPSG:4490)网格的地图。  *图1:3857坐标系瓦片转换为4490坐标系效果图* #### 示例二:3857 → 4490 坐标系转换 将 Web Mercator(EPSG:3857)网格的 arcgis 地图转换为 CGCS2000(EPSG:4490)网格的地图。  *图2:3857坐标系瓦片转换为4490坐标系效果图* ### 1.3 技术架构 ``` ┌─────────────────────────────────────────────────────────────┐ │ 客户端请求 │ └─────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────┐ │ TileServiceTranController │ │ (REST API 接口层) │ └─────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────┐ │ TileServiceTran │ │ (业务逻辑层 - 坐标系转换) │ └─────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────┐ │ GirFuserLayerTileGetterImpl │ │ (图层获取器实现) │ └─────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────┐ │ 数据库 (PostgreSQL) │ │ tgwc_layer_pxy_info 表 │ └─────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────┐ │ TileGetterFactory → LayerTileGetter │ │ (瓦片获取器工厂) │ └─────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────┐ │ FileTileCache (本地缓存) │ │ 缓存目录: /path/to/cache/ │ └─────────────────────────────────────────────────────────────┘ ``` --- ## 2. 环境要求 ### 2.1 基础环境 | 组件 | 版本要求 | |------|----------| | JDK | 1.8+ | | Spring Boot | 2.x | | PostgreSQL | 9.6+ | | Maven | 3.6+ | ### 2.2 依赖说明 - **PostgreSQL**:存储图层配置信息 - **Liquibase**:数据库版本管理 - **Hutool**:工具类库 - **Lombok**:代码简化 --- ## 3. 快速开始 ### 3.1 克隆项目 ```bash git clone https://gitee.com/geoair/tilefuser-server.git cd tile-fuser ``` ### 3.2 配置数据库 编辑 `application.yml`: ```yaml spring: datasource: driverClassName: org.postgresql.Driver url: jdbc:postgresql://192.168.0.XXX:5432/your_database username: postgres password: your_password hikari: maximum-pool-size: 50 minimum-idle: 5 ``` ### 3.3 配置缓存目录(可选) ```bash # 方式一:JVM 参数 -DGTC_CACHE_DIR=/data/tile_cache # 方式二:环境变量 export GTC_CACHE_DIR=/data/tile_cache ``` ### 3.4 启动服务 ```bash mvn clean package java -jar target/tile-fuser.jar ``` 启动成功后看到: ``` ========== 瓦片融合服务启动成功 ========== 服务端口: 26889 访问地址: http://localhost:26889/geoair/ 瓦片融合缓存目录: /data/tile_cache/gwc_fuser/tile_cache/ ``` --- ## 4. 配置管理 ### 4.1 图层配置 #### 4.1.1 插入图层配置 ```sql -- 示例:OpenStreetMap 图层(带代理) INSERT INTO public.tgwc_layer_pxy_info ( id, layer_name, type, path, enable_cache, use_web_pxy, web_pxy_host, web_pxy_port, origin_type, grid_srid, image_type ) VALUES ( gen_random_uuid()::varchar, 'osm', 'web', 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', 'true', 'true', '192.168.0.196', 8887, 'google', 3857, 'png' ); -- 示例:本地瓦片图层 INSERT INTO public.tgwc_layer_pxy_info ( id, layer_name, type, path, enable_cache, use_web_pxy, origin_type, grid_srid, image_type ) VALUES ( gen_random_uuid()::varchar, 'local_tiles', 'local', '/data/tiles/{z}/{x}/{y}.png', 'true', 'false', 'google', 3857, 'png' ); ``` #### 4.1.2 配置字段说明 | 字段 | 类型 | 必填 | 说明 | 示例 | |------|------|------|------|------| | layer_name | varchar | ✅ | 图层唯一标识 | `osm` | | type | varchar | ✅ | 数据源类型:`web`/`local` | `web` | | path | varchar | ✅ | URL或本地路径模板 | `https://tile.osm.org/{z}/{x}/{y}.png` | | enable_cache | varchar | ❌ | 是否启用缓存:`true`/`false` | `true` | | use_web_pxy | varchar | ❌ | 是否使用代理:`true`/`false` | `true` | | web_pxy_host | varchar | ❌ | 代理服务器地址 | `192.168.0.196` | | web_pxy_port | int | ❌ | 代理服务器端口 | `8887` | | origin_type | varchar | ❌ | 原点类型:`google`/`tms` | `google` | | grid_srid | int | ❌ | 坐标系SRID,默认3857 | `3857` | | image_type | varchar | ❌ | 图片格式,默认`png` | `png` | ### 4.2 服务配置 ```yaml server: port: 26889 tomcat: uri-encoding: UTF-8 max-threads: 1000 min-spare-threads: 30 logging: level: root: INFO cn.geoair.map.tile.forge.fuser: DEBUG # 开启调试日志 ``` --- ## 5. API 接口文档 ### 5.1 3857 → 4326 瓦片转换 **接口描述**:将 Web Mercator 投影(EPSG:3857)的瓦片转换为 WGS84 经纬度投影(EPSG:4326) **请求方式**:`GET` **URL**:`/geoair/wm2gs84/{layerName}/{z}/{x}/{y}` **路径参数**: | 参数 | 类型 | 必填 | 说明 | 示例 | |------|------|------|------|------| | layerName | String | ✅ | 图层名称(需在数据库中配置) | `osm` | | z | Integer | ✅ | 缩放层级 | `10` | | x | Integer | ✅ | 瓦片 X 坐标 | `256` | | y | Integer | ✅ | 瓦片 Y 坐标 | `128` | **查询参数**: | 参数 | 类型 | 必填 | 默认值 | 说明 | |------|------|------|--------|------| | format | String | ❌ | `png` | 图片格式:`png`/`jpg`/`webp` | **请求示例**: ```bash # 获取 PNG 格式瓦片 curl "http://localhost:26889/geoair/wm2gs84/osm/10/256/128?format=png" # 获取 JPG 格式瓦片 curl "http://localhost:26889/geoair/wm2gs84/osm/10/256/128?format=jpg" ``` **响应**: - 成功:返回图片流(image/png、image/jpeg 等) - 失败:返回 HTTP 错误状态码 --- ### 5.2 4326 → 3857 瓦片转换 **接口描述**:将 WGS84 经纬度投影(EPSG:4326)的瓦片转换为 Web Mercator 投影(EPSG:3857) **请求方式**:`GET` **URL**:`/geoair/gs84ToWm/{layerName}/{z}/{x}/{y}` **路径参数**: | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | layerName | String | ✅ | 图层名称 | | z | Integer | ✅ | 缩放层级 | | x | Integer | ✅ | 瓦片 X 坐标 | | y | Integer | ✅ | 瓦片 Y 坐标 | **查询参数**: | 参数 | 类型 | 必填 | 默认值 | 说明 | |------|------|------|--------|------| | format | String | ❌ | `png` | 图片格式 | **请求示例**: ```bash curl "http://localhost:26889/geoair/gs84ToWm/china_map/10/256/128?format=png" ``` --- ### 5.3 预缓存 **接口描述**:对指定区域和层级进行瓦片预生成,异步执行 **请求方式**:`GET` **URL**:`/geoair/preCache` **请求参数**: | 参数 | 类型 | 必填 | 说明 | 示例 | |------|------|------|------|------| | layerName | String | ✅ | 图层名称 | `osm` | | wkt4326String | String | ✅ | WKT格式的地理范围(EPSG:4326) | `POLYGON((73.5 18.1, 135.1 18.1, 135.1 53.6, 73.5 53.6, 73.5 18.1))` | | minZoom | int | ✅ | 最小缩放层级 | `5` | | maxZoom | int | ✅ | 最大缩放层级 | `12` | **请求示例**: ```bash # 中国区域预缓存 curl "http://localhost:26889/geoair/preCache?layerName=osm&wkt4326String=POLYGON((73.5%2018.1,135.1%2018.1,135.1%2053.6,73.5%2053.6,73.5%2018.1))&minZoom=5&maxZoom=12" ``` **响应**: ```json "预缓存任务已提交,正在后台执行" ``` **注意事项**: - 大范围预缓存耗时较长,建议分批次执行 - 缓存文件保存在 `{GTC_CACHE_DIR}/gwc_fuser/tile_cache/` 目录 - 可通过日志查看缓存进度 --- ## 6. 使用示例 ### 6.1 前端调用示例 #### HTML + JavaScript ```html