Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / Route.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
18 using System;
19 using System.Collections.Generic;
20
21 namespace Tizen.Maps
22 {
23     /// <summary>
24     /// Route information, used in Route Search requests.
25     /// </summary>
26     /// <since_tizen>3</since_tizen>
27     public class Route : IDisposable
28     {
29         internal Interop.RouteHandle handle;
30
31         internal Route(Interop.RouteHandle nativeHandle)
32         {
33             handle = nativeHandle;
34         }
35
36         /// <summary>
37         /// Gets an instance of <see cref="Geocoordinates"/> object which representing destination coordinates for this route.
38         /// </summary>
39         /// <since_tizen>3</since_tizen>
40         public Geocoordinates Destination
41         {
42             get
43             {
44                 return new Geocoordinates(handle.Destination);
45             }
46         }
47
48         /// <summary>
49         /// Gets total distance for this route.
50         /// </summary>
51         /// <since_tizen>3</since_tizen>
52         public double Distance
53         {
54             get
55             {
56                 return handle.Distance;
57             }
58         }
59
60         /// <summary>
61         /// Get total duration to cover this route.
62         /// </summary>
63         /// <since_tizen>3</since_tizen>
64         public double Duration
65         {
66             get
67             {
68                 return handle.Duration;
69             }
70         }
71
72         /// <summary>
73         /// Gets an ID for this route.
74         /// </summary>
75         /// <since_tizen>3</since_tizen>
76         public string Id
77         {
78             get
79             {
80                 return handle.Id;
81             }
82         }
83
84         /// <summary>
85         /// Gets transport mode for this route.
86         /// </summary>
87         /// <since_tizen>3</since_tizen>
88         public TransportMode Mode
89         {
90             get
91             {
92                 return (TransportMode)handle.TransportMode;
93             }
94         }
95
96         /// <summary>
97         /// Gets origin coordinates for this route.
98         /// </summary>
99         /// <since_tizen>3</since_tizen>
100         public Geocoordinates Origin
101         {
102             get
103             {
104                 return new Geocoordinates(handle.Origin);
105             }
106         }
107
108         /// <summary>
109         /// Gets a coordinates list for this route.
110         /// </summary>
111         /// <since_tizen>3</since_tizen>
112         public IEnumerable<Geocoordinates> Path
113         {
114             get
115             {
116                 var path = new List<Geocoordinates>();
117                 handle.ForeachPath(coordinateHandle => path.Add(new Geocoordinates(coordinateHandle)));
118                 return path;
119             }
120         }
121
122         /// <summary>
123         /// Gets a segment list for this route.
124         /// </summary>
125         /// <since_tizen>3</since_tizen>
126         public IEnumerable<RouteSegment> Segments
127         {
128             get
129             {
130                 var segments = new List<RouteSegment>();
131                 handle.ForeachSegment(segmentHandle => segments.Add(new RouteSegment(segmentHandle)));
132                 return segments;
133             }
134         }
135
136         /// <summary>
137         /// Gets distance unit for this route.
138         /// </summary>
139         /// <since_tizen>3</since_tizen>
140         public DistanceUnit Unit
141         {
142             get
143             {
144                 return (DistanceUnit)handle.Unit;
145             }
146         }
147
148         /// <summary>
149         /// Gets an instance of <see cref="Area"/> object which representing bounding area for this route.
150         /// </summary>
151         private Area BoundingBox
152         {
153             get
154             {
155                 return new Area(handle.BoundingBox);
156             }
157         }
158
159         #region IDisposable Support
160         private bool _disposedValue = false;
161
162         protected virtual void Dispose(bool disposing)
163         {
164             if (!_disposedValue)
165             {
166                 handle.Dispose();
167                 _disposedValue = true;
168             }
169         }
170
171         /// <summary>
172         /// Releases all resources used by this object.
173         /// </summary>
174         /// <since_tizen>3</since_tizen>
175         public void Dispose()
176         {
177             Dispose(true);
178             GC.SuppressFinalize(this);
179         }
180         #endregion
181     }
182 }