GeoWebCache 1.15.2
GeoWebCache is a Java web application used to cache map tiles coming from a variety of sources such as OGC Web Map Server (WMS). It implements various service interfaces (such as WMS-C, WMTS, TMS, Google Maps KML, Virtual Earth) in order to accelerate and optimize map image delivery. It can also recombine tiles to work with regular WMS clients.
This User Manual is a guide to the most common aspects of GeoWebCache.
GeoWebCache只是拦截并缓存切片,自己并不能生成切片吧?那切片是谁生成的?
- Introduction(简介)
- What Is GeoWebCache?(GeoWebCache是什么?)
- Architecture(架构)
- Community(社区)
- Standalone vs. GeoServer-integrated(单独安装vsGeoServer集成)
- Installation(安装)
- Installing Java and Tomcat(安装Java和Tomcat)
- Installing GeoWebCache(安装GeoWebCache)
- Upgrading from a pre 1.15 release(从1.15前的版本升级)
- Upgrading from a pre 1.4 release(从1.4版本前升级)
- View preconfigured layers查看预配置的图层
- View layers from a WMS查看WMS的图层
- Special cases特殊例子
- Additional information额外信息
- Concepts(概念)
- Tiles(切片)
- Gridsets and Gridsubsets(格网集和格网子集)
- Metatiles(元切片)
- Storage components(存储组件)
- Operations(操作)
- Configuration配置)
- Configuring Layers配置图层
- Security安全
- Storage存储
- Enabling/Disabling Services开启/禁止服务
- Disk Quotas硬盘Quotas
- Reloading Configuration重新加载配置
- Web Interface网页UI
- Status Page状态页
- Demo PageDemo页
- Seed PagesSeed页
- Services服务
- WMS - Web Map ServiceWMS-网络地图服务
- WMS-C - WMS Tiling ClientsWMS-C-切片客户端
- WMTS - Web Map Tiling ServiceWMTS-网络地图切片服务
- TMS - Tile Map ServiceTMS切图服务
- KMLKML
- Google Maps谷歌地图
- Bing Maps必应地图
- Mobile GMaps移动G地图
- Special HTTP Response Headers特殊的HTTP响应头
- REST APIREST接口
- Managing Global Server Configuration through the REST API通过REST API管理全局服务器配置
- Managing Layers through the REST API通过REST API管理图层
- Managing GridSets through the REST API通过REST API管理GridSets
- Managing BlobStores through the REST API通过REST API管理BlobStores
- Seeding and truncating through the REST API通过REST API进行seed和truncate
- Querying the running tasks查询运行的任务
- Terminating running tasks终止运行的任务
- Disk Quota REST API硬盘查询REST API
- Mass Truncation批量Truncation
- In Memory Cache Statistics在内存中的缓存的统计
- Formats and representations格式和展示
- Authentication认证
- Status codes状态码
- Production生产
- Operating Environment运行环境
- Hardware considerations硬件考量
- Operating system settings运行系统设置
- Seeding and Truncating the Cache缓存的播种与裁切
- Resource Allocation资源配置
- Clustering聚类
- Troubleshooting故障处理
- Configuration problems配置问题
- Incorrect or broken tiles不正确或有损的切片
- Logging日志
- XStreamX流
- Getting help获取帮助
- Development二次开发
- Setting Up设置
- Setting up Eclipse设置Eclipse
- Contributing patches贡献补丁
- Frequently Asked Questions经常被问到的问题
GeoWebCache缓存优化:https://www.cnblogs.com/naaoveGIS/p/4195008.html
一、
Introduction简介
This section introduces GeoWebCache, what it is, how it works, and its community of users.
本部分介绍GeoWebCache,它是什么,它是如何工作的,以及它的用户社区。
- What Is GeoWebCache?GeoWebCache是什么?
- Architecture架构
- Overview简介
- Request Processing请求过程
- Community社区
- Homepage主页
- Mailing Lists邮件列表
- IRCIRC
- Source Code源码
- Issue tracking问题追踪
- License许可证
- Standalone vs. GeoServer-integrated单独vsGeoserver集成的
- Which GeoWebCache should you use?你应该选择哪个GeoWebCache?
二、
Installation安装
This section describes how to install GeoWebCache on the most common platforms. GeoWebCache will work on any operating system that supports Java 1.5, including FreeBSD and Solaris.
本部分描述了如何安装GeoWebCache在绝大多数平台。GeoWebCache将运行在任何支持Java1.5的操作系统之上。包括FreeBSD和Solaris。
The following software will need to be set up prior to installing GeoWebCache:
以下的软件需要提前安装:
Java Runtime Environment (JRE) (version 1.5 or greater, preferably from Oracle)
Java Servlet Container (such as Apache Tomcat)
In essence, GeoWebCache is a set of Java classes (program files) and a number of configuration files. The combination is known as a Java Servlet, and these are commonly distributed in a zip file known as a Web ARchive, or WAR file for short.
实际上,geowebache是一组Java类(程序文件)和一些配置文件。这种组合称为javaservlet,它们通常分布在一个zip文件中,称为webarchive,简称WAR文件。
To use its content, we need a Java Virtual Machine and a Servlet Container. The latter is a network service that accepts requests from clients, such as web browsers, and delegates them to the appropriate servlet.
为了使用它的内容,我们需要一个Java虚拟机和一个Servlet容器。后者是一种网络服务,它接受来自客户端(如web浏览器)的请求,并将它们委托给适当的servlet。
- Installing Java and Tomcat安装Java和Tomcat
- Installing GeoWebCache安装GeoWebCache
Once the Java Servlet environment is in place, installing GeoWebCache is simple.
一旦Java Servlet环境搭好了,那么安装GeoWebCache是很简单的。
The latest Web ARchive (WAR) file can be downloaded from geowebcache.org.
最新的Web ARchive(WAR)文件可以从geowebcache.org下载。
Unpack the zip file and make sure to read the software License.
解压zip文件,并确保阅读过软件许可。
-
- Option 1: Tomcat Administration Tool选项1:Tomcat管理员工具
(1)Navigate to http://localhost:8080 (or wherever your Tomcat instance resides) and click the Tomcat Manager on the left hand side.
(2)Find the section WAR file to deploy, and upload geowebcache.war
you unpacked from the zip file.
(3)After the upload is complete, look for geowebcache in the Applications table.
(4)GeoWebCache should be installed at http://localhost:8080/geowebcache
.
-
- Option 2: Manual Installation选项2:人工安装
- Upgrading from a pre 1.15 release从1.15前的版本升级
- Upgrading from a pre 1.4 release从1.4版本前升级
三、
Quickstart快速上手
This section describes how to get quickly started with GeoWebCache without knowing much about the Configuration.
本部分描述了如何快速上手GeoWebCache,而无需知道太多配置方面。
All servers conforming to the OGC Web Map Service specification publish what is known as a capabilities document (sometimes also known as a GetCapabilities document after the request used to fetch it). This is an XML file that describes the layers exposed by the WMS service and available to the user. GeoWebCache can use this information to configure itself automatically.
所有符合OGC Web Map服务规范的服务器都会发布称为capabilities文档的内容(有时以在用于获取它的请求之后命名也称为GetCapabilities文档)。这是一个XML文件,它描述了WMS服务公开并可供用户使用的图层。GeoWebCache可以使用此信息自动配置自身。
View preconfigured layers查看预先配置的图层
GeoWebCache comes preconfigured with three layers. To view them, navigate to your GeoWebCache demo page at http://GEOWEBCACHE_URL/demo
(often this is http://localhost:8080/geowebcache/demo
). Click on any of the links next to the OpenLayers column.
GeoWebCache预配置了3个图层。要查看它们,导航到你的GeoWebCache代码页:http://geowebcache_url/demo(通常来说是http://localhost:8080/geowebcache/demo)。点击靠近OpenLayer一列的任一链接。
These layers are all served by the WMS available at http://demo.opengeo.org/geoserver/
.
这些图层都是由WMS提供服务的:http://demo.opengeo.org/geoserver/。
Layer Name (Title) |
WMS layer(s) |
---|---|
img states |
nurc:Img_Sample,topp:states |
raster test layer |
nurc:Img_Sample |
topp:states |
topp:states |
Note注意
This information is set in the geowebcache.xml
file, which is typically available at opt/apache-tomcat-6.0.29/webapps/geowebcache/WEB-INF/classes
or C:\Program Files\Apache Software Foundation\Tomcat 6.0.29\webapps\geowebcache\WEB-INF\classes
. See the section on Configuring Layers for more information on customizing this file.
该信息是在geowebcache.xml文件中设置的,它通常是在opt/apache-tomcat-6.029/webapps/geowebcache/WEB-INF/classes或者C:\Program Files\Apache Software Foundation\Tomcat 6.0.29\webapps\geowebcache\WEB-INF\classes。查看Configuring Layers更多配置该文件的信息。
View layers from a WMS查看来自WMS的图层
The file geowebcache-core-context.xml
is a configuration file controling how the application is loaded. It is located inside the WEB-INF folder, typically /opt/apache-tomcat-6.0.29/webapps/geowebcache/WEB-INF/
or C:\Program Files\Apache Software Foundation\Tomcat 6.0.29\webapps\geowebcache\WEB-INF
along with several other configuration files.
文件geowebcache-core-context.xml是一个配置文件,控制程序如何加载的。它位于WEB-INF文件夹中,通常位于/opt/apache-tomcat-6.0.29/webapps/geowebcache/WEB-INF/或者C:\Program Files\Apache Software Foundation\Tomcat 6.0.29\webapps\geowebcache\WEB-INF。跟它在同一目录的还有其它配置文件。
-
Open
geowebcache-core-context.xml
in a text editor.在文本编辑器中打开geowebcache-core-context.xml -
Find the block beginning with:你会发现该文件以以下开头:
<bean id="gwcWMSConfig" class="org.geowebcache.config.wms.GetCapabilitiesConfiguration">
On the second line you will see a value that contains a URL:在第二行你会看到一个值包含URL:
<constructor-arg value="http://localhost:8282/geoserver/wms?request=getcapabilities&version=1.1.0&service=wms" />
-
Replace the value with a URL pointing to a valid WMS capabilities document, such as:替换该值以一个URL指向一个有效的WMS capabilities文件,例如:
<constructor-arg value="http://demo.opengeo.org/geoserver/ows?service=WMS&request=GetCapabilities&version=1.1.0" />
Warning
The ampersand sign,
&
has to be written out as&
in XML files. Also, make sure to omit the line breaks. -
Save the file and reload the servlet using Tomcat’s Manager, or by restarting the servlet container.
-
Navigate to or reload your GeoWebCache demo page. You should see the list of layers as advertised in the WMS capabilities document.
Special cases特殊例子
Below are some extra parameters that may be needed or that you may want to add to get your WMS layers loading properly in GeoWebCache.
以下是一些可能需要的额外的参数,或者你可能想要添加到你的文件中从而让你的WMS图层合理的加载到GeoWebCache中。
Map vendor parameters映射供应商参数
If your WMS server requires additional vendor parameters to be passed with every request, such as MapServer’s map
argument, set this in the fifth constructor-arg
value.
如果你的WMS服务器需要额外的供应参数,每次请求都要带上,例如MapServer的map参数,设置它为第五个constructor-arg值。
Replace:
<constructor-arg value=""/>
with:
<constructor-arg value="map=name&otherkey=othervalue"/>
Cached vendor parameters缓存的供应商参数
By default vendor parameters included in requests are ignored. To pass on the value of a vendor parameter to your wms server, and cache the result seperately depending on the given value, set the sixth constructor-arg
value.
默认情况下,包含在请求中的供应参数是被忽略的。要传递供应参数到你的wms服务器,并且根据给定的值分开单独缓存结果,设置第六个constructor-arg值。
For each cached vender parameter add a line between the <map> tags of the form:
对于每一个缓存的供应参数,添加一行在<map>标签中:
<entry key="parameterName" value="defaultvalue" />
Other image formats其它的图片格式
To get 24 bit PNGs from MapServer or ArcIMS (image/png; mode=24bit
and image/png24
respectively), or any other image format, you will need to specify those as output formats. This is set in the fourth constructor-arg
value. Replace:
要从MapServer或者ArcIMS(image/png;mode=24bit和image/png24分别)获取24位的PNG,或者是其他图片格式,你将需要指定这些为输出格式。这个设置是在第四个constructor-arg值。取代:
<constructor-arg value="image/png,image/jpeg"/>
with为:
<constructor-arg value="image/png; mode=24bit,image/png24,image/jpeg"/>
Other MIME types can be specified here as well.
其他的MIME类型也可以在这里指定。
Metatile factor元切片因子
The metatiling factor can be modified by editing the third constructor-arg
value. This will affect all layers derived from this document. See the Metatiles section for more information.
元切片因子可以通过编辑第三个constructor-arg值来进行修改。这将影响所有的图层。查看元切片一节获取更多信息。
Multiple capabilities documents多capabilities文档
GeoWebCache can be configured from multiple capabilities documents. To do this, you can duplicate the gwcWMSConfig
bean with a new id: gwcWMSConfig2
for instance.
GeoWebCache可以通过多capabilities文档来进行配置。要做到这一点,你可以用一个新的id:gwcWMSConfig2来复制gwcWMSConfig bean。
Additional information额外的信息
All layers known to GeoWebCache should be available on the demo page, along with automatically configured OpenLayers clients. The KML demos use the same sets of tiles as the OpenLayers EPSG:4326 demo.
GeoWebCache已知的所有层都应该在演示页面上提供,以及自动配置的OpenLayers客户端。KML演示使用与OpenLayers EPSG:4326演示相同的瓷砖集。
According to the WMS standard, the capabilities document is only guaranteed to contain the WGS84 (lat/lon) bounds for a layer, hence EPSG:4326, though in rare cases the WMS server will not be able to provide responses for this projection. If the capabilities document contains bounding boxes for additional projections, often the native reference system for the data, then these will be included as well. Finally, GeoWebCache will convert the EPSG:4326 bounding box to spherical mercator (EPSG:900913, now officially known as EPSG:3857). That said, the WMS server isn’t guaranteed to be able to provide a successful response to these requests.
根据WMS标准,能力文档只保证包含一个层的WGS84(lat/lon)界限,因此EPSG:4326,尽管在极少数情况下WMS服务器将无法对此投影提供响应。如果capabilities文档包含附加投影的边界框,通常是数据的本机参考系统,那么这些也将包括在内。最后,GeoWebCache将EPSG:4326边界框转换为球形墨卡托(EPSG:900913,现在正式称为EPSG:3857)。也就是说,WMS服务器不能保证能够成功响应这些请求。
If you need to support other projections, you can do so by defining grid sets manually and adding them to these layers. The same is true for supporting specific resolutions, output formats or tile sizes. See the Configuration section for more information.
如果需要支持其他投影,可以通过手动定义栅格集并将其添加到这些图层来实现。对于支持特定分辨率、输出格式或平铺大小也是如此。有关更多信息,请参阅配置部分。
四、
Concepts概念
This section explains some general concepts used when tiling, as well as special idioms used in GeoWebCache.
本部分解释了一些切图时基本的概念。还有一些GeoWebCache中使用的特殊俗语。
- Tiles切片
GeoWebCache caches images retrieved from a WMS. The smallest unit of image cached is known as a tile. All tiles are assumed to be the same dimensions and are typically square (i.e. 256 pixels by 256 pixels).
GeoWebCache缓存来自WMS的图片。缓存的图片的最小单元叫做切片。所有的切片理论上是相同的维度,并且通常是正方形(例如,256像素×256像素)
It is important to note that GeoWebCache’s tile cache is spatially agnostic. The tiles are stored in a rectangular grid, indexed by (x,y) coordinates. A z coordinate (zero-indexed) is used to denote the zoom level, resulting in each tile being indexed as a triplet (x,y,z).
需要注意到GeoWebCache的切片缓存是空间不可知的。这些切片存储在正方形的格子里,以(x,y)坐标索引。z坐标(索引为0)用来表示缩放水平,结果就是每一个瓦片都可以按照三维(x,y,z)来进行索引。
-
- Tile pyramid切片金字塔
As saved by GeoWebCache, the tile system is “pyramidal”, meaning that increasing zoom levels have a larger amount of tiles. By default, and by far the most common case, for increasing values of z, the amount of tiles in that zoom level is four times the amount of the previous zoom level:
正如GeoWebCache保存的那样,切片系统是“金字塔型”的,这意味着增加缩放级别会产生更多的切片。默认情况下,也是到目前为止最常见的情况,对于z值的增加,该缩放级别中的平铺量是上一缩放级别的四倍:
[number of tiles in zoom level z] = 4 * [number of tiles in zoom level (z-1)]
When applied to square map projections where zoom level z = 0, the number of tiles would result in a single tile (such as the Google projection EPSG:900913 / EPSG:3857):
当应用于缩放级别z=0的方形地图投影时,平铺的数量将产生一个切片(例如Google projection EPSG:900913/EPSG:3857):
[number of tiles in zoom level z] = 4^z
When applied to rectangular map projections where zoom level z=0, the number of tiles would result in two tiles (such as EPSG:4326 / lat/lon):
当应用于缩放级别z=0的矩形地图投影时,平铺的数量将产生两个切片(例如EPSG:4326/lat/lon):
[number of tiles in zoom level z] = 2 * 4^z
- Gridsets and Gridsubsets格网集合和格网子集
Gridsets and gridsubsets refer to the spatial reference system of the layers served by GeoWebCache. By nature and as introduced in the Tiles, GeoWebCache is agnostic to reference-systems. When GeoWebCache makes a request to a WMS, it uses the gridset and gridsubset information to convert its internal tile index to a spatial request that the WMS will understand.
格网集合和格网子集指的是GeoWebCache所服务的图层的空间参考系统。本质上,正如切片所介绍的,GeoWebCache对于参考系统是不可知的。当GeoWebCache向一个WMS发送请求时,它使用格网集合和格网子集信息来转换它的内部切片索引到WMS所能理解的空间请求。
A gridset is a global definition (i.e. not layer-specific) specifying:
格网集合是一个全局的定义(例如,非特定图层的)指定:
A spatial reference system (EPSG code)空间参考系统(EPSG码)
A bounding box describing the extent, typically the maximum extent for the above reference system边界框,描述范围,通常是上述参考系统的最大范围
One of either a list of scale denominators, resolutions, or zoom levels缩放分母、分辨率或缩放级别列表之一
The tile dimensions in pixels (constant for all zoom levels)切片像素维度(对于所有的缩放等级为常量)
(Optional) Pixel size (to calculate scales). The default is 0.28mm/pixel, corresponding to 90.71428571428572 DPI.(可选)像素尺寸(用来计算比例尺)。默认是0.28mm/像素,等于90.71428571428572 DPI。
A gridsubset is a layer-specific definition specifying:
格网子集是一个指定图层的定义,指的是:
The gridset for the layer该图层的格网集合。
(Optional) The bounding box for that layer (which must be a subset of the extent of the gridSet)(可选)该图层的边界框(它必须是格网集合范围的子集)
(Optional) A list of zoom levels (which must be a subset of what is defined in the gridSet)(可选)缩放等级列表(它必须是定义在格网集合的子集)
By default, this information is set in geowebcache.xml
.
默认情况下,该信息是在geowebcache.xml中定义的。
-
- From gridsets to tiles从格网集合到切片
Below there is the description for every zoom level of the interpretation process of the gridset and gridsubset at a particular zoom level and determining which tiles are being requested.

Initial bounding box - Assume the gridset bounding box is (-10.0,-30.0,85.0,21.0) and that the resolution for the zoom level is set to 11.25 degrees / 256 pixels = 0.04395 (Scale 1:1.8e7)

Gridset aligned bottom-left to the bounding box - The specified bounding box does not correspond to an integer number of tiles, so GeoWebCache expands the bounding box to (-10.0,-30.0,91.25,26.25).

Gridset aligned to the top-left of the bounding box - The default is to align the bounding box to the bottom left. This is assumed by tiling WMS clients and TMS. However, for WMTS it makes more sense to align to the top left corner. If <alignTopLeft>
is set to true, GeoWebCache will expand toward the bottom instead. In this case the bounding box becomes (-10.0,-36.75,91.25,21.0).

Gridsubset bounding box - Since a particular layer may not cover the entire gridset, GeoWebCache uses a gridsubset, which can specify only a portion of the gridset. If no extent is specified, it is assumed that the layer covers the entire gridset. This example uses the gridsubset extent of (-14.0,-15.0,48.0,16.0).

Gridsubset tiles - GeoWebCache will round up the extents to the nearest tile boundaries.
- Metatiles元切片
- What’s a metatile?元切片是什么?
- Why use metatiles?为什么使用元切片?
- Why not use metatiles?为什么不使用元切片?
- Preventing double-metatiling防止双-元切片?
- Configuring Metatiling配置元切片
- Storage components存储组件
- Operations操作
- Seeding播种
- Reseeding重复播种
- Truncating裁切
五、
Configuration配置
This section describes the several configuration options available in GeoWebCache.
本部分描述了几个GeoWebCache中可以使用的配置选项。
For information on graphical configuration options, please see the section on the Web Interface.
对于地理配置选项信息,请参考网络接口部分。
Note:注意:
After making any changes to the configuration, make sure to reload the configuration.
在对配置做出任何修改后,请一定要重新加载配置。
- Configuring Layers
- How to configure layers
- Custom projections
- Palettes
- Parameter Filters
- Styles Legends
- Request Filter
- Serving Layers From Pre-Cached ArcGIS Tiling Schemes
- Using a Static Capabilities Document
- Expiring tiles with GeoRSS
- Tile expiration
- Gridsets and Gridsubsets
- Selective zoom level caching
- WMS request modes
- Examples
- Security
- Storage
- Enabling/Disabling Services
- Disk Quotas
- Reloading Configuration
六、
Web Interface网络接口
GeoWebCache has a minimal web interface. While not fully featured, it allows the user to perform common tasks, such as: listing and viewing layers; reloading configuration; starting seeding tasks and viewing server statistics.
GeoWebCache有一个小网络接口。虽然没有全部的功能,但是它允许用户执行某些任务,例如:列出和查看图层;重加载配置;开始播种任务和查看服务器状态。
七、
Services服务
Below is a list of the standard services distributed with GeoWebCache. Being modular, it is usually easy to add new services. The file geowebcache-servlet.xml can be edited to disable certain services.
下面是一系列GeoWebCache分发的标准服务。由于是模块化的,添加新服务通常很容易。可以编辑geowebcache-servlet.xml文件以禁用某些服务。
- WMS - Web Map Service
- WMS-C - WMS Tiling Clients
- WMTS - Web Map Tiling Service
- TMS - Tile Map Service
- KML
- Google Maps
- Bing Maps
- Mobile GMaps
- Special HTTP Response Headers
八、
REST API
This section will discuss the GeoWebCache REST API.
- Managing Global Server Configuration through the REST API
- Managing Layers through the REST API
- Managing GridSets through the REST API
- Managing BlobStores through the REST API
- Seeding and truncating through the REST API
- Querying the running tasks
- Terminating running tasks
- Disk Quota REST API
- Mass Truncation
- In Memory Cache Statistics
Formats and representations
A format
specifies how a resource should be represented. A format is used:
-
In an operation to specify what representation should be returned to the client
-
In a POST or PUT operation to specify the representation being sent to the server
In a GET operation the format can be specified in a number of ways. The first is with the Accepts
header. For instance setting the header to “text/xml” would specify the desire to have the resource returned as XML. The second method of specifying the format is via file extension. For example consider the resource “foo”. To request a representation of foo as XML the request uri would end with “foo.xml”. To request as JSON the request uri would end with “foo.json”. When no format is specified the server will use its own internal format, usually html.
In a POST or PUT operation the format specifies 1) the representatin of the content being sent to the server, and 2) the representation of the resposne to be sent back. The former is specified with the Content-type
header. To send a representation in XML, the content type “text/xml” or “application/xml” would be used. The latter is specified with the Accepts
header as specified in the above paragraph describing a GET operation.
The following table defines the Content-type
values for each format:
Format |
Content-type |
---|---|
XML |
text/xml |
JSON |
application/json |
HTML |
application/html |
Authentication
POST, PUT, and DELETE requests (requests that modify resources) require the client to be authenticated. Currently the only supported method of authentication is Basic authentication.
Status codes
A Http request uses a status code
to relay the outcome of the request to the client. Different status codes are used for various purposes through out this document. These codes are described in detail by the http specification.
九、
Production生产
This section is a work in progress, and will eventually be extended to cover topics such as:
-
Service architecture
-
Apache Portable Runtime
-
Java Advanced Imaging / ImageIO
-
External tools for optimizing tiles
-
Profiling
-
Links for tips on improving WMS performance
Operating Environment
Java Settings
GeoWebCache speed depends in part on the chosen Java Runtime Environment (JRE). For best performance use a Java 6 JRE. If not possible, use a Java 5 JRE. JREs other than those released by Sun may work correctly, but are not tested nor supported.
GeoWebCache does not need a lot of heap memory assigned to the JVM. Usually 512M is just fine if its the only web application running on the servlet container.
Servlet container settings
Depending on the power of your hardware setup and your expected user load, consider increasing the number of concurrent connections the servlet container is allowed to handle. For a high end set up you can even set it to 2000. In Tomcat, that’s performed by modifying the maxThreads attribute for the tomcatThreadPool Executor in server.xml.
Hardware considerations
Having substantial (spare) RAM is of great help. Not for the JVM Heap, but for the Operating System’s disk block cache.
Regular SATA drives or RAID arrays work fine, if you use NAS or SAN then things become a bit more tricky. Often these devices have a ton of overhead due to capabilities like deduplication, shared locks and so forth, and sometimes they kill the disk block cache altogether.
Keeping an eye on the hard-drive access LED indicators might be a good idea (if you are not using SSDs), but also the IO Wait percentange in utilities like top might help diagnose I/O bottlenecks.
Operating system settings
Open Files
GeoWebCache will probably open lots of files from the file system the cache is stored on, depending on the request load, though through short periods of time, as it opens the tile files to deliver their contents to the client. Therefore it is recommended that you set your Operating System settings to allow for at least 4 times as much open files the number of maximum concurrent connections configured in your servlet container.
File System Performance
Storing tiles on a NFS mount point is known to be slow. Ext3, Ext4 and XFS are known to perform well. btrfs should be ok too, as well as ZFS, though we didn’t actually test on them. Depending on the average tile size, a too small block size may lead to too much fragmentation, and a too big block size to too much wasted storage space.
If possible, turn off File System’s last access time (atime) as it avoids writing to the File System for every tile read (check Criticism of atime ).
File System Block Size
Since the Tile Cache stores thousands or even millions of files, the File System block size is of great importance for optimizing the actually used storage space for the cache. If that could be an issue, consider tuning your File System block size. Modern file systems usually have a default block size of 16K, which should be fine for most situations. If your average tile is a small 8-bit png you may want to use a 8K block size. If its a large JPEG you may want to increase the block size to 64K.
If the block size is too large, it’s more likely that more disk space is gonna be wasted (since a tile file will use an integral number of blocks on disk, as for any file in your file system). If the block size is too small, performance will probably degrade as more I/O operations will be needed to read a single file.
Seeding and Truncating the Cache
From the page that lists the demos there is a link for seeding each layer. This page presents a form with the seed/truncate options for the layer, as well as a summary of all the running tasks, if any. The following options can be set to submit a seed task:
-
Number of threads to use
-
Type of operation (seed|re-seed|truncate)
-
Grid Set
-
Image format
-
Start and stop zoom levels
-
Modifiable parameters (for any configured parameter filter)
-
Bounding box
Seeding and truncating with parameter filters is supported since version 1.2.5. If a layer is configured with parameter filters a dynamically generated input will be presented for each parameter filter, with the parameter filter’s default value. Every combination of different parameter filter values will generage a different tile set.
Seed Failure Tolerance
As of version 1.2.5, it is possible to control how GWC behaves in the event that a backend (WMS for example) request fails during seeding, by using the following environment variables:
-
GWC_SEED_RETRY_COUNT
: specifies how many times to retry a failed request for each tile being seeded. Use0
for no retries, or any higher number. Defaults to0
, meaning no retries are performed. It also means that the defaults to the other two variables do not apply at least you specify a higher value forGWC_SEED_RETRY_COUNT
. -
GWC_SEED_RETRY_WAIT
: specifies how much to wait before each retry upon a failure to seed a tile, in milliseconds. Defaults to100ms
-
GWC_SEED_ABORT_LIMIT
: specifies the aggregated number of failures that a group of seeding threads should reach before aborting the seeding operation as a whole. This value is shared by all the threads launched as a single thread group; so if the value is10
and you launch a seed task with four threads, when10
failures are reached by all or any of those four threads the four threads will abort the seeding task. The default is1000
.
These environment variables can be established by any of the following ways, in order of precedence:
-
As a Java environment variable: for example java -DGWC_SEED_RETRY_COUNT=5 …
-
As a Servlet context parameter in the web application’s
WEB-INF/web.xml
configuration file. for example:
<context-param>
<!-- milliseconds between each retry upon a backend request failure -->
<param-name>GWC_SEED_RETRY_WAIT</param-name>
<param-value>500</param-value>
</context-param>
-
As a System environment variable: export GWC_SEED_ABORT_LIMIT=2000; <your usual command to run GWC here> (or for Tomcat, use the Tomcat’s CATALINA_OPTS in Tomcat’s bin/catalina.sh as this: CATALINA_OPTS=”GWC_SEED_ABORT_LIMIT=2000 GWC_SEED_RETRY_COUNT=2
Resource Allocation
Also see http://geowebcache.org/trac/wiki/resources for tools that can be used to estimate how much storage you need and how long seeding will take
Clustering
GeoWebCache is quite an efficient piece of software, as such it normally does not need clustering for performance reasons (GeoWebCache running on an old notebook with a seeded tile can literally flood a gigabit line), but it may still make sense to cluster GeoWebCache for high availability reasons.
Before the GeoWebCache 1.4.x clustering GeoWebCache instances required: * turning off the disk quota subsystem * turning off the metastore subsystem * setting up clustering in active/passing mode
Starting with 1.4.0 the metastore subsystem has been removed and replaced with full on disk metadata, which makes it possible to keep on using tile expiration and layer parameters even with clustering active, and the disk quota subsystem allows connection to a central database. Moreover, the tile creation workflow has been modified to allow for an active/active setup, meaning several GWC instances can now share the same cache directory without risks of file corruption or incomplete tiles being served back to clients.
Each GWC internally synchs to avoid two requests end up working on the same meta tile, but by default separate GWC instances do not and will end up wasting time. In case you want to make sure two separate instances do not end up working on the same metatile you have two options:
make it unlikely for two instances to work on the same metatile by using sticky sessions in the load balancer (very often requests for the tiles making up a metatile originate from the same client)
switch to file based locking so that the GWC instances properly synch up activity
In order to activate file based locking you will have to chage the geowebcache.xml configuration and activate the “NIO locks” as follows:
..
<backendTimeout>120</backendTimeout>
<lockProvider>nioLock</lockProvider>
<serviceInformation>
<title>GeoWebCache</title>
...
A new lockfiles
directory will be created in the cache directory where all GeoWebCache instances will create the lock files for the time it takes to request and write out a metatile (a separate file will be used for each metatile).
When setting up active/active clustering the disk quota subsystem will have to be configured in order to use an external JDBC database so that all nodes share the same disk quota metadata.
十、
Troubleshooting故障问题
This section describes some common problems encountered when running GeoWebCache.
Configuration problems
Configuring OpenLayers with GeoWebCache can be complicated because the grid alignment can be determined from a large number of sources. Note that the “base layer” has a special meaning in these applications; certain options pertain to all layers added to the client. The best advice is therefore to look closely at the source code of the automatically generated demos (available at http://<GEOWEBCACHE_URL>/demo/
), and customize them to your needs.
If you receive a “broken tile”, you can use a tool like Firebug to examine the response or attempt to view it as a separate page. Often these tiles are really plain text and contain an error message. For instance, you may be told that the resolution does not match one that is available, or that the grid is misaligned.
Errors caused by incorrectly configured clients are usually not logged on the server, because a incorrectly configured client could easily fill up the logs.
If you have a problem with scales, it can be due to the fact that OpenLayers by default assumes 72 DPI, whereas OGC standards such as WMS 1.3.0 assume 0.28mm per pixel (90.72 DPI). To workaround this, you can change the value <pixelSize>
. The value is simply expressed in meters per pixel, i.e. 0.0254 / DPI.
Incorrect or broken tiles
GeoWebCache does not track configuration changes internally. So if you reconfigure GeoWebCache, but old tiles overlap with the new layer, you will usually get the old tiles. One of the most common issues is caused by changing the gridset extent or adding a new, intermediary resolution or scale. This means that the X,Y,Z indexes used to store tiles no longer refer to the same thing as before.
In this case you should stop the servlet container and wipe the appropriate cache directories. See the Storage for more details.
Note that you can safely modify gridsubsets, but the gridset should always be the full extent for the projection.
Logging
Logging can be controlled through WEB-INF/classes/log4j.properties
. By default, log messages will end up in the standard log of the container, which is for Apache Tomcat is inside the logs
directory.
XStream
GeoWebCache uses XStream to read and write XML for configuration and for its REST API. In order to do this securely, it needs a list of Java classes that are safe to convert between objects and XML. If a class not on that list is given to XStream, it will generate the error com.thoughtworks.xstream.security.ForbiddenClassException
. The specific class that was a problem should aslo be included. This may be a result of GeoWebCache’s list of allowed classes missing a class, which should be reported as a bug, or it may be caused by an extension/plugin not adding its classes to the list.
This can be worked arround by setting the system property GEOWEBCACHE_XSTREAM_WHITELIST
to a semicolon separated list of qualified class names. The class names may include wildcards ?
for a single character, *
for any number of characters not including the separater .
, and **
for any number of characters including separators. For instance, org.example.blah.SomeClass; com.demonstration.*; ca.test.**
will allow, the specific class org.example.blah.SomeClass
, any class immediately within the package com.demonstration
, and any class within the package ca.test
or any of its descendant packages.
GEOWEBCACHE_XSTREAM_WHITELIST
should only be used as a workarround until GWC or the extension causing the problem has been updated.
Getting help
Help is readily available on the GeoWebCache Users mailing list. Please subscribe before posting, and include any configuration files you may have modified.
Learn more about the GeoWebCache Community.
十一、
Development二次开发
You are encouraged to help contribute code to GeoWebCache. To do so, you will first need to set up the proper development environment.
This is the current prerequisites:
Java 7 (Oracle JDK or OpenJDK )
Please make sure you use Java 7 to compile to ensure that we don’t accidentally use new features only available in Java 8.
You are encouraged to join the GeoWebCache Developers mailing list to discuss your work. It is always a good idea to ask whether anyone else has already solved the same problem.
Setting Up
-
The Maven build system respects the current setting of JAVA_HOME.
To define JAVA_HOME be sure to point to the root directory of your JDK.
Windows:
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_79
Linux/OS X:
export JAVA_HOME=/opt/jdk1.7.0_79
-
You can download maven from http://maven.apache.org/download.html, unpack and include the
bin
directory in your PATH variable.Windows:
set M2_HOME = C:\java\apache-maven-3.0.5 set PATH=%PATH%;%M2_HOME%\bin;%JAVA_HOME%\bin
Linux:
export M2_HOME = ~/java/apache-maven-3.0.5 export PATH=$PATH:$M2_HOME/bin:$JAVA_HOME/bin
For more detail instructions on maven see the download page.
-
Test that Maven is installed correctly:
mvn -version
-
Check that you are using the right version of the
javac
compiler (as this is determined byPATH
, notJAVA_HOME
):javac -version
Build
-
Check out the code:
mkdir gwc cd gwc git clone https://github.com/GeoWebCache/geowebcache.git
-
To build the code, enter the
geowebcache
directory and run:cd geowebcache mvn clean install
-
To quickly run a local GeoWebCache for testing:
cd web mvn jetty:run
-
A WAR is built as the last step in
mvn clean install
above.It is located in
geowebcache/web/target/geowebcache.war
Setting up Eclipse
-
Inside the source code directory, run:
cd geowebcache mvn eclipse:eclipse
This generates the
.project
and.classpath
files used to define an Eclipse project. -
Create a new workspace in Eclipse
-
Configure the Maven repository
-
Navigate to
-
Add a new variable M2_REPO, and set the path to
.m2/repository
in your home directory as shown below:System
PATH
Windows
C:\Users\You\.m2\repository
Linux or Mac
~/.m2/repository
-
-
Next we will configure Eclipse for working on GeoWebCache files.
-
Navigate to to
-
Click on Import, choose
geowebcache/tools/formatter.xml
-
-
There is also a
geowebcache/tools/codetemplates.xml
to assist with creating new files. -
Now we need to import the actual project:
-
Open the appropriate wizard menuselection:File –> Import –> Existing Projects into Workspace
-
Choose your
geowebcache
folder
This step depends on the
.project
and.classpath
files generated bymvn eclipse:eclipse
above. -
-
To run GeoWebCache use the main menu
-
Set Name: GWC
-
The Project: geowebcache
-
For main class, set Start
Then press Close, or Debug if you want to try it right away.
-
Contributing patches
The preferred way of providing patches is to create an issue in GitHub, develop the patch, and then make a GitHub Pull Request referencing the ticket. If appropriate please backport fixes to the Stable and Maintenance branches. New features may be backported if they have been on Master for a month without issue and if they are backward compatible for users and down stream developers.
In addition to creating the issue ticket, you are highly encouraged to bring it up on the GeoWebCache Developers mailing list first. Other developers or users may have considered the problem before or have other useful input.
Please include unit tests for any patches that change behaviour: For a bug fix, include tests to confirm the bug is fixed, for a new feature include tests to check that the feature works. Please also include the copyright header for the LGPL 3.0 in any new source files.
Please squash your working commits before creating a pull request. The commits in a pull request should represent clear semantic parts of the patch, not the work history. Added extension point -> New module implementing extension point -> Added documentation for new module is a good break down while Did some work -> Work from tuesday -> Stuff I forgot is not.
Avoid non-semantic whitespace and formatting changes as this makes your intent less clear and makes it harder to understand the change history. If you do clean things up, please do so via a separate commit. In particular, please avoid using automatic code formatters to reformat an entire existing file.
Use javadoc comments to document APIs and additional comments to clarify obtuse code. Do not use comments to identify yourself as that’s what the Git history is for. Do not leave commented out code blocks. Commented out examples in human readable config files however are OK.
十二、
Frequently Asked Questions经常被问到的问题
This section will answer common questions about GeoWebCache.
- Does GeoWebCache support WFS feature caching?
-
Not currently. Earlier versions of GeoWebCache had an experimental prototype of vector feature caching, but it was highly unstable and was removed from GeoWebCache as of version 1.2.5.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2020-05-27 基于Python的arcgis二次开发和ENVI二次开发