smart pieces of code
TGAgisRouter is a native Delphi / C++ Builder component, capable of optimum path calculation. In other words, it solves travelling salesman problems accurately. In web service mode, it can directly retrieve costs between waypoints, from Google Servers.
Or it can acquire costs from a connected TGAgisGoogleMap or TGAgisBingMap, set with a valid URL / Key pair.
The component can calculate both shortest and fastest paths among up to 256 waypoints, from real cost values, not from pixel coordinates, which would definitely result in wrong paths because of distortion caused from mercator projection, no direct roads existing in real life and more..
“As the crow flies” distances between waypoints can also be calculated and used, instead of querying from web service or through map, and use those in optimum route calculations. This can be used when query limit is over, to reduce network traffic or when faster calculation is preferred along with tolerable accuracy.
Optimizations can be done against minimum distance or minimum duration according to the setting.
Travel mode can be chosen as Driving, Walking or Bicycling.
Highway usage and toll roads can be allowed or avoided.
Start and finish waypoints can be chosen or left undefined.
Choosing the same for both will result in a ring path.
It has also a cache system, to reduce network traffic between Google/Bing Server, and improve performance. It will not ask a cost more than once, just remember if previously asked. You can also limit number of cachable distances in case of memory concerns.
The component can use two different algorithms. One is the Brute Force Algorithm, it is %100 accurate; but will need more time for calculations, especially over 14 waypoints. And the Genetic Algorithm, which reduces calculation time required radically, while keeping the accuracy fall in a neglectable range (less than 1 percent).
With the embedded error handling, it automatically retries getting costs, in case Server returns TooManyQueries error. Maximum number of retries can be set, or left unlimited.
For a closer look please check the demo.
Copyright © 2009 - 2022 Smart.Info Software - All rights reserved.