TurbulenceClusterer

public class TurbulenceClusterer

Group TurbulenceItem based on distance. New turbulence will be added to existing clusters or to new clusters. Clusters will be removed when become empty or reset() is called.

Usage example:

private let alertClusterer = TurbulenceClusterer()
...
alertClusterer.process(turbulence: alertResult.turbulence)
  • Parameters for grouping turbulence into clusters.

    See more

    Declaration

    Swift

    public struct Options

Properties

Initializers

  • Default initializer.

    Declaration

    Swift

    public init(options: TurbulenceClusterer.Options = .init())

    Parameters

    options

    Options for clustering. Has default values.

Actions

  • Update clusters using turbulence.

    clusters array will be updated in the following way:

    • existing clusters’ turbulence that is not in turbulence anymore will be removed from the cluster
    • empty existing clusters will be removed
    • new cluster will be created when a turbulence item can’t be added to any of the existing clusters

    Declaration

    Swift

    public func process(turbulence: [TurbulenceItem])

    Parameters

    turbulence

    Turbulence to group into clusters.

  • Checks if the cluster has turbulence tiles that were already alerted (based on tiles) to not alert again.

    For example, if turbulence in some tile was alerted when it was in cluster A, then later this turbulence moved to cluster B, it will not be alerted again even when it is in a different cluster.

    Should be used in conjunction with alerted(cluster:).

    Declaration

    Swift

    public func isAlerted(cluster: TurbulenceCluster) -> Bool

    Parameters

    cluster

    A generated cluster to check turbulence in.

  • Save cluster turbulence as alerted to check by isAlerted(cluster:) to not alert the same turbulence multiple times.

    Declaration

    Swift

    public func alerted(cluster: TurbulenceCluster)

    Parameters

    cluster

    A generated cluster to save turbulence tiles from.

  • Removes generated and alerted clusters. Should be called when stopped monitoring alerts or stopped the route, or when no need to cluster anymore.

    Declaration

    Swift

    public func reset()