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
coordinatesThe
ArrayofCLLocationCoordinate2Dthat you want to encodelevelsThe optional
Arrayof levels that you want to encode (default:nil)precisionThe precision used for encoding (default:
1e5) -
This designated initializer decodes a polyline
StringDeclaration
Swift
public init(encodedPolyline: String, encodedLevels: String? = nil, precision: Double = 1e5)Parameters
encodedPolylineThe polyline that you want to decode
encodedLevelsThe levels that you want to decode (default:
nil)precisionThe precision used for decoding (default:
1e5) -
This init encodes a
[CLLocation]Declaration
Swift
public init(locations: [CLLocation], levels: [UInt32]? = nil, precision: Double = 1e5)Parameters
locationsThe
ArrayofCLLocationthat you want to encodelevelsThe optional array of levels that you want to encode (default:
nil)precisionThe precision used for encoding (default:
1e5)
View on GitHub
Polyline Structure Reference