コード例 #1
0
        public void reversed()
        {
            // tests when the last node of of way, matches the last node of another way
            var ringOrganiser = new RingOrganiser();
            var c1            = new Coordinates {
                Lon = 150.91094970703125, Lat = -23.26027250312138
            };
            var c2 = new Coordinates {
                Lon = 150.86151123046875, Lat = -23.28928776494912
            };
            var c3 = new Coordinates {
                Lon = 150.84228515625, Lat = -23.342255835130516
            };
            var c4 = new Coordinates {
                Lon = 150.87799072265625, Lat = -23.26027250312138
            };
            var c5 = new Coordinates {
                Lon = 150.9624481201172, Lat = -23.357385691338713
            };
            var c6 = new Coordinates {
                Lon = 150.96656799316406, Lat = -23.295594594020272
            };

            var way1 = new Way {
                Id = "1", Geometry = new List <Coordinates> {
                    c3, c2, c1
                }
            };
            var way2 = new Way {
                Id = "2", Geometry = new List <Coordinates> {
                    c3, c4, c5
                }
            };
            var way3 = new Way {
                Id = "3", Geometry = new List <Coordinates> {
                    c5, c6, c1
                }
            };

            SetNodes(way1);
            SetNodes(way2);
            SetNodes(way3);
            var joined = ringOrganiser.AssignToRings(new List <Way> {
                way1, way2, way3
            });

            Assert.That(joined[0].Count == 7);
            Assert.That(NodeMatchesCoordinates(joined[0][0], c5));
            Assert.That(NodeMatchesCoordinates(joined[0][1], c6));
            Assert.That(NodeMatchesCoordinates(joined[0][2], c1));
            Assert.That(NodeMatchesCoordinates(joined[0][3], c2));
            Assert.That(NodeMatchesCoordinates(joined[0][4], c3));
            Assert.That(NodeMatchesCoordinates(joined[0][5], c4));
            Assert.That(NodeMatchesCoordinates(joined[0][6], c5));
        }
コード例 #2
0
        public void if_2_ways_create_a_ring_then_join_them()
        {
            var ringOrganiser = new RingOrganiser();
            var c1            = new Coordinates {
                Lon = 1.0, Lat = 1.0
            };
            var c2 = new Coordinates {
                Lon = 2.0, Lat = 2.0
            };
            var c3 = new Coordinates {
                Lon = 1.0, Lat = 2.0
            };

            var way1 = new Way()
            {
                Geometry = new List <Coordinates> {
                    c1, c2, c3
                }
            };
            var way2 = new Way()
            {
                Geometry = new List <Coordinates> {
                    c3, c1
                }
            };

            SetNodes(way1);
            SetNodes(way2);
            var joined = ringOrganiser.AssignToRings(new List <Way> {
                way1, way2
            });

            Assert.That(joined[0].Count == 4);
            Assert.That(NodeMatchesCoordinates(joined[0][0], c3));
            Assert.That(NodeMatchesCoordinates(joined[0][1], c1));
            Assert.That(NodeMatchesCoordinates(joined[0][2], c2));
            Assert.That(NodeMatchesCoordinates(joined[0][3], c3));
        }