UPDATE – With Geoserver 2.0 out a while now, the information in this post is growing stale, as GeoWebCache is now an integral part of GeoServer, and overall installation and configuration of Geoserver has changed a lot – read: got a lot easier. Configuring GeoWebCache under GeoServer 2.0.x is described here. Grab a copy of GeoServer 2.0.x here. Read about upgrading to 2.0.x from earlier versions here.
I will keep this post available for archival purposes.
I came across yet another tile caching implementation, GeoWebCache, through this article on the Google Open Source blog. It integrates nicely with the Geoserver OGC server, which should make it very easy to set up on a Windows box. So let’s try that.First, we need to get the Java SDK (not the runtime environment) from Sun; Geoserver needs it. An older 1.4.x version will do, but if you start a-fresh, you might as well get the Java 6 SDK from here. Download and install it.
UPDATE 1.6.4 is out, as Mike Pumphrey pointed out already in the comments section. Improved support for the GeoWebCache plug-in is among the new features. Read on for the implications for this guide.
While you’re there, download the GeoWebCachce extension as well.
Unzip the GeoWebCache extension, which comes as a zip file.
Install the Geoserver package. It will try and locate the Java SDK and notify you about it. I don’t think installing in the default location is such a nice solution, so I changed this to c:\geoserver\ instead. The data directory then defaults to c:\geoserver\data_dir which I left like that.
When Geoserver is installed, we need to add all the JAR files that comprise the GeoWebCache extension to C:\geoserver\webapps\geoserver\WEB-INF\lib.
UPDATE The following config file tweak is obsolete as of Geoserver 1.6.4. Only if you want to stick with 1.6.3 or earlier, the following paragraph applies:
We need to make a small manual change to one of the Geoserver config files, web.xml in C:\geoserver\webapps\geoserver\WEB-INF\web.xml. This is described in the extension README:
<servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/gwc/*</url-pattern> </servlet-mapping>
Before we start Geoserver, we are going to change the default admin credentials just to be on the safe side. To do this, we open C:\geoserver\data_dir\security\users.properties and change ‘admin=geoserver’ to ‘admin=[yourpassword]’.
Now we’re ready to start Geoserver and try to call the tile cache. We’re not going to add our own layers just yet; Geoserver comes with some simple sample data. To stret Geoserver, use the Start Menu entry or call
from the Run box or a command line.
This will open a Java command line which should remain opened. The output shown could also be useful when you start hacking the Geoserver configuration. Your Windows firewall could complain about Java, in which case you could ‘Unblock’ Java to allow http access from outside your box.
To confirm that it all works, type
in your browser, which should yield your Geoserver Admin home page (no maps there).
which should yield a Microsoft Virtual Earth tile schema compliant tile:
The last thing I want to do right now is to integrate this into a Microsoft Virtual Earth map client. This is quite well described in the GWC documentation and is dead simple anyway. Basically, you take a barebones VE map client template and add a VETileSourceSpecification:
var tileSourceSpec3 = new VETileSourceSpecification(“GeoserverSample”, “http://martijne:8080/geoserver/gwc/service/ve?quadkey=%4&format=image/png&layers=topp:states”);
tileSourceSpec3.NumServers = 1;
tileSourceSpec3.MinZoomLevel = 1;
tileSourceSpec3.MaxZoomLevel = 16;
tileSourceSpec3.Opacity = 0.3;
tileSourceSpec3.ZIndex = 100;
You only need to change the server part of the URL in the first line to your computer name (or localhost if you’re only going to access the sample from your own machine).
The major disadvantage of Geoserver for me is that it cannot do cascading WMS, although cascading WFS was recently implemented. So I’d like to set up GeoWebCache together with UMN MapServer to be able to do this.
When that’s done, I’d like to do some performance benchmarking and compare it to the Metacarta TileCache solution.