itinero / routing

The routing core of itinero.
Apache License 2.0
221 stars 70 forks source link

Slow calculation between 2 points #228

Closed vincent-caron closed 5 years ago

vincent-caron commented 5 years ago

Hello,

I want to calculate a route between those 2 points

Start : (38.98962 , -1.861485) End : (39.00459 , -1.860476)

I've calculed a routerdb file from europe.osm et spain.osm with idp tool

if i use the europe.routerdb, it takes almost 2Mn to calculate the route. If i use the spain.routerdb, it takes almost 6s to calculate the route.

here my test code :

    static void Main(string[] args)
    {
        ComputeWays.InitRouter(@"c:\temp\routerdb\spain.routerdb");

        ComputeWays computeWays = new ComputeWays();

        System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
        stopwatch.Start();
        computeWays.TestCalculPoint(38.98962, -1.861485, 39.00459, -1.860476);
        stopwatch.Stop();

    }

    public void TestCalculPoint(double latD, double lnD, double latF, double lnF)
    {
        var profile = Vehicle.Pedestrian.Fastest();

        RouterPoint pointDepartItinero = router.Resolve(profile, (float)latD, (float)lnD);
        Result<RouterPoint> pointTest = router.TryResolve(profile, (float)latF, (float)lnF, 30);
        System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
        stopwatch.Start();
        Result<Route> chemin = router.TryCalculate(profile, pointDepartItinero, pointTest.Value);
        stopwatch.Stop();

    }

    public static void InitRouter(string pathOfPbf)
    {
        if (router == null)
        {
            var routerDb = new RouterDb();

            using (var stream = File.OpenRead(pathOfPbf))
            {
                routerDb = RouterDb.Deserialize(stream);
            }

            router = new Router(routerDb);
        }
    }

I use the latest nugget itinero : 1.4.0-pre87

Any help appreciated Thanks

Vincent

pietervdvn commented 5 years ago

IDP prepossesses the data, but the routerDB will only be optimally fast when contraction is enabled in the preprocessing.

Try placing the profile next to your OSM-data, and invoke IDP with the extra flag --contract "pedestrian". Keep in mind that IDP will run way longer.

You can find a bunch of profiles here)