当前位置: 首页>>代码示例>>C#>>正文


C# Map.Render方法代码示例

本文整理汇总了C#中Map.Render方法的典型用法代码示例。如果您正苦于以下问题:C# Map.Render方法的具体用法?C# Map.Render怎么用?C# Map.Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map的用法示例。


在下文中一共展示了Map.Render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Image_SetGrayScaleToAlpha

        public void Image_SetGrayScaleToAlpha()
        {
            Map m = new Map(256, 256);
            Image i = new Image(256, 256);
            m.Background = new Color("white");
            m.Render(i);
            i.SetGrayScaleToAlpha();
            Color c = i.GetPixel(0, 0);
            Assert.AreEqual(c.R, 255);
            Assert.AreEqual(c.G, 255);
            Assert.AreEqual(c.B, 255);
            Assert.AreEqual(c.A, 255);

            m.Background = new Color("black");
            m.Render(i);
            i.SetGrayScaleToAlpha();
            Color c1 = i.GetPixel(0, 0);
            Assert.AreEqual(c1.R, 255);
            Assert.AreEqual(c1.G, 255);
            Assert.AreEqual(c1.B, 255);
            Assert.AreEqual(c1.A, 0);

            i.SetGrayScaleToAlpha(new Color("green"));
            Color c2 = i.GetPixel(0, 0);
            Assert.AreEqual(c2.R, 0);
            Assert.AreEqual(c2.G, 128);
            Assert.AreEqual(c2.B, 0);
            Assert.AreEqual(c2.A, 255);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:29,代码来源:ImageTests.cs

示例2: Grid_Encode

        public void Grid_Encode()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Map m = new Map(256, 256);
            m.Load(@".\data\test.xml");
            m.ZoomAll();
            Grid g = new Grid(256, 256);
            var options = new Dictionary<string, object>()
            {
                {"Fields", new List<string>() { "FIPS" } },
                {"Layer", "world" }
            };

            m.Render(g, options);
            Dictionary<string, object> UTFGridDict = g.Encode();

            Assert.AreEqual(UTFGridDict.Keys.Count, 3);

            //Test for keys
            List<string> keyList = (List<string>)UTFGridDict["keys"];
            Assert.AreNotEqual(keyList.Count, 0);

            //Test for data
            Dictionary<string, object> dataDict = (Dictionary<string, object>)UTFGridDict["data"];
            Assert.AreNotEqual(dataDict.Count, 0);

            //data count should equal keys + 1
            Assert.AreEqual(keyList.Count, dataDict.Count + 1);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:29,代码来源:GridTests.cs

示例3: GridView_IsSolid

        public void GridView_IsSolid()
        {
            Map m = new Map(256, 256);
            m.AddLayer(new Layer("test"));
            m.ZoomAll();
            Grid g = new Grid(256, 256);
            m.Render(g);
            GridView v1 = g.View(0, 0, 256, 256);
            Assert.IsTrue(v1.IsSolid());

            m.Clear();
            g.Clear();
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            m.Load(@".\data\test.xml");
            m.ZoomAll();
            m.Render(g);
            GridView v2 = g.View(0, 0, 256, 256);
            Assert.IsFalse(v2.IsSolid());
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:19,代码来源:GridViewTests.cs

示例4: Image_Open

        public void Image_Open()
        {
            Map m = new Map(10, 10);
            Image i1 = new Image(10, 10);
            m.Background = new Color("green");
            m.Render(i1);

            Image i2 = Image.Open(@".\data\10x10green.png");
            Assert.AreEqual(i1.Compare(i2), 0);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:10,代码来源:ImageTests.cs

示例5: VectorTile_SimpleComposite

        public void VectorTile_SimpleComposite()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Map m = new Map(256, 256);
            m.Load(@".\data\layer.xml");
            m.ZoomAll();

            VectorTile v1 = new VectorTile(0, 0, 0, 256, 256);
            m.Render(v1);
            int v1before = v1.GetData().Length;

            VectorTile v2 = new VectorTile(0, 0, 0, 256, 256);
            m.Render(v2);

            v1.Composite(new List<VectorTile>() { v2 });
            int v1after = v1.GetData().Length;

            Assert.AreEqual(v1before * 2, v1after);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:19,代码来源:VectorTileTests.cs

示例6: ImageView_Encode

 public void ImageView_Encode()
 {
     Map m = new Map(100, 100);
     Image i = new Image(100, 100);
     m.Background = new Color("green");
     m.Render(i);
     ImageView iv = i.View(0, 0, 10, 10);
     byte[] bytes1 = iv.Encode("png");
     byte[] bytes2 = File.ReadAllBytes(@".\data\10x10green.png");
     CollectionAssert.AreEqual(bytes1, bytes2);
 }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:11,代码来源:ImageViewTests.cs

示例7: Render

		internal override void Render(Map map, Geometry2D.Single.Point leftTop, Geometry2D.Single.Point rightTop, Geometry2D.Single.Point leftBottom, Geometry2D.Single.Point rightBottom, Geometry2D.Single.Box destination)
		{
			if (map.NotNull())
				map.Render(() => this.Channels[0].Backend.Render(leftTop, rightTop, leftBottom, rightBottom, destination), this.Channels);
			else
			{
				this.Channels[0].Backend.Use();
				this.Channels[0].Backend.Render(leftTop, rightTop, leftBottom, rightBottom, destination);
				this.Channels[0].Backend.UnUse();
			}
		}
开发者ID:imintsystems,项目名称:Kean,代码行数:11,代码来源:Planar.cs

示例8: Image_FromBytes

        public void Image_FromBytes()
        {
            Map m = new Map(10, 10);
            Image i1 = new Image(10, 10);
            m.Background = new Color("green");
            m.Render(i1);

            byte[] buffer = File.ReadAllBytes(@".\data\10x10green.png");
            Image i2 = Image.FromBytes(buffer);
            Assert.AreEqual(i1.Compare(i2), 0);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:11,代码来源:ImageTests.cs

示例9: GridView_GetPixel

 public void GridView_GetPixel()
 {
     Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
     Map m = new Map(256, 256);
     m.Load(@".\data\test.xml");
     m.ZoomAll();
     Grid g = new Grid(256, 256);
     m.Render(g);
     GridView v = g.View(0, 0, 256, 256);
     long pixel = v.GetPixel(25, 100);
     Assert.AreEqual(207, pixel);
 }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:12,代码来源:GridViewTests.cs

示例10: VectorTile_OverzoomComposite

        public void VectorTile_OverzoomComposite()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Map m = new Map(256, 256);
            m.Load(@".\data\layer.xml");

            VectorTile v1 = new VectorTile(1, 0, 0, 256, 256);
            m.ZoomToBox(-20037508.34, 0, 0, 20037508.34);
            m.Render(v1);
            int v1before = v1.GetData().Length;

            VectorTile v2 = new VectorTile(0, 0, 0, 256, 256);
            m.ZoomToBox(-20037508.34, -20037508.34, 20037508.34, 20037508.34);
            m.Render(v2);

            v1.Composite(new List<VectorTile>() { v2 });
            int v1after = v1.GetData().Length;

            //composite bytes will actually be a little bit bigger than 2* original
            //Assert.AreEqual(v1before * 2, v1after);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:21,代码来源:VectorTileTests.cs

示例11: Grid_Encode_Resolution

        public void Grid_Encode_Resolution()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Map m = new Map(256, 256);
            m.Load(@".\data\test.xml");
            m.ZoomAll();
            Grid g1 = new Grid(256, 256);
            m.Render(g1);
            List<string> data = (List<string>) g1.Encode()["grid"];
            Assert.AreEqual(64, data.Count());
            Assert.AreEqual(64, data[0].Length);

            Grid g2 = new Grid(256, 256);
            m.Render(g2);
            var options = new Dictionary<string, object>()
            {
                { "Resolution", 1 }
            };
            data = (List<string>)g1.Encode(options)["grid"];
            Assert.AreEqual(256, data.Count());
            Assert.AreEqual(256, data[0].Length);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:22,代码来源:GridTests.cs

示例12: ImageView_Save

 public void ImageView_Save()
 {
     Map m = new Map(100, 100);
     Image i = new Image(100, 100);
     m.Background = new Color("green");
     m.Render(i);
     ImageView iv = i.View(0,0,10,10);
     string filename = @".\data\tmp\" + Guid.NewGuid().ToString() + ".png";
     iv.Save(filename);
     byte[] bytes1 = File.ReadAllBytes(filename);
     byte[] bytes2 = File.ReadAllBytes(@".\data\10x10green.png");
     CollectionAssert.AreEqual(bytes1, bytes2);
 }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:13,代码来源:ImageViewTests.cs

示例13: ImageView_Init

        public void ImageView_Init()
        {
            Map m = new Map(256, 256);
            Image i = new Image(256, 256);
            ImageView iv = i.View(0, 0, 256, 256);
            Assert.IsTrue(iv.IsSolid());
            Color pixel = iv.GetPixel(0, 0);
            Assert.AreEqual(pixel.ToString(), "rgba(0,0,0,0.0)");

            m.Background = new Color(255, 255, 255);
            m.Render(i);
            iv = i.View(0, 0, 256, 256);
            Assert.IsTrue(iv.IsSolid());
            pixel = iv.GetPixel(0, 0);
            Assert.AreEqual(pixel.ToString(), "rgb(255,255,255)");
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:16,代码来源:ImageViewTests.cs

示例14: Image_Save

        public void Image_Save()
        {
            Map m = new Map(10, 10);
            Image i1 = new Image(10, 10);
            m.Background = new Color("green");
            m.Render(i1);
            string filename = @".\data\tmp\" + Guid.NewGuid().ToString() + ".png";
            i1.Save(filename);

            MD5 md5 = MD5.Create();
            byte[] hash1 = md5.ComputeHash(File.ReadAllBytes(filename));
            byte[] hash2 = md5.ComputeHash(File.ReadAllBytes(@".\data\10x10green.png"));
            CollectionAssert.AreEqual(hash1, hash2);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:14,代码来源:ImageTests.cs

示例15: DoNotRenderLabelsForVectorLayerFeaturesWhenLabelsAreNotVisible

        public void DoNotRenderLabelsForVectorLayerFeaturesWhenLabelsAreNotVisible()
        {
            var featureProvider = new DataTableFeatureProvider();
            featureProvider.Add(new WKTReader().Read("POINT(0 0)"));
            featureProvider.Add(new WKTReader().Read("POINT(100 100)"));

            var layer = new VectorLayer
                            {
                                DataSource = featureProvider
                            };

            // make label layer use delegate so that we can check if it renders
            var callCount = 0;
            layer.LabelLayer.LabelStringDelegate = delegate(IFeature feature)
                                                       {
                                                           callCount++;
                                                           return feature.ToString();
                                                       };

            var map = new Map {Layers = {layer}, Size = new Size(1000, 1000)};
            map.Render();

            callCount
                .Should("labels are not rendered when label layer is not visible").Be.EqualTo(0);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:VectorLayerTest.cs


注:本文中的Map.Render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。