Skip to main content

CLASS

ArdkMapStorage

public final class ArdkMapStorage: ArdkSession.IDisposable

A storage system for managing device-generated maps.

The map storage feature provides capabilities for capturing, storing, and managing map data from AR sessions. This data can be persisted and used for Visual Positioning System (VPS) localization and map updates.

Methods​

mapData()​

public func mapData() -> ArdkBuffer?

Gets the complete map data.

This function returns all the map data accumulated during the AR session, serialized as a DeviceMap protobuf. This data can be saved, shared, and/or used for localization.

  • Returns: The serialized map data buffer if available, nil if no map data exists.

mapUpdate()​

public func mapUpdate() -> ArdkBuffer?

Gets the latest map update data.

This method returns the incremental map changes (new nodes and edges) that have been added since the last update.

  • Returns: The serialized map update if available, nil if no updates exist.

createRootAnchor()​

public func createRootAnchor() -> String?

Creates an anchor on the existing map located at the origin of the current AR session, if possible.

The root anchor represents the origin point of the map coordinate system and can be used with VPS for localization.

  • Returns: The payload of the root anchor, encoded as a base64 string if available, nil if otherwise.

addMap(map:)​

public func addMap(map: ArdkBuffer) throws

Adds previously serialized map data to the map storage.

  • Parameter map: The serialized map data to add. It should be encoded as a DeviceMap protobuf and can be obtained from mapData(), mapUpdate(), or mergeMapUpdate(existingMap:mapUpdate:).
  • Throws: ArdkError.invalidArgumentor ArdkError.nullArgument indicating a problem with the map argument . Check ARDK's C logs for more information.

Parameters​

NameDescription
mapThe serialized map data to add. It should be encoded as a DeviceMap protobuf and can be obtained from mapData(), mapUpdate(), or mergeMapUpdate(existingMap:mapUpdate:).

clear()​

public func clear()
  • Note: Must not be called if VPS is running. If called, localization data will be discarded and the session state will be undefined.

extractMapMetadata(anchorPayload:map:)​

public func extractMapMetadata(anchorPayload: String, map: ArdkBuffer) throws -> MapMetadata?

Extracts metadata from a map relative to a specified anchor.

Render the feature points in the metadata relative to the specified anchor to visualize the map. This is only possible when the anchor is linked directly to the map's node(s), or if the anchor's nodes are reachable to the map's nodes from the currently active transform graph.

  • Parameter anchorPayload: The base64-encoded payload of the anchor that the returned points will be relative to.
  • Parameter map: The map buffer to extract metadata from.
  • Returns: The metadata of the map if successful, nil if otherwise.
  • Throws: ArdkError.invalidArgumentor ArdkError.nullArgument indicating a problem with either argument. Check ARDK's C logs for more information.

Parameters​

NameDescription
anchorPayloadThe base64-encoded payload of the anchor that the returned points will be relative to.
mapThe map buffer to extract metadata from.

mergeMapUpdate(existingMap:mapUpdate:)​

public func mergeMapUpdate(existingMap: ArdkBuffer, mapUpdate: ArdkBuffer) throws -> ArdkBuffer

Merges a map update into an existing map.

This method combines incremental map updates with a base map to produce a merged map buffer containing the complete map data.

  • Parameter existingMap: The existing map to merge the update into.
  • Parameter mapUpdate: The map update to merge into the existing map.
  • Returns: The merged map buffer
  • Throws: ArdkError of type ArdkError.invalidArgumentor ArdkError.nullArgument indicating a problem with either argument . Check ARDK's C logs for more information.

Parameters​

NameDescription
existingMapThe existing map to merge the update into.
mapUpdateThe map update to merge into the existing map.