4 * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #ifndef __LOCATION_BOUNDARY_H_
20 #define __LOCATION_BOUNDARY_H_
22 #include <location-types.h>
23 #include <location-position.h>
27 GType location_boundary_get_type(void);
28 #define LOCATION_TYPE_BOUNDARY (location_boundary_get_type())
31 * @file location-boundary.h
32 * @brief This file contains the definitions, structures, and functions related to boundary information.
35 * @addtogroup LocationAPI
37 * @defgroup LocationAPIBoundary Location Boundary
38 * @breif This provides APIs related to Location Boundary
39 * @addtogroup LocationAPIBoundary
45 * The type of the @location_boundary_foreach function of #LocationObject
47 typedef void (*LocationBoundaryFunc)(LocationBoundary *boundary, gpointer user_data);
50 * @brief This represents used geographical type, and supports rectangle or circle area.
53 LOCATION_BOUNDARY_NONE = 0, /*/< Undefined geographical area type. */
54 LOCATION_BOUNDARY_RECT, /*/< Rectangular geographical area type. */
55 LOCATION_BOUNDARY_CIRCLE, /*/< Circle geographical area type. */
56 LOCATION_BOUNDARY_POLYGON /*/< Polygon geographical area type. */
57 } LocationBoundaryType;
60 * @brief This represents a rectangular geographical area.
63 LocationPosition *left_top; /*/< The left top position of rectangle. */
64 LocationPosition *right_bottom; /*/< The right bottom position of rectangle. */
68 * @brief This represents a circle geographical area with center geographic position and radius.
71 LocationPosition *center; /*/< The center position of a circle. */
72 gdouble radius; /*/< The radius of a circle. */
76 * @brief This represents a polygon geographical area.
79 GList *position_list; /*/< The collection of positions */
83 * @brief This represents boundary information such as rectangular or circle area.
85 struct _LocationBoundary {
86 LocationBoundaryType type; /*/< The boundary type of this information. */
88 LocationRect rect; /*/< The geographical information of a rectangle. */
89 LocationCircle circle; /*/< The geographical information of a circle. */
90 LocationPolygon polygon; /*/< The geographical information of a polygon. */
95 * @brief Create a rectangular type of new #LocationBoundary with given information.
97 * @pre #location_init should be called before.\n
99 * @param [in] left_top - left top position.
100 * @param [in] right_bottom - right bottom position.
101 * @return a new #LocationBoundary
102 * @retval NULL if error occured
104 LocationBoundary *location_boundary_new_for_rect(LocationPosition *left_top, LocationPosition *right_bottom);
107 * @brief Create a circle type of new #LocationBoundary with given information.
109 * @pre #location_init should be called before.\n
111 * @param [in] center - center position.
112 * @param [in] radius - radius.
113 * @return a new #LocationBoundary
114 * @retval NULL if error occured
116 LocationBoundary *location_boundary_new_for_circle(LocationPosition *center, gdouble radius);
119 * @brief Create a polygon type of new #LocationBoundary with given information.
121 * @pre #location_init should be called before.\n
123 * @param [in] position_list - the list of positions.
124 * @return a new #LocationBoundary
125 * @retval NULL if error occured
127 LocationBoundary *location_boundary_new_for_polygon(GList *position_list);
130 * @brief Free a #LocationBoundary.
132 * @pre #location_init should be called before.\n
134 * @param [in] boundary - a #LocationBoundary.
137 void location_boundary_free(LocationBoundary *boundary);
140 * @brief Makes a copy of #LocationBoundary
142 * @pre #location_init should be called before.\n
144 * @param [in] boundary - a #LocationBoundary
145 * @return a new #LocationBoundary
146 * @retval NULL if error occured
148 LocationBoundary *location_boundary_copy(const LocationBoundary *boundary);
151 * @brief Add Boundary on LocationFW. You should call this fuction when you want to receive a crossing signal(zone-in/zone-out) from #LocationBoundary.
152 * @remarks It supports multi-boundaries. However a duplicated boundary would not be allowed.
153 * @pre #location_new should be called before.\n
155 * @param [in] obj - a #LocationObject
156 * @param [in] boundary - a #LocationBoundary
160 int location_boundary_add(const LocationObject *obj, const LocationBoundary *boundary);
163 * @brief Remove Boundary on LocationFW.
164 * You should call this function when you don't want to receive a crossing signal(zone-in/zone-out) from #LocationBoundary any more.
165 * @remarks It supports multi-boundaries.
166 * @pre #location_init should be called before.\n
168 * @param [in] obj - a #LocationObject
169 * @param [in] boundary - a #LocationBoundary
173 int location_boundary_remove(const LocationObject *obj, const LocationBoundary *boundary);
176 * @brief Call a function for each element of a Boundary list.
178 * @pre #location_init should be called before.\n
180 * @param [in] obj - a #LocationObject
181 * @param [in] func - a #LocationBoundaryFunc
182 * @param [in] user_data - a #void
186 int location_boundary_foreach(const LocationObject *obj, LocationBoundaryFunc func, gpointer user_data);
190 * @brief Check if #LocationPosition is inside #LocationBoundary.
192 * @pre #location_init should be called before.\n
193 * @post None.* @param [in] boundary - a #LocationBoundary
194 * @param [in] position - a #LocationPosition
196 * @retval\n TRUE - if inside\n FALSE - if outside\n
198 gboolean location_boundary_if_inside(LocationBoundary *boundary, LocationPosition *position);
201 * @brief Get bounding box of #LocationBoundary
203 LocationBoundary *location_boundary_get_bounding_box(LocationBoundary *boundary);
207 * @brief Get the center position of #LocationBoundary
209 LocationPosition *location_boundary_get_center_position(LocationBoundary *boundary);