]> err.no Git - mapper/blob - src/gps.c
Get rid of _pos, move data to gpsdata struct.
[mapper] / src / gps.c
1 /*
2  * This file is part of mapper
3  *
4  * Copyright (C) 2007 Kaj-Michael Lang
5  * Copyright (C) 2006-2007 John Costigan.
6  *
7  * POI and GPS-Info code originally written by Cezary Jackiewicz.
8  *
9  * Default map data provided by http://www.openstreetmap.org/
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #include "gps.h"
27 #include "latlon.h"
28 #include "map.h"
29
30 GpsData *
31 gps_init(void)
32 {
33 GpsData *gps;
34
35 gps=g_slice_new0(GpsData);
36 gps->fix=FIX_NOFIX;
37 gps_integerize_data(gps);
38 return gps;
39 }
40
41 /**
42  * Convert the float lat/lon/speed/heading data into integer units.
43  */
44 void 
45 gps_integerize_data(GpsData *gps)
46 {
47 gdouble tmp;
48
49 tmp=(gps->heading*(1.f/180.f))*G_PI;
50 latlon2unit(gps->lat, gps->lon, gps->unitx, gps->unity);
51 gps->vel_offsetx=(gint)(floor(gps->speed*sin(tmp)+0.5f));
52 gps->vel_offsety=-(gint)(floor(gps->speed*cos(tmp)+0.5f));
53 }