public void TestGetBoundingBox()
        {
            var dataSource = new MemoryDataSource();

            // test nodes.
            Node node = new Node();
            node.Id = 1;
            node.Longitude = -2;
            node.Latitude = -1;
            dataSource.AddNode(node);

            node = new Node();
            node.Id = 2;
            node.Longitude = 2;
            node.Latitude = 1;
            dataSource.AddNode(node);

            GeoCoordinateBox box = dataSource.BoundingBox;

            IList<OsmGeo> boxResults = dataSource.Get(box, null);
            Assert.IsNotNull(boxResults);
            Assert.AreEqual(1, boxResults.Count);

            boxResults = dataSource.Get(box.Resize(0.1), null);
            Assert.IsNotNull(boxResults);
            Assert.AreEqual(2, boxResults.Count);

            node = new Node();
            node.Id = 3;
            node.Latitude = 10;
            node.Longitude = 10;
            dataSource.AddNode(node);

            node = new Node();
            node.Id = 4;
            node.Latitude = -10;
            node.Longitude = -10;
            dataSource.AddNode(node);

            boxResults = dataSource.Get(box, null);
            Assert.IsNotNull(boxResults);
            Assert.AreEqual(1, boxResults.Count);

            boxResults = dataSource.Get(box.Resize(0.1), null);
            Assert.IsNotNull(boxResults);
            Assert.AreEqual(2, boxResults.Count);

            // test ways.
            Way positive = new Way();
            positive.Id = 1;
            positive.Nodes = new List<long>();
            positive.Nodes.Add(1);
            positive.Nodes.Add(2);
            dataSource.AddWay(positive);

            Way halfPositive = new Way();
            halfPositive.Id = 2;
            halfPositive.Nodes = new List<long>();
            halfPositive.Nodes.Add(1);
            halfPositive.Nodes.Add(3);
            dataSource.AddWay(halfPositive);

            Way negative = new Way();
            negative.Id = 3;
            negative.Nodes = new List<long>();
            negative.Nodes.Add(3);
            negative.Nodes.Add(4);
            dataSource.AddWay(negative);

            HashSet<OsmGeo> boxResultWithWays = new HashSet<OsmGeo>(dataSource.Get(box, null));
            Assert.IsTrue(boxResultWithWays.Contains(positive));
            Assert.IsTrue(boxResultWithWays.Contains(halfPositive));
            Assert.IsFalse(boxResultWithWays.Contains(negative));

            // test relations.
            Relation positiveRelation1 = new Relation();
            positiveRelation1.Id = 1;
            positiveRelation1.Members = new List<RelationMember>();
            positiveRelation1.Members.Add(new RelationMember()
            {
                MemberId = 1,
                MemberType = OsmGeoType.Node,
                MemberRole = "node"
            });
            dataSource.AddRelation(positiveRelation1);

            Relation positiveRelation2 = new Relation();
            positiveRelation2.Id = 2;
            positiveRelation2.Members = new List<RelationMember>();
            positiveRelation2.Members.Add(new RelationMember()
            {
                MemberId = 1,
                MemberType = OsmGeoType.Way,
                MemberRole = "way"
            });
            dataSource.AddRelation(positiveRelation2);

            Relation negativeRelation3 = new Relation();
            negativeRelation3.Id = 3;
            negativeRelation3.Members = new List<RelationMember>();
            negativeRelation3.Members.Add(new RelationMember()
            {
                MemberId = 3,
                MemberType = OsmGeoType.Way,
                MemberRole = "way"
            });
            dataSource.AddRelation(positiveRelation2);

            HashSet<OsmGeo> boxResultWithWaysAndRelations = new HashSet<OsmGeo>(dataSource.Get(box, null));
            Assert.IsTrue(boxResultWithWaysAndRelations.Contains(positiveRelation1));
            Assert.IsTrue(boxResultWithWaysAndRelations.Contains(positiveRelation2));
            Assert.IsFalse(boxResultWithWaysAndRelations.Contains(negativeRelation3));

            // test recursive relations.
            Relation recusive1 = new Relation();
            recusive1.Id = 10;
            recusive1.Members = new List<RelationMember>();
            recusive1.Members.Add(new RelationMember()
            {
                MemberId = 1,
                MemberType = OsmGeoType.Relation,
                MemberRole = "relation"
            });
            dataSource.AddRelation(recusive1);
            Relation recusive2 = new Relation();
            recusive2.Id = 11;
            recusive2.Members = new List<RelationMember>();
            recusive2.Members.Add(new RelationMember()
            {
                MemberId = 10,
                MemberType = OsmGeoType.Relation,
                MemberRole = "relation"
            });
            dataSource.AddRelation(recusive2);
            Relation recusive3 = new Relation();
            recusive3.Id = 12;
            recusive3.Members = new List<RelationMember>();
            recusive3.Members.Add(new RelationMember()
            {
                MemberId = 11,
                MemberType = OsmGeoType.Relation,
                MemberRole = "relation"
            });
            dataSource.AddRelation(recusive3);

            boxResultWithWaysAndRelations = new HashSet<OsmGeo>(dataSource.Get(box, null));
            Assert.IsTrue(boxResultWithWaysAndRelations.Contains(recusive1));
            Assert.IsTrue(boxResultWithWaysAndRelations.Contains(recusive2));
            Assert.IsTrue(boxResultWithWaysAndRelations.Contains(recusive3));
        }