Exemplo n.º 1
0
        public void TestAddNode()
        {
            Node test_node = OsmBaseFactory.CreateNode(-1);
            MemoryDataSource source = new MemoryDataSource();
            source.AddNode(test_node);

            // test if the node is actually there.
            Assert.AreEqual(test_node, source.GetNode(-1));

            // test if the node was not remove after getting it.
            Assert.AreEqual(test_node, source.GetNode(-1));

            // test if the node will be retrieved using a list of ids.
            List<long> ids = new List<long>();
            ids.Add(-1);
            IList<Node> nodes = source.GetNodes(ids);
            Assert.IsNotNull(nodes);
            Assert.AreEqual(1, nodes.Count);
            Assert.AreEqual(test_node, nodes[0]);
        }
Exemplo n.º 2
0
        public void TestAddRelation()
        {
            Relation test_relation = OsmBaseFactory.CreateRelation(-1);
            MemoryDataSource source = new MemoryDataSource();
            source.AddRelation(test_relation);

            // test if the relation is actually there.
            Assert.AreEqual(test_relation, source.GetRelation(-1));

            // test if the relation was not remove after getting it.
            Assert.AreEqual(test_relation, source.GetRelation(-1));

            // test if the relation will be retrieved using a list of ids.
            List<long> ids = new List<long>();
            ids.Add(-1);
            IList<Relation> relations = source.GetRelations(ids);
            Assert.IsNotNull(relations);
            Assert.AreEqual(1, relations.Count);
            Assert.AreEqual(test_relation, relations[0]);
        }
Exemplo n.º 3
0
        public void TestAddWay()
        {
            Way test_way = OsmBaseFactory.CreateWay(-1);
            MemoryDataSource source = new MemoryDataSource();
            source.AddWay(test_way);

            // test if the way is actually there.
            Assert.AreEqual(test_way, source.GetWay(-1));

            // test if the way was not remove after getting it.
            Assert.AreEqual(test_way, source.GetWay(-1));

            // test if the way will be retrieved using a list of ids.
            List<long> ids = new List<long>();
            ids.Add(-1);
            IList<Way> ways = source.GetWays(ids);
            Assert.IsNotNull(ways);
            Assert.AreEqual(1, ways.Count);
            Assert.AreEqual(test_way, ways[0]);
        }
Exemplo n.º 4
0
        public void TestRemoveWay()
        {
            Way test_way = OsmBaseFactory.CreateWay(-1);
            MemoryDataSource source = new MemoryDataSource();
            source.AddWay(test_way);

            // test if the way is actually there.
            Assert.AreEqual(test_way, source.GetWay(-1));

            // remove the way.
            source.RemoveWay(-1);

            // test if the way is actually gone.
            Assert.IsNull(source.GetWay(-1));
        }
Exemplo n.º 5
0
        public void TestWayNodeRelation()
        {
            Way test_way = OsmBaseFactory.CreateWay(-1);
            Node node1 = OsmBaseFactory.CreateNode(-1);
            test_way.Nodes.Add(node1);
            Node node2 = OsmBaseFactory.CreateNode(-2);
            test_way.Nodes.Add(node2);
            MemoryDataSource source = new MemoryDataSource();
            source.AddWay(test_way);

            // test if node1 is present.
            Assert.AreEqual(node1, source.GetNode(-1));
            Assert.AreEqual(node2, source.GetNode(-2));
            Assert.AreEqual(test_way, source.GetWay(-1));

            // test if the way is present in the node's way list.
            IList<Way> ways = source.GetWaysFor(node1);
            Assert.IsNotNull(ways);
            Assert.IsTrue(ways.Contains(test_way));
            ways = source.GetWaysFor(node2);
            Assert.IsTrue(ways.Contains(test_way));
        }
Exemplo n.º 6
0
        public void TestRemoveRelation()
        {
            Relation test_relation = OsmBaseFactory.CreateRelation(-1);
            MemoryDataSource source = new MemoryDataSource();
            source.AddRelation(test_relation);

            // test if the relation is actually there.
            Assert.AreEqual(test_relation, source.GetRelation(-1));

            // remove the relation.
            source.RemoveRelation(-1);

            // test if the relation is actually gone.
            Assert.IsNull(source.GetRelation(-1));
        }
Exemplo n.º 7
0
        public void TestRemoveNode()
        {
            Node test_node = OsmBaseFactory.CreateNode(-1);
            MemoryDataSource source = new MemoryDataSource();
            source.AddNode(test_node);

            // test if the node is actually there.
            Assert.AreEqual(test_node, source.GetNode(-1));

            // remove the node.
            source.RemoveNode(-1);

            // test if the node is actually gone.
            Assert.IsNull(source.GetNode(-1));
        }
 /// <summary>
 /// Creates a memory data processor target.
 /// </summary>
 /// <param name="string_table"></param>
 /// <param name="source"></param>
 public MemoryDataSourceProcessorTarget(ObjectTable<string> string_table, MemoryDataSource source)
 {
     _source = source;
     _string_table = string_table;
 }
 /// <summary>
 /// Creates a memory data processor target.
 /// </summary>
 /// <param name="source"></param>
 public MemoryDataSourceProcessorTarget(MemoryDataSource source)
 {
     _source = source;
 }
Exemplo n.º 10
0
        /// <summary>
        /// Tests reading a PBF and see if the data is there.
        /// </summary>
        /// <param name="resource"></param>
        private void TestReadPBF(string resource)
        {
            // create the pbf source from a pbf in the resources of this assembly.
            PBFDataProcessorSource source = new PBFDataProcessorSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(resource));

            // pull the data from the source into the memory data source.
            MemoryDataSource data = new MemoryDataSource();
            data.PullFromSource(source);

            // test the data.
            this.TestData(data);
        }