Parent Directory | Revision Log
Use liblocation if available to access gps
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 ENABLE_LIBLOCATION |
63 | #include <location/location-gps-device.h> |
64 | #include <location/location-gpsd-control.h> |
65 | #endif |
66 | |
67 | #ifdef ENABLE_GPSBT |
68 | #include <gpsbt.h> |
69 | #include <gpsmgr.h> |
70 | #endif |
71 | |
72 | typedef struct gps_state_s { |
73 | #ifdef ENABLE_LIBLOCATION |
74 | LocationGPSDevice *device; |
75 | LocationGPSDControl *control; |
76 | guint idd_changed; |
77 | |
78 | gboolean fix; |
79 | double latitude, longitude; |
80 | |
81 | #else |
82 | /* setup for direct gpsd based communication */ |
83 | |
84 | #ifdef ENABLE_GPSBT |
85 | gpsbt_t context; |
86 | #endif |
87 | |
88 | GThread* thread_p; |
89 | GMutex *mutex; |
90 | GnomeVFSInetConnection *iconn; |
91 | GnomeVFSSocket *socket; |
92 | |
93 | struct gps_data_t gpsdata; |
94 | #endif |
95 | } gps_state_t; |
96 | |
97 | void gps_init(appdata_t *appdata); |
98 | void gps_release(appdata_t *appdata); |
99 | pos_t *gps_get_pos(appdata_t *appdata); |
100 | |
101 | #endif // GPS_H |