/// <summary>
        /// Returns a new router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="embeddedName"></param>
        /// <param name="contract"></param>
        /// <returns></returns>
        public override Router BuildRouter(IOsmRoutingInterpreter interpreter, string embeddedName, bool contract)
        {
            if (_data == null)
            {
                _data = new Dictionary<string, DynamicGraphRouterDataSource<CHEdgeData>>();
            }
            DynamicGraphRouterDataSource<CHEdgeData> data = null;
            if (!_data.TryGetValue(embeddedName, out data))
            {
                var tagsIndex = new SimpleTagsIndex();

                // do the data processing.
                data =
                    new DynamicGraphRouterDataSource<CHEdgeData>(tagsIndex);
                var targetData = new CHEdgeGraphOsmStreamTarget(
                    data, interpreter, tagsIndex, Vehicle.Car);
                var dataProcessorSource = new XmlOsmStreamSource(
                    Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format(
                    "OsmSharp.Test.Unittests.{0}", embeddedName)));
                var sorter = new OsmStreamFilterSort();
                sorter.RegisterSource(dataProcessorSource);
                targetData.RegisterSource(sorter);
                targetData.Pull();

                // do the pre-processing part.
                var preProcessor = new CHPreProcessor(data,
                    new SparseOrdering(data), new DykstraWitnessCalculator());
                preProcessor.Start();

                _data[embeddedName] = data;
            }
            return Router.CreateCHFrom(data, new CHRouter(), interpreter);
        }
        /// <summary>
        /// Returns a new router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="embeddedName"></param>
        /// <returns></returns>
        public override Router BuildRouter(IOsmRoutingInterpreter interpreter, string embeddedName)
        {
            if (_data == null)
            {
                _data = new Dictionary<string, RouterDataSource<CHEdgeData>>();
            }
            RouterDataSource<CHEdgeData> data = null;
            if (!_data.TryGetValue(embeddedName, out data))
            {
                var tagsIndex = new TagsIndex();

                // do the data processing.
                data = new RouterDataSource<CHEdgeData>(new DirectedGraph<CHEdgeData>(), tagsIndex);
                var targetData = new CHEdgeGraphOsmStreamTarget(
                    data, interpreter, tagsIndex, Vehicle.Car);
                var dataProcessorSource = new XmlOsmStreamSource(
                    Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format(
                    "OsmSharp.Test.Unittests.{0}", embeddedName)));
                var sorter = new OsmStreamFilterSort();
                sorter.RegisterSource(dataProcessorSource);
                targetData.RegisterSource(sorter);
                targetData.Pull();

                _data[embeddedName] = data;
            }
            return Router.CreateCHFrom(data, new CHRouter(), interpreter);
        }
        public void RoutingRegressionTest1()
        {
            var interpreter = new OsmRoutingInterpreter();
            var tagsIndex = new TagsTableCollectionIndex();

            // do the data processing.
            var memoryData = new DynamicGraphRouterDataSource<LiveEdge>(tagsIndex);
            var targetData = new LiveGraphOsmStreamTarget(memoryData, interpreter, tagsIndex);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Test.Unittests.test_routing_regression1.osm"));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            var basicRouter = new Dykstra();
            var router = Router.CreateLiveFrom(memoryData, basicRouter, interpreter);

            // resolve the three points in question.
            var point35 = new GeoCoordinate(51.01257, 4.000753);
            var point35resolved = router.Resolve(Vehicle.Car, point35);
            var point45 = new GeoCoordinate(51.01315, 3.999588);
            var point45resolved = router.Resolve(Vehicle.Car, point45);

            // route between 35 and 45.
            var routebefore = router.Calculate(Vehicle.Car, point35resolved, point45resolved);

            // route between 35 and 45.
            var routeafter = router.Calculate(Vehicle.Car, point35resolved, point45resolved);
            Assert.AreEqual(routebefore.TotalDistance, routeafter.TotalDistance);
        }
        /// <summary>
        /// Returns a new router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="embeddedName"></param>
        /// <param name="contract"></param>
        /// <returns></returns>
        public override Router BuildRouter(IOsmRoutingInterpreter interpreter, string embeddedName, bool contract)
        {
            if (_data == null)
            {
                _data = new Dictionary<string, DynamicGraphRouterDataSource<LiveEdge>>();
            }
            DynamicGraphRouterDataSource<LiveEdge> data = null;
            if (!_data.TryGetValue(embeddedName, out data))
            {
                var tagsIndex = new TagsTableCollectionIndex();

                // do the data processing.
                data = new DynamicGraphRouterDataSource<LiveEdge>(tagsIndex);
                var targetData = new LiveGraphOsmStreamTarget(
                    data, interpreter, tagsIndex, new Vehicle[] { Vehicle.Car }, false);
                var dataProcessorSource = new XmlOsmStreamSource(
                    Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format(
                    "OsmSharp.Test.Unittests.{0}", embeddedName)));
                var sorter = new OsmStreamFilterSort();
                sorter.RegisterSource(dataProcessorSource);
                targetData.RegisterSource(sorter);
                targetData.Pull();

                _data[embeddedName] = data;
            }
            return Router.CreateLiveFrom(data, new Dykstra(), interpreter);
        }
Esempio n. 5
0
 public async Task<List<CompleteWay>> GetHighways(LatLng northEast, LatLng southWest)
 {
     var boundsString = string.Join(",", southWest.lat, southWest.lng, northEast.lat, northEast.lng);
     var address = $"{OVERPASS_INTERPRETER_ADDRESS}?data=(way[\"highway\"]({boundsString});>;);out;";
     using (var client = new HttpClient())
     {
         var response = await client.GetAsync(address);
         var source = new XmlOsmStreamSource(await response.Content.ReadAsStreamAsync());
         var completeSource = new OsmSimpleCompleteStreamSource(source);
         return completeSource.OfType<CompleteWay>().ToList();
     }
 }
Esempio n. 6
0
        public void FixtureSetUp()
        {
            // Arrange
            const string connectionString = @"Server=TestDataWindows\SQLEXPRESS;Database=osmsharp;User Id=osmsharp;Password=osmsharp;";

            var sqlConnection = new SqlConnection(connectionString);
            sqlConnection.Open();

            var source = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Data.Test.Unittests.SQLServer.Data.ukraine1.osm"));
            //var source = new PBFDataProcessorSource(new FileInfo("C:\\great-britain-latest.osm.pbf").OpenRead());

            // Act
            _testTarget = new SQLServerDDLChecksStreamTarget(connectionString);
            _testTarget.RegisterSource(source);
            _testTarget.Pull();
        }
        /// <summary>
        /// Returns a new router.
        /// </summary>
        /// <returns></returns>
        public override Router BuildRouter(IOsmRoutingInterpreter interpreter, string embeddedName)
        {
            var tagsIndex = new TagsIndex();

            // do the data processing.
            var data = new RouterDataSource<Edge>(new Graph<Edge>(), tagsIndex);
            var targetData = new GraphOsmStreamTarget(
                data, interpreter, tagsIndex, new Vehicle[] { Vehicle.Car }, false);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format(
                "OsmSharp.Routing.Test.data.{0}", embeddedName)));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            return Router.CreateFrom(data, new Dykstra(), interpreter);
        }
        /// <summary>
        /// Creates a router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="manifestResourceName"></param>
        /// <returns></returns>
        protected override Router CreateRouter(IOsmRoutingInterpreter interpreter, string manifestResourceName)
        {
            TagsIndex tagsIndex = new TagsIndex();

            // do the data processing.
            var memoryData =
                new RouterDataSource<Edge>(new Graph<Edge>(), tagsIndex);
            var targetData = new GraphOsmStreamTarget(
                memoryData, interpreter, tagsIndex, null, false);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(manifestResourceName));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            IRoutingAlgorithm<Edge> basicRouter = new Dykstra();
            return Router.CreateFrom(memoryData, basicRouter, interpreter);
        }
        /// <summary>
        /// Creates a router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="manifestResourceName"></param>
        /// <returns></returns>
        protected override Router CreateRouter(IOsmRoutingInterpreter interpreter, string manifestResourceName)
        {
            SimpleTagsIndex tagsIndex = new SimpleTagsIndex();

            // do the data processing.
            DynamicGraphRouterDataSource<LiveEdge> memoryData =
                new DynamicGraphRouterDataSource<LiveEdge>(tagsIndex);
            LiveGraphOsmStreamTarget target_data = new LiveGraphOsmStreamTarget(
                memoryData, interpreter, memoryData.TagsIndex);
            XmlOsmStreamSource dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(manifestResourceName));
            OsmStreamFilterSort sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            target_data.RegisterSource(sorter);
            target_data.Pull();

            IBasicRouter<LiveEdge> basicRouter = new DykstraRoutingLive(memoryData.TagsIndex);
            return Router.CreateLiveFrom(memoryData, basicRouter, interpreter);
        }
        /// <summary>
        /// Builds a raw data source.
        /// </summary>
        /// <returns></returns>
        public DynamicGraphRouterDataSource<LiveEdge> BuildDykstraDataSource(
            IOsmRoutingInterpreter interpreter, string embeddedName)
        {
            var tagsIndex = new SimpleTagsIndex();

            // do the data processing.
            var data = new DynamicGraphRouterDataSource<LiveEdge>(tagsIndex);
            var targetData = new LiveGraphOsmStreamTarget(
                data, interpreter, data.TagsIndex);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format(
                "OsmSharp.Test.Unittests.{0}", embeddedName)));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            return data;
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            // query to find all bicyle stations within the city of Antwerp.
            var query = "node(51.18881185379808,4.370841979980469,51.244939510768184,4.454612731933594)[\"amenity\"=\"bicycle_rental\"];out;";

            // create and execute the webrequest.
            var request = WebRequest.Create(
                "http://overpass.osm.rambler.ru/cgi/interpreter?data=" + query);
            request.Method = "GET";
            var requestStream = request.GetResponse().GetResponseStream(); // get the data.

            // use an XML data processor source.
            var source = new XmlOsmStreamSource(requestStream);

            // pull the data from the stream and deserialize XML.
            var osmEntities = new List<OsmGeo>(source);
            var outputCsv = new List<string[]>();
            for(int idx = 0; idx < osmEntities.Count; idx++)
            {
                var node = osmEntities[idx] as Node;
                var refId = string.Empty;
                var name = string.Empty;
                if (node != null &&
                    node.Tags.TryGetValue("ref", out refId) &&
                    node.Tags.TryGetValue("name", out name))
                {
                    var latitude = node.Coordinate.Latitude;
                    var longitude = node.Coordinate.Longitude;

                    outputCsv.Add(new string[] { latitude.ToInvariantString(), longitude.ToInvariantString(), refId, name });
                }
                if (!node.Tags.TryGetValue("ref", out refId))
                {
                    Console.WriteLine("Node {0} has no ref.", node.Id.Value);
                }
                if (!node.Tags.TryGetValue("name", out name))
                {
                    Console.WriteLine("Node {0} has no name.", node.Id.Value);
                }
            }
            OsmSharp.IO.DelimitedFiles.DelimitedFileHandler.WriteDelimitedFile(null, outputCsv.ToArray(),
                new StreamWriter(new FileInfo("bicylestations.csv").OpenWrite()), OsmSharp.IO.DelimitedFiles.DelimiterType.DotCommaSeperated);
        }
        public void XmlDataProcessorSourceReset()
        {
            // generate the source.
            var source = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(
                    "OsmSharp.Test.Unittests.api.osm"));

            // pull the data out.
            var target = new OsmStreamTargetEmpty();
            target.RegisterSource(source);
            target.Pull();

            // reset the source.
            if (source.CanReset)
            {
                source.Reset();

                // pull the data again.
                target.Pull();
            }
        }
        public void RoutingRegressionTest1()
        {
            OsmRoutingInterpreter interpreter = new OsmRoutingInterpreter();

            SimpleTagsIndex tags_index = new SimpleTagsIndex();

            // do the data processing.
            DynamicGraphRouterDataSource<LiveEdge> memory_data =
                new DynamicGraphRouterDataSource<LiveEdge>(tags_index);
            LiveGraphOsmStreamTarget target_data = new LiveGraphOsmStreamTarget(
                memory_data, interpreter, memory_data.TagsIndex);
            XmlOsmStreamSource data_processor_source = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Test.Unittests.test_routing_regression1.osm"));
            OsmStreamFilterSort sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(data_processor_source);
            target_data.RegisterSource(sorter);
            target_data.Pull();

            IBasicRouter<LiveEdge> basic_router = new DykstraRoutingLive(memory_data.TagsIndex);
            Router router = Router.CreateLiveFrom(memory_data, basic_router, interpreter);

            // resolve the three points in question.
            GeoCoordinate point35 = new GeoCoordinate(51.01257, 4.000753);
            RouterPoint point35resolved = router.Resolve(Vehicle.Car, point35);
            //            GeoCoordinate point40 = new GeoCoordinate(51.01250, 4.000013);
            //            RouterPoint point40resolved = router.Resolve(Vehicle.Car, point40);
            GeoCoordinate point45 = new GeoCoordinate(51.01315, 3.999588);
            RouterPoint point45resolved = router.Resolve(Vehicle.Car, point45);

            // route between 35 and 45.
            Route routebefore = router.Calculate(Vehicle.Car, point35resolved, point45resolved);

            //            GeoCoordinate point129 = new GeoCoordinate(51.01239, 3.999573);
            //            RouterPoint point129resolved = router.Resolve(Vehicle.Car, point129);

            // route between 35 and 45.
            Route routeafter = router.Calculate(Vehicle.Car, point35resolved, point45resolved);
            Assert.AreEqual(routebefore.TotalDistance, routeafter.TotalDistance);
        }
        /// <summary>
        /// Creates a router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="manifestResourceName"></param>
        /// <returns></returns>
        protected override Router CreateRouter(IOsmRoutingInterpreter interpreter, string manifestResourceName)
        {
            TagsIndex tagsIndex = new TagsIndex();

            // do the data processing.
            var data = new RouterDataSource<CHEdgeData>(new DirectedGraph<CHEdgeData>(), tagsIndex);
            var targetData = new CHEdgeGraphOsmStreamTarget(
                data, interpreter, tagsIndex, Vehicle.Car);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(manifestResourceName));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            // do the pre-processing part.
            var witnessCalculator = new DykstraWitnessCalculator();
            var preProcessor = new CHPreprocessor(data,
                new EdgeDifferenceContractedSearchSpace(data, witnessCalculator), witnessCalculator);
            preProcessor.Start();

            return Router.CreateCHFrom(data, new CHRouter(), interpreter);
        }
Esempio n. 15
0
        public async Task<List<CompleteWay>> GetHighwaysAroundATrace(IEnumerable<Coordinate> coordinates)
        {
            var overpassQueryPostfix = @"way[highway](bn)-> .w;
                                        node(w.w)-> .n;
                                        (node._.n; way.w);
                                        out qt; ";
            var overpassQueryNodes = "";
            foreach (var coordinate in coordinates)
            {
                // lat, lng
                overpassQueryNodes += $"(._; node(around: 300, {coordinate.Y}, {coordinate.X}););\n";
            }

            using (var client = new HttpClient())
            {
                var response = await client.PostAsync(OVERPASS_INTERPRETER_ADDRESS, new StringContent(overpassQueryNodes + overpassQueryPostfix));
                Trace.WriteLine(await response.Content.ReadAsStringAsync());
                var source = new XmlOsmStreamSource(await response.Content.ReadAsStreamAsync());
                var cache = new OsmDataCacheMemory();
                var completeSource = new OsmSimpleCompleteStreamSource(source, cache);
                var list = completeSource.OfType<CompleteWay>().ToList();
                return list;
            }
        }
        /// <summary>
        /// Creates a router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="manifestResourceName"></param>
        /// <returns></returns>
        protected override Router CreateRouter(IOsmRoutingInterpreter interpreter, string manifestResourceName)
        {
            SimpleTagsIndex tagsIndex = new SimpleTagsIndex();

            // do the data processing.
            var data = new DynamicGraphRouterDataSource<CHEdgeData>(tagsIndex);
            var targetData = new CHEdgeGraphOsmStreamTarget(
                data, interpreter, data.TagsIndex, Vehicle.Car);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(manifestResourceName));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            // do the pre-processing part.
            var witnessCalculator = new DykstraWitnessCalculator(data);
            var preProcessor = new CHPreProcessor(data,
                new EdgeDifference(data, witnessCalculator), witnessCalculator);
            preProcessor.Start();

            //IBasicRouter<LiveEdge> basicRouter = new DykstraRoutingLive(memoryData.TagsIndex);
            return Router.CreateCHFrom(data, new CHRouter(data), interpreter);
        }
Esempio n. 17
0
        public void RoutingRegressionTest8Contracted()
        {
            double e = 0.2; // 10 cm

            // network: (a/b) a=vertexX, b=contractedVertexId
            //                x(6/5)--------x(8/x)-x(4/2)---x(5/3)
            //               /                    /
            // x(1/4)--x(2/1)-x(7/6)--------x(3/x)

            // x(7/5) is one of the shapepoints converted to an actual vertex to prevent two edges 1<->2.
            // this regression test has everything to do with x(7/5).

            var vertex1 = new GeoCoordinate(50.984988723456084, 4.828170772332617);
            var vertex2 = new GeoCoordinate(50.984987035397620, 4.828346366914291);
            var vertex3 = new GeoCoordinate(50.984985823202960, 4.828728258663133);
            var vertex4 = new GeoCoordinate(50.985013303511700, 4.828792771883094);
            var vertex5 = new GeoCoordinate(50.985012880931120, 4.828949650265730);
            var vertex6 = new GeoCoordinate(50.985017593072016, 4.828410262241598);
            var vertex7 = new GeoCoordinate(50.984986416884716, 4.828409529435097);
            var vertex8 = new GeoCoordinate(50.985013738270930, 4.828723851247985);

            var source = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Test.Unittests.test_routing_regression6.osm"));
            var router = Router.CreateCHFrom(source, new OsmRoutingInterpreter(), Vehicle.Car);

            var resolved1 = router.Resolve(Vehicle.Car, vertex1, true);
            Assert.AreEqual(0, resolved1.Location.DistanceReal(vertex1).Value, e);
            var resolved2 = router.Resolve(Vehicle.Car, vertex2, true);
            Assert.AreEqual(0, resolved2.Location.DistanceReal(vertex2).Value, e);
            var resolved3 = router.Resolve(Vehicle.Car, vertex3, true);
            Assert.AreEqual(0, resolved3.Location.DistanceReal(vertex3).Value, e);
            var resolved4 = router.Resolve(Vehicle.Car, vertex4, true);
            Assert.AreEqual(0, resolved4.Location.DistanceReal(vertex4).Value, e);
            var resolved5 = router.Resolve(Vehicle.Car, vertex5, true);
            Assert.AreEqual(0, resolved5.Location.DistanceReal(vertex5).Value, e);
            var resolved6 = router.Resolve(Vehicle.Car, vertex6, true);
            Assert.AreEqual(0, resolved6.Location.DistanceReal(vertex6).Value, e);
            var resolved7 = router.Resolve(Vehicle.Car, vertex7, true);
            Assert.AreEqual(0, resolved7.Location.DistanceReal(vertex7).Value, e);
            var resolved8 = router.Resolve(Vehicle.Car, vertex8, true);
            Assert.AreEqual(0, resolved8.Location.DistanceReal(vertex8).Value, e);
        }
Esempio n. 18
0
        public void RoutingRegressionTest8()
        {
            double e = 0.2; // 10 cm

            // network:
            //            x(6)--------x(8)-x(4)---x(5)
            //           /                /
            // x(1)--x(2)-x(7)--------x(3)

            var vertex1 = new GeoCoordinate(50.984988723456084, 4.828170772332617);
            var vertex2 = new GeoCoordinate(50.984987035397620, 4.828346366914291);
            var vertex3 = new GeoCoordinate(50.984985823202960, 4.828728258663133);
            var vertex4 = new GeoCoordinate(50.985013303511700, 4.828792771883094);
            var vertex5 = new GeoCoordinate(50.985012880931120, 4.828949650265730);
            var vertex6 = new GeoCoordinate(50.985017593072016, 4.828410262241598);
            var vertex7 = new GeoCoordinate(50.984986416884716, 4.828409529435097);
            var vertex8 = new GeoCoordinate(50.985013738270930 ,4.828723851247985);

            var source = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Test.Unittests.test_routing_regression6.osm"));
            var router = Router.CreateLiveFrom(source, new OsmRoutingInterpreter());

            var resolved1 = router.Resolve(Vehicle.Car, vertex1, true);
            Assert.AreEqual(0, resolved1.Location.DistanceReal(vertex1).Value, e);
            var resolved2 = router.Resolve(Vehicle.Car, vertex2, true);
            Assert.AreEqual(0, resolved2.Location.DistanceReal(vertex2).Value, e);
            var resolved3 = router.Resolve(Vehicle.Car, vertex3, true);
            Assert.AreEqual(0, resolved3.Location.DistanceReal(vertex3).Value, e);
            var resolved4 = router.Resolve(Vehicle.Car, vertex4, true);
            Assert.AreEqual(0, resolved4.Location.DistanceReal(vertex4).Value, e);
            var resolved5 = router.Resolve(Vehicle.Car, vertex5, true);
            Assert.AreEqual(0, resolved5.Location.DistanceReal(vertex5).Value, e);
            var resolved6 = router.Resolve(Vehicle.Car, vertex6, true);
            Assert.AreEqual(0, resolved6.Location.DistanceReal(vertex6).Value, e);
            var resolved7 = router.Resolve(Vehicle.Car, vertex7, true);
            Assert.AreEqual(0, resolved7.Location.DistanceReal(vertex7).Value, e);
            var resolved8 = router.Resolve(Vehicle.Car, vertex8, true);
            Assert.AreEqual(0, resolved8.Location.DistanceReal(vertex8).Value, e);
        }
Esempio n. 19
0
        public void RoutingRegressionTest7Contracted()
        {
            double e = 0.2; // 10 cm

            // network:
            //        x(6)-----------x(4)---x(5)
            //        /              /
            // x(1)--x(2)---------x(3)

            var vertex1 = new GeoCoordinate(50.984988723456084, 4.828170772332617);
            var vertex2 = new GeoCoordinate(50.984987035397620, 4.828346366914291);
            var vertex3 = new GeoCoordinate(50.984985823202960, 4.828728258663133);
            var vertex4 = new GeoCoordinate(50.985013303511700, 4.828792771883094);
            var vertex5 = new GeoCoordinate(50.985012880931120, 4.828949650265730);
            var vertex6 = new GeoCoordinate(50.985017593072016, 4.828410262241598);

            var source = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Test.Unittests.test_routing_regression5.osm"));
            var router = Router.CreateCHFrom(source, new OsmRoutingInterpreter(), Vehicle.Car);

            var resolved1 = router.Resolve(Vehicle.Car, vertex1, true);
            Assert.AreEqual(0, resolved1.Location.DistanceReal(vertex1).Value, e);
            var resolved2 = router.Resolve(Vehicle.Car, vertex2, true);
            Assert.AreEqual(0, resolved2.Location.DistanceReal(vertex2).Value, e);
            var resolved3 = router.Resolve(Vehicle.Car, vertex3, true);
            Assert.AreEqual(0, resolved3.Location.DistanceReal(vertex3).Value, e);
            var resolved4 = router.Resolve(Vehicle.Car, vertex4, true);
            Assert.AreEqual(0, resolved4.Location.DistanceReal(vertex4).Value, e);
            var resolved5 = router.Resolve(Vehicle.Car, vertex5, true);
            Assert.AreEqual(0, resolved5.Location.DistanceReal(vertex5).Value, e);

            var route = router.Calculate(Vehicle.Car, resolved1, resolved5);
            var points = new List<GeoCoordinate>(route.GetPoints());

            Assert.AreEqual(5, points.Count);
            Assert.AreEqual(0, points[0].DistanceReal(vertex1).Value, e);
            Assert.AreEqual(0, points[1].DistanceReal(vertex2).Value, e);
            Assert.AreEqual(0, System.Math.Min(points[2].DistanceReal(vertex6).Value, points[2].DistanceReal(vertex3).Value), e);
            Assert.AreEqual(0, points[3].DistanceReal(vertex4).Value, e);
            Assert.AreEqual(0, points[4].DistanceReal(vertex5).Value, e);

            route = router.Calculate(Vehicle.Car, resolved5, resolved1);
            points = new List<GeoCoordinate>(route.GetPoints());

            Assert.AreEqual(5, points.Count);
            Assert.AreEqual(0, points[4].DistanceReal(vertex1).Value, e);
            Assert.AreEqual(0, points[3].DistanceReal(vertex2).Value, e);
            Assert.AreEqual(0, System.Math.Min(points[2].DistanceReal(vertex6).Value, points[2].DistanceReal(vertex3).Value), e);
            Assert.AreEqual(0, points[1].DistanceReal(vertex4).Value, e);
            Assert.AreEqual(0, points[0].DistanceReal(vertex5).Value, e);
        }
Esempio n. 20
0
        public void RoutingRegressionTest6Contracted()
        {
            double e = 0.1; // 10 cm

            // network:
            //        x(1)------x(2)
            //       /           \
            // x(3)--x(4)---------x(5)--x(6)

            // 1: 50.98508962508, 4.82958530756
            // 2: 50.98509255957, 4.83009340615
            // 3: 50.98496931078, 4.82889075077
            // 4: 50.98496931078, 4.82939884936
            // 5: 50.98496931078, 4.83025189562
            // 6: 50.98496931078, 4.83079728585

            var vertex1 = new GeoCoordinate(50.98508962508, 4.82958530756);
            var vertex2 = new GeoCoordinate(50.98509255957, 4.83009340615);
            var vertex3 = new GeoCoordinate(50.98496931078, 4.82889075077);
            var vertex4 = new GeoCoordinate(50.98496931078, 4.82939884936);
            var vertex5 = new GeoCoordinate(50.98496931078, 4.83025189562);
            var vertex6 = new GeoCoordinate(50.98496931078, 4.83079728585);

            var source = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Test.Unittests.test_routing_regression4.osm"));
            var router = Router.CreateCHFrom(source, new OsmRoutingInterpreter(), Vehicle.Car);

            var resolved3 = router.Resolve(Vehicle.Car, vertex3, true);
            var resolved6 = router.Resolve(Vehicle.Car, vertex6, true);

            var route = router.Calculate(Vehicle.Car, resolved3, resolved6);
            var points = new List<GeoCoordinate>(route.GetPoints());

            Assert.AreEqual(4, points.Count);
            Assert.AreEqual(0, points[0].DistanceReal(vertex3).Value, e);
            Assert.AreEqual(0, points[1].DistanceReal(vertex4).Value, e);
            Assert.AreEqual(0, points[2].DistanceReal(vertex5).Value, e);
            Assert.AreEqual(0, points[3].DistanceReal(vertex6).Value, e);

            route = router.Calculate(Vehicle.Car, resolved6, resolved3);
            points = new List<GeoCoordinate>(route.GetPoints());

            Assert.AreEqual(4, points.Count);
            Assert.AreEqual(0, points[0].DistanceReal(vertex6).Value, e);
            Assert.AreEqual(0, points[1].DistanceReal(vertex5).Value, e);
            Assert.AreEqual(0, points[2].DistanceReal(vertex4).Value, e);
            Assert.AreEqual(0, points[3].DistanceReal(vertex3).Value, e);
        }
Esempio n. 21
0
        public void RoutingRegressionTest4()
        {
            var interpreter = new OsmRoutingInterpreter();
            var tagsIndex = new TagsTableCollectionIndex();

            // do the data processing.
            var memoryData = new DynamicGraphRouterDataSource<LiveEdge>(tagsIndex);
            var targetData = new LiveGraphOsmStreamTarget(memoryData, interpreter, tagsIndex);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Test.Unittests.test_routing_regression1.osm"));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            var basicRouter = new Dykstra();
            var router = Router.CreateLiveFrom(memoryData, basicRouter, interpreter);

            // resolve the three points in question.
            var point35 = new GeoCoordinate(51.01257, 4.000753);
            var point35ResolvedCar = router.Resolve(Vehicle.Car, point35);
            var point35ResolvedBicycle = router.Resolve(Vehicle.Bicycle, point35);
        }
Esempio n. 22
0
        public void RoutingRegressionTest2()
        {
            var interpreter = new OsmRoutingInterpreter();
            var tagsIndex = new TagsIndex();

            // do the data processing.
            var memoryData = new RouterDataSource<Edge>(new Graph<Edge>(), tagsIndex);
            var targetData = new GraphOsmStreamTarget(memoryData, interpreter, tagsIndex);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Routing.Test.data.test_network.osm"));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            var basicRouter = new Dykstra();
            var router = Router.CreateFrom(memoryData, basicRouter, interpreter);

            // build coordinates list of resolved points.
            var testPoints = new List<GeoCoordinate>();
            testPoints.Add(new GeoCoordinate(51.0582204, 3.7193524));
            testPoints.Add(new GeoCoordinate(51.0582199, 3.7194002));

            testPoints.Add(new GeoCoordinate(51.0581727, 3.7195833));
            testPoints.Add(new GeoCoordinate(51.0581483, 3.7195553));

            testPoints.Add(new GeoCoordinate(51.0581883, 3.7196617));
            testPoints.Add(new GeoCoordinate(51.0581628, 3.7196889));

            // build a matrix of routes between all points.
            var referenceRoutes = new Route[testPoints.Count][];
            var permuationArray = new int[testPoints.Count];
            for (int fromIdx = 0; fromIdx < testPoints.Count; fromIdx++)
            {
                permuationArray[fromIdx] = fromIdx;
                referenceRoutes[fromIdx] = new Route[testPoints.Count];
                for (int toIdx = 0; toIdx < testPoints.Count; toIdx++)
                {
                    // create router from scratch.
                    router = Router.CreateFrom(
                        memoryData, basicRouter, interpreter);

                    // resolve points.
                    var from = router.Resolve(Vehicle.Car, testPoints[fromIdx]);
                    var to = router.Resolve(Vehicle.Car, testPoints[toIdx]);

                    // calculate route.
                    referenceRoutes[fromIdx][toIdx] = router.Calculate(Vehicle.Car, from, to);
                }
            }

            // resolve points in some order and compare the resulting routes.
            // they should be identical in length except for some numerical rounding errors.
            var enumerator = new PermutationEnumerable<int>(permuationArray);
            foreach (int[] permutation in enumerator)
            {
                // create router from scratch.
                router = Router.CreateFrom(memoryData, basicRouter, interpreter);

                // resolve in the order of the permutation.
                var resolvedPoints = new RouterPoint[permutation.Length];
                for (int idx = 0; idx < permutation.Length; idx++)
                {
                    resolvedPoints[permutation[idx]] = router.Resolve(Vehicle.Car, testPoints[permutation[idx]]);
                }

                for (int fromIdx = 0; fromIdx < testPoints.Count; fromIdx++)
                {
                    for (int toIdx = 0; toIdx < testPoints.Count; toIdx++)
                    {
                        // calculate route.
                        var route = router.Calculate(Vehicle.Car, resolvedPoints[fromIdx], resolvedPoints[toIdx]);

                        // TODO: changed the resolve accuracy to .5m. Make sure this is more accurate in the future.
                        Assert.AreEqual(referenceRoutes[fromIdx][toIdx].TotalDistance, route.TotalDistance, 1);
                    }
                }
            }
        }
        /// <summary>
        /// Builds a raw router to compare against.
        /// </summary>
        /// <returns></returns>
        public void BuildDykstraRouter(string embeddedName,
            IOsmRoutingInterpreter interpreter)
        {
            var tagsIndex = new TagsIndex();

            // do the data processing.
            var data = new RouterDataSource<Edge>(new Graph<Edge>(), tagsIndex);
            var targetData = new GraphOsmStreamTarget(
                data, interpreter, tagsIndex, new Vehicle[] { Vehicle.Car });
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedName));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            // initialize the router.
            _referenceRouter = Router.CreateFrom(data, new Dykstra(), interpreter);
        }
        /// <summary>
        /// Test simple to complete conversion on the given resource.
        /// </summary>
        /// <param name="embeddedResource"></param>
        private void TestSimpleToCompleteOn(string embeddedResource)
        {
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedResource));

            // fill the memory data source with source-data.
            var referenceSource = MemoryDataSource.CreateFrom(dataProcessorSource);

            // pull the complete objects.
            dataProcessorSource.Reset();
            var list = this.PullToCompleteList(dataProcessorSource);

            // compare the two.
            this.Compare(referenceSource, list);
        }
Esempio n. 25
0
            public void doWork()
            {
                handler.Invoke(true);
                SQLServerOsmStreamTarget sqlTarget = new SQLServerOsmStreamTarget("Server=VIRTUALBOX;Database=osm_test;User Id=sa; Password=0773", true);

                sqlTarget.Initialize();
                FileStream stream = File.OpenRead(filename);
                OsmStreamSource src;

                switch (Path.GetExtension(filename).ToLower())
                {
                    case ".pbf":
                        src = new OsmSharp.Osm.PBF.Streams.PBFOsmStreamSource(stream);
                        break;
                    case ".osm":
                    default:
                        src = new XmlOsmStreamSource(stream);
                        break;
                }

                if (!_shouldStop)
                    transferData(src, sqlTarget);
                handler.Invoke(false);

            }
Esempio n. 26
0
        /// <summary>
        /// Builds the data source.
        /// </summary>
        /// <returns></returns>
        private DynamicGraphRouterDataSource<CHEdgeData> BuildData(IOsmRoutingInterpreter interpreter)
        {
            DynamicGraphRouterDataSource<CHEdgeData> data = null;
            if (data == null)
            {
                var tagsIndex = new SimpleTagsIndex();

                // do the data processing.
                data = new DynamicGraphRouterDataSource<CHEdgeData>(tagsIndex);
                var targetData = new CHEdgeGraphOsmStreamTarget(
                    data, interpreter, tagsIndex, Vehicle.Car);
                var dataProcessorSource = new XmlOsmStreamSource(
                    Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Test.Unittests.test_network.osm"));
                var sorter = new OsmStreamFilterSort();
                sorter.RegisterSource(dataProcessorSource);
                targetData.RegisterSource(sorter);
                targetData.Pull();
            }
            return data;
        }
Esempio n. 27
0
        /// <summary>
        /// Standard constructor of OsmData
        /// </summary>
        public OsmData() {    
            fileInfo = new FileInfo(OSMFILE);
            xmlSource = new XmlOsmStreamSource(fileInfo.OpenRead());

            nodes = new Dictionary<long, OsmSharp.Osm.Node>();
            buildings = new List<Building>();
            landuses = new List<Landuse>();

            /* Declare the colors of the brushes*/

            // Create Wallbrush
            WallTexture texture = new WallTexture(100, 1);
            Bitmap bitmap = texture.DrawTexture();

            using (MemoryStream memory = new MemoryStream())
            {
                bitmap.Save(memory, ImageFormat.Png);
                memory.Position = 0;
                bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = memory;
                bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
                bitmapImage.EndInit();
            }

            Rect rect = new Rect(0, 0, bitmapImage.PixelWidth, bitmapImage.PixelHeight);
            WALLBRUSH = new ImageBrush(bitmapImage);
            WALLBRUSH.Viewport = rect;
            WALLBRUSH.ViewportUnits = BrushMappingMode.Absolute;
            WALLBRUSH.Stretch = Stretch.None;
            WALLBRUSH.AlignmentX = AlignmentX.Left;
            WALLBRUSH.AlignmentY = AlignmentY.Top;
            WALLBRUSH.TileMode = TileMode.Tile;


            // Create GrassBrush
            DiamondSquare textureGrass = new DiamondSquare(1, 256, 256);
            Bitmap bitmapGrass = textureGrass.getPoints("green");

            using (MemoryStream memory = new MemoryStream())
            {
                bitmapGrass.Save(memory, ImageFormat.Png);
                memory.Position = 0;
                bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = memory;
                bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
                bitmapImage.EndInit();
            }

            Rect rectGrass = new Rect(0, 0, bitmapImage.PixelWidth, bitmapImage.PixelHeight);
            GRASSBRUSH = new ImageBrush(bitmapImage);
            GRASSBRUSH.Viewport = rectGrass;
            GRASSBRUSH.ViewportUnits = BrushMappingMode.Absolute;
            GRASSBRUSH.Stretch = Stretch.None;
            GRASSBRUSH.AlignmentX = AlignmentX.Left;
            GRASSBRUSH.AlignmentY = AlignmentY.Top;
            GRASSBRUSH.TileMode = TileMode.Tile;

            // Define rest of brushes
            SURFACEBRUSH = new SolidColorBrush(Colors.Black);
            LANDUSECOMMERCIALBRUSH = new SolidColorBrush(Colors.LightPink);
            LANDUSECOSTRUCIONBRUSH = new SolidColorBrush(Colors.DarkOliveGreen);
            LANDUSEFARMLANDBRUSH = new SolidColorBrush(Colors.LightYellow);
            LANDUSEFORESTBRUSH = new SolidColorBrush(Colors.LightGreen);
            LANDUSEGARAGESBRUSH = new SolidColorBrush(Colors.Gray);
            LANDUSEGRASSBRUSH = new SolidColorBrush(Colors.LawnGreen);
            LANDUSEINDUSTRIALBRUSH = new SolidColorBrush(Colors.MediumPurple);
            LANDUSERAILWAYBRUSH = new SolidColorBrush(Colors.Black);
            LANDUSERESIDENTIALBRUSH = new SolidColorBrush(Colors.WhiteSmoke);
            LANDUSEDEFAULTBRUSH = new SolidColorBrush(Colors.Orange);

            getBounds();                // declares the object map
            getNodes();                 // fills the dictonary nodes
            getBuildingsAndLanduses();  // fills the lists buildings and landuses
        }
Esempio n. 28
0
        public void RoutingSerializationRoutingTest()
        {
            const string embeddedString = "OsmSharp.Test.Unittests.test_network.osm";

            // create the tags index (and make sure it's serializable).
            var tagsIndex = new TagsIndex(new MemoryMappedStream(new MemoryStream()));

            // creates a new interpreter.
            var interpreter = new OsmRoutingInterpreter();

            // do the data processing.
            var original =
                new RouterDataSource<Edge>(new Graph<Edge>(), tagsIndex);
            var targetData = new GraphOsmStreamTarget(
                original, interpreter, tagsIndex, null, false);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedString));
            targetData.RegisterSource(dataProcessorSource);
            targetData.Pull();

            // create serializer.
            var routingSerializer = new RoutingDataSourceSerializer();

            // serialize/deserialize.
            TagsCollectionBase metaData = new TagsCollection();
            metaData.Add("some_key", "some_value");
            byte[] byteArray;
            using (var stream = new MemoryStream())
            {
                try
                {
                    routingSerializer.Serialize(stream, original, metaData);
                    byteArray = stream.ToArray();
                }
                catch (Exception)
                {
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                    throw;
                }
            }

            var deserializedVersion = routingSerializer.Deserialize(new MemoryStream(byteArray), out metaData);
            Assert.AreEqual(original.TagsIndex.Get(0), deserializedVersion.TagsIndex.Get(0));

            // try to do some routing on the deserialized version.
            var basicRouter = new Dykstra();
            var router = Router.CreateFrom(deserializedVersion, basicRouter, interpreter);
            var source = router.Resolve(Vehicle.Car,
                new GeoCoordinate(51.0578532, 3.7192229));
            var target = router.Resolve(Vehicle.Car,
                new GeoCoordinate(51.0576193, 3.7191801));

            // calculate the route.
            var route = router.Calculate(Vehicle.Car, source, target);
            Assert.IsNotNull(route);
            Assert.AreEqual(5, route.Segments.Length);

            float latitude, longitude;
            //deserializedVersion.GetVertex(20, out latitude, out longitude);
            Assert.AreEqual(51.0578537, route.Segments[0].Latitude, 0.00001);
            Assert.AreEqual(3.71922255, route.Segments[0].Longitude, 0.00001);
            Assert.AreEqual(RouteSegmentType.Start, route.Segments[0].Type);

            //deserializedVersion.GetVertex(21, out latitude, out longitude);
            Assert.AreEqual(51.0578537, route.Segments[1].Latitude, 0.00001);
            Assert.AreEqual(3.71956515, route.Segments[1].Longitude, 0.00001);
            Assert.AreEqual(RouteSegmentType.Along, route.Segments[1].Type);

            //deserializedVersion.GetVertex(16, out latitude, out longitude);
            Assert.AreEqual(51.05773, route.Segments[2].Latitude, 0.00001);
            Assert.AreEqual(3.719745, route.Segments[2].Longitude, 0.00001);
            Assert.AreEqual(RouteSegmentType.Along, route.Segments[2].Type);

            //deserializedVersion.GetVertex(22, out latitude, out longitude);
            Assert.AreEqual(51.05762, route.Segments[3].Latitude, 0.00001);
            Assert.AreEqual(3.71965766, route.Segments[3].Longitude, 0.00001);
            Assert.AreEqual(RouteSegmentType.Along, route.Segments[3].Type);

            deserializedVersion.GetVertex(23, out latitude, out longitude);
            Assert.AreEqual(51.05762, route.Segments[4].Latitude, 0.00001);
            Assert.AreEqual(3.71917963, route.Segments[4].Longitude, 0.00001);
            Assert.AreEqual(RouteSegmentType.Stop, route.Segments[4].Type);
        }
Esempio n. 29
0
        /// <summary>
        /// Sets all the info about the buildings and landuses into their lists
        /// </summary>
        private void getBuildingsAndLanduses() {
            FileInfo fileInfo = new FileInfo(OSMFILE);
            XmlOsmStreamSource xmlSource = new XmlOsmStreamSource(fileInfo.OpenRead());
            xmlSource.Initialize();

            while (xmlSource.MoveNextWay()) {
                OsmSharp.Osm.Way way = (OsmSharp.Osm.Way)xmlSource.Current();
                if ((way != null) && (way.Visible.HasValue) && (bool)(way.Visible) && (way.Tags != null)) {

                    // Info about buildings
                    if (way.Tags.ContainsKey("building")) {
                        List<long> buildingNodes = new List<long>();
                        int height = 10; // Standard height is 10
                        string amenity = "";

                        // Check amenity and if it is a church
                        if (way.Tags.ContainsKey("amenity")) {
                            amenity = way.Tags["amenity"];

                            if (amenity == "place_of_worship") height = 25;
                        }

                        // Check height
                        if (way.Tags.ContainsKey("height")) {
                            height = (int)(float.Parse(way.Tags["height"], System.Globalization.CultureInfo.InvariantCulture));
                        } else if (way.Tags.ContainsKey("building:levels")) {
                            string[] verdiepen = way.Tags["building:levels"].Split('-');
                            height = 3 * Convert.ToInt32(verdiepen[verdiepen.Length - 1]);
                            amenity = "apartment";
                        }

                        foreach (long id in way.Nodes) buildingNodes.Add(id);

                        buildings.Add(new Building(buildingNodes, height, amenity, ZOOM));
                    }

                    // Info about landuses
                    if (way.Tags.ContainsKey("landuse")) {
                        List<long> landuseNodes = new List<long>();
                        foreach (long id in way.Nodes) landuseNodes.Add(id);

                        landuses.Add(new Landuse(landuseNodes, 0, way.Tags["landuse"], ZOOM));
                    }
                }
            }

            xmlSource.Dispose();
        }
Esempio n. 30
0
        public void RoutingRegressionTest3()
        {
            var interpreter = new OsmRoutingInterpreter();
            var tagsIndex = new TagsTableCollectionIndex();

            // do the data processing.
            var memoryData = new DynamicGraphRouterDataSource<LiveEdge>(tagsIndex);
            var targetData = new LiveGraphOsmStreamTarget(memoryData, interpreter, tagsIndex);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Test.Unittests.test_network.osm"));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            var basicRouter = new Dykstra();
            var router = Router.CreateLiveFrom(memoryData, basicRouter, interpreter);

            // build coordinates list of resolved points.
            var testPoints = new List<GeoCoordinate>();
            testPoints.Add(new GeoCoordinate(51.0581719, 3.7201622));
            testPoints.Add(new GeoCoordinate(51.0580439, 3.7202134));
            testPoints.Add(new GeoCoordinate(51.0580573, 3.7204378));
            testPoints.Add(new GeoCoordinate(51.0581862, 3.7203758));

            // build a matrix of routes between all points.
            var referenceRoutes = new Route[testPoints.Count][];
            var permuationArray = new int[testPoints.Count];
            for (int fromIdx = 0; fromIdx < testPoints.Count; fromIdx++)
            {
                permuationArray[fromIdx] = fromIdx;
                referenceRoutes[fromIdx] = new Route[testPoints.Count];
                for (int toIdx = 0; toIdx < testPoints.Count; toIdx++)
                {
                    // create router from scratch.
                    router = Router.CreateLiveFrom(
                        memoryData, basicRouter, interpreter);

                    // resolve points.
                    var from = router.Resolve(Vehicle.Car, testPoints[fromIdx]);
                    var to = router.Resolve(Vehicle.Car, testPoints[toIdx]);

                    // calculate route.
                    referenceRoutes[fromIdx][toIdx] = router.Calculate(Vehicle.Car, from, to);
                }
            }

            // resolve points in some order and compare the resulting routes.
            // they should be identical in length except for some numerical rounding errors.
            var enumerator = new PermutationEnumerable<int>(
                permuationArray);
            foreach (int[] permutation in enumerator)
            {
                // create router from scratch.
                router = Router.CreateLiveFrom(memoryData, basicRouter, interpreter);

                // resolve in the order of the permutation.
                var resolvedPoints = new RouterPoint[permutation.Length];
                for (int idx = 0; idx < permutation.Length; idx++)
                {
                    resolvedPoints[permutation[idx]] = router.Resolve(Vehicle.Car, testPoints[permutation[idx]]);
                }

                for (int fromIdx = 0; fromIdx < testPoints.Count; fromIdx++)
                {
                    for (int toIdx = 0; toIdx < testPoints.Count; toIdx++)
                    {
                        // calculate route.
                        var route = router.Calculate(Vehicle.Car, resolvedPoints[fromIdx], resolvedPoints[toIdx]);

                        Assert.AreEqual(referenceRoutes[fromIdx][toIdx].TotalDistance, route.TotalDistance, 0.1);
                    }
                }
            }
        }