public void VectorTile_GeoJSON() { Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "geojson.input")); string json = @"{""type"":""FeatureCollection"",""name"":""layer"",""features"":[{""type"":""Feature"",""geometry"":{""type"":""Point"",""coordinates"":[-121.9921875,47.9899216674142]},""properties"":{""name"":""geojson data""}}]}"; VectorTile v = new VectorTile(0, 0, 0); v.AddGeoJSON(json, "layer"); byte[] bytes = v.GetData(); Assert.AreEqual(53, bytes.Length); Assert.IsFalse(v.Empty()); Assert.IsTrue(v.Painted()); CollectionAssert.AreEquivalent(new List <string>() { "layer" }, v.Names().ToList()); //ToGeoJSON dynamic expected = JObject.Parse(json); var results = new List <JObject>() { JObject.Parse(v.ToGeoJSON("layer")), JObject.Parse(v.ToGeoJSON(0)) }; foreach (dynamic actual in results) { Assert.AreEqual(expected.FeatureCollection, actual.FeatureCollection); Assert.AreEqual(expected.features[0].properties.name, actual.features[0].properties.name); Assert.AreEqual(expected.features[0].geometry.type, actual.features[0].geometry.type); Assert.AreEqual(expected.features[0].geometry.coordinates[0], actual.features[0].geometry.coordinates[0]); Assert.AreEqual(expected.features[0].geometry.coordinates[1], actual.features[0].geometry.coordinates[1]); } }
public void VectorTile_Init() { VectorTile v = new VectorTile(0, 0, 0); Assert.AreEqual(256, v.Width()); Assert.AreEqual(256, v.Height()); Assert.IsFalse(v.Painted()); Assert.AreEqual("", v.IsSolid()); Assert.IsTrue(v.Empty()); Assert.AreEqual(0, v.GetData().Length); }
public void VectorTile_GetSetData() { VectorTile v = new VectorTile(9, 112, 195); byte[] bytes = File.ReadAllBytes(@".\data\9.112.195.pbf"); v.SetData(bytes); Assert.IsFalse(v.Empty()); Assert.IsTrue(v.Painted()); byte[] actual = v.GetData(); CollectionAssert.AreEquivalent(bytes, actual); }
public void VectorTile_Clear() { VectorTile v = new VectorTile(9, 112, 195); byte[] bytes = File.ReadAllBytes(@".\data\9.112.195.pbf"); v.SetData(bytes); Assert.IsFalse(v.Empty()); Assert.IsTrue(v.Painted()); CollectionAssert.AreEquivalent(new List <string>() { "world" }, v.Names().ToList()); byte[] actual = v.GetData(); Assert.AreEqual(bytes.Length, actual.Length); v.Clear(); Assert.IsTrue(v.Empty()); Assert.IsFalse(v.Painted()); Assert.AreEqual("", v.IsSolid()); CollectionAssert.AreEquivalent(new List <string>(), v.Names().ToList()); actual = v.GetData(); Assert.AreEqual(0, actual.Length); }
public void VectorTile_AddImage() { VectorTile v = new VectorTile(1, 0, 0); byte[] bytes = File.ReadAllBytes(@".\data\world_1.0.0.png"); v.AddImage(bytes, "raster"); Assert.IsFalse(v.Empty()); Assert.IsTrue(v.Painted()); CollectionAssert.AreEquivalent(new List <string>() { "raster" }, v.Names().ToList()); Map m = new Map(256, 256); m.Load(@".\data\raster_style.xml"); Image i = new Image(256, 256); v.Render(m, i); Assert.AreEqual(0, i.Compare(Image.FromBytes(bytes))); }
public void VectorTile_GetSetData() { VectorTile v = new VectorTile(9,112,195); byte[] bytes = File.ReadAllBytes(@".\data\9.112.195.pbf"); v.SetData(bytes); Assert.IsFalse(v.Empty()); Assert.IsTrue(v.Painted()); byte[] actual = v.GetData(); CollectionAssert.AreEquivalent(bytes, actual); }
public void VectorTile_Clear() { VectorTile v = new VectorTile(9,112,195); byte[] bytes = File.ReadAllBytes(@".\data\9.112.195.pbf"); v.SetData(bytes); Assert.IsFalse(v.Empty()); Assert.IsTrue(v.Painted()); CollectionAssert.AreEquivalent(new List<string>() { "world" }, v.Names().ToList()); byte[] actual = v.GetData(); Assert.AreEqual(bytes.Length, actual.Length); v.Clear(); Assert.IsTrue(v.Empty()); Assert.IsFalse(v.Painted()); Assert.AreEqual("",v.IsSolid()); CollectionAssert.AreEquivalent(new List<string>(), v.Names().ToList()); actual = v.GetData(); Assert.AreEqual(0, actual.Length); }
public void VectorTile_GeoJSON() { Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "geojson.input")); string json = @"{""type"":""FeatureCollection"",""name"":""layer"",""features"":[{""type"":""Feature"",""geometry"":{""type"":""Point"",""coordinates"":[-121.9921875,47.9899216674142]},""properties"":{""name"":""geojson data""}}]}"; VectorTile v = new VectorTile(0, 0, 0); v.AddGeoJSON(json, "layer"); byte[] bytes = v.GetData(); Assert.AreEqual(53, bytes.Length); Assert.IsFalse(v.Empty()); Assert.IsTrue(v.Painted()); CollectionAssert.AreEquivalent(new List<string>() { "layer" }, v.Names().ToList()); //ToGeoJSON dynamic expected = JObject.Parse(json); var results = new List<JObject>() { JObject.Parse(v.ToGeoJSON("layer")), JObject.Parse(v.ToGeoJSON(0)) }; foreach (dynamic actual in results) { Assert.AreEqual(expected.FeatureCollection, actual.FeatureCollection); Assert.AreEqual(expected.features[0].properties.name, actual.features[0].properties.name); Assert.AreEqual(expected.features[0].geometry.type, actual.features[0].geometry.type); Assert.AreEqual(expected.features[0].geometry.coordinates[0], actual.features[0].geometry.coordinates[0]); Assert.AreEqual(expected.features[0].geometry.coordinates[1], actual.features[0].geometry.coordinates[1]); } }
public void VectorTile_AddImage() { VectorTile v = new VectorTile(1, 0, 0); byte[] bytes = File.ReadAllBytes(@".\data\world_1.0.0.png"); v.AddImage(bytes, "raster"); Assert.IsFalse(v.Empty()); Assert.IsTrue(v.Painted()); CollectionAssert.AreEquivalent(new List<string>() { "raster" }, v.Names().ToList()); Map m = new Map(256, 256); m.Load(@".\data\raster_style.xml"); Image i = new Image(256, 256); v.Render(m, i); Assert.AreEqual(0,i.Compare(Image.FromBytes(bytes))); }