Click or drag to resize

MultiThreadMatrix Class

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Provides functionality similar to RouteMatrix, but with the added benefit of being able to specify the number of threads to be used; ideal for multi-core systems working with large matrices. When the matrix is instantiated, the whole matrix is calculated in one go. Using persist provides the option to save the results to disk for faster, subsequent, data retrieval.
Inheritance Hierarchy
SystemObject
  Telogis.GeoBase.RoutingMultiThreadMatrix

Namespace:  Telogis.GeoBase.Routing
Assembly:  geobase.net (in geobase.net.dll) Version: 4.99.0.0
Syntax
public class MultiThreadMatrix

The MultiThreadMatrix type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleMultiThreadMatrix(RouteStop)
Create a MultiThreadMatrix using an array of RouteStops. The default RoutingStrategy is RoutingStrategyFastest. The default number of threads is equal to the number of CPU cores available on the local machine.
Public methodCode exampleMultiThreadMatrix(RouteStop, LinkCost)
Create a MultiThreadMatrix using an array of RouteStops. The RoutingStrategy defaults to RoutingStrategyFastest. The default number of threads is equal to the number of CPU cores available on the local machine.
Public methodCode exampleMultiThreadMatrix(RouteStop, RoutingStrategy)
Create a MultiThreadMatrix using an array of RouteStops, and a RoutingStrategy. The default number of threads is equal to the number of CPU cores available on the local machine.
Public methodCode exampleMultiThreadMatrix(RouteStop, RoutingStrategy, LatLon)
Create a MultiThreadMatrix using an array of RouteStops, and a RoutingStrategy. The default number of threads is equal to the number of CPU cores available on the local machine.
Public methodCode exampleMultiThreadMatrix(RouteStop, RoutingStrategy, Int32, Boolean)
Create a MultiThreadMatrix using an array of RouteStops, and a RoutingStrategy. Define the number of threads to use (NumThreads), and specify if the calculated data should be saved to disk (persist = true) for quicker, subsequent data reading.
Public methodCode exampleMultiThreadMatrix(RouteStop, RoutingStrategy, Int32, Boolean, LinkCost)
Create a MultiThreadMatrix using an array of RouteStops, and a RoutingStrategy. Define the number of threads to use (NumThreads), and specify if the calculated data should be saved to disk (persist = true) for quicker, subsequent data reading.
Public methodCode exampleMultiThreadMatrix(RouteStop, RoutingStrategy, LatLon, Int32, Boolean, LinkCost)
Create a MultiThreadMatrix using an array of RouteStops, and a RoutingStrategy. Define the number of threads to use (NumThreads), and specify if the calculated data should be saved to disk (persist = true) for quicker, subsequent data reading.
Top
Properties
  NameDescription
Public propertyCustomRoutingAccessKeys Obsolete.
Top
Methods
  NameDescription
Public methodCode exampleDistances
Returns an array of distances (in meters) from the specified stop (LatLon) to all other stops.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodCode exampleGetDistance
Get the distance (in meters) between two points.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodCode exampleGetSlot
Returns the slot value (row index) for the specified LatLon
Public methodCode exampleGetTime
Get the time (in seconds) from point to point.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodCode exampleTimes
Returns an array of times (in seconds) from the specified stop (LatLon) to all other stops.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks

When the MultiThreadMatrix is 'persistent' the calculation results are automatically saved and loaded from disk, as and when required.

Related articles: Using a RouteMatrix.

Examples
This example creates five RouteStops, and then displays the time and distance between the first one ('start'), and each stop.
C#
{
     //Create stops
     RouteStop start = new RouteStop(33.84105, -117.91133);
     RouteStop stop1 = new RouteStop(33.84123, -117.92153);
     RouteStop stop2 = new RouteStop(33.83373, -117.91278);
     RouteStop stop3 = new RouteStop(33.83818, -117.90488);
     RouteStop stop4 = new RouteStop(33.82960, -117.90041);

     //Create new MultiThreadMatrix
     //    * RouteStop array
     //    * strategy -> RoutingStrategyFastest
     //    * number of threads -> 4
     //    * persist -> true
     MultiThreadMatrix myMTM = new MultiThreadMatrix(new RouteStop[] { start, stop1, stop2, stop3, stop4 }, new RoutingStrategyFastest(), 4, true);

     //Get time and distances
     double[] myMTMTimes = myMTM.Times(0); // seconds
     double[] myMTMDistances = myMTM.Distances(0); // meters

     //Output time and distance calculations to console
     for (int i = 1; i < myMTMTimes.Length; i++) {
         //Get distance (meters)
         string distance = MathUtil.ConvertUnits(myMTMDistances[i], DistanceUnit.METERS, DistanceUnit.KILOMETERS).ToString(".##");

         //Get time (seconds)
         TimeSpan time = TimeSpan.FromSeconds(myMTMTimes[i]);

         //Output to console
         Console.WriteLine("Distance to stop " + i + " is " + distance + "km, " + time + " minutes away" + Environment.NewLine);
     }
}
See Also