NDSStoreUpdater

public class NDSStoreUpdater : NDSMapUpdater

Implements the update logic of the provided NDSStore.

Important

This is a Public Preview API. It may be changed or removed at any time.
  • Creates an instance of NDSStoreUpdater.

    NDS map path, decryption keys and such will be retreived from the supplied NDSStore instance.

    Throws

    MapUpdateError/initFailed if there is something wrong with the configuration.

    Important

    For the same NDSStore only one instance of the NDSStoreUpdater should be created.

    Declaration

    Swift

    public init(config: NDSStoreUpdateConfig, ndsStore: NDSStore) throws

    Parameters

    config

    Update configuration parameters.

    ndsStore

    An instance of NDSStore configured for the NDS map on which the updater should work.

  • Path to the NDS map data, the directory that contains the ‘ROOT.NDS’ file. Has the same value as in the NDSStore passed in the constructor.

    Declaration

    Swift

    public let ndsMapDataPath: String
  • Synchronizes access to the NDS map. Has the same value as in the NDSStore passed in the constructor.

    Declaration

    Swift

    public let ndsMapAccessSync: NDSStoreAccessSync
  • Enables or disables map updates. Default value is false.

    When updates are enabled, automatic update operations (including map extension and repair of unusable regions) are started, according to the configuration.

    If map updates are disabled, this component will not write to the map for any reason. Automatic updates will not run. Updates that were running are safely interrupted. In such case, call to this method will block until all ongoing updates, if any, have stopped.

    Note

    When an update of the map is interrupted unexpectedly (e.g. power loss), the region that was being updated could become unusable.

    Declaration

    Swift

    public var updatesEnabled: Bool { get set }
  • Sets current position.

    Declaration

    Swift

    public func updatePosition(_ position: CLLocationCoordinate2D)

    Parameters

    position

    The new value for current position.

  • Sets the active route.

    Note

    Updating the active route triggers map update if along route update is enabled. and the polyline differs from the previous one.

    Declaration

    Swift

    public func updateActiveRoute(_ polyline: [CLLocationCoordinate2D])

    Parameters

    polyline

    The polyline representing the new active route.

  • Adds observer that is called when an automatic update fails due to an irrecoverable error.

    Declaration

    Swift

    public func addAutomaticMapUpdateFailureObserver(_ observer: AutomaticMapUpdateFailureObserver)

    Parameters

    observer

    The observer to be registered.

  • Removes previously registered observer.

    Declaration

    Swift

    public func removeAutomaticMapUpdateFailureObserver(_ observer: AutomaticMapUpdateFailureObserver)

    Parameters

    observer

    The registered observer.

  • Adds an observer for information about the state of the map.

    Note

    The observer is called with the current region graph as soon as it is added. The first observer that is added triggers the process of determining the region graph. If the region graph cannot be determined, an error is returned. In that case, the observer will be called when and if the error is resolved.

    Declaration

    Swift

    public func addRegionGraphObserver(_ observer: RegionGraphObserver)

    Parameters

    observer

    The observer to be added.

  • Removes a previously registered observer.

    Declaration

    Swift

    public func removeRegionGraphObserver(_ observer: RegionGraphObserver)

    Parameters

    observer

    The registered observer.

  • Schedules the given operations to be performed on the offline map.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    public func schedule(operations: [MapOperation])

    Parameters

    operations

    The operations to be performed on the offline map.

  • Requests cancelation of all operations scheduled with NDSStore/schedule(operations:) for the specified updatable regions.

    If the operations for a node have been successfully canceled, then the CompletedMapOperation/errorCode of the corresponding lastCompletedOperation is set to MapUpdateError/canceled.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    public func cancelAllMapOperations(for nodeIDs: [RegionGraphNodeID])

    Parameters

    nodeIDs

    The list of node IDs that were previously passed to NDSStore/schedule(operations:) to schedule an operation.

  • Finds the updatable regions within radius of position.

    Throws

    MapUpdateError/invalidArgument if the provided position is invalid.

    Note

    When cancelled with cancel(), callback will not be called.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    @discardableResult
    public func findRegionsAroundPosition(
        position: CLLocationCoordinate2D,
        radius: Measurement<UnitLength>,
        callback: @escaping (Result<RegionsAroundPosition, MapUpdateError>) -> ()
    ) throws
        -> Cancellable

    Parameters

    position

    The position around which to get the regions.

    radius

    The radius of the circle around the position to search for regions.

    callback

    Invoked when the operation has been finished either successfully or unsuccessfully (with an error). It is called from main thread. Possible errors in callback: MapUpdateError/unexpected, MapUpdateError/sharedMapAccessError, MapUpdateError/noMapAvailable, MapUpdateError/databaseError``.

    Return Value

    The Cancellable operation.

  • Finds the updatable regions along a polyline within a half-corridor width radius.

    Throws

    MapUpdateError/invalidArgument if the provided polyline contains any invalid location.

    Note

    When cancelled with cancel(), callback will not be called.

    Declaration

    Swift

    @discardableResult
    public func findRegionsAlongPolyline(
        polyline: [CLLocationCoordinate2D],
        radius: Measurement<UnitLength>,
        callback: @escaping (Result<RegionsAlongPolyline, MapUpdateError>) -> ()
    ) throws
        -> Cancellable

    Parameters

    polyline

    Points that define a polyline on the map.

    radius

    Distance from the polyline (or half-width of the corridor) within which search is performed.

    callback

    Invoked when the operation has been finished either successfully or unsuccessfully (with an error). It is called from main thread. Possible errors in callback: MapUpdateError/unexpected, MapUpdateError/sharedMapAccessError, MapUpdateError/noMapAvailable, MapUpdateError/databaseError``.

    Return Value

    The Cancellable operation.

  • Calculates the uninstallation size of the specified regions.

    Note

    When cancelled with cancel(), completion will not be called.

    Note

    The calculated size may be inaccurate if any region is currently undergoing a map operation.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    public func calculateUninstallSize(
        regions: Set<RegionGraphNodeID>,
        completion: @escaping (Result<Measurement<UnitInformationStorage>, MapUpdateError>) -> ()
    )
        -> Cancellable

    Parameters

    regions

    The set of updatable RegionGraphNodeID for calculating the uninstall size. If any RegionGraphNodeID does not exist in the RegionGraph or is not an updatable region, completion will be called with the MapUpdateError/invalidArgument error.

    completion

    Invoked when the operation has been finished either successfully or unsuccessfully (with an error). It is executed on the main thread. Possible errors in completion: MapUpdateError/unexpected, MapUpdateError/sharedMapAccessError, MapUpdateError/noMapAvailable, MapUpdateError/databaseError``.

    Return Value

    The Cancellable operation.