upload tizen1.0 source
[framework/location/gps-manager.git] / gps-manager / last_position.c
1 /*
2  * gps-manager
3  *
4  * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
7  *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 #include <stdio.h>
23 #include <glib.h>
24
25 #include "gps_manager_data_types.h"
26 #include "last_position.h"
27 #include "debug_util.h"
28 #include "setting.h"
29
30 void gps_manager_set_last_position(pos_data_t * last_pos)
31 {
32         LOG_GPS(DBG_LOW, "set Latitude = %f Longitude = %f Altitude = %f", last_pos->latitude, last_pos->longitude, last_pos->altitude);
33         LOG_GPS(DBG_LOW, "set Speed = %f Direction = %f", last_pos->speed, last_pos->bearing);
34         LOG_GPS(DBG_LOW, "set H_Accuracy = %f V_Accuracy = %f", last_pos->hor_accuracy, last_pos->ver_accuracy);
35
36         int timestamp = last_pos->timestamp;
37         double lat = last_pos->latitude;
38         double lon  = last_pos->longitude;
39         double alt = last_pos->altitude;
40         double spd  = last_pos->speed;
41         double dir = last_pos->bearing;
42         double h_acc = last_pos->hor_accuracy;
43         double v_acc = last_pos->ver_accuracy;
44
45         setting_set_int(LAST_TIMESTAMP, timestamp);
46         setting_set_double(LAST_LATITUDE, lat);
47         setting_set_double(LAST_LONGITUDE, lon);
48         setting_set_double(LAST_ALTITUDE, alt);
49         setting_set_double(LAST_SPEED, spd);
50         setting_set_double(LAST_DIRECTION, dir);
51         setting_set_double(LAST_HOR_ACCURACY, h_acc);
52         setting_set_double(LAST_VER_ACCURACY, v_acc);
53 }
54
55 void gps_manager_get_last_position(pos_data_t * last_pos)
56 {
57         int timestamp;
58         double lat, lon, alt;
59         double spd, dir;
60         double h_acc, v_acc;
61
62         setting_get_int(LAST_TIMESTAMP, &timestamp);
63         setting_get_double(LAST_LATITUDE, &lat);
64         setting_get_double(LAST_LONGITUDE, &lon);
65         setting_get_double(LAST_ALTITUDE, &alt);
66         setting_get_double(LAST_SPEED, &spd);
67         setting_get_double(LAST_DIRECTION, &dir);
68         setting_get_double(LAST_HOR_ACCURACY, &h_acc);
69         setting_get_double(LAST_VER_ACCURACY, &v_acc);
70
71         last_pos->timestamp = timestamp;
72         last_pos->latitude = lat;
73         last_pos->longitude = lon;
74         last_pos->altitude = alt;
75         last_pos->speed = spd;
76         last_pos->bearing = dir;
77         last_pos->hor_accuracy = h_acc;
78         last_pos->ver_accuracy = v_acc;
79
80         LOG_GPS(DBG_LOW, "get Latitude = %f Longitude = %f Altitude = %f", last_pos->latitude, last_pos->longitude, last_pos->altitude);
81         LOG_GPS(DBG_LOW, "get Speed = %f Direction = %f", last_pos->speed, last_pos->bearing);
82         LOG_GPS(DBG_LOW, "get H_Accuracy = %f V_Accuracy = %f", last_pos->hor_accuracy, last_pos->ver_accuracy);
83 }