【问题标题】:IOS Mapkit or Core Location Solution for Traveling Salesman ProblemIOS Mapkit 或 Core Location 解决旅行商问题
【发布时间】:2018-12-17 22:48:10
【问题描述】:

Google Directions 有一个 api 来解决Traveling Salesman Problem--计算一组点上的最短路线--但收费。在 Apple 世界中,Polyline 和 MKRoute 似乎很有希望,但我在文档中找不到任何内容表明它们支持两个以上的点——start 和 dest。有没有人在使用 MapKit 和/或 Core Location 时遇到过 TSP 问题?似乎可以使用以下方法及时计算节点之间所有边的距离:

request.source = startLocation
        request.destination = destLocation
        request.requestsAlternateRoutes = true
        request.transportType = .automobile

        let directions = MKDirections(request: request)
        directions.calculate { (directions, error) in

            if var routeResponse = directions?.routes {
                routeResponse.sort(by: {$0.expectedTravelTime <
                    $1.expectedTravelTime})
                let quickestRouteForSegment: MKRoute = routeResponse[0]

                completion(quickestRouteForSegment.expectedTravelTime)  
            }
        }
    }

并手动开发一种算法来尝试各种可能性并选择最快的算法。但这很快就会变得复杂,需要很多请求。只是想知道是否有人发现了一种更复杂的方法来处理它。

【问题讨论】:

    标签: ios swift mapkit core-location


    【解决方案1】:

    您将无法使用 Mapkit 实现您想要的,因为您需要大量请求,Apple 会限制您的应用程序。坚持使用 Google 或 Mapbox,他们有用于 STP 的矩阵 api,而 Mapkit 没有。

    【讨论】:

    • 另外,您需要使用 carthage 或 cocoapods 安装 mapbox 吗?如果可能,我宁愿不使用依赖项。
    • 您可以使用任何一种安装它,请参阅本指南:mapbox.com/ios-sdk/navigation/overview/installation-and-setup 是的 Mapbox 是可靠的,它与 Google 的型号略有不同,请检查适合您的型号并选择它。
    猜你喜欢
    • 2019-07-27
    • 2019-11-16
    • 2018-03-26
    • 2011-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-02
    • 1970-01-01
    相关资源
    最近更新 更多