Exemplo n.º 1
0
        public void TestSerializeWmsLayerWithCredentials()
        {
            SharpMap.Map             m = new SharpMap.Map();
            SharpMap.Layers.WmsLayer l = new SharpMap.Layers.WmsLayer("testwms", "http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer", TimeSpan.MaxValue,
                                                                      System.Net.WebRequest.DefaultWebProxy, new NetworkCredential("test", "pw"));
            l.AddChildLayers(l.RootLayer, false);
            m.Layers.Add(l);
            MemoryStream ms = new MemoryStream();

            SharpMap.Serialization.MapSerialization.SaveMapToStream(m, ms);
            string txt = System.Text.ASCIIEncoding.ASCII.GetString(ms.ToArray());

            Console.WriteLine(txt);
            Assert.IsTrue(txt.Contains(@"<Layers>
    <MapLayer xsi:type=""WmsLayer"">
      <Name>testwms</Name>
      <MinVisible>0</MinVisible>
      <MaxVisible>1.7976931348623157E+308</MaxVisible>
      <OnlineURL>http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?SERVICE=WMS&amp;REQUEST=GetCapabilities&amp;</OnlineURL>
      <WmsUser>test</WmsUser>
      <WmsPassword>pw</WmsPassword>
      <WmsLayers>0,1,2</WmsLayers>
    </MapLayer>
  </Layers>"));
            ms.Close();
        }
Exemplo n.º 2
0
        public void TestSerializeWmsLayer()
        {
            SharpMap.Map             m = new SharpMap.Map();
            SharpMap.Layers.WmsLayer l = new SharpMap.Layers.WmsLayer("testwms", "http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer");
            l.AddChildLayers(l.RootLayer, false);
            m.Layers.Add(l);
            MemoryStream ms = new MemoryStream();

            SharpMap.Serialization.MapSerialization.SaveMapToStream(m, ms);
            string txt = System.Text.ASCIIEncoding.ASCII.GetString(ms.ToArray());

            Console.WriteLine(txt);
            Assert.IsTrue(txt.Contains(@"<Layers>
    <MapLayer xsi:type=""WmsLayer"">
      <Name>testwms</Name>
      <MinVisible>0</MinVisible>
      <MaxVisible>1.7976931348623157E+308</MaxVisible>
      <OnlineURL>http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer</OnlineURL>
      <WmsLayers>0,1,2</WmsLayers>
    </MapLayer>
  </Layers>"));
            ms.Close();
        }
 public void TestSerializeWmsLayer()
 {
     SharpMap.Map m = new SharpMap.Map();
     SharpMap.Layers.WmsLayer l = new SharpMap.Layers.WmsLayer("testwms", "http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer");
     l.AddChildLayers(l.RootLayer, false);
     m.Layers.Add(l);
     MemoryStream ms = new MemoryStream();
     SharpMap.Serialization.MapSerialization.SaveMapToStream(m, ms);
     string txt = System.Text.ASCIIEncoding.ASCII.GetString(ms.ToArray());
     Console.WriteLine(txt);
     Assert.IsTrue(txt.Contains(@"<Layers>
     <MapLayer xsi:type=""WmsLayer"">
       <Name>testwms</Name>
       <MinVisible>0</MinVisible>
       <MaxVisible>1.7976931348623157E+308</MaxVisible>
       <OnlineURL>http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer</OnlineURL>
       <WmsLayers>0,1,2</WmsLayers>
     </MapLayer>
       </Layers>"));
     ms.Close();
 }
 public void TestSerializeWmsLayerWithCredentials()
 {
     SharpMap.Map m = new SharpMap.Map();
     SharpMap.Layers.WmsLayer l = new SharpMap.Layers.WmsLayer("testwms", "http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer", TimeSpan.MaxValue,
         System.Net.WebRequest.DefaultWebProxy, new NetworkCredential("test", "pw"));
     l.AddChildLayers(l.RootLayer, false);
     m.Layers.Add(l);
     MemoryStream ms = new MemoryStream();
     SharpMap.Serialization.MapSerialization.SaveMapToStream(m, ms);
     string txt = System.Text.ASCIIEncoding.ASCII.GetString(ms.ToArray());
     Console.WriteLine(txt);
     Assert.IsTrue(txt.Contains(@"<Layers>
     <MapLayer xsi:type=""WmsLayer"">
       <Name>testwms</Name>
       <MinVisible>0</MinVisible>
       <MaxVisible>1.7976931348623157E+308</MaxVisible>
       <OnlineURL>http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?SERVICE=WMS&amp;REQUEST=GetCapabilities&amp;</OnlineURL>
       <WmsUser>test</WmsUser>
       <WmsPassword>pw</WmsPassword>
       <WmsLayers>0,1,2</WmsLayers>
     </MapLayer>
       </Layers>"));
     ms.Close();
 }