瞭解 AnchorLocateCriteria 類別Understanding the AnchorLocateCriteria class

在本文中,您將瞭解查詢錨點時可使用的不同選項。In this article you will learn the different options you can use when querying an anchor. 我們將探討 AnchorLocateCriteria 類別、其選項和有效的選項群組合。We will go over the AnchorLocateCriteria class, its options and valid option combinations.

錨點尋找準則Anchor locate criteria

AnchorLocateCriteria 類別可協助您查詢先前建立錨點的服務。The AnchorLocateCriteria class helps you query the service for previously created anchors. 每個監看員都可以隨時使用一個 AnchorLocateCriteria 物件。One AnchorLocateCriteria object may be used per watcher at any time. 每個 AnchorLocateCriteria 物件都必須只包含下列 其中一個 屬性: 識別碼NearAnchorNearDeviceEach AnchorLocateCriteria object must include exactly one of the following properties: Identifiers, NearAnchor, or NearDevice. 如有需要,可以設定其他屬性,例如 策略BypassCacheRequestedCategoriesAdditional properties such as Strategy, BypassCache, and RequestedCategories can be set if desired.

屬性Properties

在您的監看員中明確定義下列 其中一個 屬性:Define exactly one of the following properties in your watcher:

識別碼Identifiers

預設值:空字串陣列Default Value: empty string array

您可以使用識別碼,針對您想要尋找的錨點定義錨點識別碼的清單。Using Identifiers, you can define a list of anchor IDs for anchors you would like to locate. 在成功建立錨點之後,錨點識別碼一開始會傳回給您。Anchor IDs are initially returned to you after successful anchor creation. 使用指定的識別碼時,AnchorLocateCriteria 會將要求的錨點集合限制為具有相符錨點識別碼的錨點。With Identifiers specified, AnchorLocateCriteria restricts the set of requested anchors to anchors with matching anchor IDs. 這個屬性是使用字串陣列來指定。This property is specified using a string array.

NearAnchorNearAnchor

預設值:未設定Default Value: not set

您可以使用 NearAnchor,指定 AnchorLocateCriteria 將要求的錨點集合限制在遠離所選錨點的所需距離內。Using NearAnchor, you can specify that AnchorLocateCriteria restricts the set of requested anchors to anchors within a desired distance away from a chosen anchor. 您必須提供此選擇的錨點做為來源錨點。You must provide this chosen anchor as the source anchor. 您也可以設定所需距離來源錨點的距離,以及所傳回錨點的最大數目,以進一步限制搜尋。You may also set the desired distance away from the source anchor, and the maximum number of anchors returned, to further limit the search. 這個屬性是使用 NearAnchorCriteria 物件指定的。This property is specified using a NearAnchorCriteria object.

NearDeviceNearDevice

預設值:未設定Default Value: not set

您可以使用 NearDevice,指定 AnchorLocateCriteria 將要求的錨點集合限制在接近裝置實體位置的位置。Using NearDevice, you can specify that AnchorLocateCriteria restricts the set of requested anchors to those close to the device’s physical location. 任何啟用的感應器將用來協助探索裝置周圍的錨點。Any enabled sensors will be used to help discover anchors around your device. 若要找出錨點的最大機會,您應該設定 SensorCapabilities,讓會話存取所有適當的感應器。To have the best chance of finding anchors, you should configure SensorCapabilities to give the session access to all appropriate sensors. 如需有關設定和使用此屬性的詳細資訊,請參閱 粗略粗略重新置放-Azure 空間錨點 |Microsoft Docs以及如何在 c #目標 cSwiftJAVAc + +/NDKc + +/WinRT使用粗略粗略重新置放來建立和尋找錨點For more information on setting up and using this property, see Coarse Relocalization - Azure Spatial Anchors | Microsoft Docs and How to create and locate anchors using coarse relocalization in C#, Objective-C, Swift, Java, C++/NDK, C++/WinRT. 這個屬性是使用 NearDeviceCriteria 物件指定的。This property is specified using a NearDeviceCriteria object.

其他屬性Additional properties

BypassCacheBypassCache

預設值: falseDefault Value: false

在會話中建立或找到錨點時,它也會儲存在快取中。When an anchor has been created or found in a session, it is also stored in the cache. 當這個屬性設定為 false 時,相同會話中的任何後續查詢都會傳回快取的值。With this property set to false, any subsequent query in the same session will return the cached value. 對 ASA 服務沒有任何要求。No request to the ASA service is made.

RequestedCategoriesRequestedCategories

預設值:屬性 |空間Default Value: Properties | Spatial

這個屬性是用來決定使用 AnchorLocateCriteria 從查詢傳回哪些資料。This property is used to determine what data is returned from a query using AnchorLocateCriteria. 預設值會傳回屬性和空間資料,如果同時需要屬性和空間資料,則不應變更此值。The default value returns both properties and spatial data, this should not be changed if properties and spatial data are both desired. 您可以使用 AnchorDataCategory 列舉來指定這個屬性。This property can be specified using the AnchorDataCategory enum.

AnchorDataCategory 列舉值AnchorDataCategory Enum Value 傳回的資料Returned Data
None 未傳回任何資料No data is returned
屬性Properties 會傳回包含 AppProperties 的錨點屬性。Anchor properties including AppProperties are returned.
空間Spatial 傳回錨點的空間資訊。Spatial information about an anchor is returned.

策略Strategy

預設值: AnyStrategyDefault Value: AnyStrategy

策略會進一步定義錨點的位置。Strategy further defines how anchors should be located. 您可以使用 LocateStrategy 列舉來指定策略屬性。The Strategy property may be specified using a LocateStrategy enum.

LocateStrategy 列舉值LocateStrategy Enum Value 描述Description
AnyStrategyAnyStrategy 此策略允許系統使用 VisualInformation 和關聯性策略的組合來尋找錨點。This strategy permits the system to use combinations of VisualInformation and Relationship strategies to find anchors.
VisualInformationVisualInformation 此策略會藉由比對目前周圍周圍的視覺效果資訊與錨點視覺效果使用量的視覺效果,以嘗試尋找錨點。This strategy attempts to find anchors by matching visual information from the current surroundings to those of the anchor’s visual footprint. 錨點的視覺效果使用量指的是目前與錨點相關聯的視覺效果資訊。An anchor’s visual footprint refers to the visual information currently associated with the anchor. 這種視覺效果資訊通常不會在錨定建立期間以獨佔方式收集。This visual information is typically but not exclusively gathered during anchor creation. 目前,這個策略只允許與 NearDevice 或識別碼屬性搭配使用。Currently, this strategy is only permitted in conjunction with the NearDevice or Identifiers properties.
關聯性Relationship 此策略會使用現有的 連接錨點,嘗試尋找錨點。This strategy attempts to find anchors by making use of existing connected anchors. 目前,這個策略只允許與 NearAnchor 或識別碼屬性搭配使用。Currently, this strategy is only permitted in conjunction with the NearAnchor or Identifiers properties. 與 [識別碼] 屬性搭配使用時,必須在相同的會話中,在相同的會話中找出錨點 (s) ,其中已針對識別碼陣列中指定識別碼的錨點建立連線關聯性。When used with the Identifiers property, it is required that, in the same session, the user should have previously located an anchor(s) with already established connective relationships to the anchors whose IDs are specified in the Identifiers array.

LocateStrategy 和 AnchorLocateCriteria 屬性的有效組合Valid combinations of LocateStrategy and AnchorLocateCriteria properties

目前系統不允許所有策略和 AnchorLocateCriteria 屬性的組合。Not all combinations of Strategy and AnchorLocateCriteria properties are currently permitted by the system. 下表顯示允許的組合:The following table shows the allowed combinations:

屬性Property AnyStrategyAnyStrategy 關聯性Relationship VisualInformationVisualInformation
識別碼Identifiers
NearAnchorNearAnchor ✓ (將預設為關聯性) ✓ (will default to Relationship)
NearDeviceNearDevice

下一步Next steps

瞭解 如何使用 Azure 空間錨點來建立和尋找錨點 ,以取得使用 AnchorLocateCriteria 類別的一些範例。See How to create and locate anchors using Azure Spatial Anchors for some more examples using the AnchorLocateCriteria class.