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


C# Grid.Encode方法代码示例

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


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

示例1: 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

示例2: 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

示例3: VectorTile_Render_Grid

        public void VectorTile_Render_Grid()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Map m = new Map(256, 256);
            m.Load(@".\data\layer.xml");
            m.Extent = new double[] { -20037508.34, 0, 0, 20037508.34 };
            VectorTile v = new VectorTile(1, 0, 0);
            m.Render(v);

            VectorTile v2 = new VectorTile(1, 0, 0);
            v2.SetData(v.GetData());

            Map m2 = new Map(256, 256);
            m2.Load(@".\data\style.xml");
            Grid g = new Grid(256, 256);
            var options = new Dictionary<string, object>()
            {
                {"Fields", new List<string>() { "FIPS" } },
                {"Layer", "world" }
            };
            v2.Render(m2, g, options);
            Dictionary<string, object > grid = g.Encode();
            Assert.AreEqual(grid.Keys.Count, 3);

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

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

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


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