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. SeeHorizonPosition
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 optionsHorizonOptions
for which it was generated must specify sub-path search optionsSubPathSearchOptions
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. SeeHorizonPosition
for more details.
-
Initializes instance of
HorizonSnapshot
.Declaration
Swift
public init( paths: [HorizonPath], state: HorizonSnapshotState, mainPathID: Int? )
-
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]
-
The
HorizonSnapshotState
.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). SeeHorizonPosition
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 optionsSubPathSearchOptions
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 positionHorizonPosition
on the pathHorizonPath
to which the position belongs, within the given distance. Elements of the same typeHorizonElementType
are provided in increasing order of the start offsetHorizonElement
.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 pathHorizonPath
to which the position belongs, within the given distance. The list is empty if the position does not have a valid path IDHorizonPath.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 typesHorizonElementType
that are ahead of the given positionHorizonPosition
on the pathHorizonPath
to which the position belongs, within the given distance. Elements of the same type are provided in increasing order of the start offsetHorizonElement
.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 pathHorizonPath
to which the position belongs, within the given distance. The list is empty if the position does not have a valid path IDHorizonPath
.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 typesHorizonElementType
that are ahead of the given positionHorizonPosition
on the pathHorizonPath
to which the position belongs, within the given distance. Elements of the same type are provided in increasing order of the start offsetHorizonElement
.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 pathHorizonPath
to which the position belongs, within the given distance. The list is empty if the position does not have a valid path IDHorizonPath
.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 offsetHorizonElement
.startOffset of the given horizon elementHorizonElement
.The distance is strictly positive for elements in front of the position, i.e.
- Elements on the position path
HorizonPath
in front of the positionHorizonPosition
(the start offsetHorizonElement
.startOffset of the element is greater than the position offsetHorizonPosition
.offset). - 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.:
- Elements on the position path
HorizonPath
that are completely behind the positionHorizonPosition
or overlap the position, but start before the position (the start offsetHorizonElement
.startOffset of the element is less than the position offsetHorizonPosition
.offset). - 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 offsetHorizonElement
.startOffset of the element on the position pathHorizonPath
is the same as the position offsetHorizonPosition
.offset).The distance is null if any of the following is true:
- The position
HorizonPosition
does not have a valid path IDHorizonPath
.pathID - There is no path
HorizonPath
in the snapshot with the same ID as the one stored in the position - The given element does not exist in the snapshot
- 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.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public func distance( to element: HorizonElement, from position: HorizonPosition ) -> Measurement<UnitLength>?
Return Value
The tree distance to the given horizon element.
- Elements on the position path
-
Returns the coordinates
CLLocationCoordinate2D
of the given elementHorizonElement
on the pathHorizonPath
. 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.Important
This is a Public Preview API. It may be changed or removed at any time.
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.