我正在使用 C# WebClient 和 UriBuilder 类,与 Google 距离矩阵 API 进行通信。我的程序正在发送以逗号分隔的纬度、经度对。一个起点和多个目的地都可以正常工作:查询字符串上的目的地值只需要用竖线字符“|”分隔:
&destinations=latitude1,longitude1|latitude2,longitude2...
但我想让它与多个来源一起工作,每个来源都有自己的多个目的地。那可能吗?或者 API 是否生成笛卡尔积,计算每个起点到每个目的地的距离?
如果可能的话,如何在查询字符串上origins[i]
进行协调?destinations[i]
这是我的 C# 程序中的示例结构(地理位置被遮挡):
我需要将该结构转换为 API 将在查询字符串上接受的格式,以destinationArray[0]
与origin[0]
和destinationArray[1]
with链接的方式origin[1]
。