HorizonSnapshot

public struct HorizonSnapshot

Snapshot of the horizon.

Snapshot of the horizon provided by the HorizonEngine for a set of registered HorizonOptions. These options define the extent of the paths HorizonPath on the horizon and which map attributes are collected for those paths.

Horizon snapshot holds state of the horizon for HorizonOptions provided by user and current position. Snapshot contains data such as:

  • paths: List of horizon paths HorizonPath, consisting of the main path and zero or more sub-paths. The main path is the path on which the likeliest map-matched on-road position is located. If there is no on-road map-matched position candidate, there is no main path either. This is because no horizon can be provided if there is no on-road map-matched position. See HorizonPosition for more details. A sub-path is any path in the horizon snapshot that is not the main path. For a horizon snapshot to contain sub-paths, the options HorizonOptions for which it was generated must specify sub-path search options SubPathSearchOptions for at least one sub-path level.
  • state: The horizon snapshot state HorizonSnapshotState
  • mainPathID: The ID of the main path HorizonPath. Nil if there is no on-road map-matched position candidate. See HorizonPosition for more details.
  • The array of HorizonPath, consisting of the main path and zero or more sub-paths. The main path is where the vehicle is located. A sub-path is any path in the horizon snapshot that is not the main path.

    Declaration

    Swift

    public let paths: [HorizonPath]
  • Declaration

    Swift

    public let state: HorizonSnapshotState
  • Returns the main horizon path. The main path is the path on which the likeliest map-matched on-road position is located. If there is no on-road map-matched position candidate, there is no main path either because no horizon can be provided. See HorizonPosition for more details.

    Declaration

    Swift

    public func mainPath() -> HorizonPath?

    Return Value

    The main horizon path HorizonPath. Nil if there is no main path because no horizon can be generated (there is no on-road map-matched position candidate). See HorizonPosition for more details.

  • Returns the list of horizon sub-paths. A sub-path is any path that is not the main path. For a horizon snapshot to contain sub-paths, the options HorizonOptions for which it was generated must specify sub-path search options SubPathSearchOptions for at least one sub-path level.

    Declaration

    Swift

    public func subPaths() -> [HorizonPath]

    Return Value

    The list of horizon sub-paths HorizonPath. Empty list if there are no sub-paths in the horizon.

  • Returns the horizon elements HorizonElement that are ahead of the given position HorizonPosition on the path HorizonPath to which the position belongs, within the given distance. Elements of the same type HorizonElementType are provided in increasing order of the start offset HorizonElement.startOffset.

    Declaration

    Swift

    public func elementsAhead(
        position: HorizonPosition,
        distanceAhead: Measurement<UnitLength>
    ) -> [HorizonElement]

    Return Value

    The list of horizon elements HorizonElement ahead of the given position on the path HorizonPath to which the position belongs, within the given distance. The list is empty if the position does not have a valid path ID HorizonPath.pathID or there is no path in the snapshot with the same ID as the one stored in the position.

  • Returns the horizon elements HorizonElement of the given types HorizonElementType that are ahead of the given position HorizonPosition on the path HorizonPath to which the position belongs, within the given distance. Elements of the same type are provided in increasing order of the start offset HorizonElement.startOffset .

    Declaration

    Swift

    public func elementsAhead(
        position: HorizonPosition,
        distanceAhead: Measurement<UnitLength>,
        types: [HorizonElementType]
    ) -> [HorizonElement]

    Return Value

    The list of horizon elements HorizonElement of the given types ahead of the given position on the path HorizonPath to which the position belongs, within the given distance. The list is empty if the position does not have a valid path ID HorizonPath.pathID or there is no path in the snapshot with the same ID as the one stored in the position.

  • Returns the horizon elements HorizonElement of the given types HorizonElementType that are ahead of the given position HorizonPosition on the path HorizonPath to which the position belongs, within the given distance. Elements of the same type are provided in increasing order of the start offset HorizonElement.startOffset.

    Declaration

    Swift

    public func elementsAhead(
        position: HorizonPosition,
        distanceAhead: Measurement<UnitLength>,
        type: HorizonElementType
    ) -> [HorizonElement]

    Return Value

    The list of horizon elements HorizonElement of the given types ahead of the given position on the path HorizonPath to which the position belongs, within the given distance. The list is empty if the position does not have a valid path ID HorizonPath.pathID or there is no path in the snapshot with the same ID as the one stored in the position.

  • Returns the tree distance from the specified position HorizonPosition to the start offset HorizonElement.startOffset of the given horizon element HorizonElement.

    The distance is strictly positive for elements in front of the position, i.e.

    1. Elements on the position path HorizonPath in front of the position HorizonPosition (the start offset HorizonElement.startOffset of the element is greater than the position offset HorizonPosition.offset).
    2. Elements on sub-paths that the vehicle can reach by successively deviating to child paths.

    The distance is strictly negative for elements behind the vehicle that the vehicle has moved past, i.e.:

    1. Elements on the position path HorizonPath that are completely behind the position HorizonPosition or overlap the position, but start before the position (the start offset HorizonElement.startOffset of the element is less than the position offset HorizonPosition.offset).
    2. Elements on sub-paths that the vehicle has deviated from at some point in the past.

    The distance is 0 for elements that start at the position HorizonPosition (the start offset HorizonElement.startOffset of the element on the position path HorizonPath is the same as the position offset HorizonPosition.offset).

    The distance is null if any of the following is true:

    1. The position HorizonPosition does not have a valid path ID HorizonPath.pathID
    2. There is no path HorizonPath in the snapshot with the same ID as the one stored in the position
    3. The given element does not exist in the snapshot
    4. The given element is an element behind the position that the vehicle has not moved past, i.e., elements on sub-paths behind the vehicle that the vehicle has not taken.

    Declaration

    Swift

    public func distance(
        to element: HorizonElement,
        from position: HorizonPosition
    ) -> Measurement<UnitLength>?

    Return Value

    The tree distance to the given horizon element.

  • Returns the coordinates CLLocationCoordinate2D of the given element HorizonElement on the path HorizonPath. If the element is a spot element, the returned list contains a single point. If the element is a segment element, the returned list contains a sequence of points from the element start to the element end, including all the intermediate points. If the element is not in the snapshot, the returned list is empty.

    Declaration

    Swift

    public func elementGeometry(element: HorizonElement) -> [CLLocationCoordinate2D]

    Parameters

    element

    The horizon element HorizonElement to return geometry for.

    Return Value

    The list of coordinates CLLocationCoordinate2D for the given element.