AR + GPS Location  3.0.0
All Classes Namespaces Functions Variables Properties Events Pages
MockLocationProvider.cs
1 using UnityEngine;
2 
3 namespace ARLocation
4 {
5 
7  {
8  public override string Name => "MockLocationProvider";
9 
10  public override bool IsCompassEnabled => true;
11 
12  public Location mockLocation = new Location();
13 
14  protected override HeadingReading? ReadHeading()
15  {
16  var mainCamera = ARLocationManager.Instance.MainCamera;
17 
18  var transform = mainCamera.transform;
19 
20  var localEulerAngles = transform.localEulerAngles;
21  return new HeadingReading
22  {
23  heading = localEulerAngles.y,
24  magneticHeading = localEulerAngles.y,
25  accuracy = 0,
26  isMagneticHeadingAvailable = true,
27  timestamp = (long)(Time.time * 1000)
28  };
29  }
30 
31  protected override LocationReading? ReadLocation()
32  {
33  return new LocationReading
34  {
35  latitude = mockLocation.Latitude,
36  longitude = mockLocation.Longitude,
37  altitude = mockLocation.Altitude,
38  accuracy = 0.0,
39  floor = -1,
40  timestamp = (long)(Time.time * 1000)
41  };
42  }
43 
44  private bool requested = true;
45 
46  protected override void RequestLocationAndCompassUpdates()
47  {
48  requested = true;
49  }
50 
51  protected override void UpdateLocationRequestStatus()
52  {
53  if (requested)
54  {
55  Status = LocationProviderStatus.Initializing;
56  requested = false;
57  }
58 
59  if (Status == LocationProviderStatus.Initializing)
60  {
61  Status = LocationProviderStatus.Started;
62  }
63  }
64  }
65 }
ARLocation.MockLocationProvider.ReadHeading
override? HeadingReading ReadHeading()
Reads the heading from the device; should be implemented by each provider.
Definition: MockLocationProvider.cs:14
ARLocation.ARLocationManager
This Component manages all positioned GameObjects, synchronizing their world position in the scene wi...
Definition: ARLocationManager.cs:30
ARLocation.MockLocationProvider
Definition: MockLocationProvider.cs:7
ARLocation.AbstractLocationProvider.Status
LocationProviderStatus Status
Gets or sets the current status of the location provider.
Definition: AbstractLocationProvider.cs:72
ARLocation.MockLocationProvider.UpdateLocationRequestStatus
override void UpdateLocationRequestStatus()
Updates the location service status from the device; should be implemented by each provider.
Definition: MockLocationProvider.cs:51
ARLocation.Location
Represents a geographical location.
Definition: Location.cs:19
ARLocation.Utils.Singleton.Instance
static T Instance
Access singleton instance through this propriety.
Definition: Singleton.cs:18
ARLocation.MockLocationProvider.RequestLocationAndCompassUpdates
override void RequestLocationAndCompassUpdates()
Requests the location and compass updates from the device; should be implemented by each provider.
Definition: MockLocationProvider.cs:46
ARLocation.AbstractLocationProvider
Abstract location provider. All concrete location provider implementations should derive from this.
Definition: AbstractLocationProvider.cs:15
ARLocation.HeadingReading
Definition: HeadingReading.cs:5
ARLocation.LocationReading
Definition: LocationReading.cs:5
ARLocation
Definition: ARLocationConfigInspector.cs:7
ARLocation.MockLocationProvider.ReadLocation
override? LocationReading ReadLocation()
Reads the location from the device; should be implemented by each provider.
Definition: MockLocationProvider.cs:31