summaryrefslogtreecommitdiff
path: root/include/location_bounds.h
blob: 08146fc519850854024640f53493a58e0edd8f3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. 
*/

#ifndef __TIZEN_LOCATION_BOUNDS_H__
#define __TIZEN_LOCATION_BOUNDS_H__

#include <tizen_type.h>
#include <tizen_error.h>

#ifdef __cplusplus
extern "C" {
#endif

#define LOCATION_BOUNDS_ERROR_CLASS          TIZEN_ERROR_LOCATION_CLASS | 0x20

/**
 * @addtogroup CAPI_LOCATION_BOUNDS_MODULE
 * @{
 */

/**
 * @brief Represents a coordinates with latitude and longitude.
 */
typedef struct
{
	double latitude;	/**< The latitude [-90.0 ~ 90.0] (degrees) */
	double longitude;	/**< The longitude [-180.0 ~ 180.0] (degrees) */
} location_coords_s;

/**
 * @brief The location boundary handle.
 */
 typedef void *location_bounds_h;

/**
 * @brief Enumerations of error code for Location manager.
 */
typedef enum
{
    LOCATION_BOUNDS_ERROR_NONE = TIZEN_ERROR_NONE,                                        /**< Successful */
    LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,                    /**< Out of memory */
    LOCATION_BOUNDS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,            /**< Invalid parameter */
    LOCATION_BOUNDS_ERROR_INCORRECT_TYPE = LOCATION_BOUNDS_ERROR_CLASS | 0x01,         /**< Incorrect bounds type for a given call */
} location_bound_error_e;


/**
 * @brief Location boundary type.
 */
typedef enum
{
    LOCATION_BOUNDS_RECT=1,    /**< Rectangular geographical area type. */
    LOCATION_BOUNDS_CIRCLE,       /**< Circle geographical area type.. */
    LOCATION_BOUNDS_POLYGON,       /**< Polygon geographical area type.. */
} location_bounds_type_e;

/**
 * @brief Gets called iteratively to notify you of coordinates of polygon. 
 * @param[in] coords   The coordinates
 * @param[in] user_data	The user data passed from the foreach function
 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
 * @pre location_bounds_foreach_polygon_coords() will invoke this callback.
 * @see location_bounds_foreach_polygon_coords() 
 */
typedef bool (*polygon_coords_cb)(location_coords_s coords, void *user_data);


/**
 * @brief Creates a rect type of new location bounds.
 * @remarks @a bounds must be released location_bounds_destroy() by you.
 * @param[in] top_left  The top left position
 * @param[in] bottom_right  The bottom right position
 * @param[out] bounds  A location bounds handle to be newly created on success
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
 * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory
 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER	Invalid parameter
 * @see location_bounds_get_rect_coords() 
 * @see location_bounds_destroy()
 */
int location_bounds_create_rect(location_coords_s top_left, location_coords_s bottom_right, location_bounds_h* bounds);

/**
 * @brief Creates a circle type of new location bounds.
 * @remarks @a bounds must be released location_bounds_destroy() by you.
 * @param[in] center  The center  position
 * @param[in] radius  The radius of a circle (meters)
 * @param[out] bounds  A location bounds handle to be newly created on success
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
 * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory
 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER	Invalid parameter
 * @see location_bounds_get_circle_coords()
 * @see location_bounds_destroy()
 */
int location_bounds_create_circle(location_coords_s center, double radius, location_bounds_h* bounds);

/**
 * @brief Creates a polygon type of new location bounds.
 * @remarks @a bounds must be released location_bounds_destroy() by you.
 * @remarks @a length sholud be over than 3 to represent polygon.
 * @param[in] coords_list  The list of coordinates
 * @param[in] length  The length of the coordinates list
 * @param[out] bounds  A location bounds handle to be newly created on success
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
 * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory
 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER	Invalid parameter
 * @see location_bounds_foreach_polygon_coords()
 * @see location_bounds_destroy()
 */
int location_bounds_create_polygon(location_coords_s* coords_list, int length, location_bounds_h* bounds);

/**
 * @brief Check if the bounds contains the specified coordinates.
 * @param[in]   bounds  The location bounds handle
 * @param[in]   coords   The coordinates
 * @param[out]   contained  The result indicating whether the boundary contains the specified coordinate (@c true = contained, @c false = not contained )
 * @return @c true if the bouns contains the specified coordinates. \n else @c false
 * @see location_bounds_create_rect()
 * @see location_bounds_create_circle()
 * @see location_bounds_create_polygon()
 */
bool location_bounds_contains_coordinates(location_bounds_h bounds, location_coords_s coords);

/**
 * @brief Get the type of location bounds.
 * @param[in] bounds  The location bounds handle
 * @param[out] type The type of location bounds
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER	Invalid parameter
 * @see location_bounds_create_rect()
 * @see location_bounds_create_circle()
 * @see location_bounds_create_polygon()
 */
int location_bounds_get_type(location_bounds_h bounds, location_bounds_type_e *type);

/**
 * @brief Get the center position and radius of circle bounds.
 * @param[in] bounds  The location bounds handle
 * @param[out] top_left  The top left position
 * @param[out] bottom_right  The bottom right position
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER	Invalid parameter
 * @retval #LOCATION_BOUNDS_ERROR_INCORRECT_TYPE Incorrect bounds type
 * @see location_bounds_create_rect()
 */
int location_bounds_get_rect_coords(location_bounds_h bounds, location_coords_s  *top_left, location_coords_s  *bottom_right);

/**
 * @brief Get the center position and radius of circle bounds.
 * @param[in] bounds  The location bounds handle
 * @param[out] center The center position of circle
 * @param[radius] center The radius of circle
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER	Invalid parameter
 * @retval #LOCATION_BOUNDS_ERROR_INCORRECT_TYPE Incorrect bounds type
 * @see location_bounds_create_circle()
 */
int location_bounds_get_circle_coords(location_bounds_h bounds, location_coords_s  *center, double *radius);

/**
 * @brief Get the coordinates of polygon.
 * @param[in] bounds  The location bounds handle
 * @param[in] callback	The geocoder get positions callback function
 * @param[in] user_data The user data to be passed to the callback function
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER	Invalid parameter
 * @retval #LOCATION_BOUNDS_ERROR_INCORRECT_TYPE Incorrect bounds type
 * @post It invokes polygon_coords_cb() to get coordinates of polygon.
 * @see polygon_coords_cb()
 * @see location_bounds_create_polygon()
 */
int location_bounds_foreach_polygon_coords(location_bounds_h bounds, polygon_coords_cb callback, void *user_data);

/**
 * @brief Releases the location bounds.
 * @param[in] bounds The location bounds handle
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
 * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER	Invalid parameter
 * @see location_bounds_create_rect()
 * @see location_bounds_create_circle()
 * @see location_bounds_create_polygon()
*/
int location_bounds_destroy(location_bounds_h bounds);

/**
 * @}
 */
#ifdef __cplusplus
}
#endif

#endif /* __TIZEN_LOCATION_BOUNDS_H__ */