2

我正在与一所大学合作开发他们的校园 iOS 应用程序。该应用程序的功能之一是能够确定哪些校园巴士路线最适合到达目的地(以及巴士到达时间的列表等)。

如果我有代表路线停靠点的长/纬度数据集,那么确定到长/纬度目的地点的最近路线的最简单方法是什么?我有 10 多个 roues 需要考虑。

4

1 回答 1

2

If you want to determine the closest point to a route, you can use the Distance to a Ray or Segment formula using a lat-lng as the reference point.

There is another option, if you are using a Google Map, because the Terms of Service require that the service be used in the context of a Google Map; you may want to consider the Google Maps Distance Matrix Servicedev-guide. The service allows you to submit a request with an origins property, which must be an array of google.maps.LatLng starting points and a destinations property, which must be an array of google.maps.LatLng ending points. The DistanceMatrixServiceapi-doc also allows you to define a TravelModeapi-doc, which may be one of: BICYCLING, DRIVING, or WALKING. It has the advantage over simple distance calculation, because it accounts for the natural activity of traveling from one point to another using the existing network of streets.

于 2012-05-28T22:46:36.197 回答