ILocationProvider.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. using UnityEngine.Serialization;
  5. namespace ARLocation
  6. {
  7. [Serializable]
  8. public class LocationProviderOptions
  9. {
  10. /// <summary>
  11. /// The minimum desired update time, in seconds.
  12. /// </summary>
  13. [Tooltip("The minimum desired update time, in seconds.")]
  14. public float TimeBetweenUpdates = 2.0f;
  15. /// <summary>
  16. /// The minimum distance between consecutive location updates, in meters.
  17. /// </summary>
  18. [Tooltip("The minimum distance between consecutive location updates, in meters.")]
  19. public double MinDistanceBetweenUpdates = 0;
  20. /// <summary>
  21. /// The minimum accuracy of accepted location measurements, in meters.
  22. /// </summary>
  23. [FormerlySerializedAs("MaxAccuracyRadius")]
  24. [Tooltip("The minimum accuracy of accepted location measurements, in meters. " +
  25. "Accuracy here means the radius of uncertainty of the device's location, " +
  26. "defining a circle where it can possibly be found in.")]
  27. public double AccuracyRadius = 25.0f;
  28. [Tooltip("The global maximum number of location updates. The updates will be paused after this amount. Zero means there is no limit and " +
  29. "the updates won't be paused automatically. Note that this will possibly override the settings from individual components, like 'PlaceAtLocation'.")]
  30. public uint MaxNumberOfUpdates;
  31. }
  32. public enum LocationProviderStatus
  33. {
  34. Idle,
  35. Initializing,
  36. Started,
  37. Failed
  38. }
  39. // Location provider delegates/events
  40. public delegate void LocationUpdatedDelegate(LocationReading currentLocation, LocationReading lastLocation);
  41. public delegate void CompassUpdateDelegate(HeadingReading heading, HeadingReading lastReading);
  42. public delegate void LocationEnabledDelegate();
  43. public delegate void LocationFailedDelegate(string message);
  44. public interface ILocationProvider
  45. {
  46. string Name { get; }
  47. LocationProviderOptions Options { get; set; }
  48. LocationReading CurrentLocation { get; }
  49. LocationReading CurrentLocationRaw { get; }
  50. LocationReading LastLocation { get; }
  51. LocationReading LastLocationRaw { get; }
  52. LocationReading FirstLocation { get; }
  53. HeadingReading CurrentHeading { get; }
  54. HeadingReading LastHeading { get; }
  55. float StartTime { get; }
  56. bool IsCompassEnabled { get; }
  57. double DistanceFromStartPoint { get; }
  58. bool IsEnabled { get; }
  59. bool Paused { get; }
  60. int LocationUpdateCount { get; }
  61. bool HasStarted { get; }
  62. bool ApplyCompassTiltCompensationOnAndroid { get; set; }
  63. event LocationUpdatedDelegate LocationUpdated;
  64. event LocationUpdatedDelegate LocationUpdatedRaw;
  65. event CompassUpdateDelegate CompassUpdated;
  66. event LocationEnabledDelegate LocationEnabled;
  67. event LocationFailedDelegate LocationFailed;
  68. IEnumerator Start(uint maxWaitTime = 10000, uint delay = 0);
  69. void ForceLocationUpdate();
  70. void Pause();
  71. void Resume();
  72. void Update();
  73. void Restart();
  74. void OnEnabled(LocationEnabledDelegate del);
  75. void OnFail(LocationFailedDelegate del);
  76. void SetCompassLowPassFactor(double factor);
  77. string GetInfoString();
  78. string GetStatusString();
  79. }
  80. }