Tile Cache best approach?

Topics: Web Controls, WinForms Controls
Mar 30, 2010 at 9:43 AM
Edited Mar 30, 2010 at 10:41 AM


i'm trying to understand which is the best approach to Tile Caching...


My idea is...  a WMS server exposed using: 

     SharpMap.Web.Wms.WmsServer.ParseQueryString(myMap, description);

But how to cache it?


Then "Client Side"...  can i use TiledWmsLayer  ?

I saw that if i try to consume a WMS exposed by SharpMap ParseQueryString  it gives me an XML Node error....   



p.s. is TiledWmsLayer really deprecated?  is it better to use the TileLayer ?    Examples?????




Mar 30, 2010 at 7:16 PM
Edited Mar 30, 2010 at 7:21 PM

Hi Sandex,

Yes, TiledWmsLayer is deprected en replaced by he TileLayer, which is more generic. TiledWmsLayer is a client for the WMS-C protocol. With the TileLayer you can do the same like this:

            string url = "http://labs.metacarta.com/wms-c/tilecache.py?version=1.1.1&request=GetCapabilities&service=wms-c";
            var tileSources = TileSourceWmsC.TileSourceBuilder(new Uri(url), null);
            var tileSource = new List<ITileSource>(tileSources).Find(source => source.Schema.Name == "satellite-merc");
            map.RootLayer = new TileLayer(tileSource);

You can see it in action in the BruTile.Wpf sample app. Some more samples here:


The WMS-C protocol can be used to talk to a tilecache, but it is primarily useful to talk to a WMS directly. I prefer TMS to talk to a tilecache because there can be no rounding errors. 

About how to set this up. The usual approach is to put some tilecache tool on the server in front of your WMS. Currently there is no such tool in .net. At our company we have been working with tilecache.py, geowebcache and arcgisserver. 

It is possible to create such a server side tool using BruTile but I have no immediate plans to do so. A simple version will not be so hard, but to get it working properly will be quite an effort. What needs to be done is:

  • Parse a TMS GET request.
  • Create a TileKey from that.
  • Lookup if that tile exists in a DbCache.
  • If not use a WmsCRequest to retrieve it from the WMS.
  • Store it in the DbCache.
  • return the tile to the client.



Mar 30, 2010 at 7:49 PM

Thanks for the answere...  

....but...  in your opinion should be a good think to provide a WMS server using Sharp Map?    for what i saw it seems to run in a good way....   

then...    i saw http://geocache.codeplex.com/ it seems it is a "porting" of tilecache.py,but i saw it support wms 1.1.1  (i'm trying to modify it in order to shallow even 1.3.0)


My last question is...        a smart client...   which is the best library?  i suppose BruTile?  even for WPF / Silverlight  right?  

Mar 30, 2010 at 8:19 PM
Edited Mar 30, 2010 at 9:14 PM

hey, I had never seen that project, although very relevant. Thanks.

For tile layers BruTile performs smooth because of it's async tile fetching. But currently there is no support for any kind of vector rendering. My plan is to use SharpMap for that. A first step in that direction is BruTile's SharpMapProvider. There is a sample in BruTile.UI.Wpf. That sample is using a version of SharpMap that does not have the TileLayer yet. You might want to update that. 

I am working on closer integration between SharpMap and BruTile.UI. 

I have not worked much with SharpMap as a WMS, but others have. Since it is a separate component it could easily be replace with another WMS later on.


Mar 31, 2010 at 7:56 AM

yeeeaaa!!!!  with few modification http://geocache.codeplex.com/ runs even on WMS 1.3.0  


So now i've...   Sharp Map as WMS Server    GeoCache as Tile Cache Server that ask tile to SharpMap...    now i'll try to use BruTile from a Windows Form in order to download the Images...    but...  i've a question...   with BruTile is it possible to make the "ImageToWorld" and reverse functionality like SharpMap...

I need to render Splines over the map but i need to know the coordinate of the point on which i click on....     SharpMap i know that can do this.... i've already used...  but i don't know BruTile...  



Anyway...  in my opinion geocache seems to be a nice project...   but it is completly abandoned.....   or ...  it seems so....     i'll contact the developer and i'll promote to renew some code....  




Mar 31, 2010 at 10:35 AM

congrats :) It would be nice if the project could use BruTile as a core component so it can benefit from other protocols that it supports.

In BruTile.UI you can do the equivalent with MapTransform.MapToWorld and WorldToMap. 

Future development will probably focus on SL/WPF so I would advice to go for WPF instead of WinForms.


Sep 13, 2010 at 10:05 AM

just a question...     where is defined the Tile Source WmsC???

Sep 14, 2010 at 10:40 AM

Not sure which version is now part of SharpMap but this was renamed to WmscTileSource.