diff options
author | Kangho Hur <kangho.hur@samsung.com> | 2012-02-10 15:36:45 +0900 |
---|---|---|
committer | Kangho Hur <kangho.hur@samsung.com> | 2012-02-10 15:36:45 +0900 |
commit | baf374be8907dddba192d638e29618c1719f2575 (patch) | |
tree | f10815ff3931ffdafb1b7022c06f27b2aee4f550 | |
parent | ab97bfba13fed2bbe8f2ee2939da0ec66bda1867 (diff) | |
download | geocoder-baf374be8907dddba192d638e29618c1719f2575.tar.gz geocoder-baf374be8907dddba192d638e29618c1719f2575.tar.bz2 geocoder-baf374be8907dddba192d638e29618c1719f2575.zip |
Support to multiple geocoding result
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | src/geocoder.c | 37 | ||||
-rw-r--r--[-rwxr-xr-x] | test/geocoder_test.c | 2 |
3 files changed, 27 insertions, 18 deletions
diff --git a/debian/changelog b/debian/changelog index a74d251..89bcb7e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +capi-location-geocoder (0.1.0-7) unstable; urgency=low + + * Support to multiple geocoding result + + -- Kangho Hur <kangho.hur@samsung.com> Fri, 10 Feb 2012 15:36:17 +0900 + capi-location-geocoder (0.1.0-5) unstable; urgency=low * Initial release. diff --git a/src/geocoder.c b/src/geocoder.c index 6d37b5f..9dafadf 100644 --- a/src/geocoder.c +++ b/src/geocoder.c @@ -50,6 +50,7 @@ int _convert_error_code(int code, char* func_name) msg = "GEOCODER_ERROR_NONE"; break; case LOCATION_ERROR_NETWORK_FAILED: + case LOCATION_ERROR_NETWORK_NOT_CONNECTED: ret = GEOCODER_ERROR_NETWORK_FAILED; msg = "GEOCODER_ERROR_NETWORK_FAILED"; break; @@ -91,27 +92,26 @@ static void cb_address_from_position (LocationError error, LocationAddress *addr } } -static void cb_position_from_address (LocationError error, LocationPosition *pos, LocationAccuracy *acc, gpointer userdata) +static void cb_position_from_address (LocationError error, GList *position_list, GList *accuracy_list, gpointer userdata) { geocoder_s * handle = (geocoder_s*)userdata; if(handle->user_cb[_GEOCODER_CB_POSITION_FROM_ADDRESS]) { - if(error != LOCATION_ERROR_NONE || pos == NULL) + if(error != LOCATION_ERROR_NONE || position_list == NULL || position_list->data ==NULL || accuracy_list==NULL ) { _convert_error_code(error,(char*)__FUNCTION__); } else { - int i; - int temp_max = 1; - for( i=0 ; i < temp_max ; i++) + while(position_list) { - LOGI("[%s] Position[%d] - time: %d, lat: %f, long: %f, alt: %f, status: %d", __FUNCTION__, (i+1), pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status); + LocationPosition *pos = position_list->data; if ( ((geocoder_get_position_cb)handle->user_cb[_GEOCODER_CB_POSITION_FROM_ADDRESS])(pos->latitude, pos->longitude, handle->user_data[_GEOCODER_CB_POSITION_FROM_ADDRESS]) != TRUE ) { - LOGI("[%s] User quit the loop [count : %d]", __FUNCTION__, (i+1)); + LOGI("[%s] User quit the loop ", __FUNCTION__); break; } + position_list = g_list_next(position_list); } } } @@ -297,29 +297,32 @@ int geocoder_foreach_positions_from_address_sync(geocoder_h geocoder,const char geocoder_s *handle = (geocoder_s*)geocoder; int ret; - LocationPosition *pos = NULL; - LocationAccuracy *acc = NULL; + GList *pos_list = NULL; + GList *acc_list = NULL; char* addr_str = g_strdup(address); - - ret = location_get_position_from_freeformed_address(handle->object, addr_str, &pos, &acc); + + + ret = location_get_position_from_freeformed_address(handle->object, addr_str, &pos_list, &acc_list); + if( ret != LOCATION_ERROR_NONE) { g_free(addr_str); return _convert_error_code(ret,(char*)__FUNCTION__); } - int i; - int temp_max = 1; - for( i=0 ; i < temp_max ; i++) + while(pos_list) { + LocationPosition *pos = pos_list->data; if ( callback(pos->latitude, pos->longitude, user_data) != TRUE ) { - LOGI("[%s] User quit the loop [count : %d]", __FUNCTION__, (i+1)); + LOGI("[%s] User quit the loop ", __FUNCTION__); break; } + pos_list = g_list_next(pos_list); } + g_free(addr_str); - location_position_free(pos); - location_accuracy_free(acc); + g_list_free (pos_list); + g_list_free (acc_list); return GEOCODER_ERROR_NONE; } diff --git a/test/geocoder_test.c b/test/geocoder_test.c index bf2e653..493ada0 100755..100644 --- a/test/geocoder_test.c +++ b/test/geocoder_test.c @@ -110,7 +110,7 @@ int main(int argc, char ** argv) geocoder_test(); reverse_geocoder_test(); - g_timeout_add_seconds(10, exit_program, NULL); + g_timeout_add_seconds(30, exit_program, NULL); g_main_loop_run (loop); return 0; |