Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Interop / Interop.Route.Maneuver.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 using System.Runtime.InteropServices;
19
20 internal static partial class Interop
21 {
22     internal enum RouteDirection
23     {
24         None, // MAPS_ROUTE_DIRECTION_NONE
25         North, // MAPS_ROUTE_DIRECTION_NORTH
26         NorthWest, // MAPS_ROUTE_DIRECTION_NORTHWEST
27         NorthEast, // MAPS_ROUTE_DIRECTION_NORTHEAST
28         South, // MAPS_ROUTE_DIRECTION_SOUTH
29         SouthEast, // MAPS_ROUTE_DIRECTION_SOUTHEAST
30         SouthWest, // MAPS_ROUTE_DIRECTION_SOUTHWEST
31         West, // MAPS_ROUTE_DIRECTION_WEST
32         East, // MAPS_ROUTE_DIRECTION_EAST
33     }
34
35     internal enum RouteTurnType
36     {
37         None, // MAPS_ROUTE_TURN_TYPE_NONE
38         Straight, // MAPS_ROUTE_TURN_TYPE_STRAIGHT
39         BearRight, // MAPS_ROUTE_TURN_TYPE_BEAR_RIGHT
40         LightRight, // MAPS_ROUTE_TURN_TYPE_LIGHT_RIGHT
41         Right, // MAPS_ROUTE_TURN_TYPE_RIGHT
42         HardRight, // MAPS_ROUTE_TURN_TYPE_HARD_RIGHT
43         UturnRight, // MAPS_ROUTE_TURN_TYPE_UTURN_RIGHT
44         UturnLeft, // MAPS_ROUTE_TURN_TYPE_UTURN_LEFT
45         HardLeft, // MAPS_ROUTE_TURN_TYPE_HARD_LEFT
46         Left, // MAPS_ROUTE_TURN_TYPE_LEFT
47         LightLeft, // MAPS_ROUTE_TURN_TYPE_LIGHT_LEFT
48         BearLeft, // MAPS_ROUTE_TURN_TYPE_BEAR_LEFT
49         RightFork, // MAPS_ROUTE_TURN_TYPE_RIGHT_FORK
50         LeftFork, // MAPS_ROUTE_TURN_TYPE_LEFT_FORK
51         StraightFork, // MAPS_ROUTE_TURN_TYPE_STRAIGHT_FORK
52     }
53
54     [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_direction_id")]
55     internal static extern ErrorCode GetDirectionId(this RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out RouteDirection /* maps_route_direction_e */ directionId);
56
57     [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_turn_type")]
58     internal static extern ErrorCode GetTurnType(this RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out RouteTurnType /* maps_route_turn_type_e */ turnType);
59
60     [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_position")]
61     internal static extern ErrorCode GetPosition(this RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out IntPtr /* maps_coordinates_h */ position);
62
63     [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_road_name")]
64     internal static extern ErrorCode GetRoadName(this RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out string roadName);
65
66     [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_instruction_text")]
67     internal static extern ErrorCode GetInstructionText(this RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out string instructionText);
68
69     [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_locale")]
70     internal static extern ErrorCode GetLocale(this RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out string locale);
71
72     [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_time_to_next_instruction")]
73     internal static extern ErrorCode GetTimeToNextInstruction(this RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out int timeToNextInstruction);
74
75     [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_distance_to_next_instruction")]
76     internal static extern ErrorCode GetDistanceToNextInstruction(this RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out double distanceToNextInstruction);
77
78     internal class RouteManeuverHandle : SafeMapsHandle
79     {
80         [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_destroy")]
81         internal static extern ErrorCode Destroy(IntPtr /* maps_route_maneuver_h */ maneuver);
82
83         [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_clone")]
84         internal static extern ErrorCode Clone(IntPtr /* maps_route_maneuver_h */ origin, out IntPtr /* maps_route_maneuver_h */ cloned);
85
86         internal string RoadName
87         {
88             get { return NativeGet(this.GetRoadName); }
89         }
90
91         internal string Instruction
92         {
93             get { return NativeGet(this.GetInstructionText); }
94         }
95
96         internal string Locale
97         {
98             get { return NativeGet(this.GetLocale); }
99         }
100
101         internal int TimeToNextInstruction
102         {
103             get { return NativeGet<int>(this.GetTimeToNextInstruction); }
104         }
105
106         internal double DistanceToNextInstruction
107         {
108             get { return NativeGet<double>(this.GetDistanceToNextInstruction); }
109         }
110
111         internal RouteDirection Direction
112         {
113             get { return NativeGet<RouteDirection>(this.GetDirectionId); }
114         }
115
116         internal RouteTurnType TurnType
117         {
118             get { return NativeGet<RouteTurnType>(this.GetTurnType); }
119         }
120
121         internal CoordinatesHandle Coordinates
122         {
123             get { return NativeGet(this.GetPosition, CoordinatesHandle.Create); }
124         }
125
126         public RouteManeuverHandle(IntPtr handle, bool needToRelease) : base(handle, needToRelease, Destroy)
127         {
128         }
129
130         internal static RouteManeuverHandle CloneFrom(IntPtr nativeHandle)
131         {
132             IntPtr handle;
133             Clone(nativeHandle, out handle).ThrowIfFailed("Failed to clone native handle");
134             return new RouteManeuverHandle(handle, true);
135         }
136     }
137 }