TCustomLocationSensor = class abstract(TCustomSensor)
class PASCALIMPLEMENTATION TCustomLocationSensor : public TCustomSensor
Used to determine the location information of the device.
The location sensor needs to be started using the Start method. Start notifies the user about the device location changes and other information that it can provide. Using the Stop method, the location sensor ceases receiving location information updates.
The location sensor may determine the location information of the device through a variety of hardware-specific methods. The method in use gives the location sensor a certain type. SensorType returns the location sensor type.
Because location sensors differ in functionality and amount of location information that they are able to provide, the AvailableProperties property has to be interrogated to determine which actual properties, within the location sensor object, are usable and have valid values. For example, there may be a sensor that can only provide values for the Latitude and Longitude properties. In this case, AvailableProperties will contain only Latitude and Longitude. The rest of the properties related to location information will not contain any valid values.
A location sensor can return location information updates only if it has been authorized to do so. Before it can do that, the user is asked by the operating system whether or not it is appropriate for the sensor to determine the location of the device. Authorized contains the value that indicates the user's response on the matter.
Accuracy represents the level of precision by which the sensor locates the device geographically, relative to the geographical point at which the device is actually located.
Distance is the minimum distance by which the device must move in order to make the location sensor relocate the device and return new location information.
The location sensor has properties used to obtain information about the location of the device. Depending on platform and sensor hardware, the information in these properties may not be available immediately at the request, but only when the sensor receives the actual information.
Some sensors work synchronously, while other asynchronously. TCustomLocationSensor tries to overcome these differences between location sensors and platform-specific functionality, and unify them under an interface that is simple to use. While data requests from synchronous sensors make the calling thread to wait until they can obtain the information, data requests from asynchronous sensors are not thread-blocking and let the program flow continue normally, up until the moment the location sensor determines the location information. At that point the location sensor calls a callback to gain information about the location of the device.
To overcome the differences between these two totally opposite behaviors, TCustomLocationSensor works as if the actual sensor was synchronous. When reading a property and the underlying platform classes work asynchronous, TCustomLocationSensor will return a cached value for that property, usually the last determined value. If there is no last value, then it will return a default one up until the moment the sensor will determine the location information.