Sharpmap OSM Cache Data over Geoserver

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

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;
                    map.BackgroundLayer.Add(tileLayer);
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.

Thanks.
Developer
Jul 10, 2014 at 11: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 https://brutile.codeplex.com/SourceControl/changeset/d9581c65201b
Jul 11, 2014 at 2: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 3:05 PM
Edited Jul 11, 2014 at 3:08 PM
Coordinator
Jul 14, 2014 at 10: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..
Developer
Jul 14, 2014 at 12:28 PM
tyakar wrote:
And my question is how can I send request as tiled=true.
if you've used geowebcache, try using "http://example.com/geoserver/gwc/service/wms"
http://docs.geoserver.org/stable/en/user/geowebcache/using.html
Marked as answer by petlof on 7/16/2014 at 12:37 AM
Developer
Jul 14, 2014 at 1: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' (http://wiki.osgeo.org/wiki/WMS_Tiling_Client_Recommendation). 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.
Developer
Jul 14, 2014 at 3:43 PM
Edited Jul 14, 2014 at 3:47 PM
But first try Diego's solution!

Replace:
geoServerAddress + "/wms?....
With :
geoServerAddress + "/gwc/service/wms?...
Jul 16, 2014 at 8: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 at 12:22 PM
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?