Use aws-geospatial/polyline (#4027)
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
{
|
||||
"identity" : "polyline",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/raphaelmor/Polyline",
|
||||
"location" : "https://github.com/aws-geospatial/polyline/",
|
||||
"state" : {
|
||||
"revision" : "353f80378dcd8f17eefe8550090c6b1ae3c9da23",
|
||||
"version" : "5.1.0"
|
||||
"revision" : "deaef283f8040debf7cbd21bf95d779d2d1a798e",
|
||||
"version" : "0.3.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ let package = Package(
|
||||
defaultLocalization: "en",
|
||||
platforms: [.iOS(.v12)],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/raphaelmor/Polyline", from: "5.1.0"),
|
||||
.package(url: "https://github.com/aws-geospatial/polyline/", from: "0.3.1"),
|
||||
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.54.0"),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -144,7 +144,11 @@ class NavigationRoute {
|
||||
init(json: [String: Any], mapView: MLNMapView) {
|
||||
self.mapView = mapView
|
||||
|
||||
load(json: json)
|
||||
do {
|
||||
try load(json: json)
|
||||
} catch {
|
||||
print("Error loading route: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -152,7 +156,7 @@ class NavigationRoute {
|
||||
mapView?.locationManager = nil
|
||||
}
|
||||
|
||||
private func load(json: [String: Any]) {
|
||||
private func load(json: [String: Any]) throws {
|
||||
let routeJson = (json["routes"] as! [[String: Any]]).first!
|
||||
|
||||
// stats
|
||||
@@ -164,7 +168,11 @@ class NavigationRoute {
|
||||
destination = CLLocationCoordinate2D(latitude: destinationJson.last!, longitude: destinationJson.first!)
|
||||
|
||||
// route geometry
|
||||
let geometry: [LocationCoordinate2D] = decodePolyline(routeJson["geometry"] as! String, precision: 1e6)!
|
||||
Polyline.setCompressionAlgorithm(CompressionAlgorithm.Polyline6)
|
||||
|
||||
let geometry = try Polyline.decodeToLngLatArray(routeJson["geometry"] as! String).map {
|
||||
CLLocationCoordinate2D(latitude: $0.last!, longitude: $0.first!)
|
||||
}
|
||||
|
||||
loadGeometry(from: geometry)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user