2 * Copyright (c) 2011-2013 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.
17 #ifndef __TIZEN_LOCATION_BOUNDS_H__
18 #define __TIZEN_LOCATION_BOUNDS_H__
20 #include <tizen_type.h>
21 #include <tizen_error.h>
27 #define LOCATION_BOUNDS_ERROR_CLASS TIZEN_ERROR_LOCATION_MANAGER | 0x20
31 * @addtogroup CAPI_LOCATION_BOUNDS_MODULE
37 * @brief The structure type to represent coordinates with latitude and longitude.
38 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
41 double latitude; /**< The latitude [-90.0 ~ 90.0] (degrees) */
42 double longitude; /**< The longitude [-180.0 ~ 180.0] (degrees) */
47 * @brief Enumeration for error code for Location manager.
50 LOCATION_BOUNDS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
51 LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
52 LOCATION_BOUNDS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
53 LOCATION_BOUNDS_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
54 LOCATION_BOUNDS_ERROR_INCORRECT_TYPE = LOCATION_BOUNDS_ERROR_CLASS | 0x01, /**< Incorrect bounds type for a given call */
55 LOCATION_BOUNDS_ERROR_IS_ADDED = LOCATION_BOUNDS_ERROR_CLASS | 0x02, /**< Cannot remove bounds handle from location manager */
56 } location_bound_error_e;
60 * @brief Enumeration for Location boundary type.
61 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
64 LOCATION_BOUNDS_RECT = 1, /**< Rectangular geographical area type. */
65 LOCATION_BOUNDS_CIRCLE, /**< Circle geographical area type.. */
66 LOCATION_BOUNDS_POLYGON, /**< Polygon geographical area type.. */
67 } location_bounds_type_e;
71 * @brief Enumeration for the boundary state.
72 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
75 LOCATIONS_BOUNDARY_IN, /**< Boundary In (Zone In) */
76 LOCATIONS_BOUNDARY_OUT /**< Boundary Out (Zone Out) */
77 } location_boundary_state_e;
81 * @brief The location boundary handle.
82 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
84 typedef struct location_bounds_s *location_bounds_h;
88 * @brief Gets called iteratively to notify you of coordinates of a polygon.
89 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
90 * @param[in] coords The coordinates
91 * @param[in] user_data The user data passed from the foreach function
92 * @return @c true to continue with the next iteration of the loop, \n
93 * @c false to break out of the loop
94 * @pre location_bounds_foreach_polygon_coords() will invoke this callback.
95 * @see location_bounds_foreach_polygon_coords()
97 typedef bool (*polygon_coords_cb)(location_coords_s coords, void *user_data);
101 * @brief Called when the given boundary is entered or exited.
102 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
103 * @param[in] state The boundary state
104 * @pre location_manager_start() will invoke this callback if you register this callback using location_bounds_set_state_changed_cb().
105 * @see #location_boundary_state_e
106 * @see location_manager_start()
107 * @see location_bounds_set_state_changed_cb()
109 typedef void (*location_bounds_state_changed_cb)(location_boundary_state_e state, void *user_data);
113 * @brief Creates a rect type of new location bounds.
114 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
115 * @remarks You must release @a bounds using location_bounds_destroy().
116 * @param[in] top_left The top left position
117 * @param[in] bottom_right The bottom right position
118 * @param[out] bounds The location bounds handle that is newly created
119 * @return @c 0 on success,
120 * otherwise a negative error value
121 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
122 * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory
123 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter
124 * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported
125 * @see location_bounds_get_rect_coords()
126 * @see location_bounds_destroy()
128 int location_bounds_create_rect(location_coords_s top_left, location_coords_s bottom_right, location_bounds_h *bounds);
132 * @brief Creates a circle type of new location bounds.
133 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
134 * @remarks You must release @a bounds using location_bounds_destroy().
135 * @param[in] center The center position
136 * @param[in] radius The radius of a circle (meters)
137 * @param[out] bounds The location bounds handle that is newly created
138 * @return @c 0 on success,
139 * otherwise a negative error value
140 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
141 * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory
142 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter
143 * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported
144 * @see location_bounds_get_circle_coords()
145 * @see location_bounds_destroy()
147 int location_bounds_create_circle(location_coords_s center, double radius, location_bounds_h *bounds);
151 * @brief Creates a polygon type of new location bounds.
152 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
153 * @remarks You must release @a bounds using location_bounds_destroy().
154 * @remarks @a length should be more than @c 3 to represent polygon.
155 * @param[in] coords_list The list of coordinates
156 * @param[in] length The length of the coordinates list
157 * @param[out] bounds The location bounds handle that is newly created on success
158 * @return @c 0 on success,
159 * otherwise a negative error value
160 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
161 * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory
162 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter
163 * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported
164 * @see location_bounds_foreach_polygon_coords()
165 * @see location_bounds_destroy()
167 int location_bounds_create_polygon(location_coords_s *coords_list, int length, location_bounds_h *bounds);
171 * @brief Checks whether the bounds contains the specified coordinates.
172 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
173 * @remark The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
174 * @param[in] bounds The location bounds handle
175 * @param[in] coords The coordinates
176 * @return @c true if the bounds contains the specified coordinates,
177 * otherwise else @c false
178 * @exception #LOCATION_BOUNDS_ERROR_NONE Successful
179 * @exception #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory
180 * @exception #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter
181 * @exception #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported
182 * @see location_bounds_create_rect()
183 * @see location_bounds_create_circle()
184 * @see location_bounds_create_polygon()
186 bool location_bounds_contains_coordinates(location_bounds_h bounds, location_coords_s coords);
190 * @brief Gets the type of location bounds.
191 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
192 * @param[in] bounds The location bounds handle
193 * @param[out] type The type of location bounds
194 * @return @c 0 on success,
195 * otherwise a negative error value
196 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
197 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter
198 * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported
199 * @see location_bounds_create_rect()
200 * @see location_bounds_create_circle()
201 * @see location_bounds_create_polygon()
203 int location_bounds_get_type(location_bounds_h bounds, location_bounds_type_e *type);
207 * @brief Gets the center position and radius of circle bounds.
208 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
209 * @param[in] bounds The location bounds handle
210 * @param[out] top_left The top left position
211 * @param[out] bottom_right The bottom right position
212 * @return @c 0 on success,
213 * otherwise a negative error value
214 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
215 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter
216 * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported
217 * @retval #LOCATION_BOUNDS_ERROR_INCORRECT_TYPE Incorrect bounds type
218 * @see location_bounds_create_rect()
220 int location_bounds_get_rect_coords(location_bounds_h bounds, location_coords_s *top_left, location_coords_s *bottom_right);
224 * @brief Gets the center position and radius of circle bounds.
225 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
226 * @param[in] bounds The location bounds handle
227 * @param[out] center The center position of the circle
228 * @param[out] radius The radius of the circle
229 * @return @c 0 on success,
230 * otherwise a negative error value
231 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
232 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter
233 * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported
234 * @retval #LOCATION_BOUNDS_ERROR_INCORRECT_TYPE Incorrect bounds type
235 * @see location_bounds_create_circle()
237 int location_bounds_get_circle_coords(location_bounds_h bounds, location_coords_s *center, double *radius);
241 * @brief Get the coordinates of a polygon.
242 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
243 * @param[in] bounds The location bounds handle
244 * @param[in] callback The iteration callback
245 * @param[in] user_data The user data to be passed to the callback function
246 * @return @c 0 on success,
247 * otherwise a negative error value
248 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
249 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter
250 * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported
251 * @retval #LOCATION_BOUNDS_ERROR_INCORRECT_TYPE Incorrect bounds type
252 * @post It invokes polygon_coords_cb() to get coordinates of polygon.
253 * @see polygon_coords_cb()
254 * @see location_bounds_create_polygon()
256 int location_bounds_foreach_polygon_coords(location_bounds_h bounds, polygon_coords_cb callback, void *user_data);
260 * @brief Releases the location bounds.
261 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
262 * @param[in] bounds The location bounds handle
263 * @return @c 0 on success,
264 * otherwise a negative error value
265 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
266 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter
267 * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported
268 * @see location_bounds_create_rect()
269 * @see location_bounds_create_circle()
270 * @see location_bounds_create_polygon()
272 int location_bounds_destroy(location_bounds_h bounds);
276 * @brief Registers a callback function to be invoked when the boundary area is entered or exited.
277 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
278 * @param[in] bounds The location bounds handle
279 * @param[in] callback The callback function to register
280 * @param[in] user_data The user data to be passed to the callback function
281 * @return @c 0 on success,
282 * otherwise a negative error value
283 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
284 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter
285 * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported
286 * @post location_bounds_state_changed_cb() will be invoked.
287 * @see location_bounds_unset_state_changed_cb()
288 * @see location_bounds_state_changed_cb()
290 int location_bounds_set_state_changed_cb(location_bounds_h bounds, location_bounds_state_changed_cb callback, void *user_data);
294 * @brief Unregisters the callback function.
295 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
296 * @param[in] bounds The location bounds handle
297 * @return @c 0 on success,
298 * otherwise a negative error value
299 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
300 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter
301 * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported
302 * @see location_bounds_set_state_changed_cb()
304 int location_bounds_unset_state_changed_cb(location_bounds_h bounds);
314 #endif /* __TIZEN_LOCATION_BOUNDS_H__ */