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.
21 #include <locations.h>
22 #include <location_bounds.h>
23 #include <location_batch.h>
27 static location_manager_h manager;
28 static GMainLoop *g_mainloop = NULL;
31 static int repeat_count;
32 static void location_cleanup();
33 static int location_test();
34 static guint test_timer;
36 static gboolean exit_program(gpointer data)
38 g_main_loop_quit(g_mainloop);
43 static gboolean wait_test()
46 g_source_remove(test_timer);
57 void zone_event_cb(location_boundary_state_e state, double latitude, double longitude, double altitude, time_t timestamp, void *user_data)
59 if (state == LOCATIONS_BOUNDARY_IN) {
60 fprintf(stderr, "Entering zone\n");
61 } else { /* state == LOCATIONS_BOUNDARY_OUT */
62 fprintf(stderr, "Leaving zone\n");
65 fprintf(stderr, "Latitude: %lf, longitude: %lf, altitude: %lf\n", latitude, longitude, altitude);
67 fprintf(stderr, "Time: %s\n", ctime(×tamp));
70 static bool last_satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use, void *user_data)
72 fprintf(stderr, "[Last Satellite information] azimuth : %d, elevation: %d, prn: %d, snr: %d, used: %d\n", azimuth, elevation,
77 static bool __poly_coords_cb(location_coords_s coords, void *user_data)
79 fprintf(stderr, "location_bounds_foreach_rect_coords(latitude: %lf, longitude: %lf) \n", coords.latitude, coords.longitude);
83 static bool __location_bounds_cb(location_bounds_h bounds, void *user_data)
86 fprintf(stderr, "bounds ==NULL\n");
88 location_bounds_type_e type;
89 location_bounds_get_type(bounds, &type);
90 if (type == LOCATION_BOUNDS_CIRCLE) {
91 location_coords_s center;
93 location_bounds_get_circle_coords(bounds, ¢er, &radius);
94 fprintf(stderr, "location_bounds_get_circle_coords(center: %lf, %lf, radius: %lf) \n", center.latitude, center.longitude, radius);
96 } else if (type == LOCATION_BOUNDS_RECT) {
97 location_coords_s left_top;
98 location_coords_s right_bottom;
99 location_bounds_get_rect_coords(bounds, &left_top, &right_bottom);
100 fprintf(stderr, "location_bounds_get_rect_coords(left_top: %lf, %lf - right_bottom: %lf, %lf) \n",
101 left_top.latitude, left_top.longitude, right_bottom.latitude, right_bottom.longitude);
102 } else if (type == LOCATION_BOUNDS_POLYGON) {
103 location_bounds_foreach_polygon_coords(bounds, __poly_coords_cb, NULL);
109 void location_bounds_test()
112 location_coords_s center;
113 center.latitude = 37.258;
114 center.longitude = 127.056;
116 location_bounds_h bounds_circle;
117 ret = location_bounds_create_circle(center, radius, &bounds_circle);
118 if (ret != LOCATION_BOUNDS_ERROR_NONE)
119 fprintf(stderr, "location_bounds_create_circle() failed\n");
121 fprintf(stderr, "Bounds(circle) has been created successfully.\n");
123 ret = location_manager_add_boundary(manager, bounds_circle);
124 if (ret != LOCATIONS_ERROR_NONE)
125 fprintf(stderr, "Setting boundary failed\n");
127 fprintf(stderr, "Boundary set\n");
129 location_coords_s center2;
131 ret = location_bounds_get_circle_coords(bounds_circle, ¢er2, &radius2);
132 if (ret != LOCATIONS_ERROR_NONE) {
133 fprintf(stderr, "location_bounds_get_circle_coords() failed\n");
135 fprintf(stderr, "location_bounds_get_circle_coords(center: %lf, %lf, radius: %lf) \n", center2.latitude,
136 center2.longitude, radius2);
138 /*Add the rect bounds */
139 location_coords_s left_top;
140 left_top.latitude = 30;
141 left_top.longitude = 30;
143 location_coords_s right_bottom;
144 right_bottom.latitude = 10;
145 right_bottom.longitude = 50;
147 location_bounds_h bounds_rect;
148 ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect);
149 if (ret != LOCATION_BOUNDS_ERROR_NONE)
150 fprintf(stderr, "location_bounds_create_rect() failed\n");
152 fprintf(stderr, "Bounds(rect) has been created successfully.\n");
154 ret = location_manager_add_boundary(manager, bounds_rect);
155 if (ret != LOCATIONS_ERROR_NONE)
156 fprintf(stderr, "Setting boundary failed\n");
158 fprintf(stderr, "Boundary set\n");
160 location_coords_s left_top2;
161 location_coords_s right_bottom2;
163 ret = location_bounds_get_rect_coords(bounds_rect, &left_top2, &right_bottom2);
164 if (ret != LOCATIONS_ERROR_NONE) {
165 fprintf(stderr, "location_bounds_get_rect_coords() failed\n");
167 fprintf(stderr, "location_bounds_get_rect_coords(left_top: %lf, %lf - right_bottom: %lf, %lf) \n", left_top2.latitude,
168 left_top2.longitude, right_bottom2.latitude, right_bottom2.longitude);
170 /*Add the polygon bounds */
173 location_coords_s coord_list[poly_size];
175 coord_list[0].latitude = 10;
176 coord_list[0].longitude = 10;
177 coord_list[1].latitude = 20;
178 coord_list[1].longitude = 20;
179 coord_list[2].latitude = 30;
180 coord_list[2].longitude = 30;
182 location_bounds_h bounds_poly;
183 ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly);
184 if (ret != LOCATION_BOUNDS_ERROR_NONE)
185 fprintf(stderr, "location_bounds_create_polygon() failed\n");
187 fprintf(stderr, "Bounds(polygon) has been created successfully.\n");
189 ret = location_manager_add_boundary(manager, bounds_poly);
190 if (ret != LOCATIONS_ERROR_NONE)
191 fprintf(stderr, "Setting boundary failed\n");
193 fprintf(stderr, "Boundary set\n");
195 ret = location_bounds_foreach_polygon_coords(bounds_poly, __poly_coords_cb, NULL);
196 if (ret != LOCATIONS_ERROR_NONE)
197 fprintf(stderr, "location_bounds_get_rect_coords() failed\n");
199 location_coords_s test_coords;
200 test_coords.latitude = 12;
201 test_coords.longitude = 12;
203 if (location_bounds_contains_coordinates(bounds_poly, test_coords))
204 fprintf(stderr, "location_bounds_contains_coordinates() retrun TRUE \n");
206 fprintf(stderr, "location_bounds_contains_coordinates() retrun FALSE \n");
208 /*print current bounds */
209 ret = location_manager_foreach_boundary(manager, __location_bounds_cb, (void *)manager);
210 if (ret != LOCATIONS_ERROR_NONE)
211 fprintf(stderr, "location_manager_foreach_boundary() failed\n");
215 void location_get_last_information_test()
218 double altitude, latitude, longitude;
219 double climb, direction, speed;
220 double horizontal, vertical;
221 location_accuracy_level_e level;
223 int num_of_inview, num_of_active;
225 ret = location_manager_get_last_position(manager, &altitude, &latitude, &longitude, ×tamp);
226 if (ret != LOCATIONS_ERROR_NONE)
227 fprintf(stderr, " Fail: location_manager_get_last_position ---> %d \n", ret);
229 fprintf(stderr, "[%ld] alt: %g, lat: %g, long: %g\n", timestamp, altitude, latitude, longitude);
231 ret = location_manager_get_last_velocity(manager, &climb, &direction, &speed, ×tamp);
232 if (ret != LOCATIONS_ERROR_NONE)
233 fprintf(stderr, " Fail: location_manager_get_last_velocity ---> %d \n", ret);
235 fprintf(stderr, "climb: %f, direction: %f, speed: %f\n", climb, direction, speed);
237 ret = location_manager_get_last_accuracy(manager, &level, &horizontal, &vertical);
238 if (ret != LOCATIONS_ERROR_NONE)
239 fprintf(stderr, " Fail: location_manager_get_last_accuracy ---> %d \n", ret);
241 fprintf(stderr, "Level: %d, horizontal: %g, vertical: %g\n", level, horizontal, vertical);
243 ret = gps_status_get_last_satellite(manager, &num_of_active, &num_of_inview, ×tamp);
244 if (ret != LOCATIONS_ERROR_NONE)
245 fprintf(stderr, " Fail: gps_status_get_last_satellite_count_in_view ---> %d \n", ret);
247 fprintf(stderr, "[%ld] Satellite number of active: %d, in view: %d\n", timestamp, num_of_active, num_of_inview);
249 ret = gps_status_foreach_last_satellites_in_view(manager, last_satellites_foreach_cb, NULL);
250 if (ret != LOCATIONS_ERROR_NONE)
251 fprintf(stderr, " Fail: gps_status_foreach_last_satellites_in_view ---> %d \n", ret);
255 static void _state_change_cb(location_service_state_e state, void *user_data)
257 fprintf(stderr, "--------------------------state change: %d---------\n", state);
258 location_manager_h lm = (location_manager_h) user_data;
259 if (state == LOCATIONS_SERVICE_ENABLED) {
265 ret = location_manager_get_position(lm, &altitude, &latitude, &longitude, ×tamp);
266 if (ret != LOCATIONS_ERROR_NONE)
267 fprintf(stderr, " Fail: location_manager_get_position ---> %d \n", ret);
269 fprintf(stderr, "[%ld] lat: %f, lng: %f, alt: %f\n", timestamp, latitude, longitude, altitude);
271 location_accuracy_level_e level;
274 ret = location_manager_get_accuracy(lm, &level, &horizontal, &vertical);
275 if (ret != LOCATIONS_ERROR_NONE)
276 fprintf(stderr, " Fail: location_manager_get_accuracy ---> %d \n", ret);
278 fprintf(stderr, "Level: %d, horizontal: %f, vertical %f\n", level, horizontal, vertical);
281 ret = gps_status_get_nmea(lm, &nmea);
282 if (ret != LOCATIONS_ERROR_NONE) {
283 fprintf(stderr, " Fail: gps_status_get_nmea ---> %d \n", ret);
285 fprintf(stderr, "NMEA: %s\n", nmea);
293 void _position_updated_cb(double latitude, double longitude, double altitude, time_t timestamp, void *user_data)
295 fprintf(stderr, "-------------------------- position updated --------------------------\n");
296 fprintf(stderr, "[%ld] lat: %f, lng: %f, alt: %f\n", timestamp, latitude, longitude, altitude);
298 location_manager_h lm = (location_manager_h) user_data;
299 location_accuracy_level_e level;
302 int ret = location_manager_get_accuracy(lm, &level, &horizontal, &vertical);
303 if (ret != LOCATIONS_ERROR_NONE)
304 fprintf(stderr, " Fail: location_manager_get_accuracy ---> %d \n", ret);
306 fprintf(stderr, "Level: %d, horizontal: %f, vertical %f\n", level, horizontal, vertical);
310 if (repeat_count > 9)
311 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
314 void _velocity_updated_cb(double speed, double direction, double climb, time_t timestamp, void *user_data)
316 fprintf(stderr, "-------------------------- velocity updated --------------------------\n");
317 fprintf(stderr, "[%ld] speed[%f] direction[%f] climb[%f]\n", timestamp, speed, direction, climb);
320 void _location_cb(int error, double latitude, double longitude, double altitude, time_t timestamp, double speed, double climb, double direction, void *user_data)
322 fprintf(stderr, "error[%d]\n", error);
323 fprintf(stderr, "location_cb: lat[%f] lon[%f] alt[%f]\n", latitude, longitude, altitude);
324 fprintf(stderr, "speed[%f] climb[%f] direction[%f]\n", speed, climb, direction);
326 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
329 void _location_changed_cb(double latitude, double longitude, double altitude, double speed, double direction, double horizontal_accuracy, time_t timestamp, void *user_data)
331 fprintf(stderr, "-------------------------- location changed --------------------------\n");
332 fprintf(stderr, "[%ld] lat[%f] lon[%f] alt[%f] speed[%lf] direction[%lf], horizontal_accuracy[%lf]\n", timestamp, latitude, longitude, altitude, speed, direction, horizontal_accuracy);
336 if (repeat_count > 5)
337 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
341 bool _get_location_cb(double latitude, double longitude, double altitude, double speed, double direction, double horizontal, double vertical, time_t timestamp, void *user_data)
343 fprintf(stderr, "-------------------------- batch: get location --------------------------\n");
344 fprintf(stderr, "[%ld] lat[%f] lon[%f] alt[%f] speed[%lf] direction[%lf], horizontal_accuracy[%lf]\n", timestamp, latitude, longitude, altitude, speed, direction, horizontal);
348 void _location_batch_cb(int num_of_location, void *user_data)
350 fprintf(stderr, "-------------------------- location batch --------------------------\n");
351 fprintf(stderr, "num_of_location: [%d]\n", num_of_location);
353 location_manager_h manager = user_data;
355 if (num_of_location > 0)
356 location_manager_foreach_location_batch(manager, _get_location_cb, user_data);
360 if (repeat_count > 1)
361 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
364 static void _setting_cb(location_method_e method, bool enable, void *user_data)
366 fprintf(stderr, "method[%d], enable[%d]\n", method, enable);
369 void _satellite_updated_cb(int num_of_active, int num_of_inview, time_t timestamp, void *user_data)
371 fprintf(stderr, "-------------------------- satellite updated --------------------------\n");
372 fprintf(stderr, "num_of_active[%d] num_of_inview[%d] timestamp[%ld]\n", num_of_active, num_of_inview, timestamp);
374 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
377 static void print_location_status()
379 fprintf(stderr, "==== LOCATION Setting state =====\n");
380 bool is_enabled = FALSE;
381 location_manager_is_enabled_method(LOCATIONS_METHOD_HYBRID, &is_enabled);
382 fprintf(stderr, "hybrid: %d, ", is_enabled);
384 location_manager_is_enabled_method(LOCATIONS_METHOD_GPS, &is_enabled);
385 fprintf(stderr, "gps: %d, ", is_enabled);
387 location_manager_is_enabled_method(LOCATIONS_METHOD_WPS, &is_enabled);
388 fprintf(stderr, "wps: %d, ", is_enabled);
390 /* location_manager_is_test_location_enabled(&is_enabled); */
391 location_manager_is_enabled_method(LOCATIONS_METHOD_MOCK, &is_enabled);
392 fprintf(stderr, "mock: %d\n", is_enabled);
395 static int enable_method(location_method_e method, bool enable)
398 fprintf(stderr, "==== LOCATION Setting changed =====\n");
400 location_manager_set_setting_changed_cb(LOCATIONS_METHOD_HYBRID, _setting_cb, NULL);
402 fprintf(stderr, "method[%d], enable[%d]\n", method, enable);
403 ret = location_manager_enable_method(method, enable);
405 location_manager_unset_setting_changed_cb(LOCATIONS_METHOD_HYBRID);
409 static int test_clear_mock_location(gpointer user_data)
411 location_manager_h manager = (location_manager_h) user_data;
414 ret = location_manager_clear_mock_location(manager);
415 fprintf(stderr, "\n==== location_manager_clear_mock_location: %d ====\n\n", ret);
419 ret = location_manager_get_service_state(manager, &state);
420 fprintf(stderr, "the current state: %d, ret = %d\n", state, ret);
427 static int test_set_mock_location(gpointer user_data)
429 location_manager_h manager = (location_manager_h) user_data;
434 ret = location_manager_get_service_state(manager, &state);
435 fprintf(stderr, "the current state: %d, ret = %d\n", state, ret);
438 ret = location_manager_set_mock_location(manager, 20, 20, 0, 40, 50, 100);
439 fprintf(stderr, "\n==== location_manager_set_location: %d ====\n\n", ret);
440 if (ret != LOCATIONS_ERROR_NONE)
441 g_timeout_add_seconds(3, test_clear_mock_location, manager);
446 static void print_menu()
448 fprintf(stderr, "============= LOCATION TEST =============\n");
449 fprintf(stderr, "[1] Get location: LOCATIONS_METHOD_HYBRID\n");
450 fprintf(stderr, "[2] Get location: LOCATIONS_METHOD_GPS\n");
451 fprintf(stderr, "[3] Get location: LOCATIONS_METHOD_WPS\n");
452 fprintf(stderr, "[4] Single location: LOCATIONS_METHOD_HYBRID\n");
453 fprintf(stderr, "[5] Single location: LOCATIONS_METHOD_GPS\n");
454 fprintf(stderr, "[6] Single location: LOCATIONS_METHOD_WPS\n\n");
455 fprintf(stderr, "[11] Change update interval: LOCATIONS_METHOD_HYBRID\n");
456 fprintf(stderr, "[12] Change update interval: LOCATIONS_METHOD_GPS\n\n");
457 fprintf(stderr, "[21] Distance based location update: LOCATIONS_METHOD_HYBRID\n");
458 fprintf(stderr, "[22] Distance based location update: LOCATIONS_METHOD_GPS\n");
459 fprintf(stderr, "[23] Distance based location update: LOCATIONS_METHOD_WPS\n\n");
460 fprintf(stderr, "[31] Location batch update: LOCATIONS_METHOD_GPS\n\n");
461 fprintf(stderr, "[41] Turn on/off mock test: LOCATIONS_METHOD_MOCK\n");
462 fprintf(stderr, "[42] Set & Clear location: LOCATIONS_METHOD_HYBRID\n\n");
463 fprintf(stderr, "[51] Turn on/off method: LOCATIONS_METHOD_HYBRID\n");
464 fprintf(stderr, "[52] Turn on/off method: LOCATIONS_METHOD_GPS\n");
465 fprintf(stderr, "[53] Turn on/off method: LOCATIONS_METHOD_WPS\n\n");
466 fprintf(stderr, "[61] Boundary Test\n\n");
467 fprintf(stderr, "[0] Exit!!!\n\n");
468 fprintf(stderr, "Select menu: ");
470 if (scanf("%d", &menu) < 0)
471 fprintf(stderr, "Can't read menu !!!\n");
474 static int location_test()
476 int ret = LOCATIONS_ERROR_NONE;
481 print_location_status();
490 int method = menu - 1;
491 ret = location_manager_create(method, &manager);
492 fprintf(stderr, "location_manager_create (method: %d): %d\n", method, ret);
494 ret = location_manager_start(manager);
495 fprintf(stderr, "start: %d\n", ret);
497 if (method == LOCATIONS_METHOD_GPS) {
498 ret = gps_status_set_satellite_updated_cb(manager, _satellite_updated_cb, 1, &manager);
499 fprintf(stderr, "gps_status_set_satellite_updated_cb: %d\n", ret);
508 fprintf(stderr, "\n Input timeout ==> ");
509 ret = scanf("%d", &timeout);
511 int method = menu - 4;
512 ret = location_manager_create(method, &manager);
513 ret = location_manager_request_single_location(manager, timeout, _location_cb, manager);
514 fprintf(stderr, "request single_location (method: %d): %d\n", method, ret);
522 fprintf(stderr, "\n Input position interval ==> ");
523 ret = scanf("%d", &interval);
525 int method = menu - 11;
526 ret = location_manager_create(method, &manager);
527 fprintf(stderr, "location_manager_create (method: %d): %d\n", method, ret);
529 ret = location_manager_set_position_updated_cb(manager, _position_updated_cb, interval, (void *)manager);
530 fprintf(stderr, "set_position_updated_cb: %d\n", ret);
533 ret = location_manager_set_velocity_updated_cb(manager, _velocity_updated_cb, interval*2, (void *)manager);
534 fprintf(stderr, "set_velocity_updated_cb: %d\n", ret);
537 ret = location_manager_set_location_changed_cb(manager, _location_changed_cb, interval * 2, (void *)manager);
538 fprintf(stderr, "set_location_changed_cb: %d\n", ret);
540 ret = location_manager_start(manager);
541 fprintf(stderr, "start: %d\n", ret);
548 int method = menu - 21;
550 fprintf(stderr, "\n Input position interval ==> ");
551 ret = scanf("%d", &interval);
553 ret = location_manager_create(method, &manager);
554 fprintf(stderr, "location_manager_create (method : %d)", method);
556 /*ret = location_manager_set_position_updated_cb(manager, _position_updated_cb, interval, (void *)manager); */
557 /*fprintf(stderr, "set position changed callback: %d\n", ret); */
559 ret = location_manager_set_distance_based_location_changed_cb(manager, _location_changed_cb, interval, 30, (void *)manager);
560 fprintf(stderr, "set_distance_based_location_changed_cb: %d\n", ret);
562 ret = location_manager_start(manager);
563 fprintf(stderr, "start: %d\n", ret);
568 fprintf(stderr, "\n Input batch interval ==> ");
569 ret = scanf("%d", &interval);
572 fprintf(stderr, " Input batch period ==> ");
573 ret = scanf("%d", &period);
575 ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager);
576 fprintf(stderr, "location_manager_create (method : %d)\n", LOCATIONS_METHOD_GPS);
578 ret = location_manager_set_location_batch_cb(manager, _location_batch_cb, interval, period, (void *)manager);
579 fprintf(stderr, "set_location_batch_cb: %d\n", ret);
581 ret = location_manager_start_batch(manager);
582 fprintf(stderr, "start_batch: %d\n", ret);
589 fprintf(stderr, "\n Mock Location (ON: 1 or OFF: 0) Input ==> ");
590 ret = scanf("%d", &onoff);
592 ret = location_manager_enable_mock_location(onoff);
593 fprintf(stderr, "Enabling mock test: ret=%d\n", ret);
595 ret = location_manager_create(LOCATIONS_METHOD_MOCK, &manager);
596 fprintf(stderr, "location_manager_create (method: %d): %d\n", LOCATIONS_METHOD_MOCK, ret);
598 ret = location_manager_set_mock_location(manager, 10, 20, 0, 40, 50, 100);
599 fprintf(stderr, "location_manager_set_mock_location: %d\n", ret);
600 if (ret == LOCATIONS_ERROR_SETTING_OFF) {
601 fprintf(stderr, "Setting for Mock Location is turned OFF!!!\n");
605 ret = location_manager_start(manager);
606 fprintf(stderr, "start: %d\n", ret);
608 g_timeout_add_seconds(3, test_clear_mock_location, manager);
609 g_timeout_add_seconds(10, wait_test, NULL);
616 ret = location_manager_create(LOCATIONS_METHOD_HYBRID, &manager);
617 fprintf(stderr, "location_manager_create (method: %d): %d\n", LOCATIONS_METHOD_HYBRID, ret);
619 ret = location_manager_start(manager);
620 fprintf(stderr, "start: %d\n", ret);
624 ret = location_manager_get_service_state(manager, &state);
625 fprintf(stderr, "the current state: %d, ret = %d\n", state, ret);
628 g_timeout_add_seconds(5, test_set_mock_location, manager);
635 int method = menu - 51;
638 fprintf(stderr, "\n Input ON: 1 or OFF: 0 ==> ");
639 ret = scanf("%d", &onoff);
641 if (onoff == 0 || onoff == 1) {
642 ret = enable_method(method, onoff);
643 fprintf(stderr, "Enabling method: [%d], ret=%d\n", method, ret);
648 location_bounds_h hPolyLocationBound = NULL;
649 bool bIsContained = false;
651 location_coords_s location_coord_list[nPolySize];
652 location_coord_list[0].latitude = 10;
653 location_coord_list[0].longitude = 10;
654 location_coord_list[1].latitude = 20;
655 location_coord_list[1].longitude = 20;
656 location_coord_list[2].latitude = 30;
657 location_coord_list[2].longitude = 10;
659 /* Checking coordinates in location boundary */
660 location_coords_s testLocationCoordinates;
661 testLocationCoordinates.latitude = 20;
662 testLocationCoordinates.longitude = 12;
663 location_bound_error_e nRet = location_bounds_create_polygon(location_coord_list, nPolySize, &hPolyLocationBound);
665 fprintf(stderr, "location_bounds_create_polygon: %d\n", nRet);
667 bIsContained = location_bounds_contains_coordinates(hPolyLocationBound, testLocationCoordinates);
668 fprintf(stderr, "bIsContained: %d\n", bIsContained);
670 location_bounds_destroy(hPolyLocationBound);
674 g_timeout_add_seconds(1, exit_program, NULL);
677 fprintf(stderr, "Exit!!! Input: %d\n", menu);
678 g_timeout_add_seconds(1, exit_program, NULL);
682 if (ret != LOCATIONS_ERROR_NONE) {
683 fprintf(stderr, "Test Failed!!! [%d]\n", ret);
684 g_timeout_add_seconds(1, exit_program, NULL);
688 if (menu > 0 && menu < 50) {
689 ret = location_manager_set_service_state_changed_cb(manager, _state_change_cb, (void *)manager);
690 fprintf(stderr, "set_service_state_changed_cb: %d\n", ret);
693 ret = location_manager_set_position_updated_cb(manager, _position_updated_cb, interval, (void *)manager);
694 fprintf(stderr, "set_position_updated_cb: %d\n", ret);
697 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
703 static void location_cleanup()
706 if (manager != NULL) {
707 ret = location_manager_stop(manager);
708 fprintf(stderr, "stop: %d\n", ret);
710 ret = location_manager_unset_service_state_changed_cb(manager);
711 fprintf(stderr, "unset_service_state_changed_cb: %d\n", ret);
713 ret = location_manager_unset_position_updated_cb(manager);
714 fprintf(stderr, "unset_position_updated_cb: %d\n", ret);
716 ret = gps_status_unset_satellite_updated_cb(manager);
717 fprintf(stderr, "gps_status_unset_satellite_updated_cb: %d\n", ret);
719 ret = location_manager_destroy(manager);
720 fprintf(stderr, "destroy: %d\n", ret);
725 int main(int argc, char **argv)
727 g_mainloop = g_main_loop_new(NULL, 0);
729 g_main_loop_run(g_mainloop);