Parent Directory | Revision Log
Begin trunk. No code changes.
1 | /* |
2 | * Copyright (C) 2008 Till Harbaum <till@harbaum.org>. |
3 | * |
4 | * This file is part of OSM2Go. |
5 | * |
6 | * OSM2Go 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 3 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * OSM2Go 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 |
17 | * along with OSM2Go. If not, see <http://www.gnu.org/licenses/>. |
18 | */ |
19 | |
20 | #ifndef POS_H |
21 | #define POS_H |
22 | |
23 | #include <math.h> |
24 | |
25 | #ifndef NAN |
26 | #define NAN (0.0/0.0) |
27 | #endif |
28 | |
29 | /* equatorial radius in meters */ |
30 | #define POS_EQ_RADIUS (6378137.0) |
31 | #define KMPMIL (1.609344) |
32 | #define KM2MIL(a) ((a)/KMPMIL) |
33 | #define MIL2KM(a) ((a)*KMPMIL) |
34 | |
35 | #define DEG2RAD(a) ((a) * M_PI / 180.0) |
36 | #define RAD2DEG(a) ((a) * 180.0 / M_PI) |
37 | |
38 | /* global position */ |
39 | typedef struct pos { |
40 | double lat, lon; |
41 | } pos_t; |
42 | |
43 | /* local position */ |
44 | typedef struct lpos { |
45 | gint x, y; |
46 | } lpos_t; |
47 | |
48 | struct bounds_s; |
49 | void pos2lpos(struct bounds_s *bounds, pos_t *pos, lpos_t *lpos); |
50 | void pos2lpos_center(pos_t *pos, lpos_t *lpos); |
51 | void lpos2pos(struct bounds_s *bounds, lpos_t *lpos, pos_t *pos); |
52 | |
53 | void pos_lat_str(char *str, int len, double latitude); |
54 | void pos_lon_str(char *str, int len, double longitude); |
55 | |
56 | double pos_parse_lat(char *str); |
57 | double pos_parse_lon(char *str); |
58 | |
59 | GtkWidget *pos_lat_entry_new(double lat); |
60 | GtkWidget *pos_lon_entry_new(double lon); |
61 | void pos_lat_entry_set(GtkWidget *label, double lat); |
62 | void pos_lon_entry_set(GtkWidget *label, double lon); |
63 | |
64 | GtkWidget *pos_lat_label_new(double lat); |
65 | GtkWidget *pos_lon_label_new(double lon); |
66 | void pos_lat_label_set(GtkWidget *label, double lat); |
67 | void pos_lon_label_set(GtkWidget *label, double lon); |
68 | |
69 | double pos_lat_get(GtkWidget *widget); |
70 | double pos_lon_get(GtkWidget *widget); |
71 | |
72 | gboolean pos_lat_valid(double lat); |
73 | gboolean pos_lon_valid(double lon); |
74 | |
75 | double pos_parse_dist(char *str, gboolean is_mil); |
76 | void pos_dist_str(char *str, int len, double dist, gboolean is_mil); |
77 | void pos_dist_entry_set(GtkWidget *entry, double dist, gboolean is_mil); |
78 | double pos_dist_get(GtkWidget *widget, gboolean is_mil); |
79 | |
80 | #endif // POS_H |