2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
20 internal static partial class Interop
22 internal enum RouteDirection
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
35 internal enum RouteTurnType
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
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);
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);
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);
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);
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);
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);
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);
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);
78 internal class RouteManeuverHandle : SafeMapsHandle
80 [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_destroy")]
81 internal static extern ErrorCode Destroy(IntPtr /* maps_route_maneuver_h */ maneuver);
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);
86 internal string RoadName
88 get { return NativeGet(this.GetRoadName); }
91 internal string Instruction
93 get { return NativeGet(this.GetInstructionText); }
96 internal string Locale
98 get { return NativeGet(this.GetLocale); }
101 internal int TimeToNextInstruction
103 get { return NativeGet<int>(this.GetTimeToNextInstruction); }
106 internal double DistanceToNextInstruction
108 get { return NativeGet<double>(this.GetDistanceToNextInstruction); }
111 internal RouteDirection Direction
113 get { return NativeGet<RouteDirection>(this.GetDirectionId); }
116 internal RouteTurnType TurnType
118 get { return NativeGet<RouteTurnType>(this.GetTurnType); }
121 internal CoordinatesHandle Coordinates
123 get { return NativeGet(this.GetPosition, CoordinatesHandle.Create); }
126 public RouteManeuverHandle(IntPtr handle, bool needToRelease) : base(handle, needToRelease, Destroy)
130 internal static RouteManeuverHandle CloneFrom(IntPtr nativeHandle)
133 Clone(nativeHandle, out handle).ThrowIfFailed("Failed to clone native handle");
134 return new RouteManeuverHandle(handle, true);