# GeospatialMode

Artifact: [androidx.xr.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/xr-runtime) [View Source](https://cs.android.com/search?q=file:androidx/xr/runtime/XrCapabilities.kt+class:androidx.xr.runtime.GeospatialMode) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-runtime#1.0.0)

*** ** * ** ***


```
class GeospatialMode
```

<br />

*** ** * ** ***

Feature that allows Geospatial localization and tracking. The Geospatial API uses a combination of Google's Visual Positioning System (VPS) and GPS to determine the geospatial pose.

The Geospatial API is able to provide the best user experience when it is able to generate high accuracy poses. However, the Geospatial API can be used anywhere, as long as the device is able to determine its location, even if the available location information has low accuracy.

- In areas with VPS coverage, the Geospatial API is able to generate high accuracy poses. This can work even where GPS accuracy is low, such as dense urban environments. Under typical conditions, VPS can be expected to provide positional accuracy typically better than 5 meters and often around 1 meter, and a rotational accuracy of better than 5 degrees. Use `Geospatial.checkVpsAvailability` to determine if a given location has VPS coverage.

- In outdoor environments with few or no overhead obstructions, GPS may be sufficient to generate high accuracy poses. GPS accuracy may be low in dense urban environments and indoors.

Note that setting this mode will consume additional runtime resources.

## Summary

| ### Public companion properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode#DISABLED()` The Geospatial API is disabled. |
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode#INERTIAL()` Geospatial tracking mode that uses only inertial measurement unit (IMU) and GPS data for localization. |
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode#SPATIAL()` The Geospatial API is enabled. |

| ### Public functions |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode#toString()()` Returns a string representation of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode` for debugging. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode#mode()` |

## Public companion properties

### DISABLED

```
val DISABLED: GeospatialMode
```

The Geospatial API is disabled. When GeospatialMode is disabled, current `Anchor` objects created from `Geospatial` will stop updating, and have their `https://developer.android.com/reference/kotlin/androidx/xr/arcore/TrackingState` set to `https://developer.android.com/reference/kotlin/androidx/xr/arcore/TrackingState#STOPPED()`.

### INERTIAL

```
val INERTIAL: GeospatialMode
```

Geospatial tracking mode that uses only inertial measurement unit (IMU) and GPS data for localization.

This mode provides a lower-power alternative to visual positioning systems, allowing the camera to be disabled when high precision is not strictly required.

To use this mode, the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` must first be configured with `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode#SPATIAL()` and `https://developer.android.com/reference/kotlin/androidx/xr/runtime/DeviceTrackingMode#SPATIAL()`. Once initialized, the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` can be toggled via `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)` to `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode#INERTIAL()` for power savings, and back to `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode#SPATIAL()` for the accuracy needed.

Supported runtimes:

- Projected

Required permissions:

- `https://developer.android.com/reference/android/Manifest.permission.html#ACCESS_FINE_LOCATION`

### SPATIAL

```
val SPATIAL: GeospatialMode
```

The Geospatial API is enabled. `Geospatial` should enter the running state shortly after this mode is set.

Using this mode requires your app do the following, depending on the Runtime:

On mobile and projected devices:

- Include the [INTERNET](https://developer.android.com/training/basics/network-ops/connecting) permission to the app's AndroidManifest

- Request and be granted the [ACCESS_FINE_LOCATION permission](https://developer.android.com/training/location/permissions); otherwise, `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)` throws `https://developer.android.com/reference/java/lang/SecurityException.html`.

On mobile devices:

- Include the Google Play Services Location Library as a dependency for your app. See [dependencies for Google Play services](https://developers.google.com/android/guides/setup#declare-dependencies) for instructions on how to include this library in your app. If this library is not linked, `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)` returns `https://developer.android.com/reference/kotlin/androidx/xr/runtime/SessionConfigureLibraryNotLinked`.

Location is tracked only while the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` is resumed.

On mobile devices, when the Geospatial API and the Depth API are enabled, output images from the Depth API will include terrain and building geometry when in a location with VPS coverage.

Not all devices support GeospatialMode.SPATIAL, use `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice#isGeospatialModeSupported(androidx.xr.runtime.GeospatialMode)` to check if the current device and selected camera support enabling this mode. These checks are done in the call to `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)`.

Supported runtimes:

- Play Services (on supported devices)

- Projected

Required permissions:

- `https://developer.android.com/reference/android/Manifest.permission.html#INTERNET`

- `https://developer.android.com/reference/android/Manifest.permission.html#ACCESS_FINE_LOCATION`

- `https://developer.android.com/reference/android/Manifest.permission.html#CAMERA` (Play Services runtimes only)

## Public functions

### toString

```
open fun toString(): String
```

Returns a string representation of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode` for debugging.

Note: Not intended for production use.

## Public properties

### mode

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-runtime#1.0.0)

```
val mode: Int
```