Polyline
struct Polyline
This class can be used for :
- Encoding an [CLLocation] or a [CLLocationCoordinate2D] to a polyline String
- Decoding a polyline String to an [CLLocation] or a [CLLocationCoordinate2D]
- Encoding / Decoding associated levels
it is aims to produce the same results as google’s iOS sdk not as the online tool which is fuzzy when it comes to rounding values
it is based on google’s algorithm that can be found here :
:see: https://developers.google.com/maps/documentation/utilities/polylinealgorithm
-
The array of coordinates (nil if polyline cannot be decoded)
Declaration
Swift
public let coordinates: [CLLocationCoordinate2D]?
-
The encoded polyline
Declaration
Swift
public let encodedPolyline: String
-
The array of levels (nil if cannot be decoded, or is not provided)
Declaration
Swift
public let levels: [UInt32]?
-
The encoded levels (nil if cannot be encoded, or is not provided)
Declaration
Swift
public let encodedLevels: String?
-
The array of location (computed from coordinates)
Declaration
Swift
public var locations: [CLLocation]? { get }
-
This designated initializer encodes a
[CLLocationCoordinate2D]
Declaration
Swift
public init(coordinates: [CLLocationCoordinate2D], levels: [UInt32]? = nil, precision: Double = 1e5)
Parameters
coordinates
The
Array
ofCLLocationCoordinate2D
that you want to encodelevels
The optional
Array
of levels that you want to encode (default:nil
)precision
The precision used for encoding (default:
1e5
) -
This designated initializer decodes a polyline
String
Declaration
Swift
public init(encodedPolyline: String, encodedLevels: String? = nil, precision: Double = 1e5)
Parameters
encodedPolyline
The polyline that you want to decode
encodedLevels
The levels that you want to decode (default:
nil
)precision
The precision used for decoding (default:
1e5
) -
This init encodes a
[CLLocation]
Declaration
Swift
public init(locations: [CLLocation], levels: [UInt32]? = nil, precision: Double = 1e5)
Parameters
locations
The
Array
ofCLLocation
that you want to encodelevels
The optional array of levels that you want to encode (default:
nil
)precision
The precision used for encoding (default:
1e5
)