4 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
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>
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include "location/location-accuracy.h"
27 #include "location/location-log.h"
30 location_accuracy_get_type (void)
32 static volatile gsize type_volatile = 0;
33 if(g_once_init_enter(&type_volatile)) {
34 GType type = g_boxed_type_register_static (
35 g_intern_static_string ("LocationAccuracy"),
36 (GBoxedCopyFunc) location_accuracy_copy,
37 (GBoxedFreeFunc) location_accuracy_free);
38 g_once_init_leave(&type_volatile, type);
43 EXPORT_API LocationAccuracy*
44 location_accuracy_new (LocationAccuracyLevel level,
45 gdouble horizontal_accuracy,
46 gdouble vertical_accuracy)
48 LocationAccuracy* accuracy = g_slice_new0 (LocationAccuracy);
49 accuracy->level = level;
50 accuracy->horizontal_accuracy = horizontal_accuracy;
51 accuracy->vertical_accuracy = vertical_accuracy;
57 location_accuracy_free (LocationAccuracy* accuracy)
59 g_return_if_fail (accuracy);
60 g_slice_free (LocationAccuracy, accuracy);
64 comp_int(int a, int b){
71 comp_double_reverse(double a, double b) {
73 else if (a == b) return 0;
78 location_accuracy_level_compare(const LocationAccuracy *accuracy1, const LocationAccuracy *accuracy2)
80 g_return_val_if_fail(accuracy1, -1);
81 g_return_val_if_fail(accuracy2, 1);
83 return comp_int(accuracy1->level, accuracy2->level);
87 location_accuracy_compare (const LocationAccuracy *accuracy1, const LocationAccuracy *accuracy2)
90 ret = location_accuracy_level_compare(accuracy1, accuracy2);
92 ret = comp_double_reverse(accuracy1->horizontal_accuracy, accuracy2->horizontal_accuracy);
93 if(!ret) return comp_double_reverse(accuracy1->vertical_accuracy, accuracy2->vertical_accuracy);
98 EXPORT_API LocationAccuracy*
99 location_accuracy_copy (const LocationAccuracy *accuracy)
101 g_return_val_if_fail(accuracy, NULL);
102 return location_accuracy_new(accuracy->level,
103 accuracy->horizontal_accuracy,
104 accuracy->vertical_accuracy);