meface/docs/article/gis/geoserver/createtitlecaching.md

81 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 生成瓦片数据(tile 缓存)
date: 2020-03-02
author: ac
tags:
- Tile cache
- GeoServer
categories:
- GIS
---
### 1 新建切图策略
![1615181978106](../images/geoserver/1615181978106.png)
创建时,选择数据的空间参考、切图范围、瓦片大小以及各个级别的比例尺和分辨率 。
> 注意:切图范围需要填写图层服务上的 Bounding Box
![1615182224816](../images/geoserver/1615182224816.png)
**nyc:测试北京18层**服务图层的边界如下:
![1615173829712](../images/geoserver/1615173829712.png)
### 2 添加到缓存配置
返回主页,点击【图层】,选择需要进行缓存的图层服务;
在"Tile Caching"tab页中增加刚刚新增切图策略。
![1615182749787](../images/geoserver/1615182749787.png)
![1615182975014](../images/geoserver/1615182975014.png)
> 这里可以选择Tile Image Formatsjpeg只有R,G,B三个通道但png有四个通道R,G,B,A)可以将切图空白部分渲染呈透明而jpeg不行。
### 3 创建缓存
`GeoServer` 创建缓存的方式有两种:
- 一种是当用户查看地图时创建浏览的地图范围及相应等级下的部分缓存,主要优点是,它不需要预处理,并且仅缓存已请求的数据,因此也可节省磁盘空间。该方法的缺点是地图查看只会间歇性地加速,从而降低了用户体验的质量;
- 另一种方式是通过 `Seed/Truncate `创建缺点是Seed可能是非常耗时和磁盘消耗的过程。
![1615183529095](../images/geoserver/1615183529095.png)
点击 `Seed/Truncate `进入`GeoWebCache`页面:
![1615183909611](../images/geoserver/1615183909611.png)
点击"Submit"提交切片任务:
![1615184398829](../images/geoserver/1615184398829.png)
当任务执行完后可以在数据目录的gwc目录下查看到已经切好的图。
![1615184495244](../images/geoserver/1615184495244.png)
![tilesetss](../images/geoserver/tilesetss.png)
### 4 图层预览
返回主页进入Tile Layers 页面选择Preview中的`beijing18/png`,进行预览。
![1615184939415](../images/geoserver/1615184939415.png)
> 出现一个问题就是开始图层名命名为中文名称结果前端请求瓦片的请求都是400的状态中文乱码问题所以请求失败。解决方法是将图层名换成英文。
![result](../images/geoserver/result.png)
### 参考文章
[1] Seeding and refreshing https://docs.geoserver.org/latest/en/user/geowebcache/seeding.html#generating-tiles