This document identifies missing components required for geo-alignment in a user agent.
Geo-alignment is defined by location and orientation with respect to the Earth's axes: east, north and up. These data can be accessed via the following interfaces already proposed in W3C:
| W3C Document | Current Status | Interface |
|---|---|---|
| Geolocation API | Proposed Recommendation | Geolocation interface and callbacks |
| Orientation Sensor | Working Draft | OrientationSensor interface |
| Permissions | Working Draft | Permissions interface |
| Generic Sensor API | Candidate Recommendation Draft | Sensor SensorErrorEvent |
| DeviceOrientation Event | Working Draft | DeviceOrientationEvent |
W3C Devices and Sensors (DAS) Working Group published a roadmap giving a useful overview of W3C sensor document status including motion sensors.
Web Platform Test results snapshot on 13 June 2022 - latest results available via link in Path column. MDN results also include mobile browsers.
| Path | Chrome | Edge | Firefox | Safari | MDN Results |
|---|---|---|---|---|---|
| geolocation-API | 43 / 67 | 44 / 67 | 31 / 67 | 31 / 67 | Geolocation API |
| orientation-sensor | 121 / 123 | 73 / 123 | 16 / 123 | 16 / 123 | OrientationSensor RelativeOrientationSensor AbsoluteOrientationSensor |
| permissions | 119 / 125 | 120 / 125 | 82 / 125 | 79 / 125 | Permissions API |
| generic-sensor | 49 / 49 | 49 / 49 | 5 / 49 | 5 / 49 | Sensor API |
| orientation-event | 140 / 144 | 108 / 144 | 77 / 144 | 23 / 144 | DeviceOrientation deviceorientation deviceorientationabsolute |
Several key issues have been identified:
-
Agnostic interface
Geo-alignment is a high-level sensor interface which should be agnostic of the underlying low-level sensors since position and orientation can be calculated by many different means. Position can be determined from visual, inertial or satellite navigation data and this is reflected in the Geolocation API. Orientation should be handled in a similar way. -
Capability
Geo-alignment can be determined only if three elements are present and correct:-
User agent support in the chosen web client. If this is not supported, sensor information cannot be accessed by the browser to calculate position and/or orientation.
-
User permission to access sensors obtained through Permissions. If this is not supported or not allowed, accessing sensor information could pose a security risk to the user since location is personal information and the data privacy rights of web users should be properly respected.
-
Suitable sensors to provide position and orientation data. If less than the required number of sensors are available, geo-alignment calculations may be less accurate or completely impossible.
-
-
Accuracy
Correct assessment of geo-alignment accuracy is critical since identified use cases require sufficient precision to yield a successful result. For example, Augmented Reality (AR) use cases need high accuracy geo-alignment to correctly overlay virtual assets on a video stream. Mobile devices may lack this accuracy and sufficient information should be provided in the API to determine the quality of geo-alignment available to the user agent so best use can be made of the available data. -
Privacy & security
Data from accelerometer, magnetometer and gyroscope sensors could be combined using inertial navigation techniques to track a user's movements from a known location such as that of a Wifi or Bluetooth device so proper security permissions should be enforced. Privacy and security issues are discussed in the DeviceOrientation Event and Generic Sensor documents. -
Prototype evaluation
Experimental features proposed for the DeviceOrientationEvent interface includewebkitCompassHeadingandwebkitCompassAccuracy. Such prototypes should be evaluated with a view to inclusion in any proposed geo-alignment interface.
Several omissions for geo-alignment have been identified in the current W3C APIs:
-
Data accuracy
Data accuracy is quantified for position by accuracy and altitudeAccuracy attributes in the Geolocation interface. No accuracy metrics are available in the OrientationSensor interface so geo-alignment accuracy cannot be determined. -
Geo-alignment permission
Standardised permissions in the Permissions Registry includegeolocationto allow position data access. No entry exists to request permission fororientation(or individual sensors such as accelerometer, magnetometer and gyroscope) in the provisional permissions. Proper consideration should be given to whetherorientation(ormotion) is a powerful feature with and withoutgeolocation. -
Required permission
The DeviceOrientationEvent interface requires no permissions prior to accessing device orientation details despite aRequestPermissionmethod in the interface. This is also inconsistent with the OrientationSensor model which is a policy-controlled feature requiring permissions. -
Permission Registry
No entries forcameraandmicrophoneexist in the provisional permissions though both are implemented in Chrome (v64 onwards) and this should be updated. -
Device capability
Geo-alignment is a high-level interface which relies on fusion of data from multiple sensors. No high-level permission exists to request orientation sensor access which is inconsistent with the high-level interface togeolocation. -
LiDAR support
No W3C interface documentation has been found for LiDAR (light detection and ranging) which is already included as standard in some high-end tablets and can be used to improve geo-alignment accuracy. AbsoluteOrientationSensor and RelativeOrientationSensor could benefit from such support. -
Geo-aligned orientation
Orientation sensor interface does not indicate whether or not orientation is geo-aligned. This is inconsistent with the DeviceOrientationEvent interface which includes theabsoluteattribute to indicate geo-alignment. -
Yaw, pitch and roll angles
Orientation sensor interface does not include yaw, pitch and roll angles which represent rotations about the up, left and front axes respectively of an object. See w3c/orientation-sensor#43 -
Sensor options
The OrientationSensor interface includes theSensorOptionsattribute to control sampling frequency. No such options are provided by DeviceOrientationEvent interface which updates on orientation change events rather than at a given frequency and this is inconsistent. -
Event support
Few implementations of the DeviceOrientationEvent interface support geo-alignment since only Chrome (v102) currently implements thedeviceorientationabsoluteevent. Support for this event must be explicitly checked as no error is (correctly) reported byaddEventListenerand no events are generated if the user agent does not support this feature which is a pitfall for developers. -
Missing sensors
The DeviceOrientationEvent interface has no explicit way of reporting that a web device lacks the required sensors to generate geo-aligned orientation data. Either no events are generated as there are no valid data, or events are generated withnulldata.
An alternative access model for video capture is proposed by WebRTC with implicit camera and microphone permission requests using MediaDevices.getUserMedia. This may serve as a useful template for a convenience API for geo-alignment.