Beispiel #1
0
        public void Test1TwoPointsWithMatching()
        {
            // build test case.
            var router    = new RouterMock(new AttributeCollection(new Itinero.Attributes.Attribute("highway", "residential")));
            var locations = new Coordinate[] {
                new Coordinate(0, 0),
                new Coordinate(1, 1)
            };
            var resolver = new MassResolvingAlgorithm(router, new Itinero.Profiles.Profile[] { Itinero.Osm.Vehicles.Vehicle.Car.Fastest() }, locations,
                                                      (edge, i) =>
            {
                return(true);
            });

            // run.
            resolver.Run();

            // check result.
            Assert.IsNotNull(resolver);
            Assert.IsTrue(resolver.HasRun);
            Assert.IsTrue(resolver.HasSucceeded);
            Assert.AreEqual(0, resolver.Errors.Count);
            Assert.AreEqual(2, resolver.RouterPoints.Count);
            Assert.AreEqual(0, resolver.ResolvedIndexOf(0));
            Assert.AreEqual(1, resolver.ResolvedIndexOf(1));

            // build test case.
            router    = new RouterMock(new AttributeCollection(new Itinero.Attributes.Attribute("highway", "primary")));
            locations = new Coordinate[] {
                new Coordinate(0, 0),
                new Coordinate(1, 1)
            };
            resolver = new MassResolvingAlgorithm(router, new Itinero.Profiles.Profile[] { Itinero.Osm.Vehicles.Vehicle.Car.Fastest() }, locations,
                                                  (edge, i) =>
            {
                return(false);
            });

            // run.
            resolver.Run();

            Assert.IsNotNull(resolver);
            Assert.IsTrue(resolver.HasRun);
            Assert.IsTrue(resolver.HasSucceeded);
            Assert.AreEqual(2, resolver.Errors.Count);
            Assert.AreEqual(LocationErrorCode.NotResolved, resolver.Errors[0].Code);
            Assert.AreEqual(LocationErrorCode.NotResolved, resolver.Errors[1].Code);
        }
Beispiel #2
0
        public void Test2TwoPoints()
        {
            // build test case.
            var router    = new RouterMock();
            var locations = new Coordinate[] {
                new Coordinate(0, 0),
                new Coordinate(180, 1)
            };
            var resolver = new MassResolvingAlgorithm(router, new Itinero.Profiles.Profile[] { Itinero.Osm.Vehicles.Vehicle.Car.Fastest() }, locations);

            // run.
            resolver.Run();

            Assert.IsNotNull(resolver);
            Assert.IsTrue(resolver.HasRun);
            Assert.IsTrue(resolver.HasSucceeded);
            Assert.AreEqual(1, resolver.Errors.Count);
            Assert.IsTrue(resolver.Errors.ContainsKey(1));
            Assert.AreEqual(1, resolver.RouterPoints.Count);
            Assert.AreEqual(0, resolver.ResolvedIndexOf(0));
            Assert.AreEqual(0, resolver.LocationIndexOf(0));

            // build test case.
            locations = new Coordinate[] {
                new Coordinate(180, 0),
                new Coordinate(1, 1)
            };
            resolver = new MassResolvingAlgorithm(router, new Itinero.Profiles.Profile[] { Itinero.Osm.Vehicles.Vehicle.Car.Fastest() }, locations);

            // run.
            resolver.Run();

            Assert.IsNotNull(resolver);
            Assert.IsTrue(resolver.HasRun);
            Assert.IsTrue(resolver.HasSucceeded);
            Assert.AreEqual(1, resolver.Errors.Count);
            Assert.IsTrue(resolver.Errors.ContainsKey(0));
            Assert.AreEqual(0, resolver.ResolvedIndexOf(1));
            Assert.AreEqual(1, resolver.LocationIndexOf(0));
        }