]> err.no Git - mapper/blob - src/position.c
Remove old map sources
[mapper] / src / position.c
1 /*
2  * This file is part of mapper
3  *
4  * Copyright (C) 2008 Kaj-Michael Lang
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 #include <config.h>
22
23 #include <math.h>
24 #include <glib.h>
25
26 #include "position.h"
27
28 Position *
29 position_new(PositionType type, guint id)
30 {
31 Position *pos;
32
33 pos=g_slice_new0(Position);
34 pos->type=type;
35 pos->id=id;
36 return pos;
37 }
38
39 void
40 position_free(Position *pos)
41 {
42 g_return_if_fail(pos);
43 g_slice_free(Position, pos);
44 }
45
46 void
47 position_set(Position *pos, gboolean valid, gdouble lat, gdouble lon, gfloat alt)
48 {
49 g_return_if_fail(pos);
50 pos->valid=valid;
51 pos->lat=valid ? lat : NAN;
52 pos->lon=valid ? lon : NAN;
53 pos->altitude=valid ? lon : NAN;
54 }