340e91d8b7d74ee04aaa6fc6dc41b8a5e6f85b83
[platform/core/csapi/maps.git] / 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 co-ordinates
23     /// </summary>
24     public class Geocoordinates : IDisposable
25     {
26         internal Interop.CoordinatesHandle handle;
27
28         /// <summary>
29         /// Constructs map coordinate object
30         /// </summary>
31         /// <param name="latitude">latitude value, must be between (-90.0 ~ 90.0) degrees</param>
32         /// <param name="longitude">longitude value, must be between (-180.0 ~ 180.0) degrees</param>
33         /// <exception cref="System.ArgumentException">Throws if values for latitude and longitude are not valid</exception>
34         /// <exception cref="System.InvalidOperationException">Throws if native operation failed to allocate memory</exception>
35         public Geocoordinates(double latitude, double longitude)
36         {
37             handle = new Interop.CoordinatesHandle(latitude, longitude);
38         }
39
40         internal Geocoordinates(Interop.CoordinatesHandle nativeHandle)
41         {
42             handle = nativeHandle;
43         }
44
45         /// <summary>
46         /// Latitude for this coordinate
47         /// </summary>
48         public double Latitude
49         {
50             get
51             {
52                 return handle.Latitude;
53             }
54         }
55
56         /// <summary>
57         /// Longitude for this coordinate
58         /// </summary>
59         public double Longitude
60         {
61             get
62             {
63                 return handle.Longitude;
64             }
65         }
66
67         public override string ToString()
68         {
69             return $"[{Latitude}, {Longitude}]";
70         }
71
72         #region IDisposable Support
73         private bool _disposedValue = false;
74
75         protected virtual void Dispose(bool disposing)
76         {
77             if (!_disposedValue)
78             {
79                 handle.Dispose();
80                 _disposedValue = true;
81             }
82         }
83
84         public void Dispose()
85         {
86             Dispose(true);
87         }
88         #endregion
89     }
90 }