WMS newbie question

Jul 1, 2011 at 8:04 PM

I'm relatively new to using WMS, but I've been trying for about a full day now trying to find a WMS server anywhere that BruTile likes.  Hopefully, it's just operator error and someone can set me straight.

Here is the API I'm trying to use:

tileSources = BruTile.Web.WmscTileSource.TileSourceBuilder(new Uri(txtUrl.Text), null);

The URL text I'm supplying is the GetCapabilities link to any WMS server I've tried like:


I get one of any number of errors such as:

NullReferenceException in ParseVendorSpecificCapabilitiesNode - I've stepped through the code and it appears the VendorSpecificCapabilities is missing.  I suppose this means the service is not meeting the WMS Tiled spec.  If that is true, fine, but please show me some services that DO meet the spec.


No Service Tag Found!

I've tried with the latest version and also with a version of BruTile from December.  No luck.  I'd really like an example URL that works and has coverage over the US, but if not, anywhere would be better than what I'm getting now.

Any help would be appreciated.  Thanks. kellison

Jul 3, 2011 at 12:13 PM
Edited Aug 4, 2011 at 2:30 PM

It looks like you are trying to use the WMS-C on an ordinary WMS. WMS-C looks for the VendorSpecificCapabilities for its tiling info. It is also possible to use an ordinary WMS as a source for tiles. Samples for both are in Mapsui.Wpf:




Aug 2, 2011 at 7:51 PM

Thanks Paul.  That example was very helpful.  I was able to get it working.  I ran into 2 issues.  First, I had black lines between the virtual WMS tiles, but I think that was my drawing code and I fixed that.  Secondly, the Styles value in WmscRequest was being ignored.  I found the code that was commented out in WmscRequest.GetUri(), uncommented it and it worked like a champ.  I have included a couple of classes I wrote to pull this off in case someone else needs a little help like I did.  Thanks again.  Kyle

    class WmsTileSchema : TileSchema
        public WmsTileSchema(string name, BruTile.Extent extent, string srs, string format, int tileSize, double highestResUnitsPerPixel, AxisDirection axis)
            // Make us a new extent that is square
            double minx, miny, maxx, maxy, size;
            if (extent.Width > extent.Height)
                minx = extent.MinX;
                maxx = extent.MaxX;
                size = maxx - minx;
                miny = extent.MinY;
                maxy = miny + size;

                miny = extent.MinY;
                maxy = extent.MaxY;
                size = maxy - miny;
                minx = extent.MinX;
                maxx = minx + size;
            int count = 0;
            double unitsPerPixel = size / tileSize;
                Resolutions.Add(new Resolution { Id = count.ToString(), UnitsPerPixel = unitsPerPixel });
                unitsPerPixel /= 2;
            } while (unitsPerPixel > highestResUnitsPerPixel);
            BruTile.Extent myExtent = new BruTile.Extent(minx, miny, maxx, maxy);
            Width = tileSize;
            Height = tileSize;
            Extent = myExtent;
            OriginX = myExtent.MinX;
            OriginY = myExtent.MinY;
            Name = name;
            Format = format;
            Axis = axis;
            Srs = srs;

    class WmsTileSource : ITileSource
        public WmsTileSource(string name, BruTile.Extent extent, string srs, string format, int tileSize, double highestResUnitsPerPixel, AxisDirection axis, string url, IList<string> layers, IList<string> styles, IDictionary<string, string> parameters)
            var schema = new WmsTileSchema(name, extent, srs, format, tileSize, highestResUnitsPerPixel, axis);
            var request = new WmscRequest(new Uri(url), schema, layers,
                                          styles, parameters);
            Provider = new WebTileProvider(request);
            Schema = schema;
        public ITileProvider Provider { get; private set; }
        public ITileSchema Schema { get; private set; }


Aug 4, 2011 at 2:55 PM

hi Kyle,

thanks for the example!

I just enabled the style code again but only if not null or empty.