public static extern bool IsValidCoordinates(IntPtr handle, Coordinate coordinate);
[DllImport(Libraries.Location, EntryPoint = "location_bounds_destroy")]
- public static extern bool DestroyBoundary(IntPtr handle);
+ public static extern int DestroyBoundary(IntPtr handle);
}
internal static partial class GpsSatellite
return dateTime;
}
-}
\ No newline at end of file
+}
/// </summary>
public class Location
{
- private double _altitude;
private double _latitude;
private double _longitude;
+ private double _altitude;
+ private double _horizontal;
private double _direction;
private double _speed;
- private double _horizontal;
internal int _timestamp;
/// <summary>
}
/// <summary>
- /// The current altitude (meters).
+ /// The current latitude [-90.0 ~ 90.0] (degrees).
/// </summary>
- public double Altitude
+ public double Latitude
{
get
{
- return _altitude;
+ return _latitude;
}
set
{
- _altitude = value;
+ _latitude = value;
}
}
/// <summary>
- /// The current latitude [-90.0 ~ 90.0] (degrees).
+ /// The current longitude [-180.0 ~ 180.0] (degrees).
/// </summary>
- public double Latitude
+ public double Longitude
{
get
{
- return _latitude;
+ return _longitude;
}
set
{
- _latitude = value;
+ _longitude = value;
}
}
/// <summary>
- /// The current longitude [-180.0 ~ 180.0] (degrees).
+ /// The current altitude (meters).
/// </summary>
- public double Longitude
+ public double Altitude
{
get
{
- return _longitude;
+ return _altitude;
}
set
{
- _longitude = value;
+ _altitude = value;
}
}
/// <summary>
- /// The direction, degrees from the north.
+ /// The horizontal accuracy.
/// </summary>
- public double Direction
+ public double HorizontalAccuracy
{
get
{
- return _direction;
+ return _horizontal;
}
set
{
- _direction = value;
+ _horizontal = value;
}
}
/// <summary>
- /// The Device Speed (km/h).
+ /// The direction, degrees from the north.
/// </summary>
- public double Speed
+ public double Direction
{
get
{
- return _speed;
+ return _direction;
}
set
{
- _speed = value;
+ _direction = value;
}
}
/// <summary>
- /// The horizontal accuracy.
+ /// The Device Speed (km/h).
/// </summary>
- public double HorizontalAccuracy
+ public double Speed
{
get
{
- return _horizontal;
+ return _speed;
}
set
{
- _horizontal = value;
+ _speed = value;
}
}
/// <summary>
/// Abstract class which provides functions related to geographic bounds information.
/// </summary>
- public abstract class LocationBoundary
+ public abstract class LocationBoundary : IDisposable
{
internal IntPtr handle;
+ private bool _disposed = false;
/// <summary>
/// Gets the location boundary type.
/// </summary>
public BoundaryType BoundaryType{ get; internal set; }
+ /// <summary>
+ /// The destructor of LocationBoundary class.
+ /// </summary>
+ ~LocationBoundary()
+ {
+ Log.Info(Globals.LogTag, "The destructor of LocationBoundary class");
+ Dispose(false);
+ }
+
internal IntPtr GetHandle()
{
return handle;
Log.Info(Globals.LogTag, "Checking if coordinates are contained within boundary");
return Interop.LocationBoundary.IsValidCoordinates(handle, coordinate);
}
+
+ /// <summary>
+ /// The overidden Dispose method of the IDisposable class.
+ /// </summary>
+ public void Dispose()
+ {
+ Log.Info(Globals.LogTag, "Dispose");
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ Log.Info(Globals.LogTag, "Dispose");
+ if (_disposed)
+ return;
+
+ DestroyHandle();
+ _disposed = true;
+ }
+
+ private void DestroyHandle()
+ {
+ Log.Info(Globals.LogTag, "DestroyHandle");
+ int ret = Interop.LocationBoundary.DestroyBoundary(handle);
+ if (((LocationError)ret != LocationError.None))
+ {
+ Log.Error(Globals.LogTag, "Error in DestroyBoundary handle" + (LocationError)ret);
+ throw LocationErrorFactory.ThrowLocationException(ret);
+ }
+ }
}
/// <summary>
int ret = Interop.Locator.SetMockLocation(_handle, location.Latitude, location.Longitude, location.Altitude, location.Speed, location.Direction, location.HorizontalAccuracy);
if (((LocationError)ret == LocationError.None))
{
- _location.Altitude = 0;
+ _location.Altitude = location.Altitude;
_location.Latitude = location.Latitude;
_location.Longitude = location.Longitude;
_location.Speed = location.Speed;
/// </summary>
public enum LocationType
{
- None = -1, /**<Undefined method.*/
- Hybrid, /**<This method selects the best method available at the moment.*/
+ Hybrid = 0, /**<This method selects the best method available at the moment.*/
Gps, /**<This method uses Global Positioning System.*/
Wps, /**<This method uses WiFi Positioning System.*/
}