1 /* vim: set et ts=8 sw=8: */
2 /* gclue-location.h
3  *
4  * Copyright 2012 Bastien Nocera
5  * Copyright 2015 Ankit (Verma)
6  *
7  * Geoclue is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License as published by the Free
9  * Software Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * Geoclue is distributed in the hope that it will be useful, but WITHOUT ANY
13  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with Geoclue; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  *
21  *    Authors: Bastien Nocera <hadess@hadess.net>
22  *             Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
23  *             Ankit (Verma) <ankitstarski@gmail.com>
24  */
25 
26 #ifndef GCLUE_LOCATION_H
27 #define GCLUE_LOCATION_H
28 
29 #include <glib-object.h>
30 #include <gio/gio.h>
31 
32 G_BEGIN_DECLS
33 
34 #define GCLUE_TYPE_LOCATION            (gclue_location_get_type ())
35 #define GCLUE_LOCATION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCLUE_TYPE_LOCATION, GClueLocation))
36 #define GCLUE_IS_LOCATION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCLUE_TYPE_LOCATION))
37 #define GCLUE_LOCATION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GCLUE_TYPE_LOCATION, GClueLocationClass))
38 #define GCLUE_IS_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GCLUE_TYPE_LOCATION))
39 #define GCLUE_LOCATION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GCLUE_TYPE_LOCATION, GClueLocationClass))
40 
41 #define INVALID_COORDINATE -G_MAXDOUBLE
42 
43 typedef struct _GClueLocation        GClueLocation;
44 typedef struct _GClueLocationClass   GClueLocationClass;
45 typedef struct _GClueLocationPrivate GClueLocationPrivate;
46 
47 struct _GClueLocation
48 {
49         /* Parent instance structure */
50         GObject parent_instance;
51 
52         GClueLocationPrivate *priv;
53 };
54 
55 struct _GClueLocationClass
56 {
57         /* Parent class structure */
58         GObjectClass parent_class;
59 };
60 
61 GType gclue_location_get_type (void);
62 
63 /**
64  * GCLUE_LOCATION_ALTITUDE_UNKNOWN:
65  *
66  * Constant representing unknown altitude.
67  */
68 #define GCLUE_LOCATION_ALTITUDE_UNKNOWN -G_MAXDOUBLE
69 
70 /**
71  * GCLUE_LOCATION_ACCURACY_UNKNOWN:
72  *
73  * Constant representing unknown accuracy.
74  */
75 #define GCLUE_LOCATION_ACCURACY_UNKNOWN -1
76 
77 /**
78  * GCLUE_LOCATION_ACCURACY_STREET:
79  *
80  * Constant representing street-level accuracy.
81  */
82 #define GCLUE_LOCATION_ACCURACY_STREET 1000 /* 1 km */
83 
84 /**
85  * GCLUE_LOCATION_ACCURACY_CITY:
86  *
87  * Constant representing city-level accuracy.
88  */
89 #define GCLUE_LOCATION_ACCURACY_CITY 15000 /* 15 km */
90 
91 /**
92  * GCLUE_LOCATION_ACCURACY_REGION:
93  *
94  * Constant representing region-level accuracy.
95  */
96 #define GCLUE_LOCATION_ACCURACY_REGION 50000 /* 50 km */
97 
98 /**
99  * GCLUE_LOCATION_ACCURACY_COUNTRY:
100  *
101  * Constant representing country-level accuracy.
102  */
103 #define GCLUE_LOCATION_ACCURACY_COUNTRY 300000 /* 300 km */
104 
105 /**
106  * GCLUE_LOCATION_ACCURACY_CONTINENT:
107  *
108  * Constant representing continent-level accuracy.
109  */
110 #define GCLUE_LOCATION_ACCURACY_CONTINENT 3000000 /* 3000 km */
111 
112 /**
113  * GCLUE_LOCATION_HEADING_UNKNOWN:
114  *
115  * Constant representing unknown heading.
116  */
117 #define GCLUE_LOCATION_HEADING_UNKNOWN -1.0
118 
119 /**
120  * GCLUE_LOCATION_SPEED_UNKNOWN:
121  *
122  * Constant representing unknown speed.
123  */
124 #define GCLUE_LOCATION_SPEED_UNKNOWN -1.0
125 
126 GClueLocation *gclue_location_new (gdouble latitude,
127                                    gdouble longitude,
128                                    gdouble accuracy);
129 
130 GClueLocation *gclue_location_new_full
131                                   (gdouble     latitude,
132                                    gdouble     longitude,
133                                    gdouble     accuracy,
134                                    gdouble     speed,
135                                    gdouble     heading,
136                                    gdouble     altitude,
137                                    guint64     timestamp,
138                                    const char *description);
139 
140 GClueLocation *gclue_location_create_from_gga
141                                   (const char *gga,
142                                    GError    **error);
143 
144 GClueLocation *gclue_location_duplicate
145                                   (GClueLocation *location);
146 
147 void gclue_location_set_description
148                                   (GClueLocation *loc,
149                                    const char      *description);
150 const char *gclue_location_get_description
151                                   (GClueLocation *loc);
152 
153 gdouble gclue_location_get_latitude
154                                   (GClueLocation *loc);
155 gdouble gclue_location_get_longitude
156                                   (GClueLocation *loc);
157 gdouble gclue_location_get_altitude
158                                   (GClueLocation *loc);
159 gdouble gclue_location_get_accuracy
160                                   (GClueLocation *loc);
161 guint64 gclue_location_get_timestamp
162                                   (GClueLocation *loc);
163 void gclue_location_set_speed     (GClueLocation *loc,
164                                    gdouble        speed);
165 
166 void gclue_location_set_speed_from_prev_location
167                                   (GClueLocation *location,
168                                    GClueLocation *prev_location);
169 
170 gdouble gclue_location_get_speed  (GClueLocation *loc);
171 
172 void gclue_location_set_heading   (GClueLocation *loc,
173                                    gdouble        heading);
174 
175 void gclue_location_set_heading_from_prev_location
176                                   (GClueLocation *location,
177                                    GClueLocation *prev_location);
178 
179 
180 gdouble gclue_location_get_heading
181                                   (GClueLocation *loc);
182 double gclue_location_get_distance_from
183                                   (GClueLocation *loca,
184                                    GClueLocation *locb);
185 
186 #endif /* GCLUE_LOCATION_H */
187