DistanceMatrixTool 1.0.0
dotnet add package DistanceMatrixTool --version 1.0.0
NuGet\Install-Package DistanceMatrixTool -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DistanceMatrixTool" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DistanceMatrixTool" Version="1.0.0" />
<PackageReference Include="DistanceMatrixTool" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DistanceMatrixTool --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DistanceMatrixTool, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DistanceMatrixTool@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DistanceMatrixTool&version=1.0.0
#tool nuget:?package=DistanceMatrixTool&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Distance Matrix Package
Package description
Given a list of origins and destinations, the DistanceMatrix package provides the time taken to travel by car from each origin to each destination.
Use
Steps to use
- Create a list of origins defined by the
Locationclass - Create a list of destinations defined by the
Locationclass - A
Locationobject is constructed using a latitude as a first parameter and a longitude as a second parameter - Both
Locationconstructor parameters are supplied using decimal degees notation - Invoke the
DistanceMatrixCreatorstatic class methodGenerateDistanceMatrixto return aDistanceMatrix - The
GenerateDistanceMatrixmethod takes three parameters- List of origins
- List of destinations
- Google Maps API key
- The returned distance matrix contains the time taken to travel by car from each origin to each destination as demonstrated below:
+------------+------------+------------+------------+ | | D | E | F | +------------+------------+------------+------------+ | A | A - D | A - E | A - F | +------------+------------+------------+------------+ | B | B - D | B - E | B - F | +------------+------------+------------+------------+ | C | C - D | C - E | C - F | +------------+------------+------------+------------+ - The data in the matrix can be consumed row wise by using the
distanceMatrix[originIndex]. This returns the time taken to travel from the origin to each destination. - The data in the matrix can be consumed cell wise by using
distanceMatrix[originIndex][destinationIndex]. This returns the time taken to travel from a given origin to a given destination.
Assumptions
The distance matrix package relies on the Google Maps API without any additional parameters. It is therefore subject to the same assumptions as the parameterless API, namely:
- The time duration is based on travelling by car
- The time duration assumes no traffic
- If a provided location is off a road, the location will be attached onto the nearest road
Example use
List<Location> origins = new List<Location>() {
new Location(37.73475, -122.47523),
new Location(38.11751, -121.53500),
new Location(38.58993, -121.73333),
};
List<Location> destinations = new List<Location>() {
new Location(37.67184, -122.43652),
new Location(38.45499, -120.88909),
new Location(38.66347, -121.85902),
};
var distanceMatrix = DistanceMatrixCreator.GenerateDistanceMatrix(origins, destinations, "GOOGLE_MAPS_API_KEY");
var Origin1ToAllDestinations = distanceMatrix[0];
var Origin2ToAllDestinations = distanceMatrix[1];
var Origin3ToAllDestinations = distanceMatrix[2];
var Origin2ToDestination2 = distanceMatrix[1][1];
Package dependencies
Microsoft.AspNet.WebApi.Client
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.AspNet.WebApi.Client (>= 5.2.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 420 | 5/10/2022 |