MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / get_route

Function get_route

bmtools/tools/map/bing_map/api.py:36–51  ·  view source on GitHub ↗

Get the route between two locations in miles

(start:str, end:str)

Source from the content-addressed store, hash-verified

34
35 @tool.get("/get_route")
36 def get_route(start:str, end:str):
37 """Get the route between two locations in miles"""
38 # Request URL
39 url = BASE_URL + "Routes/Driving?o=json&wp.0=" + start + "&wp.1=" + end + "&key=" + KEY
40 # GET request
41 r = requests.get(url)
42 data = json.loads(r.text)
43 # Extract route information
44 route = data["resourceSets"][0]["resources"][0]
45 itinerary = route["routeLegs"][0]["itineraryItems"]
46 # Extract route text information
47 route_text = []
48 for item in itinerary:
49 if "instruction" in item:
50 route_text.append(item["instruction"]["text"])
51 return route_text
52
53 @tool.get("/get_coordinates")
54 def get_coordinates(location:str):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected