GeoPolyline

public struct GeoPolyline : Hashable

A list of geographic coordinates representing the vertices of a polyline. An instance of this class, initialized with appropriate vertices. Represents a GeoPolyline as a series of geographic coordinates.

  • The list of vertices representing the polyline.

    Declaration

    Swift

    public let vertices: [GeoCoordinates]
  • Constructs a GeoPolyline from the provided vertices. Throws an InstantiationError if the number of vertices is less than two.

    Throws

    InstantiationError Instantiation error.

    Declaration

    Swift

    public init(vertices: [GeoCoordinates]) throws

    Parameters

    vertices

    List of vertices representing the polyline.

  • Constructs an instance of this class from GeoBox.

    Declaration

    Swift

    public init(geoBox: GeoBox)

    Parameters

    geoBox

    A rectangle defined by the GeoBox to be converted into GeoPolyline. The corner coordinates of the GeoBox will define the points of the resulting GeoPolyline.

  • Returns the index of the nearest vertex to the given point.

    Declaration

    Swift

    public func getNearestIndexTo(point: GeoCoordinates) -> UInt32

    Parameters

    point

    Coordinates of the point.

    Return Value

    Index of the closest vertex of the polyline.

  • Returns the coordinates at the given distance along the polyline. When the polyline is traversed from the beginning, the distance is calculated from the start of the polyline; while a direction from the end indicates a distance from the last vertex.

    The offset is expected to be non-negative and smaller than the length of the polyline. When the offset is negative, the function returns the starting end point of the polyline, i.e. the first vertex in positive direction and the last vertex in the negative direction. Similarly, when the offset is larger than the length of the polyline, then the function returns the opposite end point of the polyline.

    The distance between two consecutive vertices is calculated using the GeoCoordinates.distance(...) function. Therefore, it computes the distance (in meters) along the great circle between the two vertices. Similarly, the full length of the polyline is the sum of the distances between its vertices. The interpolation coordinates between two vertices is calculated using the GeoCoordinates.interpolate(...) function.

    Note: the result may different from the analogue result from other matching components since they may adapt the result to the length of the underlying object described by the polyline.

    Declaration

    Swift

    public func coordinatesAt(offsetInMeters: Double, direction: GeoPolylineDirection) -> GeoCoordinates

    Parameters

    offsetInMeters

    The distance along the polyline in meters

    direction

    The direction in which the polyline is traversed.

    Return Value

    The coordinates of the point at the given distance