Esempio n. 1
0
        public static Map InitializeMap()
        {
            Map map = new Map();


            //string url = "http://labs.metacarta.com/wms-c/tilecache.py?version=1.1.1&request=GetCapabilities&service=wms-c";
            string url = "http://resource.sgu.se/service/wms/130/brunnar?SERVICE=WMS&VERSION=1.3&REQUEST=getcapabilities&TILED=true";
            //string url = "http://dev:8080/geoserver/gwc/service/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities&TILED=true";
            //string url = "http://dev:8080/geoserver/ows?service=wms&version=1.3.0&request=GetCapabilities&tiled=true";
            //TiledWmsLayer tiledWmsLayer = new TiledWmsLayer("Metacarta", url);
            //tiledWmsLayer.TileSetsActive.Add(tiledWmsLayer.TileSets["avalon"].Name);
            //map.Layers.Add(tiledWmsLayer);
            //map.ZoomToBox(new BoundingBox(-180.0, -90.0, 180.0, 90.0));

            //WmscRequest req;
            //ITileSource tileSource;
            TileAsyncLayer tileLayer;
            //BruTile.Web.TmsTileSource source2 = new TmsTileSource(url);

            var source = new List <ITileSource>(WmscTileSource.CreateFromWmscCapabilties(new System.Uri(url)));

//            foreach (ITileSource src in source)
//            {
            tileLayer = new TileAsyncLayer(source[16], "tileLayer" + source[16]);
            tileLayer.MapNewTileAvaliable += map.MapNewTileAvaliableHandler;
            map.BackgroundLayer.Add(tileLayer);
//            }
            map.ZoomToExtents();


            return(map);
        }
Esempio n. 2
0
        private void btnRetrieve_Click(object sender, EventArgs e)
        {
            // Complete sample urrel:
            // http://labs.metacarta.com/wms-c/tilecache.py?version=1.1.1&request=GetCapabilities&service=wms-c
            // Does not work yet: http://public-wms.kaartenbalie.nl/wms/nederland
            //string url = String.Format("{0}?version={1}&request=GetCapabilities&service=wms-c", tbWmsCUrl.Text, cbbVersion.SelectedItem);
            string url = tbWmsCUrl.Text;

            try
            {
                _tileSources = new List <ITileSource>(WmscTileSource.CreateFromWmscCapabilties(ToXDocument(new Uri(url))));

                var names = new List <string>();
                foreach (var tileSource in _tileSources)
                {
                    names.Add(tileSource.Schema.Name);
                }

                lbServices.DataSource = names;

                tbWmsCUrl.Items.Add(url);
                tbWmsCUrl.SelectedIndex = tbWmsCUrl.Items.Count - 1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Esempio n. 3
0
        private void btnRetrieve_Click(object sender, EventArgs e)
        {
            // Complete sample urrel:
            // http://labs.metacarta.com/wms-c/tilecache.py?version=1.1.1&request=GetCapabilities&service=wms-c
            // Does not work yet: http://public-wms.kaartenbalie.nl/wms/nederland
            //string url = String.Format("{0}?version={1}&request=GetCapabilities&service=wms-c", tbWmsCUrl.Text, cbbVersion.SelectedItem);
            var url = tbWmsCUrl.Text;

            try
            {
                _tileSources = WmscTileSource.CreateFromWmscCapabilties(new Uri(url)).ToList();

                var names = _tileSources.Select(t => t.Schema.Name).ToList();

                lbServices.DataSource = names;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 4
0
        public void ParseCapabilitiesWmsC()
        {
            // arrange
            const int expectedNumberOfTileSources = 54;

            using (var stream = File.OpenRead(Path.Combine(Paths.AssemblyDirectory, "Resources", "Wmsc", "WmsCCapabilities_1_1_1.xml")))
            {
                // act
                var tileSources = WmscTileSource.CreateFromWmscCapabilties(XDocument.Load(stream));

                // assert
                Assert.AreEqual(tileSources.Count(), expectedNumberOfTileSources);
                foreach (var tileSource in tileSources)
                {
                    Assert.NotNull(tileSource.Schema);
                    Assert.NotNull(tileSource.Schema.Resolutions);
                    Assert.NotNull(tileSource.Schema.YAxis);
                    Assert.NotNull(tileSource.Schema.Extent);
                    Assert.NotNull(tileSource.Schema.Srs);
                }
            }
        }
Esempio n. 5
0
        public void TestParseUrl(string url, bool ignore)
        {
            if (ignore)
            {
                Assert.Pass();
            }

            // arrange
            var myWmsc = new Uri(url);
            // act
            List <ITileSource> res = null;
            var action             = new TestDelegate(() => res = new List <ITileSource>(WmscTileSource.CreateFromWmscCapabilties(myWmsc)));

            // assert
            Assert.DoesNotThrow(action);
            Assert.IsNotNull(res);
            Assert.That(res.Count, Is.GreaterThan(0));
        }