public void TestMapCSSSimpleEval() { MemoryDataSource source = new MemoryDataSource( Node.Create(1, 0, 0), Node.Create(2, 1, 0), Node.Create(3, 0, 1), Way.Create(1, new TagsCollection( Tag.Create("width", "10")), 1, 2, 3, 1)); // test closed way. string css = "way { " + " width: eval(\"tag('width')\"); " + " color: green; " + "} "; // create the projection and scene objects. var mercator = new WebMercator(); Scene2D scene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), 16); // create the projection and scene objects. scene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), 16); // create the interpreter. MapCSSInterpreter interpreter = new MapCSSInterpreter(css, new MapCSSDictionaryImageSource()); interpreter.Translate(scene, mercator, source, source.GetWay(1)); // test the scene contents. Assert.AreEqual(1, scene.Count); Primitive2D primitive = scene.Get(0); Assert.IsInstanceOf<Line2D>(primitive); Line2D line = (primitive as Line2D); Assert.AreEqual(10, line.Width); }
public void TestMapCSSArea() { MemoryDataSource source = new MemoryDataSource( Node.Create(1, 0, 0), Node.Create(2, 1, 0), Node.Create(3, 0, 1), Way.Create(1, new TagsCollection( Tag.Create("area", "yes")), 1, 2, 3, 1)); // test closed way. string css = "area { " + " fill-color: black; " + "} "; // create the projection and scene objects. var mercator = new WebMercator(); Scene2D scene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), 16); // create the projection and scene objects. scene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), 16); // create the interpreter. MapCSSInterpreter interpreter = new MapCSSInterpreter(css, new MapCSSDictionaryImageSource()); interpreter.Translate(scene, mercator, source, source.GetWay(1)); // test the scene contents. Assert.AreEqual(1, scene.Count); Primitive2D primitive = scene.Get(0); Assert.IsInstanceOf<Polygon2D>(primitive); }
public void TestRemoveWay() { Way testWay = new Way(); testWay.Id = -1; var source = new MemoryDataSource(); source.AddWay(testWay); // test if the way is actually there. Assert.AreEqual(testWay, source.GetWay(-1)); // remove the way. source.RemoveWay(-1); // test if the way is actually gone. Assert.IsNull(source.GetWay(-1)); }
public void TestAddWayAndNodes() { Way testWay = new Way(); testWay.Id = 1; testWay.Nodes = new List<long>(); testWay.Nodes.Add(1); testWay.Nodes.Add(2); Node node1 = new Node(); node1.Id = 1; node1.Longitude = 0; node1.Latitude = 0; Node node2 = new Node(); node2.Id = 2; node2.Longitude = 0; node2.Latitude = 0; var source = new MemoryDataSource(); source.AddWay(testWay); IList<Way> resultWays = source.GetWaysFor(node1); Assert.IsNotNull(resultWays); Assert.AreEqual(1, resultWays.Count); Assert.AreEqual(testWay, resultWays[0]); // test if the way is actually there. Assert.AreEqual(testWay, source.GetWay(1)); // test if the way was not removed after getting it. Assert.AreEqual(testWay, source.GetWay(1)); }
public void TestAddWay() { Way testWay = new Way(); testWay.Id = -1; var source = new MemoryDataSource(); source.AddWay(testWay); // test if the way is actually there. Assert.AreEqual(testWay, source.GetWay(-1)); // test if the way was not remove after getting it. Assert.AreEqual(testWay, source.GetWays(new List<long>() { -1 })[0]); // test if the way is in the list of ways. Assert.AreEqual(testWay, new List<Way>(source.GetWays())[0]); // test if the way will be retrieved using a list of ids. var ids = new List<long>(); ids.Add(-1); IList<Way> ways = source.GetWays(ids); Assert.IsNotNull(ways); Assert.AreEqual(1, ways.Count); Assert.AreEqual(testWay, ways[0]); }
public void TestMapCSSClosedWay() { // tests map css interpretation of a closed way marked as an area. MemoryDataSource source = new MemoryDataSource( Node.Create(1, 0, 0), Node.Create(2, 1, 0), Node.Create(3, 0, 1), Way.Create(1, new SimpleTagsCollection( Tag.Create("area", "yes")), 1, 2, 3, 1)); // test closed way. string css = "way[area] { " + " fill-color: black; " + "} "; // create the projection and scene objects. var mercator = new WebMercator(); Scene2D scene = new Scene2DSimple(); // create the interpreter. MapCSSInterpreter interpreter = new MapCSSInterpreter(css, new MapCSSDictionaryImageSource()); interpreter.Translate(scene, mercator, source, source.GetWay(1)); // test the scene contents. Assert.AreEqual(1, scene.Count); List<IScene2DPrimitive> primitives = scene.Get(0); Assert.IsNotNull(primitives); Assert.AreEqual(1, primitives.Count); IScene2DPrimitive primitive = primitives[0]; Assert.IsInstanceOf<Polygon2D>(primitive); }