Exemplo n.º 1
0
		public void Test130()
		{
			SharpMap.Web.Wms.Client c = new SharpMap.Web.Wms.Client("http://wms.iter.dk/example_capabilities_1_3_0.xml");
			Assert.AreEqual(3, c.ServiceDescription.Keywords.Length);
			Assert.AreEqual("1.3.0", c.WmsVersion);
			Assert.AreEqual("http://hostname/path?", c.GetMapRequests[0].OnlineResource);
			Assert.AreEqual("image/gif", c.GetMapOutputFormats[0]);
			Assert.AreEqual(4, c.Layer.ChildLayers.Length);
		}
Exemplo n.º 2
0
		public void TestDemisv111()
		{
			SharpMap.Web.Wms.Client c = new SharpMap.Web.Wms.Client("http://www2.demis.nl/mapserver/request.asp");
			Assert.AreEqual("Demis World Map", c.ServiceDescription.Title);
			Assert.AreEqual("1.1.1", c.WmsVersion);
			Assert.AreEqual("http://www2.demis.nl/wms/wms.asp?wms=WorldMap&", c.GetMapRequests[0].OnlineResource);
			Assert.AreEqual("image/png", c.GetMapOutputFormats[0]);
			Assert.AreEqual(20, c.Layer.ChildLayers.Length);
		}
Exemplo n.º 3
0
		/// <summary>
		/// Initializes a new layer, and downloads and parses the service description
		/// </summary>
		/// <param name="layername">Layername</param>
		/// <param name="url">Url of WMS server</param>
		/// <param name="cachetime">Time for caching Service Description (ASP.NET only)</param>
		/// <param name="proxy">Proxy</param>
		public WmsLayer(string layername, string url, TimeSpan cachetime, System.Net.WebProxy proxy)
		{
			_Proxy = proxy;
			_TimeOut = 10000;
			this.LayerName = layername;
			_ContinueOnError = true;
			if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Cache["SharpMap_WmsClient_" + url] != null)
			{
				wmsClient = (SharpMap.Web.Wms.Client)System.Web.HttpContext.Current.Cache["SharpMap_WmsClient_" + url];
			}
			else
			{
				wmsClient = new SharpMap.Web.Wms.Client(url, _Proxy);
				if (System.Web.HttpContext.Current != null)
					System.Web.HttpContext.Current.Cache.Insert("SharpMap_WmsClient_" + url, wmsClient, null,
						System.Web.Caching.Cache.NoAbsoluteExpiration, cachetime);
			}
			//Set default mimetype - We prefer compressed formats
			if (OutputFormats.Contains("image/jpeg")) _MimeType = "image/jpeg";
			else if (OutputFormats.Contains("image/png")) _MimeType = "image/png";
			else if (OutputFormats.Contains("image/gif")) _MimeType = "image/gif";
			else //None of the default formats supported - Look for the first supported output format
			{
				bool formatSupported = false;
				foreach (System.Drawing.Imaging.ImageCodecInfo encoder in System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders())
					if (OutputFormats.Contains(encoder.MimeType.ToLower()))
					{
						formatSupported = true;
						_MimeType = encoder.MimeType;
						break;
					}
				if (!formatSupported)
					throw new ArgumentException("GDI+ doesn't not support any of the mimetypes supported by this WMS service");
			}
			_LayerList = new Collection<string>();
			_StylesList = new Collection<string>();
		}