Microsoft.Maps.SpatialMath is a truly competent module. That module adds complex spatial calculations and analysis. And yet there is more, combining this module with projects like Nanjing opens up for interesting applications. For example, how far can I get with my electric car? Or, consider truck drivers, at least in Sweden, they are allowed to drive for a limit of time without having a break. Let’s say 2 hours, then they need to have a break for 15 minutes or so, then they can continue. I don’t know the exact limits. The industry definitely has a need to plan the route with stops accordingly to regulations. For example they might need to find a stop along the route between 90-120 minutes.
To resolve the use case above one way could be:
- Calculate the route from A to B.
- Calculate Isochrones from start to 120 minutes.
- Calculate Isochrones from start to 90 minutes.
- Use Microsoft.Maps.SpatialMath.difference operation to resolve the area between 90-120 minutes.
- Buffer the area, Microsoft.Maps.SpatialMath.buffer
- Use the buffered area and Microsoft.Maps.SpatialMath.intersection operation to calculate the route that is between 90-120 minutes (intersection)
- Visualize the calculated (intersected) area.
In these steps, a pretty complex problem has been addressed. From the routing-service I got the isochrones, then it is easy to combine the isochrones with geometry math operations. The operations I used is:
- Intersection (to see where the buffer overlaps the difference area.
- Buffer (for better visualization of the located area)
- Difference (between the isochrones)
Now it is easy to find a spot where the driver must find a place to stop. Remember, from the beginning this is not a trivial problem, by combining powerful geodataservices, client-side operations and knowing how to solve the pieces in the puzzle makes it is easy to finish.
I made a demo application to this post. https://github.com/perfahlen/BingMaps-Routing-And-Module-Pearls