81 lines
2.5 KiB
Markdown
81 lines
2.5 KiB
Markdown
|
---
|
|||
|
title: 生成瓦片数据(tile 缓存)
|
|||
|
date: 2020-03-02
|
|||
|
author: ac
|
|||
|
tags:
|
|||
|
- Tile cache
|
|||
|
- GeoServer
|
|||
|
categories:
|
|||
|
- GIS
|
|||
|
---
|
|||
|
|
|||
|
### 1 新建切图策略
|
|||
|
|
|||
|

|
|||
|
|
|||
|
创建时,选择数据的空间参考、切图范围、瓦片大小以及各个级别的比例尺和分辨率 。
|
|||
|
|
|||
|
> 注意:切图范围需要填写图层服务上的 Bounding Box
|
|||
|
|
|||
|

|
|||
|
|
|||
|
**nyc:测试北京18层**服务图层的边界如下:
|
|||
|
|
|||
|

|
|||
|
|
|||
|
### 2 添加到缓存配置
|
|||
|
|
|||
|
返回主页,点击【图层】,选择需要进行缓存的图层服务;
|
|||
|
|
|||
|
在"Tile Caching"tab页中增加刚刚新增切图策略。
|
|||
|
|
|||
|

|
|||
|
|
|||
|

|
|||
|
|
|||
|
> 这里可以选择Tile Image Formats,jpeg只有(R,G,B)三个通道,但png有四个通道(R,G,B,A)可以将切图空白部分渲染呈透明,而jpeg不行。
|
|||
|
|
|||
|
### 3 创建缓存
|
|||
|
|
|||
|
`GeoServer` 创建缓存的方式有两种:
|
|||
|
|
|||
|
- 一种是当用户查看地图时创建浏览的地图范围及相应等级下的部分缓存,主要优点是,它不需要预处理,并且仅缓存已请求的数据,因此也可节省磁盘空间。该方法的缺点是地图查看只会间歇性地加速,从而降低了用户体验的质量;
|
|||
|
- 另一种方式是通过 `Seed/Truncate `创建,缺点是Seed可能是非常耗时和磁盘消耗的过程。
|
|||
|
|
|||
|

|
|||
|
|
|||
|
点击 `Seed/Truncate `进入`GeoWebCache`页面:
|
|||
|
|
|||
|

|
|||
|
|
|||
|
点击"Submit"提交切片任务:
|
|||
|
|
|||
|

|
|||
|
|
|||
|
当任务执行完后,可以在数据目录的gwc目录下查看到已经切好的图。
|
|||
|
|
|||
|

|
|||
|
|
|||
|
|
|||
|
|
|||
|

|
|||
|
|
|||
|
|
|||
|
|
|||
|
### 4 图层预览
|
|||
|
|
|||
|
返回主页,进入Tile Layers 页面,选择Preview中的`beijing18/png`,进行预览。
|
|||
|
|
|||
|

|
|||
|
|
|||
|
> 出现一个问题,就是开始图层名命名为中文名称,结果前端请求瓦片的请求都是400的状态,中文乱码问题,所以请求失败。解决方法是,将图层名换成英文。
|
|||
|
|
|||
|

|
|||
|
|
|||
|
|
|||
|
|
|||
|
### 参考文章
|
|||
|
|
|||
|
[1] Seeding and refreshing https://docs.geoserver.org/latest/en/user/geowebcache/seeding.html#generating-tiles
|
|||
|
|