none
Speed in Calculating Coordinates RRS feed

  • Question

  • My Windows Store App (Win 8.1, VS2013) uses a Bing Map. My server provides me with hundreds (even thousands at times) locations that need to be displayed on the map.

    My data server only provides me with a centerpoint in Lat/Lng, and a radius (distance and units) for each location. Thanks to a response from a previous post (thanks Ricky), I was able to accurately draw these circles using a MapPolyline to connect 1 degree arcs of the circle (the geometric equations were easy to find on the web). Because I'm using MapPolyline, the drawn circles scale when the user zooms the Bing Map. Great stuff.

    The problem is that when I get into thousands of these, the time needed for the calculations is pretty noticeable to the user. I wondered if I could speed things up by calculating my circle on the Video Card GPU, rather than the CPU as I'm doing now in a Model object.

    • So, has anyone coded the creation of large numbers of MapPolylines as an IValueConverter?
    • Does an IValueConverter execute on the GPU (not CPU)?
    • Is there another approach to using the GPU that I'm missing?

    The application is targeted for a tablet or small laptop. Think something like a Surface 2 or a fliptop laptop.

    Thanks,


    Randy

    Tuesday, January 28, 2014 7:27 PM

Answers

  • A couple of ideas. The first is to calculate the coordinates on a background thread. You will need to create a class to use in place of the Location class which isn't a DependencyObject. A simple class or struct the had a latitude and longitude coordinate would work fine. You will be able to use this class in a background thread with your calculations and will just need to convert them to Location objects (by creating new Location objects on the UI thread) on the UI thread which should be a light weight operation.

    Another thought is to pre-calculate all the circles ahead of time is possible and store them in your database. If the data is stored as Well Known Text (a standard for representing spatial objects as text) it can be easily overlaid on the map using this library: http://mapstoolbox.codeplex.com/


    http://rbrundritt.wordpress.com

    Tuesday, January 28, 2014 8:12 PM

All replies

  • A couple of ideas. The first is to calculate the coordinates on a background thread. You will need to create a class to use in place of the Location class which isn't a DependencyObject. A simple class or struct the had a latitude and longitude coordinate would work fine. You will be able to use this class in a background thread with your calculations and will just need to convert them to Location objects (by creating new Location objects on the UI thread) on the UI thread which should be a light weight operation.

    Another thought is to pre-calculate all the circles ahead of time is possible and store them in your database. If the data is stored as Well Known Text (a standard for representing spatial objects as text) it can be easily overlaid on the map using this library: http://mapstoolbox.codeplex.com/


    http://rbrundritt.wordpress.com

    Tuesday, January 28, 2014 8:12 PM
  • I'm going with option 1.

    Option 2 would be viable if any number of circles had the same predictable radius. Unfortunately, every one I get is different.

    I'm guessing that any GPU usage is behind the scenes to a C#/XAML programmer. It probably helps a lot when coding lots of <Ellipses ... /> in XAML code. I cannot use that for the scaling reasons mentioned above.

    Thanks again for the help!


    Randy

    Tuesday, January 28, 2014 8:56 PM