Routing with big routes

2 posts, 0 answers
  1. Javor
    Javor avatar
    4 posts
    Member since:
    Sep 2013

    Posted 13 Jul Link to this post

    I have problem when make big route for example from Sofia, Bulgaria to Vladivostok, Russia. My code is like your example in 'Demos - Telerik UI for WPF'.
    In your example and my program when I add Polyline data in my Visualization Layer
    and start move on map or zoom in or zoom out map stopped for few seconds 10 or more the same is in your example. 
     
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 15 Jul Link to this post

    Hi Javor,

    The given route returned by the BingRouteProvider contains about 24000 points. All of them are set as points in the single Polyline object displayed in the RadMap. As a whole WPF engine is very sensitive when it renders big number of points (in terms of thousands). Also when you zoom / pan the radmap , the geometry of the polyline is changed / transformed and this additionally slows down the rendering.

    Generally, we would suggest two approaches you can try:

    1) Simplify the points displayed on the map. For example display only one from a hundred points. All route points (if your application needs them ) can be stored in a database / file / dictionary. But display only small subset of points on the map:
    PolylineData routeLine = new PolylineData()
                       {
                           //Points = routeResponse.Result.RoutePath.Points,
                           ShapeFill = new MapShapeFill()
                           {
                               Stroke = new SolidColorBrush(Colors.Red),
                               StrokeThickness = 2
                           }
                       };
                       routeLine.Points = new LocationCollection();
     
                       for (int i = 0; i < routeResponse.Result.RoutePath.Points.Count; i++)
                       {
                           if (i % 100 == 0)
                           {
                               routeLine.Points.Add(routeResponse.Result.RoutePath.Points[i]);
                           }
                       }
     
                       this.routeLayer.Items.Add(routeLine);
    This way you will see polyline consisting of 240 points instead of 24000. It will be fast to process by the RadMap. However, when you zoom in the details /quality will be lower.

    2) Instead of single polyline, add hundreds / thousands of polylines with small number of points each.
    This way you can benefit from Virtualization feature in VisualizationLayer - its a concept to request the object on demand - only the ones you need in the current viewport (defined by the center of the map and the zoom level). This approach would require storing the different polylines somehow (for example dictionary) that will be easily accessed when you need them (for certain viewport).

    Regards,
    Petar Mladenov
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top