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,
60 if (state == LOCATIONS_BOUNDARY_IN) {
61 fprintf(stderr, "Entering zone\n");
62 } else { /* state == LOCATIONS_BOUNDARY_OUT */
63 fprintf(stderr, "Leaving zone\n");
66 fprintf(stderr, "Latitude: %lf, longitude: %lf, altitude: %lf\n", latitude, longitude, altitude);
68 fprintf(stderr, "Time: %s\n", ctime(×tamp));
71 static bool last_satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use,
74 fprintf(stderr, "[Last Satellite information] azimuth : %d, elevation: %d, prn: %d, snr: %d, used: %d\n", azimuth, elevation,
79 static bool __poly_coords_cb(location_coords_s coords, void *user_data)
81 fprintf(stderr, "location_bounds_foreach_rect_coords(latitude: %lf, longitude: %lf) \n", coords.latitude, coords.longitude);
85 static bool __location_bounds_cb(location_bounds_h bounds, void *user_data)
88 fprintf(stderr, "bounds ==NULL\n");
90 location_bounds_type_e type;
91 location_bounds_get_type(bounds, &type);
92 if (type == LOCATION_BOUNDS_CIRCLE) {
93 location_coords_s center;
95 location_bounds_get_circle_coords(bounds, ¢er, &radius);
96 fprintf(stderr, "location_bounds_get_circle_coords(center: %lf, %lf, radius: %lf) \n", center.latitude,
97 center.longitude, radius);
99 } else if (type == LOCATION_BOUNDS_RECT) {
100 location_coords_s left_top;
101 location_coords_s right_bottom;
102 location_bounds_get_rect_coords(bounds, &left_top, &right_bottom);
103 fprintf(stderr, "location_bounds_get_rect_coords(left_top: %lf, %lf - right_bottom: %lf, %lf) \n",
104 left_top.latitude, left_top.longitude, right_bottom.latitude, right_bottom.longitude);
105 } else if (type == LOCATION_BOUNDS_POLYGON) {
106 location_bounds_foreach_polygon_coords(bounds, __poly_coords_cb, NULL);
112 void location_bounds_test()
115 location_coords_s center;
116 center.latitude = 37.258;
117 center.longitude = 127.056;
119 location_bounds_h bounds_circle;
120 ret = location_bounds_create_circle(center, radius, &bounds_circle);
121 if (ret != LOCATION_BOUNDS_ERROR_NONE) {
122 fprintf(stderr, "location_bounds_create_circle() failed\n");
124 fprintf(stderr, "Bounds(circle) has been created successfully.\n");
126 ret = location_manager_add_boundary(manager, bounds_circle);
127 if (ret != LOCATIONS_ERROR_NONE) {
128 fprintf(stderr, "Setting boundary failed\n");
130 fprintf(stderr, "Boundary set\n");
132 location_coords_s center2;
134 ret = location_bounds_get_circle_coords(bounds_circle, ¢er2, &radius2);
135 if (ret != LOCATIONS_ERROR_NONE) {
136 fprintf(stderr, "location_bounds_get_circle_coords() failed\n");
138 fprintf(stderr, "location_bounds_get_circle_coords(center: %lf, %lf, radius: %lf) \n", center2.latitude,
139 center2.longitude, radius2);
141 /*Add the rect bounds */
142 location_coords_s left_top;
143 left_top.latitude = 30;
144 left_top.longitude = 30;
146 location_coords_s right_bottom;
147 right_bottom.latitude = 10;
148 right_bottom.longitude = 50;
150 location_bounds_h bounds_rect;
151 ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect);
152 if (ret != LOCATION_BOUNDS_ERROR_NONE) {
153 fprintf(stderr, "location_bounds_create_rect() failed\n");
155 fprintf(stderr, "Bounds(rect) has been created successfully.\n");
157 ret = location_manager_add_boundary(manager, bounds_rect);
158 if (ret != LOCATIONS_ERROR_NONE) {
159 fprintf(stderr, "Setting boundary failed\n");
161 fprintf(stderr, "Boundary set\n");
163 location_coords_s left_top2;
164 location_coords_s right_bottom2;
166 ret = location_bounds_get_rect_coords(bounds_rect, &left_top2, &right_bottom2);
167 if (ret != LOCATIONS_ERROR_NONE) {
168 fprintf(stderr, "location_bounds_get_rect_coords() failed\n");
170 fprintf(stderr, "location_bounds_get_rect_coords(left_top: %lf, %lf - right_bottom: %lf, %lf) \n", left_top2.latitude,
171 left_top2.longitude, right_bottom2.latitude, right_bottom2.longitude);
173 /*Add the polygon bounds */
176 location_coords_s coord_list[poly_size];
178 coord_list[0].latitude = 10;
179 coord_list[0].longitude = 10;
180 coord_list[1].latitude = 20;
181 coord_list[1].longitude = 20;
182 coord_list[2].latitude = 30;
183 coord_list[2].longitude = 30;
185 location_bounds_h bounds_poly;
186 ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly);
187 if (ret != LOCATION_BOUNDS_ERROR_NONE) {
188 fprintf(stderr, "location_bounds_create_polygon() failed\n");
190 fprintf(stderr, "Bounds(polygon) has been created successfully.\n");
192 ret = location_manager_add_boundary(manager, bounds_poly);
193 if (ret != LOCATIONS_ERROR_NONE) {
194 fprintf(stderr, "Setting boundary failed\n");
196 fprintf(stderr, "Boundary set\n");
198 ret = location_bounds_foreach_polygon_coords(bounds_poly, __poly_coords_cb, NULL);
199 if (ret != LOCATIONS_ERROR_NONE) {
200 fprintf(stderr, "location_bounds_get_rect_coords() failed\n");
203 location_coords_s test_coords;
204 test_coords.latitude = 12;
205 test_coords.longitude = 12;
207 if (location_bounds_contains_coordinates(bounds_poly, test_coords))
208 fprintf(stderr, "location_bounds_contains_coordinates() retrun TRUE \n");
210 fprintf(stderr, "location_bounds_contains_coordinates() retrun FALSE \n");
212 /*print current bounds */
213 ret = location_manager_foreach_boundary(manager, __location_bounds_cb, (void *)manager);
214 if (ret != LOCATIONS_ERROR_NONE) {
215 fprintf(stderr, "location_manager_foreach_boundary() failed\n");
220 void location_get_last_information_test()
223 double altitude, latitude, longitude;
224 double climb, direction, speed;
225 double horizontal, vertical;
226 location_accuracy_level_e level;
228 int num_of_inview, num_of_active;
230 ret = location_manager_get_last_position(manager, &altitude, &latitude, &longitude, ×tamp);
231 if (ret != LOCATIONS_ERROR_NONE) {
232 fprintf(stderr, " Fail: location_manager_get_last_position ---> %d \n", ret);
234 fprintf(stderr, "[%ld] alt: %g, lat: %g, long: %g\n", timestamp, altitude, latitude, longitude);
237 ret = location_manager_get_last_velocity(manager, &climb, &direction, &speed, ×tamp);
238 if (ret != LOCATIONS_ERROR_NONE) {
239 fprintf(stderr, " Fail: location_manager_get_last_velocity ---> %d \n", ret);
241 fprintf(stderr, "climb: %f, direction: %f, speed: %f\n", climb, direction, speed);
244 ret = location_manager_get_last_accuracy(manager, &level, &horizontal, &vertical);
245 if (ret != LOCATIONS_ERROR_NONE) {
246 fprintf(stderr, " Fail: location_manager_get_last_accuracy ---> %d \n", ret);
248 fprintf(stderr, "Level: %d, horizontal: %g, vertical: %g\n", level, horizontal, vertical);
251 ret = gps_status_get_last_satellite(manager, &num_of_active, &num_of_inview, ×tamp);
252 if (ret != LOCATIONS_ERROR_NONE) {
253 fprintf(stderr, " Fail: gps_status_get_last_satellite_count_in_view ---> %d \n", ret);
255 fprintf(stderr, "[%ld] Satellite number of active: %d, in view: %d\n", timestamp, num_of_active, num_of_inview);
258 ret = gps_status_foreach_last_satellites_in_view(manager, last_satellites_foreach_cb, NULL);
259 if (ret != LOCATIONS_ERROR_NONE) {
260 fprintf(stderr, " Fail: gps_status_foreach_last_satellites_in_view ---> %d \n", ret);
265 static void _state_change_cb(location_service_state_e state, void *user_data)
267 fprintf(stderr, "--------------------------state change: %d---------\n", state);
268 location_manager_h lm = (location_manager_h) user_data;
269 if (state == LOCATIONS_SERVICE_ENABLED) {
275 ret = location_manager_get_position(lm, &altitude, &latitude, &longitude, ×tamp);
276 if (ret != LOCATIONS_ERROR_NONE) {
277 fprintf(stderr, " Fail: location_manager_get_position ---> %d \n", ret);
279 fprintf(stderr, "[%ld] lat: %f, lng: %f, alt: %f\n", timestamp, latitude, longitude, altitude);
282 location_accuracy_level_e level;
285 ret = location_manager_get_accuracy(lm, &level, &horizontal, &vertical);
286 if (ret != LOCATIONS_ERROR_NONE) {
287 fprintf(stderr, " Fail: location_manager_get_accuracy ---> %d \n", ret);
289 fprintf(stderr, "Level: %d, horizontal: %f, vertical %f\n", level, horizontal, vertical);
293 ret = gps_status_get_nmea(lm, &nmea);
294 if (ret != LOCATIONS_ERROR_NONE) {
295 fprintf(stderr, " Fail: gps_status_get_nmea ---> %d \n", ret);
297 fprintf(stderr, "NMEA: %s\n", nmea);
305 void _position_updated_cb(double latitude, double longitude, double altitude, time_t timestamp, void *user_data)
307 fprintf(stderr, "-------------------------- position updated --------------------------\n");
308 fprintf(stderr, "[%ld] lat: %f, lng: %f, alt: %f\n", timestamp, latitude, longitude, altitude);
310 location_manager_h lm = (location_manager_h) user_data;
311 location_accuracy_level_e level;
314 int ret = location_manager_get_accuracy(lm, &level, &horizontal, &vertical);
315 if (ret != LOCATIONS_ERROR_NONE) {
316 fprintf(stderr, " Fail: location_manager_get_accuracy ---> %d \n", ret);
318 fprintf(stderr, "Level: %d, horizontal: %f, vertical %f\n", level, horizontal, vertical);
323 if (repeat_count > 9) {
324 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
328 void _velocity_updated_cb(double speed, double direction, double climb, time_t timestamp, void *user_data)
330 fprintf(stderr, "-------------------------- velocity updated --------------------------\n");
331 fprintf(stderr, "[%ld] speed[%f] direction[%f] climb[%f]\n", timestamp, speed, direction, climb);
334 void _location_cb(int error, double latitude, double longitude, double altitude, time_t timestamp, double speed, double climb, double direction, void *user_data)
336 fprintf(stderr, "error[%d]\n", error);
337 fprintf(stderr, "location_cb: lat[%f] lon[%f] alt[%f]\n", latitude, longitude, altitude);
338 fprintf(stderr, "speed[%f] climb[%f] direction[%f]\n", speed, climb, direction);
340 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
343 void _location_changed_cb(double latitude, double longitude, double altitude, double speed, double direction, double horizontal_accuracy, time_t timestamp, void *user_data)
345 fprintf(stderr, "-------------------------- location changed --------------------------\n");
346 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);
350 if (repeat_count > 5) {
351 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
355 bool _get_location_cb(double latitude, double longitude, double altitude, double speed, double direction, double horizontal, double vertical, time_t timestamp, void *user_data)
357 fprintf(stderr, "-------------------------- batch: get location --------------------------\n");
358 fprintf(stderr, "[%ld] lat[%f] lon[%f] alt[%f] speed[%lf] direction[%lf], horizontal_accuracy[%lf]\n", timestamp, latitude, longitude, altitude, speed, direction, horizontal);
362 void _location_batch_cb(int num_of_location, void *user_data)
364 fprintf(stderr, "-------------------------- location batch --------------------------\n");
365 fprintf(stderr, "num_of_location: [%d]\n", num_of_location);
367 location_manager_h manager = user_data;
369 if (num_of_location > 0) {
370 location_manager_foreach_location_batch(manager, _get_location_cb, user_data);
374 if (repeat_count > 1) {
375 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
379 static void _setting_cb(location_method_e method, bool enable, void *user_data)
381 fprintf(stderr, "method[%d], enable[%d]\n", method, enable);
384 void _satellite_updated_cb(int num_of_active, int num_of_inview, time_t timestamp, void *user_data)
386 fprintf(stderr, "-------------------------- satellite updated --------------------------\n");
387 fprintf(stderr, "num_of_active[%d] num_of_inview[%d] timestamp[%ld]\n", num_of_active, num_of_inview, timestamp);
389 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
392 static void print_location_status()
394 fprintf(stderr, "==== LOCATION Setting state =====\n");
395 bool is_enabled = FALSE;
396 location_manager_is_enabled_method(LOCATIONS_METHOD_HYBRID, &is_enabled);
397 fprintf(stderr, "hybrid: %d, ", is_enabled);
399 location_manager_is_enabled_method(LOCATIONS_METHOD_GPS, &is_enabled);
400 fprintf(stderr, "gps: %d, ", is_enabled);
402 location_manager_is_enabled_method(LOCATIONS_METHOD_WPS, &is_enabled);
403 fprintf(stderr, "wps: %d, ", is_enabled);
405 /* location_manager_is_test_location_enabled(&is_enabled); */
406 location_manager_is_enabled_method(LOCATIONS_METHOD_MOCK, &is_enabled);
407 fprintf(stderr, "mock: %d\n", is_enabled);
410 static int enable_method(location_method_e method, bool enable)
413 fprintf(stderr, "==== LOCATION Setting changed =====\n");
415 location_manager_set_setting_changed_cb(LOCATIONS_METHOD_HYBRID, _setting_cb, NULL);
417 fprintf(stderr, "method[%d], enable[%d]\n", method, enable);
418 ret = location_manager_enable_method(method, enable);
420 location_manager_unset_setting_changed_cb(LOCATIONS_METHOD_HYBRID);
424 static int test_clear_mock_location(gpointer user_data)
426 location_manager_h manager = (location_manager_h) user_data;
429 ret = location_manager_clear_mock_location(manager);
430 fprintf(stderr, "\n==== location_manager_clear_mock_location: %d ====\n\n", ret);
434 ret = location_manager_get_service_state(manager, &state);
435 fprintf(stderr, "the current state: %d, ret = %d\n", state, ret);
442 static int test_set_mock_location(gpointer user_data)
444 location_manager_h manager = (location_manager_h) user_data;
449 ret = location_manager_get_service_state(manager, &state);
450 fprintf(stderr, "the current state: %d, ret = %d\n", state, ret);
453 ret = location_manager_set_mock_location(manager, 20, 20, 0, 40, 50, 100);
454 fprintf(stderr, "\n==== location_manager_set_location: %d ====\n\n", ret);
455 if (ret != LOCATIONS_ERROR_NONE) {
456 g_timeout_add_seconds(3, test_clear_mock_location, manager);
462 static void print_menu()
464 fprintf(stderr, "============= LOCATION TEST =============\n");
465 fprintf(stderr, "[1] Get location: LOCATIONS_METHOD_HYBRID\n");
466 fprintf(stderr, "[2] Get location: LOCATIONS_METHOD_GPS\n");
467 fprintf(stderr, "[3] Get location: LOCATIONS_METHOD_WPS\n");
468 fprintf(stderr, "[4] Single location: LOCATIONS_METHOD_HYBRID\n");
469 fprintf(stderr, "[5] Single location: LOCATIONS_METHOD_GPS\n");
470 fprintf(stderr, "[6] Single location: LOCATIONS_METHOD_WPS\n\n");
471 fprintf(stderr, "[11] Change update interval: LOCATIONS_METHOD_HYBRID\n");
472 fprintf(stderr, "[12] Change update interval: LOCATIONS_METHOD_GPS\n\n");
473 fprintf(stderr, "[21] Distance based location update: LOCATIONS_METHOD_HYBRID\n");
474 fprintf(stderr, "[22] Distance based location update: LOCATIONS_METHOD_GPS\n");
475 fprintf(stderr, "[23] Distance based location update: LOCATIONS_METHOD_WPS\n\n");
476 fprintf(stderr, "[31] Location batch update: LOCATIONS_METHOD_GPS\n\n");
477 fprintf(stderr, "[41] Turn on/off mock test: LOCATIONS_METHOD_MOCK\n");
478 fprintf(stderr, "[42] Set & Clear location: LOCATIONS_METHOD_HYBRID\n\n");
479 fprintf(stderr, "[51] Turn on/off method: LOCATIONS_METHOD_HYBRID\n");
480 fprintf(stderr, "[52] Turn on/off method: LOCATIONS_METHOD_GPS\n");
481 fprintf(stderr, "[53] Turn on/off method: LOCATIONS_METHOD_WPS\n\n");
482 fprintf(stderr, "[61] Boundary Test\n\n");
483 fprintf(stderr, "[0] Exit!!!\n\n");
484 fprintf(stderr, "Select menu: ");
486 if (scanf("%d", &menu) < 0) {
487 fprintf(stderr, "Can't read menu !!!\n");
491 static int location_test()
493 int ret = LOCATIONS_ERROR_NONE;
498 print_location_status();
507 int method = menu - 1;
508 ret = location_manager_create(method, &manager);
509 fprintf(stderr, "location_manager_create (method: %d): %d\n", method, ret);
511 ret = location_manager_start(manager);
512 fprintf(stderr, "start: %d\n", ret);
514 if (method == LOCATIONS_METHOD_GPS) {
515 ret = gps_status_set_satellite_updated_cb(manager, _satellite_updated_cb, 1, &manager);
516 fprintf(stderr, "gps_status_set_satellite_updated_cb: %d\n", ret);
525 fprintf(stderr, "\n Input timeout ==> ");
526 ret = scanf("%d", &timeout);
528 int method = menu - 4;
529 ret = location_manager_create(method, &manager);
530 ret = location_manager_request_single_location(manager, timeout, _location_cb, manager);
531 fprintf(stderr, "request single_location (method: %d): %d\n", method, ret);
539 fprintf(stderr, "\n Input position interval ==> ");
540 ret = scanf("%d", &interval);
542 int method = menu - 11;
543 ret = location_manager_create(method, &manager);
544 fprintf(stderr, "location_manager_create (method: %d): %d\n", method, ret);
546 ret = location_manager_set_position_updated_cb(manager, _position_updated_cb, interval, (void *)manager);
547 fprintf(stderr, "set_position_updated_cb: %d\n", ret);
550 ret = location_manager_set_velocity_updated_cb(manager, _velocity_updated_cb, interval*2, (void *)manager);
551 fprintf(stderr, "set_velocity_updated_cb: %d\n", ret);
554 ret = location_manager_set_location_changed_cb(manager, _location_changed_cb, interval * 2, (void *)manager);
555 fprintf(stderr, "set_location_changed_cb: %d\n", ret);
557 ret = location_manager_start(manager);
558 fprintf(stderr, "start: %d\n", ret);
565 int method = menu - 21;
567 fprintf(stderr, "\n Input position interval ==> ");
568 ret = scanf("%d", &interval);
570 ret = location_manager_create(method, &manager);
571 fprintf(stderr, "location_manager_create (method : %d)", method);
573 /*ret = location_manager_set_position_updated_cb(manager, _position_updated_cb, interval, (void *)manager); */
574 /*fprintf(stderr, "set position changed callback: %d\n", ret); */
576 ret = location_manager_set_distance_based_location_changed_cb(manager, _location_changed_cb, interval, 30, (void *)manager);
577 fprintf(stderr, "set_distance_based_location_changed_cb: %d\n", ret);
579 ret = location_manager_start(manager);
580 fprintf(stderr, "start: %d\n", ret);
585 fprintf(stderr, "\n Input batch interval ==> ");
586 ret = scanf("%d", &interval);
589 fprintf(stderr, " Input batch period ==> ");
590 ret = scanf("%d", &period);
592 ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager);
593 fprintf(stderr, "location_manager_create (method : %d)\n", LOCATIONS_METHOD_GPS);
595 ret = location_manager_set_location_batch_cb(manager, _location_batch_cb, interval, period, (void *)manager);
596 fprintf(stderr, "set_location_batch_cb: %d\n", ret);
598 ret = location_manager_start_batch(manager);
599 fprintf(stderr, "start_batch: %d\n", ret);
606 fprintf(stderr, "\n Mock Location (ON: 1 or OFF: 0) Input ==> ");
607 ret = scanf("%d", &onoff);
609 ret = location_manager_enable_mock_location(onoff);
610 fprintf(stderr, "Enabling mock test: ret=%d\n", ret);
612 ret = location_manager_create(LOCATIONS_METHOD_MOCK, &manager);
613 fprintf(stderr, "location_manager_create (method: %d): %d\n", LOCATIONS_METHOD_MOCK, ret);
615 ret = location_manager_set_mock_location(manager, 10, 20, 0, 40, 50, 100);
616 fprintf(stderr, "location_manager_set_mock_location: %d\n", ret);
617 if (ret == LOCATIONS_ERROR_SETTING_OFF) {
618 fprintf(stderr, "Setting for Mock Location is turned OFF!!!\n");
622 ret = location_manager_start(manager);
623 fprintf(stderr, "start: %d\n", ret);
625 g_timeout_add_seconds(3, test_clear_mock_location, manager);
627 g_timeout_add_seconds(10, wait_test, NULL);
634 ret = location_manager_create(LOCATIONS_METHOD_HYBRID, &manager);
635 fprintf(stderr, "location_manager_create (method: %d): %d\n", LOCATIONS_METHOD_HYBRID, ret);
637 ret = location_manager_start(manager);
638 fprintf(stderr, "start: %d\n", ret);
642 ret = location_manager_get_service_state(manager, &state);
643 fprintf(stderr, "the current state: %d, ret = %d\n", state, ret);
646 g_timeout_add_seconds(5, test_set_mock_location, manager);
653 int method = menu - 51;
656 fprintf(stderr, "\n Input ON: 1 or OFF: 0 ==> ");
657 ret = scanf("%d", &onoff);
659 if (onoff == 0 || onoff == 1) {
660 ret = enable_method(method, onoff);
661 fprintf(stderr, "Enabling method: [%d], ret=%d\n", method, ret);
666 location_bounds_h hPolyLocationBound = NULL;
667 bool bIsContained = false;
669 location_coords_s location_coord_list[nPolySize];
670 location_coord_list[0].latitude = 10;
671 location_coord_list[0].longitude = 10;
672 location_coord_list[1].latitude = 20;
673 location_coord_list[1].longitude = 20;
674 location_coord_list[2].latitude = 30;
675 location_coord_list[2].longitude = 10;
677 /* Checking coordinates in location boundary */
678 location_coords_s testLocationCoordinates;
679 testLocationCoordinates.latitude = 20;
680 testLocationCoordinates.longitude = 12;
681 location_bound_error_e nRet = location_bounds_create_polygon(location_coord_list, nPolySize, &hPolyLocationBound);
683 fprintf(stderr, "location_bounds_create_polygon: %d\n", nRet);
685 bIsContained = location_bounds_contains_coordinates(hPolyLocationBound, testLocationCoordinates);
686 fprintf(stderr, "bIsContained: %d\n", bIsContained);
688 location_bounds_destroy(hPolyLocationBound);
692 g_timeout_add_seconds(1, exit_program, NULL);
695 fprintf(stderr, "Exit!!! Input: %d\n", menu);
696 g_timeout_add_seconds(1, exit_program, NULL);
700 if (ret != LOCATIONS_ERROR_NONE) {
701 fprintf(stderr, "Test Failed!!! [%d]\n", ret);
702 g_timeout_add_seconds(1, exit_program, NULL);
706 if (menu > 0 && menu < 50) {
707 ret = location_manager_set_service_state_changed_cb(manager, _state_change_cb, (void *)manager);
708 fprintf(stderr, "set_service_state_changed_cb: %d\n", ret);
711 ret = location_manager_set_position_updated_cb(manager, _position_updated_cb, interval, (void *)manager);
712 fprintf(stderr, "set_position_updated_cb: %d\n", ret);
715 test_timer = g_timeout_add_seconds(1, wait_test, NULL);
721 static void location_cleanup()
724 if (manager != NULL) {
725 ret = location_manager_stop(manager);
726 fprintf(stderr, "stop: %d\n", ret);
728 ret = location_manager_unset_service_state_changed_cb(manager);
729 fprintf(stderr, "unset_service_state_changed_cb: %d\n", ret);
731 ret = location_manager_unset_position_updated_cb(manager);
732 fprintf(stderr, "unset_position_updated_cb: %d\n", ret);
734 ret = gps_status_unset_satellite_updated_cb(manager);
735 fprintf(stderr, "gps_status_unset_satellite_updated_cb: %d\n", ret);
737 ret = location_manager_destroy(manager);
738 fprintf(stderr, "destroy: %d\n", ret);
743 int main(int argc, char **argv)
745 g_mainloop = g_main_loop_new(NULL, 0);
747 g_main_loop_run(g_mainloop);