@@ -13,6 +13,7 @@ Field teams, delivery services, and survey organizations waste time and money on
1313- ** Route** : Find the shortest path through locations (TSP)
1414- ** Assign** : Match locations to nearest workers or depots
1515- ** Random Walk** : Generate survey itineraries on road networks
16+ - ** Distance Matrix** : Calculate travel times/distances via OSRM or Google Routes API
1617
1718## Install
1819
@@ -68,6 +69,31 @@ result = allocator.random_walk(G, n_walks=10, walk_length_m=5000)
6869print (result.data) # DataFrame with waypoints
6970```
7071
72+ ### Calculate distance matrix
73+
74+ ``` python
75+ from allocator.distances import get_distance_matrix
76+ import numpy as np
77+
78+ points = np.array([
79+ [- 122.4194 , 37.7749 ], # SF downtown
80+ [- 122.4089 , 37.7855 ], # North Beach
81+ ])
82+
83+ # Local calculation (fast, no API)
84+ dist = get_distance_matrix(points, method = " haversine" )
85+
86+ # OSRM (free, real driving times)
87+ dist = get_distance_matrix(points, method = " osrm" )
88+
89+ # Google Routes API (requires service account)
90+ dist = get_distance_matrix(
91+ points,
92+ method = " google_routes" ,
93+ credentials_file = " /path/to/service-account.json"
94+ )
95+ ```
96+
7197## CLI
7298
7399``` bash
0 commit comments