WMS Server HowTo

Apr 11, 2008 at 2:33 PM
Hi there,

is there a tutorial or recent example project on "how to set up a WMS Server using SharpMap"?

I found http://www.sharpgis.net/post/2005/10/12/SharpMap-as-a-WMS-server.aspx but it seems to be outdated.

I'd like to use that particular WMS server in another SharpMap project.

Any help here is appreciated.
Developer
Apr 11, 2008 at 4:49 PM
In the webapp demo (under the sharpmap sources download) there's a sample of a sharpmap wms server that looks very helpful.
Have you take a look?
Apr 15, 2008 at 8:50 AM
Thanks.
It however seems that is a WMS Client and i'm looking for some info on how to set up a WMS Server.

Developer
Apr 15, 2008 at 3:21 PM


jan99 wrote:
It however seems that is a WMS Client and i'm looking for some info on how to set up a WMS Server.

Both the samples are in the demo. You could find WMSClient AND WMSServer samples.
Apr 16, 2008 at 2:47 PM
woops, i discovered there is also a Branches part besides the Trunk part. Thanks for conferming my stupidity :o)
wms.ashx is it
Developer
Apr 16, 2008 at 4:55 PM
It is in the trunk too:
http://www.codeplex.com/SharpMap/SourceControl/FileView.aspx?itemId=39330&changeSetId=32815
The trunk is most up to date.
Apr 19, 2008 at 8:40 AM
Ok, thanks. I must have searched for *.cs or something to not see this.

How can another application talk to a Sharpmap WMS Server, i mean what is an example url/string to call the wms.ashx?

Developer
Apr 19, 2008 at 11:23 AM
There is a sample request in Default.aspx:
"wms.ashx?REQUEST=GetMap&Layers=Countries,Rivers,Country labels&STYLES=&CRS=EPSG:4326&BBOX=-180,-90,180,90&WIDTH=600&HEIGHT=300&FORMAT=image/png&VERSION=1.3.0"

You could create a WinForms client based on this:
http://www.codeplex.com/SharpMap/SourceControl/FileView.aspx?itemId=428730&changeSetId=32911

You could modify it to look like this:

using System.Drawing;
using SharpMap;

namespace WinFormSamples.Samples
{
public static class WmsSample
{
public static Map InitializeMap()
{
string wmsUrl = "http://localhost:3046/DemoWebSite/wms.ashx";

SharpMap.Map map = new SharpMap.Map();

SharpMap.Layers.WmsLayer layWms = new SharpMap.Layers.WmsLayer("SharpMap WMS", wmsUrl);
layWms.SpatialReferenceSystem = "EPSG:4326";

layWms.AddLayer("Countries");
layWms.AddLayer("Rivers");

layWms.SetImageFormat(layWms.OutputFormats0);
layWms.ContinueOnError = true; //Skip rendering the WMS Map if the server couldn't be requested (if set to false such an event would crash the app)
layWms.TimeOut = 5000; //Set timeout to 5 seconds
layWms.SRID = 4326;
map.Layers.Add(layWms);

//limit the zoom to 360 degrees width
map.MaximumZoom = 360;
map.BackColor = Color.LightBlue;

map.Zoom = 360;
map.Center = new SharpMap.Geometries.Point(0, 0);

return map;
}
}
}


You need change set 32911 for this to work because there was a little bug in the capabilities. The port was omitted from the OnlineResource url.
Apr 19, 2008 at 6:57 PM
Thanks for the very detailed reply!
Will try later,... not at home a.t.m.