Contents of /src/gps.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Tue Dec 9 20:06:06 2008 UTC (15 years, 5 months ago) by harbaum
File MIME type: text/plain
File size: 2358 byte(s)
Initial import
1 harbaum 1 /*
2     * Copyright (C) 2008 Till Harbaum <till@harbaum.org>.
3     *
4     * This file is based upon parts of gpsd/libgps
5     *
6     * This file is part of OSM2Go.
7     *
8     * OSM2Go is free software: you can redistribute it and/or modify
9     * it under the terms of the GNU General Public License as published by
10     * the Free Software Foundation, either version 3 of the License, or
11     * (at your option) any later version.
12     *
13     * OSM2Go is distributed in the hope that it will be useful,
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     * GNU General Public License for more details.
17     *
18     * You should have received a copy of the GNU General Public License
19     * along with OSM2Go. If not, see <http://www.gnu.org/licenses/>.
20     *
21     */
22    
23     #ifndef GPS_H
24     #define GPS_H
25    
26     #ifndef NAN
27     #define NAN (0.0/0.0)
28     #endif /* !NAN */
29    
30     #define MAXTAGLEN 8 /* maximum length of sentence tag name */
31     #define MPS_TO_KNOTS 1.9438445 /* Meters per second to knots */
32    
33     struct gps_fix_t {
34     int mode; /* Mode of fix */
35     #define MODE_NOT_SEEN 0 /* mode update not seen yet */
36     #define MODE_NO_FIX 1 /* none */
37     #define MODE_2D 2 /* good for latitude/longitude */
38     #define MODE_3D 3 /* good for altitude/climb too */
39     pos_t pos; /* Latitude/Longitude in degrees (valid if mode >= 2) */
40     double eph; /* Horizontal position uncertainty, meters */
41     };
42    
43     typedef unsigned int gps_mask_t;
44    
45     struct gps_data_t {
46     gps_mask_t set; /* has field been set since this was last cleared? */
47     #define LATLON_SET 0x00000008u
48     #define STATUS_SET 0x00000100u
49     #define MODE_SET 0x00000200u
50     #define SATELLITE_SET 0x00040000u
51    
52     struct gps_fix_t fix; /* accumulated PVT data */
53    
54     /* GPS status -- always valid */
55     int status; /* Do we have a fix? */
56     #define STATUS_NO_FIX 0 /* no */
57     #define STATUS_FIX 1 /* yes, without DGPS */
58     #define STATUS_DGPS_FIX 2 /* yes, with DGPS */
59    
60     };
61    
62     #ifdef USE_HILDON
63     #include <gpsbt.h>
64     #include <gpsmgr.h>
65     #include <errno.h>
66     #endif
67    
68     typedef struct gps_state_s {
69     #ifdef USE_HILDON
70     gpsbt_t context;
71     #endif
72    
73     GThread* thread_p;
74     GMutex *mutex;
75     GnomeVFSInetConnection *iconn;
76     GnomeVFSSocket *socket;
77    
78     struct gps_data_t gpsdata;
79     } gps_state_t;
80    
81     void gps_init(appdata_t *appdata);
82     void gps_release(appdata_t *appdata);
83     pos_t *gps_get_pos(appdata_t *appdata);
84    
85     #endif // GPS_H