1 // Copyright 2016 by Samsung Electronics, Inc.,
3 // This software is the confidential and proprietary information
4 // of Samsung Electronics, Inc. ("Confidential Information"). You
5 // shall not disclose such Confidential Information and shall use
6 // it only in accordance with the terms of the license agreement
7 // you entered into with Samsung.
10 using System.Collections.Generic;
12 namespace Tizen.Location
15 /// A class which contains the details of the location rrequested.
16 /// Includes the functionality to get the distance between locations.
20 private double _altitude;
21 private double _latitude;
22 private double _longitude;
23 private double _direction;
24 private double _speed;
25 private double _horizontal;
26 internal int _timestamp;
29 /// The default constructor of Location Class.
36 /// The parameterized constructor of Location Class.
37 /// <param name="latitude"> Latitude component of the device co-ordinate [-90.0 ~ 90.0] (degrees).</param>
38 /// <param name="longitude"> Longitude component of the device co-ordinate[-180.0 ~ 180.0] (degrees).</param>
39 /// <param name="altitude"> Altitude value.</param>
40 /// <param name="horizontalAccuracy"> Horizontal Accuracy in meters.</param>
41 /// <param name="speed"> Devie Speed.</param>
42 /// <param name="direction"> Device direction with respect to north.</param>
43 /// <param name="timestamp"> Time when the measurement took place.</param>
45 public Location(double latitude, double longitude, double altitude, double horizontalAccuracy, double direction, double speed, int timestamp)
48 _longitude = longitude;
50 _horizontal = horizontalAccuracy;
51 _direction = direction;
53 _timestamp = timestamp;
57 /// The current altitude (meters).
59 public double Altitude
72 /// The current latitude [-90.0 ~ 90.0] (degrees).
74 public double Latitude
87 /// The current longitude [-180.0 ~ 180.0] (degrees).
89 public double Longitude
102 /// The direction, degrees from the north.
104 public double Direction
117 /// The Device Speed (km/h).
132 /// The horizontal accuracy.
134 public double HorizontalAccuracy
147 /// The time value when the measurement was done.
149 public DateTime Timestamp
153 return Interop.ConvertDateTime(_timestamp);
163 /// Gets the distance between the two given coordinates.
165 /// <param name="startLatitude"> The latitude of the source location [-90.0 ~ 90.0] (degrees).</param>
166 /// <param name="startLongitude"> The Longitude of the source location[-180.0 ~ 180.0] (degrees).</param>
167 /// <param name="endLatitude"> The latitude of the source location [-90.0 ~ 90.0] (degrees).</param>
168 /// <param name="endLongitude"> The longitude of the source location[-180.0 ~ 180.0] (degrees).</param>
169 /// <returns>Returns the distance between source and destination.</returns>
170 public static double GetDistanceBetween(double startLatitude, double startLongitude, double endLatitude, double endLongitude)
173 Log.Info(Globals.LogTag, "Calling GetDistanceBetween");
174 int ret = Interop.Location.GetDistanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, out result);
175 if (((LocationError)ret != LocationError.None))
177 Log.Error(Globals.LogTag, "Error getting single distance information ," + (LocationError)ret);
178 LocationErrorFactory.ThrowLocationException(ret);
184 /// Gets the distance between the current and specified location.
186 /// <param name="location"> The location object to which distance is to be calculated.</param>
187 /// <returns>Returns the distance to the specified location.</returns>
188 public double GetDistanceTo(Location location)
191 Log.Info(Globals.LogTag, "Calling GetDistanceTo");
192 int ret = Interop.Location.GetDistanceBetween(this.Latitude, this.Longitude, location.Latitude, location.Longitude, out result);
193 if (((LocationError)ret != LocationError.None))
195 Log.Error(Globals.LogTag, "Error getting distance information to the specifed location," + (LocationError)ret);
196 LocationErrorFactory.ThrowLocationException(ret);