WMS Demo

Editor
Oct 10, 2013 at 3:44 PM
I'm trying to hack a few different shapefiles files into the demo to show some people how sharpmap works but I'm struggling to get it working. Running through the code it looks like the static class ShapefileHelper it seems to reload the shapefile for every tile that is requested?

Is that correct??

If so, won't that have large performance impacts if the file is quite large?

Thanks
Editor
Oct 10, 2013 at 4:21 PM
Is there a way to make it cache the rendered tiles? or does it do this automagically?

Thanks
Coordinator
Oct 10, 2013 at 4:25 PM
Yes.
Editor
Oct 10, 2013 at 4:28 PM
So it caches the tiles.....but does it reload the file for every request?
Editor
Oct 10, 2013 at 4:38 PM
Where does it cache the tiles?
Coordinator
Oct 10, 2013 at 4:47 PM
Editor
Oct 11, 2013 at 9:11 AM
Ok, I looked into that.

I can't find any reference to that method in the sharpmap.demo.wms project. What I've basically done is modified the shapefileHelper to point at my shapefile which is a bit larger that the demo ones so it takes a while to load the tiles. So I'm wondering about the general architecture of that project. As I said, it seems to reload the shp file for each request, and as far as I can tell it is not caching the rendered tiles. I'm hoping to use this of for a large project (the data for that project will probably be in a sql database though. I will probably try and prerender the tiles and serve these. So I'm assuming that will require a brutile layer?

A little more information would be great.
Developer
Oct 12, 2013 at 1:34 PM
Edited Oct 12, 2013 at 1:39 PM
Robert_Smart wrote:
As I said, it seems to reload the shp file for each request
This is absolutely true, any request made in the demo is a WMS request, completely indipendent from other WMS requests.
You should, of course, use a spatial database and not a shapefile for large datasets.
So I'm assuming that will require a brutile layer?
To me, also this looks true, although some more involved with igeneral sharpmap architecture can suggest other solutions
Developer
Oct 12, 2013 at 5:51 PM
Edited Oct 12, 2013 at 6:30 PM
a little investigation: caching is not used in WMS demo, is something that eventually can be managed inside a httprequest (i.e: inside StdWmsHandler).
What should be made, after that you have put the image inside the Cache, is a static (arghhh!) singleton (arghhh!) syncronized collection that stores, for each wms request, the image generated, so when the same request is made, it can return directly the image from the cache.
Hope to do this stuff monday
Developer
Oct 14, 2013 at 8:34 AM
this is something that involves changing WmsServer.ParseQueryString code, so I plan to add this functionality in WmsRefactoring branch, a thing that I need to start working sooner o later
Coordinator
Oct 14, 2013 at 12:43 PM
Robert, what is your goal?

Do you want to speed up rendering in a Windows.Forms application of do you want to create some SharpMap backed OpenLayers(or similar) web application?

For speeding up rendering in a Windows.Forms application,
  • you actually might want to use prerendered tiles (BruTile). Please note that you are currently stuck on the projection your tiles are in (WGS84 | [Web|Global]Merkator). If that is no problem fine.
  • The other step to speed up your rendering is to use a spatially enabled database (PostGis, SqlServer, SpatiaLite, ...) and adjust visibility of features based on zoom level.
For a web based application I cannot offer any performance tweaks.
Developer
Oct 14, 2013 at 12:52 PM
FObermaier wrote:
For a web based application I cannot offer any performance tweaks.
Same rules.
Developer
Oct 14, 2013 at 12:56 PM
@felix Robert talks about SharpMap.Demo.WMS project, so I think The Web+OpenLayers solutions is something interesting for him.

What I think, after a litte investigation, is that is wrong to add caching functionalities to SharpMap WMS, as example using Caching class: if you need to publish tiles, as felix suggests you should generate and then publish prerendered tiles via brutile, of course configuring WMS map.
Maybe this is an example that can be added to project.
Developer
Oct 14, 2013 at 1:40 PM
Edited Oct 14, 2013 at 1:52 PM
a simple map like this works in wms.demo.
Layer tileLayer = new TileLayer(new OsmTileSource(), "BruTile-OSM");
tileLayer.SRID = 900913;
Map map = new Map(new Size(1, 1));
map.Layers.Add(tileLayer);
return map;
Of course, you need to configure the layer to publish your own tiles, this is simply a SharpMap WMS+BruTile sample...

hope to commit the sample immediately (I've some strange issues with nuget+brutile references)
Editor
Oct 14, 2013 at 1:51 PM
My goal is to have a central server that has a datastore (probably SQL server) on. This server will be able to serve layers as either a geometry based layer for connected desktop clients or WMS for web clients. Also for complex layers the desktop clients will also probably access the data as WMS.

So the instance of sharpmap on the server will load data from the database and provide a wms service. instances of sharpmap on the client will either get the data directly from the datastore or via wms and web clients (using openlayers) will get most of the data via WMS and probably a few bits via JSON.

Basically we need an architecture that will allow for the same experience between thin and thick clients. but additionally the thick client will have editing capabities and some other fancier rendering that the web client will not support.

At the moment I'm just looking at loading large cad files into a SQL server, for performance reasons we have decided that it would be best to serve these as WMS layers due to the complexity. So using netDXF I can access the files and load the data into sql server.

Ideally what I now want is to be able to have a server instance of sharpmap running on that server that will expose the data via WMS with real time caching so that I can just hook my clients up to that service and it takes care of the rest. It would then save a lot of hassle of having to pre render the tiles etc.

I think the performance using SQL will be much improved, but I still think that some tile caching will improving things further.

So I think that an optional 'Server cache' option on the WMS might be useful (Geoserver allows 'auto cache generation') would be quite useful. There would have to be functions for clearing the cache etc, but I feel it would be quite useful.

Hopefully we will get the go ahead to use sharpmap in our project, which should result in us being able to feed plenty of code back into the project.
Developer
Oct 14, 2013 at 2:00 PM
Added with changeset 104168.
Hope my commit doesn't broke anything...
Developer
Oct 14, 2013 at 2:04 PM
Robert_Smart wrote:
I think the performance using SQL will be much improved, but I still think that some tile caching will improving things further.
My2Cents. Use caching only if you need absolutely. Try at first if using SQL layers your performances are good, there are a number of problems related to caching that are very annoying, like invalidation, WMS request with multiple layers, and so on...
But, if you have a datasource that doesn't change, like an image or heavy data that is static, create tiles for this data and publish via brutile, like the example above.
Editor
Oct 14, 2013 at 2:20 PM
OK, I'm not against pre-tiling the data, it is just an extra step that I thought I could avoid.

I guess like you mention, caching might bring its own problems too!
Editor
Oct 14, 2013 at 2:27 PM
thanks for the demo. I'll try and have a look later.

I also found the create tiles sample, in the winforms demo, which I can use to populate the tile structure as well.