Skip to content

Commit 9f65d9b

Browse files
committed
Remove deprecated indoors init.
1 parent fa661d7 commit 9f65d9b

File tree

2 files changed

+7
-62
lines changed

2 files changed

+7
-62
lines changed

Shared/Samples/Show device location using indoor positioning/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ When there are no IPS beacons nearby or other errors occur while initializing th
1717
## How it works
1818

1919
1. Load an IPS-aware map. This can be a web map hosted as a portal item in ArcGIS Online, an Enterprise Portal, or a mobile map package (.mmpk) created with ArcGIS Pro.
20-
2. Create and load an `IndoorPositioningDefinition` (stored with the map), then create an `IndoorsLocationDataSource` from it. See the details about creating the location data source in the "[`Additional information`](#additional-information)" section below.
20+
2. Create and load an `IndoorPositioningDefinition` (stored with IPS-aware maps), then create an `IndoorsLocationDataSource` from it.
2121
3. Handle location change events to respond to floor changes or read other metadata for locations.
2222
4. Assign the `IndoorsLocationDataSource` to the map view's location display.
2323
5. Enable and disable the map view's location display using `start()` and `stop()`. Device location will appear on the display as a blue dot and update as the user moves throughout the space.
@@ -41,9 +41,6 @@ This sample uses an [IPS-aware web map](https://www.arcgis.com/home/item.html?id
4141
## Additional information
4242

4343
* Location and Bluetooth permissions are required for this sample.
44-
* You could initialize the `IndoorsLocationDataSource` from individual feature tables stored in different data sources, such as map, mobile geodatabase, and feature services. With version 200.5 and higher, you can construct the `IndoorsLocationDataSource` using a single `IndoorPositioningDefinition` available in your IPS-aware map. In short…
45-
* If an `IndoorPositioningDefinition` is available in your IPS-aware map, use it to construct `IndoorsLocationDataSource`.
46-
* If your map does not have an `IndoorPositioningDefinition`, construct the location data source from individual feature tables as described in [Manually create an indoor location data source](https://developers.arcgis.com/swift/device-location/indoor-positioning/#manually-create-an-indoor-location-data-source) documentation.
4744
* To learn more about IPS, read the [Indoor positioning](https://developers.arcgis.com/swift/device-location/indoor-positioning/) article on ArcGIS Developer website.
4845
* To learn more about how to deploy the indoor positioning system, read the [Deploy ArcGIS IPS](https://doc.arcgis.com/en/ips/latest/get-started/introduction-to-the-deployment-of-arcgis-ips.htm) article.
4946

Shared/Samples/Show device location using indoor positioning/ShowDeviceLocationUsingIndoorPositioningView.Model.swift

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Foundation
1919
extension ShowDeviceLocationUsingIndoorPositioningView {
2020
@MainActor
2121
class Model: ObservableObject {
22-
/// An IPS-aware and floor-aware web map for all three floors of
22+
/// An IPS-aware and floor-aware web map for all three floors of
2323
/// Esri Building L in Redlands.
2424
let map = Map(item: PortalItem(portal: .arcGISOnline(connection: .anonymous), id: .indoorsMap))
2525

@@ -66,73 +66,21 @@ extension ShowDeviceLocationUsingIndoorPositioningView {
6666
}
6767

6868
/// Sets the indoors location data source on the location display
69-
/// depending on whether the map contains an indoor positioning definition.
69+
/// using the map's indoor positioning definition.
7070
private func setUpIndoorsLocationDataSource() async throws {
71-
let dataSource: IndoorsLocationDataSource
7271
if let indoorPositioningDefinition = map.indoorPositioningDefinition {
73-
// If an indoor positioning definition exists in the map, uses it
74-
// to set the IndoorsLocationDataSource. This is the recommended approach.
72+
// Gets indoor positioning definition from the IPS-aware map
73+
// and uses it to set the IndoorsLocationDataSource.
7574
try await indoorPositioningDefinition.load()
76-
dataSource = IndoorsLocationDataSource(definition: indoorPositioningDefinition)
77-
} else if let positioningTable = map.tables.first(where: { $0.tableName == "ips_positioning" }) as? ServiceFeatureTable {
78-
// Otherwise, creates the IndoorsLocationDataSource using
79-
// IPS positioning table information. This is useful for
80-
// manually creating an indoors location data source.
81-
dataSource = try await makeIndoorsLocationDataSourceFromTables(map: map, positioningTable: positioningTable)
75+
let dataSource = IndoorsLocationDataSource(definition: indoorPositioningDefinition)
76+
locationDisplay.dataSource = dataSource
8277
} else {
8378
throw SetupError()
8479
}
85-
locationDisplay.dataSource = dataSource
8680
// Starts the location display.
8781
try await locationDisplay.dataSource.start()
8882
}
8983

90-
/// Creates an indoor location data source from the maps tables
91-
/// when there is no indoors definition.
92-
/// - Parameters:
93-
/// - map: The map which contains the data in accordance with
94-
/// the ArcGIS Indoors Information Model.
95-
/// - positioningTable: The “ips\_positioning” table from
96-
/// an IPS-aware map.
97-
/// - Returns: Returns a configured `IndoorsLocationDataSource` created
98-
/// from the various tables.
99-
private func makeIndoorsLocationDataSourceFromTables(
100-
map: Map,
101-
positioningTable: ServiceFeatureTable
102-
) async throws -> IndoorsLocationDataSource {
103-
let queryParameters = QueryParameters()
104-
queryParameters.maxFeatures = 1
105-
// Gets the specific version of data that is compatible to the schema.
106-
// When use your own map, make sure the query returns the correct data.
107-
queryParameters.whereClause = "OBJECTID=2"
108-
// Queries a feature in the positioning table to get the positioning ID.
109-
let queryResult = try await positioningTable.queryFeatures(using: queryParameters)
110-
let feature = queryResult.features().makeIterator().next()!
111-
// The ID that identifies a row in the positioning table.
112-
// It is possible to initialize ILDS without globalID,
113-
// in which case the first row of the positioning table
114-
// will be used.
115-
let positioningID = feature.attributes[positioningTable.globalIDField] as? UUID
116-
// Gets the pathways table (optional for creating the IndoorsLocationDataSource).
117-
// The network pathways for routing between locations on the same level.
118-
let pathwaysTable = (
119-
map.operationalLayers.first(where: { $0.name == "Pathways" }) as! FeatureLayer
120-
).featureTable as! ArcGISFeatureTable
121-
// Gets the levels layer (optional for creating the IndoorsLocationDataSource).
122-
// The table that contains floor levels.
123-
let levelsTable = (
124-
map.operationalLayers.first(where: { $0.name == "Levels" }) as! FeatureLayer
125-
).featureTable as! ArcGISFeatureTable
126-
// Initialize an IndoorsLocationDataSource with positioning, pathways,
127-
// levels tables, and positioning ID.
128-
return IndoorsLocationDataSource(
129-
positioningTable: positioningTable,
130-
pathwaysTable: pathwaysTable,
131-
levelsTable: levelsTable,
132-
positioningID: positioningID
133-
)
134-
}
135-
13684
/// Updates the location when the location data source is triggered.
13785
func updateDisplayOnLocationChange() async {
13886
for await location in locationDisplay.dataSource.locations {

0 commit comments

Comments
 (0)