none
Getting all localities along a route RRS feed

  • Question

  • Hi.

    Does anyone know the best way to get a list of all localities along a particular route?

    Specifically for Australia, I'd like to specify destinations A and B, and get back a driving route and a list of all of the suburbs it goes through.

    Cheers,

    Ryan

    Monday, January 20, 2014 5:20 AM

Answers

  • I've only come across one other question like this before on the forums. The other question was to find all the countries a route passed through. For your question that is a couple of different approaches that can be done:

    Approach 1:

      • Get the route path from the Bing Maps REST routing service (array of coordinates).
      • Loop through the coordinates and reverse geocode each one and retrieve the locality information from the response.
      • For performance you likely won't need to do this for every coordinate. Loop through the coordinates and calculate the distances between them using the Haversine formula. Only reverse geocode coordinates after a specific distance has been travelled i.e. 5 KM.

      Approach 2:

      Approach 3:

      • This one requires the most work. Source a database of all city boundaries and store in SQL 2008, 2012 or Azure as spatial objects.
      • Get the route path from the Bing Maps REST routing service (array of coordinates).
      • Turn the route into a SQL spatial object an perform and intersection test against your database table of city boundaries.

      Approach 4:

      • Similar to approach 3 but instead get a database of city coordinates. These will likely only be single coordinates per city and a rough estimate of where the city is.
      • Get the route path from the Bing Maps REST routing service (array of coordinates).
      • Turn the route into a SQL spatial object, buffer it a specific distance (i.e. 5km) and perform and intersection test against your database table of city coordinates.
      • This will find all cities that are within 5km of your route.

    http://rbrundritt.wordpress.com

    • Proposed as answer by Ricky_Brundritt Monday, January 20, 2014 8:24 AM
    • Marked as answer by Ryan F K Monday, January 20, 2014 9:29 PM
    Monday, January 20, 2014 8:23 AM
  • I've added a code sample of how to do this here: https://code.msdn.microsoft.com/Calculate-Route-Distances-331716cf

    http://rbrundritt.wordpress.com

    Monday, December 14, 2015 9:25 PM

All replies

  • I've only come across one other question like this before on the forums. The other question was to find all the countries a route passed through. For your question that is a couple of different approaches that can be done:

    Approach 1:

      • Get the route path from the Bing Maps REST routing service (array of coordinates).
      • Loop through the coordinates and reverse geocode each one and retrieve the locality information from the response.
      • For performance you likely won't need to do this for every coordinate. Loop through the coordinates and calculate the distances between them using the Haversine formula. Only reverse geocode coordinates after a specific distance has been travelled i.e. 5 KM.

      Approach 2:

      Approach 3:

      • This one requires the most work. Source a database of all city boundaries and store in SQL 2008, 2012 or Azure as spatial objects.
      • Get the route path from the Bing Maps REST routing service (array of coordinates).
      • Turn the route into a SQL spatial object an perform and intersection test against your database table of city boundaries.

      Approach 4:

      • Similar to approach 3 but instead get a database of city coordinates. These will likely only be single coordinates per city and a rough estimate of where the city is.
      • Get the route path from the Bing Maps REST routing service (array of coordinates).
      • Turn the route into a SQL spatial object, buffer it a specific distance (i.e. 5km) and perform and intersection test against your database table of city coordinates.
      • This will find all cities that are within 5km of your route.

    http://rbrundritt.wordpress.com

    • Proposed as answer by Ricky_Brundritt Monday, January 20, 2014 8:24 AM
    • Marked as answer by Ryan F K Monday, January 20, 2014 9:29 PM
    Monday, January 20, 2014 8:23 AM
  • The only way that answer could have been better is if it somehow included velociraptors.

    I'll try to implement approach #1 and see what the performance is like first.

    I'll be sure to share my code if I get it working nicely.

    Cheers,

    R

    Monday, January 20, 2014 9:42 PM
  • I've added a code sample of how to do this here: https://code.msdn.microsoft.com/Calculate-Route-Distances-331716cf

    http://rbrundritt.wordpress.com

    Monday, December 14, 2015 9:25 PM