Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / Geocoordinates.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18
19 namespace Tizen.Maps
20 {
21     /// <summary>
22     /// Class representing geographical coordinates.
23     /// </summary>
24     /// <since_tizen>3</since_tizen>
25     public class Geocoordinates : IDisposable
26     {
27         internal Interop.CoordinatesHandle handle;
28
29         /// <summary>
30         /// Constructs map coordinates object.
31         /// </summary>
32         /// <since_tizen>3</since_tizen>
33         /// <param name="latitude">Latitude value, must be between (-90.0 ~ 90.0) degrees</param>
34         /// <param name="longitude">Longitude value, must be between (-180.0 ~ 180.0) degrees</param>
35         /// <exception cref="System.ArgumentException">Thrown when values for latitude and longitude are not valid.</exception>
36         /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory.</exception>
37         public Geocoordinates(double latitude, double longitude)
38         {
39             handle = new Interop.CoordinatesHandle(latitude, longitude);
40         }
41
42         internal Geocoordinates(Interop.CoordinatesHandle nativeHandle)
43         {
44             handle = nativeHandle;
45         }
46
47         /// <summary>
48         /// Gets latitude of the coordinates.
49         /// </summary>
50         /// <since_tizen>3</since_tizen>
51         public double Latitude
52         {
53             get
54             {
55                 return handle.Latitude;
56             }
57         }
58
59         /// <summary>
60         /// Gets longitude of the coordinates.
61         /// </summary>
62         /// <since_tizen>3</since_tizen>
63         public double Longitude
64         {
65             get
66             {
67                 return handle.Longitude;
68             }
69         }
70
71         /// <summary>
72         /// Returns a string that represents this object.
73         /// </summary>
74         /// <since_tizen>3</since_tizen>
75         /// <returns>Returns a string which presents this object.</returns>
76         public override string ToString()
77         {
78             return $"[{Latitude}, {Longitude}]";
79         }
80
81         #region IDisposable Support
82         private bool _disposedValue = false;
83
84         protected virtual void Dispose(bool disposing)
85         {
86             if (!_disposedValue)
87             {
88                 handle.Dispose();
89                 _disposedValue = true;
90             }
91         }
92
93         /// <summary>
94         /// Releases all resources used by this object.
95         /// </summary>
96         /// <since_tizen>3</since_tizen>
97         public void Dispose()
98         {
99             Dispose(true);
100             GC.SuppressFinalize(this);
101         }
102         #endregion
103     }
104 }