无痕客

落花无情,流水无痕……

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Accelerate your maps with GeoWebCache!

Introduction

GeoWebCache is a WMS tiling client. It runs as a proxy server between a map client and map server, caching tiles as they are requested, thus saving vast amounts of processing time. Written in Java, GeoWebCache is available as a standalone product which can be integrated with many client/server combinations.  However, GeoWebCache is also an extension that has been shipped with GeoServer since version 1.7.0.

Users are strongly encouraged to upgrade to 1.7.1a or greater. As of GeoServer 1.7.2, GeoWebCache can also act as a non-caching translator for Google Maps and MS Virtual Earth clients. See the links at the bottom of this page for details.

Installation

  1. By default, GeoWebCache expects GeoServer to be accessible at the following URL:
    http://localhost:8080/geoserver
    

    To point GeoWebCache elsewhere, add the following code to the web.xml file:

    <context-param>
        <param-name>GEOSERVER_WMS_URL</param-name>
        <param-value>http://EXAMPLE.COM:PORT/PATH/wms?request=GetCapabilities</param-value>
    </context-param>
    

    Make sure to replace the URL inside <param-value> with your GeoServer instance's WMS GetCapabilities path.

  2. By default GeoWebCache will store cached tiles in this path: %GEOSERVER_DATA_DIR%/gwc. To change this, add the following code to web.xml:
    <context-param>
        <param-name>GEOWEBCACHE_CACHE_DIR</param-name>
        <param-value>c:\temp</param-value>
    </context-param>
    

     Make sure to change %CACHE_PATH% to the path you wish to store your tiles (Examples:  /tmp, C:\temp)

  3. (Re)start your instance of GeoServer.

Using GeoWebCache

To get an overview of what GeoWebCache can do for you, point your browser to:  

http://localhost:8080/geoserver/gwc/demo

The demos on this page are not exhaustive, but should give you an idea of what is available.

In general, using GeoWebCache with a tiling client only requires you to change the WMS URL.  For example, if your application requests WMS tiles at the following URL:

http://example.com:8080/geoserver/wms

To instead invoke GeoWebCache from a tiling client that uses one of the global profiles of the WMS-C Tiling Client recommendations, use:

http://example.com:8080/geoserver/gwc/service/wms

If you run into problems, such as error messages saying that the resolution is not supported or the bounds do not align, then your client is most likely not making requests that align with the grid of tiles that GeoWebCache has created. If you are using OpenLayers then you should look at the source code of the automatically created demos. The most common problems is that the map or layer bounds differ from those of the grid, or that the resolution (derived from bounds, maxresolution or minresolution) is not correct.

As soon as tiles are requested through GeoWebCache, it automatically starts caching them.  These tiles are stored by default in the %GEOSERVER_DATA_DIR%/gwc path, with each FeatureType in its own subdirectory.  As more tiles are requested for each FeatureType, the size of this directory will grow.

Refreshing Data

On the demo page there is a link to "Seed this layer". Accessing it requires you to provide the username and password of the administrative user in GeoServer. Your three options are

  • Seed - Adds missing tiles, but does not overwrite existing ones
  • Reseed - Like seed, but overwrites existing tiles
  • Truncate - Deletes all tiles within the given bounds and zoomlevels

If you have direct access to the filesystem on the server, you can also delete the appropriate layers in the cache directory.

On the demo page there is also a reload button. Use this if you have added layers in GeoServer.

Projections and Other Parameters

The integrated version of GeoWebCache automatically configures every layer with the two most common projections:

  • EPSG:4326 (standard Latitude/Longitude)
  • EPSG:900913 (Spherical Mercator, the projection used in Google Maps)

If you need additional projections you can create a configuration file called geowebcache.xml  in the cache directory, for example  /var/geoserver_data/gwc/geowebcache.xml

This configuration file is the same as used by the standalone version of GeoWebCache and documented on http://geowebcache.org/  To avoid collisions, the layers in this file should be named differently from the ones that are automatically loaded from GeoServer

The configuration syntax directly supports the most common WMS parameters, such as background color, style and palette. If you need something like a CQL filter you should use the vendorParameters option.

More Information

Please see the GeoWebCache site at geowebcache.org.  The Documentationpage contains examples for integration with:

转载自:http://geoserver.org/display/GEOSDOC/5.+GWC+-+GeoWebCache

posted on 2010-06-27 22:44  无痕客  阅读(1669)  评论(0编辑  收藏  举报