Directions Magazine (DM): GeoWebCache speeds up map rendering to Web map clients. How does it do that?
Arne Kepp (AK): The key to GeoWebCache's speed improvements is to divide the world up in to preset "tiles." This is how commercial services like Google Maps and Virtual Earth achieve their speed, but GeoWebCache is different as it operates against any compliant Web Map Service (WMS) implementation. GeoWebCache acts as a proxy between the client and the WMS server. When a client requests a tile, the program will first check whether this tile has been requested before. If a tile matching the parameters has been stored, then it will simply return that. In this case, the tile cache will often be one hundred times faster than a WMS server, because all it has to do is stream a file to the network.
If it is a request for a new tile, it will create a request for a larger tile and forward this to the WMS backend. Once the response is received, the returned data are divided into tiles again, a process called metatiling, and stored for later use. The particular tile requested by the client is then returned. In this case the tile cache is slightly slower than a direct request to the WMS server. But GeoWebCache has built in tools to seed all the tiles in advance, so that this never happens when the server is in production.
DM: Describe how it might be used to speed data being rendered from GeoServer and Google Maps into a Google Maps client.
AK: GeoWebCache includes an adapter for the Google Maps client, so it is very easy to add your layers to this service. The caching works exactly the same way as it does for WMS; GeoWebCache will look for the tile and return it, if possible, alternatively forwarding the request to the backend. The only difference is that the Google Maps API facility to request a remote tile layer uses requests with integer grid coordinates instead of bounding boxes.
There is also an adapter for MS Virtual Earth, which actually uses the same grid, just a slightly different way of addressing the tiles. This means that if you create a set of tiles for one of these services, GeoWebCache will automatically let you use them in the other as well.
Both of these work great with GeoServer, but you can put GeoWebCache in front of any WMS server and make your data available on both Google Maps and MS Virtual Earth.
DM: What's the history of GeoWebCache? What was the impetus for developing it? How did Google contribute?
Through Google Summer of Code 2007 (a Google program that offers student developers stipends to write code for various open source projects), student Chris Whitney was able to spend a summer creating what became known as jTileCache. It had very basic functionality, but also original ideas like using the Java Caching System to store image objects and compress them on the fly. Over the next nine months jTileCache was reworked into what is today known as GeoWebCache. In the summer of 2008 the project benefited from another generous Summer of Code grant, allowing a second student, Marius Suta, to contribute code that enabled XML configuration using XStream and a RESTful configuration interface. Google's Open Source Office has also funded OpenGeo to add streaming Google Earth support to GeoServer, and GeoWebCache benefited from this, gaining the ability to tile and cache KML placemarks and vectors.
DM: GeoWebCache is licensed under LGPLv3, meaning it can be included in other open source and non-open source offerings. Has it been/will it be included in commercial or open source offerings?
AK: We chose LGPLv3 because it has always been a goal to use GeoWebCache as a library. In fact, GeoWebCache is already integrated into GeoServer 1.7.1. Currently this is not a very tight integration, but it will become more so when we start expiring tiles automatically based on transactions and similar events. There are also plans to provide caching for WFS requests.
We are not currently aware of anyone using the code for commercial products, but this is not surprising since we released the first stable version this week. OpenGeo is fully committed to open source and will not use it in closed products, but we encourage others to do so, and hope they will join the community and improve it in collaboration with all.
DM: What are the implications for GeoWebCache for mobile applications?
AK: The biggest problems on mobile devices are bandwidth and response times. Tiling alleviates the former, partially because you do not have to refresh the entire screen when you pan, only download tiles for the missing areas. GeoWebCache is a natural fit anywhere you do tiling, and the quick response ensures that no unnecessary delays are introduced.
Earlier in 2008 a user contributed a patch for GeoWebCache so that it also has an adapter for Mobile GMaps. This is software that works similarly to Google Maps, but on any Java J2ME-enabled phone. One idea for future development is to export the tiles, so that you can put them on flash memory in your device. This would make the map instantly available at no charge.
DM: Besides speeding up delivery of maps to the client, are there any other big benefits of using GeoWebCache?
AK: In addition to the adapters already mentioned, GeoWebCache also supports Google Earth. With a regular WMS server this means you can create image hierarchies like those provided by Google, where the resolution increases as you zoom in. If you work against GeoServer it is also possible to serve regionated KML. KML stands for Keyhole Markup Lanuage and is an XML based vector format. Regionating in this context means that you show a few features when you are zoomed far out, and load more as you zoom in. This means you can serve a lot of data without cluttering the display or overloading the client. Though it is still evolving and more clients have to be developed, OpenGeo is convinced that KML will play an important role for sharing information in the years to come.
Finally, not only is GeoWebCache fast, but you can also serve hundreds of simultaneous clients with a single instance of GeoWebCache. This can translate into significant cost savings if you have a busy site.