0

December 2

A GIS story - Introducing caching for GIS map rendering

Posted by Ajay

Once upon a map…

I have been working on geoserver for the past few days and it has been an amazing experience. Let me tell you the circumstances that led me to investigate geoserver.

We have a system that had web mapping capabilities. We provide decision support service and our GIS map enables us to visualize the service that we provide to the customers. Users of our product will be able to see multiple layers on the map, visualize many diffrent layer features and use this to make certain decisions for managing emergency. Our technical setup involved using PostGRES/PostGIS to serve spatial data, a custom built WMS/WFS server that would consume the spatial data and render geotagged PNGs, and a Mapbuilder/OpenLayer based client that would take the WMS/WFS data and render a map on the front end web page. Our setup looked something like this:

One fine day our client wanted us to design some really cool basemaps, and so there we were in the next step of the evolution of our application, We got our GIS designers to produce awesome looking geotiffs, all looking nice and sexy. But one thing about these geotiffs files was that they were huuuuge!!. Some of them at our highest level of resolution were running into 4-5 GB. Then came the next step of setting our WMS/WFS server to render these geotiffs. Using a GeoTiffReaderWriter, we were able to successfully accomplish this, but with a great drop in performance when rendering the images on the UI. So the think tank got together to solve this problem, and a brilliant young engineer (oh thats right that was me!!) of course with some help from others came up with an interesting solution to cache the WMS/WFS server.

We decided to use some of the functionality of a great open soruce caching APi called GeoWebCache. We could not use the API directly since our WMS/WFS server could not send request into geowebcache in the format that it supported (This basically tells you that we were not following the WMS/WFS specification…how cruuude!! …this of course will be remedied in a few weeks when we switch to geoserver..but thats a story for another day)

Who dat wanna cache some maps!!

Web caching is a concept used to improve server performance. The general idea of GIS web caching is to cache extents that would be executed very often, and which entitles high overhead in terms of network bandwidth, and then retrieve these extents from the cache instead of a WMS query to the server. Web caching can be implemented only for layers that do not change often. If they do change, a cache expiration policy can be implemented.

Geowebcache (http://geowebcache.org/trac) is a WMS tiling caching client that works to cache WMS data. In essence what geowebcache does is that it acts as a proxy between the client and the server helping to divide dynamic maps into static tiles. It also takes requests for each of the tile , checking to see if a particular tile that is requested is already stored on disk (the cache) if so it returns that instead of hitting the server. GeoWebCache not only turns any dynamic mapping server in to a high performance cache for the WMS-C recommendation, but the tiles are also instantly available for direct use in Google Maps, Virtual Earth and as Super-Overlays in Google Earth.

Other features include pluggable caching backends, like JCS and a pure disk cache, and support for ‘MetaTiling’ for better labels across tiles.

It works somewhat like this:

  1. GET request is intercepted and the layer requested is extracted and checks to see if the layer supports the request.
  2. The bounding box or envelope of the current request is extracted and an internal grid of the form (x,y,z) is created. This grid forms the index. Any further requests, if they fall i n the range of this grid, would make it a cache hit.
  3. Once the grid is created a cache key is generated for the grid. If this cache is empty, the WMS server is hit to populate the cache, if not the image is rendered straight off the cache.

Now to visualize it,

So all in all our experience with geowebcache was incredible. We got an almost halving of our rendering time for our basemaps, and let me tell you, our clients were Haaappyyy!!.

Some good references

http://cholmes.wordpress.com/2008/03/05/letting-everyone-remix-web-maps/

Tags: ,

Copyright © 2010 “An Image of My Life” blog series All rights reserved. Theme by Laptop Geek.

Total hits: 38496