本文整理汇总了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);
}
示例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);
}
示例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);
}