Fixed svace defects
[platform/core/location/maps-plugin-mapquest.git] / src / mapquest / mapquest_revgeocode.c
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <stdio.h>
18 #include <glib.h>
19 #include <pthread.h>
20 #include "mapquest_revgeocode.h"
21 #include "mapquest_types.h"
22 #include "mapquest_server_private.h"
23 #include "mapquest_debug.h"
24 #include "mapquest_queue.h"
25 #include "mapquest_restcurl.h"
26 #include "mapquest_util.h"
27
28 #define REVERSE_GEOCODE_URL     "https://open.mapquestapi.com/geocoding/v1/reverse?key=%s&outFormat=json"
29
30 int query_revgeocode(gchar *maps_key, gdouble latitude, gdouble longitude, gpointer user_data)
31 {
32         char url[1024];
33         char tmpStr[512];
34
35         if (maps_key != NULL)
36                 snprintf(tmpStr, sizeof(tmpStr), REVERSE_GEOCODE_URL, maps_key);
37         else
38                 snprintf(tmpStr, sizeof(tmpStr), REVERSE_GEOCODE_URL, "null");
39
40         STRCPY(url, tmpStr);
41
42         snprintf(tmpStr, sizeof(tmpStr), "&location=%f,%f", latitude, longitude);
43         STRCAT(url, tmpStr);
44
45         add_handle(url, REQ_TYPE_REVGEOCODE, user_data);
46
47         return 0;
48 }