+ }else if(0 == g_strcmp0("16", strOpt)) {
+ g_printf("location_search_poi\n");
+ //guint req_id = 0; // move to upper
+
+ LocationPOIFilter *filter = location_poi_filter_new();
+// gchar *key = g_strdup("KEYWORD");
+// gchar *value = g_strdup("pizza");
+// location_poi_filter_set(filter, key, value); // same with Type ? CATEGORY, KEYWORD, POIName
+ //location_poi_filter_set(filter, "CATEGORY", "restaurant"); // error, const char* can't be free!!!!, 120214
+ location_poi_filter_set(filter, "KEYWORD", "pizza");
+ //location_poi_filter_set(filter, "POIName", "cafe");
+
+ LocationPOIPreference *pref = location_poi_pref_new();
+ location_poi_pref_set_max_result(pref, 2);
+ gchar *item = g_strdup("Distance");
+ location_poi_pref_set_sort_by(pref, item); // can't set const char* directly !!
+ location_poi_pref_set_sort_order(pref, LOCATION_POI_PREF_SO_DESC); //LOCATION_POI_PREF_SO_ASC
+
+ // only the latitude/longitude
+ LocationPosition *position = location_position_new(0, 37.771008, -122.41175, 0, LOCATION_STATUS_2D_FIX);
+
+ ret = location_search_poi(location_obj, filter, position, pref, cb_poi, NULL, &req_id);
+ GetLocationError(str, ret);
+ if(ret != LOCATION_ERROR_NONE) {
+ g_printf("Fail to search POI. Error[%s]\n", str);
+ } else {
+ g_printf("Seach POI success, req_id %d\n", req_id);
+ }
+// g_free(item);
+// g_free(key);
+// g_free(value);
+ location_poi_filter_free(filter);
+ location_poi_pref_free(pref);
+ location_position_free(position);
+
+ }else if(0 == g_strcmp0("16a", strOpt)) {
+ g_printf("location_search_poi_by_area\n");
+
+ // only circle supported by decarta
+ LocationPosition *center = location_position_new(0, 37.336723, -121.889555, 0, LOCATION_STATUS_2D_FIX);
+ gdouble radius = 400;
+ LocationBoundary *bound = location_boundary_new_for_circle(center, radius);
+
+ LocationPOIFilter *filter = location_poi_filter_new();
+ gchar *key = g_strdup("KEYWORD");
+ gchar *value = g_strdup("cafe");
+ location_poi_filter_set(filter, key, value); // same with Type ? CATEGORY, KEYWORD, POIName
+
+ LocationPOIPreference *pref = location_poi_pref_new();
+ location_poi_pref_set_max_result(pref, 2);
+ gchar *item = g_strdup("Distance");
+ location_poi_pref_set_sort_by(pref, item); // can't set const char* directly !!
+ location_poi_pref_set_sort_order(pref, LOCATION_POI_PREF_SO_ASC); //LOCATION_POI_PREF_SO_ASC
+
+
+ ret = location_search_poi_by_area(location_obj, filter, bound, pref, cb_poi, NULL, &req_id);
+ GetLocationError(str, ret);
+ if (ret != LOCATION_ERROR_NONE) {
+ g_printf("Fail to search POI by area. Error[%s]\n", str);
+ } else {
+ g_printf("Seach POI by area sucess, req_id %d\n", req_id);
+ }
+
+ g_free(key);
+ g_free(value);
+ g_free(item);
+ location_position_free(center);
+ location_boundary_free(bound);
+ location_poi_filter_free(filter);
+ location_poi_pref_free(pref);
+ }else if(0 == g_strcmp0("16b", strOpt)) {
+ g_printf("location_search_poi_by_address\n");
+
+ LocationAddress *addr = location_address_new("51", "N SAN PEDRO ST", NULL, "SAN JOSE", "SANTA CLARA", "CA", "95110");
+ //landmark type ?
+ //landmark name ?
+
+ LocationPOIFilter *filter = location_poi_filter_new();
+ gchar *key = g_strdup("KEYWORD");
+ gchar *value = g_strdup("cafe");
+ location_poi_filter_set(filter, key, value); // same with Type ? CATEGORY, KEYWORD, POIName
+
+ LocationPOIPreference *pref = location_poi_pref_new();
+ location_poi_pref_set_max_result(pref, 10);
+ gchar *item = g_strdup("Distance");
+ location_poi_pref_set_sort_by(pref, item); // can't set const char* directly !!
+ location_poi_pref_set_sort_order(pref, LOCATION_POI_PREF_SO_ASC); //LOCATION_POI_PREF_SO_ASC
+
+ ret = location_search_poi_by_address(location_obj, filter, addr, pref, cb_poi, NULL, &req_id);
+ GetLocationError(str, ret);
+ if(ret != LOCATION_ERROR_NONE) {
+ g_printf("Fail to search POI by address. Error[%s]\n", str);
+ } else {
+ g_printf("Seach POI by address sucess, req_id %d\n", req_id);
+ }
+
+ g_free(key);
+ g_free(value);
+ g_free(item);
+
+ location_address_free(addr);
+ location_poi_filter_free(filter);
+ location_poi_pref_free(pref);
+ }else if(0 == g_strcmp0("16c", strOpt)) {
+ g_printf("location_search_poi_by_freeformed_address\n");
+
+ gchar *addr = g_strdup("North Second St.");
+
+ LocationPOIFilter *filter = location_poi_filter_new();
+ gchar *key = g_strdup("KEYWORD");
+ gchar *value = g_strdup("restaurant");
+ location_poi_filter_set(filter, key, value); // same with Type ? CATEGORY, KEYWORD, POIName
+
+ LocationPOIPreference *pref = location_poi_pref_new();
+ location_poi_pref_set_max_result(pref, 10);
+ gchar *item = g_strdup("Distance");
+ location_poi_pref_set_sort_by(pref, item); // can't set const char* directly !!
+ location_poi_pref_set_sort_order(pref, LOCATION_POI_PREF_SO_ASC); //LOCATION_POI_PREF_SO_ASC
+
+ ret = location_search_poi_by_freeformed_address(location_obj, filter, addr, pref, cb_poi, NULL, &req_id);
+ GetLocationError(str, ret);
+ if (ret != LOCATION_ERROR_NONE) {
+ g_printf("Fail to search POI by address. Error[%s]\n", str);
+ } else {
+ g_printf("Seach POI by address success, req_id %d\n", req_id);
+ }
+
+ g_free(key);
+ g_free(value);
+ g_free(item);
+
+ g_free(addr);
+ location_poi_filter_free(filter);
+ location_poi_pref_free(pref);
+ }else if(0 == g_strcmp0("16d", strOpt)) {
+ gchar value[255] = {0, };
+
+ // only circle supported by decarta
+ LocationPosition *center = location_position_new(0, 37.56693, 126.97819, 0, LOCATION_STATUS_2D_FIX);
+ gdouble radius = 800;
+ LocationBoundary *bound = location_boundary_new_for_circle(center, radius);
+
+ LocationPOIFilter *filter = location_poi_filter_new();
+
+ g_printf("Input keyword :");
+ scanf("%s", value);
+ gchar *key = g_strdup("KEYWORD");
+ location_poi_filter_set(filter, key, value); // same with Type ? CATEGORY, KEYWORD, POIName
+
+ LocationPOIPreference *pref = location_poi_pref_new();
+ location_poi_pref_set_max_result(pref, 2);
+ gchar *item = g_strdup("Distance");
+ location_poi_pref_set_sort_by(pref, item); // can't set const char* directly !!
+ location_poi_pref_set_sort_order(pref, LOCATION_POI_PREF_SO_ASC); //LOCATION_POI_PREF_SO_ASC
+
+
+ ret = location_search_poi_by_area(location_obj, filter, bound, pref, cb_poi, NULL, &req_id);
+ GetLocationError(str, ret);
+ if (ret != LOCATION_ERROR_NONE) {
+ g_printf("Fail to search POI by area. Error[%s]\n", str);
+ } else {
+ g_printf("Seach POI by area sucess, req_id %d\n", req_id);
+ }
+
+ g_free(key);
+ g_free(value);
+ g_free(item);
+ location_position_free(center);
+ location_boundary_free(bound);
+ location_poi_filter_free(filter);
+ location_poi_pref_free(pref);
+ }else if(0 == g_strcmp0("16e", strOpt)) {
+ int req_id;
+
+ g_printf("Input ReqID : ");
+ scanf("%d", &req_id);
+
+ ret = location_cancel_poi_request(location_obj, req_id);
+ GetLocationError(str, ret);
+ if (ret != LOCATION_ERROR_NONE) {
+ g_printf("Fail to cancel POI request. Error[%s]\n", str);
+ }
+ else
+ g_printf("location_cancel_poi_request, req_id %d\n", req_id);
+ }else if(0 == g_strcmp0("17", strOpt)) {
+ g_printf("17. location_request_route\n\n");
+
+ LocationPosition *origin = location_position_new(0, 37.564263, 126.974676, 0, LOCATION_STATUS_2D_FIX); // Seoul city hall
+ LocationPosition *destination = location_position_new(0, 37.557120, 126.992410, 0, LOCATION_STATUS_2D_FIX); // NamSan
+
+ GList *waypoint = NULL;
+ LocationPosition *via_pos = location_position_new(0, 37.560950, 126.986240, 0, LOCATION_STATUS_2D_FIX); // Wangsimli
+ waypoint = g_list_append (waypoint, (gpointer)via_pos);
+
+ LocationRoutePreference *pref = location_route_pref_new();
+ location_route_pref_set_route_type(pref, "FASTEST");
+
+ ret = location_request_route(location_obj, origin, destination, waypoint, pref, cb_route, NULL, &req_id);
+ GetLocationError(str, ret);
+ if (ret != LOCATION_ERROR_NONE) {
+ g_printf("Fail to search route by address. Error[%s]\n", str);
+ } else {
+ g_printf("Search Route successfully, req_id %d\n", req_id);
+ }
+ }else if(0 == g_strcmp0("17a", strOpt)) {
+ g_printf("17a. location_cancel_route_request\n");
+
+ int req_id;
+ g_printf("Input ReqID : ");
+ scanf("%d", &req_id);
+
+ ret = location_cancel_route_request(location_obj, req_id);
+ GetLocationError(str, ret);
+ if (ret != LOCATION_ERROR_NONE) {
+ g_printf("Fail to cancel route request. Error[%s]\n", str);
+ }
+ else {
+ g_printf("location_cancel_route_request, req_id %d\n", req_id);
+ }
+
+ }else if (0 == g_strcmp0 ("18", strOpt)) {
+ int idx = 0;
+ for (idx = 0; idx < MAP_SERVICE_TYPE_MAX; idx++) {
+ g_printf("[%d:%d], ", idx, location_is_supported_map_provider_capability (location_obj, idx));
+ }
+ }else if (0 == g_strcmp0 ("19", strOpt)) {
+ int idx = 0;
+ for (idx = 0; idx < MAP_SERVICE_TYPE_MAX; idx++) {
+ g_printf("[%d:", idx);
+ print_map_service_keys(location_obj, idx);
+ g_printf("]\n");
+ }