MainPathSearchOptions
public struct MainPathSearchOptions
Horizon search options for the main path.
These options specify the PathSearchDistancePolicy
and the search time for the main path.
The main path is the path the user currently follows, extending along the most likely trajectory. The search distance
policy and the search time define the extent of the main path.
To specify horizon options for the main path, create an instance of this class:
let mainPathSearchOptions = try MainPathSearchOptions(
searchTime: .tt.minutes(10),
searchDistancePolicy: ExplicitDistancePolicy(
searchDistance: PathSearchDistance(
maxHorizonLength: .tt.kilometers(5)
)
),
minDistanceAhead: .tt.kilometers(1.5)
)
For more information on horizon paths see HorizonEngine
.
For more information on horizon options see HorizonOptions
.
The PathSearchDistancePolicy
determines whether the horizon engine must search along the
entire route (see RouteLengthPolicy
) or within an explicitly specified distance (see ExplicitDistancePolicy
).
If both search time and search distance policy are provided (i.e., the options specify both a search time and a search
distance policy) for the main path, the HorizonEngine
extends the main path until time and distance
have both reached their limits.
If the search time is not specified, the horizon engine works with a default value of Defaults
.pathSearchTime
for the search time and extends the main path based on the search distance directly specified by or derived from the
search policy.
Important
This is a Public Preview API. It may be changed or removed at any time.-
Initializes instance of
MainPathSearchOptions
.Throws
InitializationError.invalidSearchTime
ifsearchTime
is negative.InitializationError.invalidMinDistanceAhead
ifminDistanceAhead
is negative.InitializationError.invalidSearchDistancePolicy
ifsearchDistancePolicy
isExplicitDistancePolicy
andminDistanceAhead
is greater than the maximum horizon length as specified byExplicitDistancePolicy.searchDistance
.Declaration
Swift
public init( searchTime: Measurement<UnitDuration> = Defaults.pathSearchTime, searchDistancePolicy: PathSearchDistancePolicy = Defaults.pathSearchPolicy, minDistanceAhead: Measurement<UnitLength> = Defaults.minDistanceAhead ) throws
-
Contains default values for
See moreMainPathSearchOptions
.Declaration
Swift
public enum Defaults
-
Path search time. 0 if the horizon options do not specify a path search time.
Declaration
Swift
public let searchTime: Measurement<UnitDuration>
-
Path search distance policy. It determines whether the horizon engine must search along the entire route (see RouteLengthPolicy) or within an explicitly specified distance (see ExplicitDistancePolicy).
Declaration
Swift
public let searchDistancePolicy: PathSearchDistancePolicy
-
The minimum length of the horizon ahead for which a horizon snapshot update is triggered. If the distance between the vehicle and the end of the horizon snapshot since the last snapshot update is less than this value, the client will receive a new horizon snapshot. If the
ExplicitDistancePolicy
is used for the main path, a value for the minimum distance ahead that is greater than the main path search distance will result in the snapshot being updated on every tick. To trigger update of the horizon snapshot on every tick, regardless of the search distance policy used for the main path, define this parameter toInt.max
in meters.Note
The value ofminDistanceAhead
must be correlated with the value ofsearchDistancePolicy
. Using a non-default value for any of these two parameters might require that the value of the other parameter be adjusted accordingly. For example:- With a custom
searchDistancePolicy
defined toExplicitDistancePolicy
and anExplicitDistancePolicy.searchDistance
of 10 km (instead of the default 2 km), it makes sense to use aminDistanceAhead
greater than the default 600 m. Otherwise, the frequency of horizon snapshot updates is very low. - With a custom
minDistanceAhead
set to 3 km (instead of the default 600 m), it makes sense to use asearchDistancePolicy
that results in a horizon longer than the 3 km (whereas the default is 2 km). Otherwise the frequency of horizon snapshot updates is very high (snapshot updated on every tick).
Declaration
Swift
public let minDistanceAhead: Measurement<UnitLength>
- With a custom
-
An error that occurs during the creation of the instance.
See moreDeclaration
Swift
public enum InitializationError : Error