Sharpmap OSM Cache Data over Geoserver

Topics: General Topics, SharpMap Project, SharpMap v0.9 / v1.x
Jul 9, 2014 at 12:04 PM

I am using Sharpmap v1.1 in my project.
I use OSM map offline as baselayer over geoserver.
Its working but so slow.
 var xDoc = ToXDocument(new Uri(geoServerAddress + "/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities&TRANSPARENT=TRUE&TILED=true&srs=EPSG:3857&layer=" + layerName));
                var source = new List<ITileSource>(WmscTileSource.CreateFromWmscCapabilties(xDoc));
                var tileSource = source.FirstOrDefault(x => x.Schema.Name == layerName);
                var tileLayer = new TileAsyncLayer(tileSource, layerName) { SRID = 3857 };

                tileLayer.MapNewTileAvaliable += map.MapNewTileAvaliableHandler;
                tileLayer.OnlyRedrawWhenComplete = true;
I cached the OSM data on geoserver. But it is still creating tile for every request. Its not working on cached data.

Can you help me, how to use cache data from geoserver on Sharpmap please.

Jul 10, 2014 at 10:14 AM
You can try to use a local file cache
var tileLayer = new TileAsyncLayer(tileSource, layerName, new Color(), true, "fileCacheDir");
Please take a look at your cache directory to see if it creates the tiles because there was a bug inside of BruTile that prevented the cache with wrong tile names, see
Jul 11, 2014 at 1:45 PM
Thanks for answer.

I use Sharpmap 1.1. which is last release on nuget.
What should I do, to get last comits for Sharpmap.
Should I compile sharpmap source manually or is there any release for new version on nuget ?

And is there any example for geoserver cached table on sharpmap.

Thank you
Jul 11, 2014 at 2:05 PM
Edited Jul 11, 2014 at 2:08 PM
Jul 14, 2014 at 9:43 AM
I think this is an issue for BruTile that WmscTileSource does not include it in the URLs.

For TileLayers, SharpMap does not do anything with the URL:s, its only BruTile functions. I will send it through to the BruTile team..
Jul 14, 2014 at 11:28 AM
tyakar wrote:
And my question is how can I send request as tiled=true.
if you've used geowebcache, try using ""
Marked as answer by petlof on 7/16/2014 at 12:37 AM
Jul 14, 2014 at 12:02 PM
BruTile expects that the 'tiled=true' parameter is part of the OnlineResource in the capabilities. This is apparently not how GeoServer works. Reading the WMS-C spec again it seems to make sense to just always pass 'tiled=true' ( This needs a new release of BruTile.

A possible workaround (that I did not test) is to save the capabilities to a local file. Edit the OnlineResource to include 'tiled=true' after the questionmark. Use this local resource to parse to an XDocument.

Another alternative is to copy the source of the WmscTileSource and WmscRequest to your own project and modify it for your own needs.
Jul 14, 2014 at 2:43 PM
Edited Jul 14, 2014 at 2:47 PM
But first try Diego's solution!

geoServerAddress + "/wms?....
With :
geoServerAddress + "/gwc/service/wms?...
Jul 16, 2014 at 7:36 AM
First I changed source code of brutile and changed the request as tiled=true.
Caching was working but geoserver was still generating tile instead of reading from cache.

Then I tried geowebcache method as Diego said;
geoServerAddress + "/gwc/service/wms?...
Its working.

Thanks for help.
Nov 12, 2016 at 11:22 AM
I want to do same. So which part of source code of Brutile should be changed?
can you exactly tell me what did you do?