]> Pileus Git - grits/blob - src/gis-world.h
78ca130463ff8b4a09f7bba4bc0d9c9d61ed98e6
[grits] / src / gis-world.h
1 /*
2  * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #ifndef __GIS_WORLD_H__
19 #define __GIS_WORLD_H__
20
21 #include <glib-object.h>
22
23 #ifndef M_PI
24 #define M_PI 3.14159265358979323846
25 #endif
26
27 #define EARTH_R (6371000)
28 #define EARTH_C (2*M_PI*EARTH_R)
29
30 /**
31  * Terms
32  * -----
33  * deg    - Degrees
34  * rad    - Radians, also radius
35  * m      - Meters, for earth-based distances
36  * px     - Pixels, for screen-based distances
37  *
38  * height - Height, the distance above the geoid (ground)
39  * elev   - Elevation, the distance above the spheroid 
40  * rad    - Radius, the distance from the center of the earth
41  *
42  * lat    - Latitude, amount north-south, -90 (S) .. 90 (N)
43  * lon    - Longitude, amount east-west, -180 (W) .. 180 (E)
44  * incl   - Inclination, polar equiv of  latitude, Pi .. 0
45  * azim   - Azimuth, polar equiv of longitude, -Pi .. Pi
46  *
47  * x      -  0° lon is positive
48  * y      - 90° lon is positive
49  * z      - North pole is positive
50  *
51  * llh    - lat,lon,height
52  * lle    - lat,lon,elev
53  * llr    - lat,lon,rad
54  * pol    - incl,azim,rad
55  * xyz    - x,y,z
56  */
57
58 /**
59  *             lat    lon   elev ->      x      y      z
60  * lle2xyz:    0.0,   0.0,   0.0 ->    0.0,   0.0,  10.0
61  * lle2xyz:   90.0,   0.0,   0.0 ->    0.0,  10.0,   0.0
62  * lle2xyz:    0.0,  90.0,   0.0 ->   10.0,   0.0,   0.0
63  * 
64  *               x      y      z ->    lat    lon   elev 
65  * xyz2lle:   10.0,   0.0,   0.0 ->    0.0,  90.0,   0.0
66  * xyz2lle:    0.0,  10.0,   0.0 ->   90.0,   0.0,   0.0
67  * xyz2lle:    0.0,   0.0,  10.0 ->    0.0,   0.0,   0.0
68  */
69
70 #define azim2lon(azim) ((azim)*180/M_PI)
71 #define lon2azim(lon)  ((lon)*M_PI/180)
72 #define incl2lat(incl) (90-(incl)*180/M_PI)
73 #define lat2incl(lat)  ((90-(lat))*M_PI/180)
74 #define rad2elev(rad)  ((rad)-EARTH_R)
75 #define elev2rad(elev) ((elev)+EARTH_R)
76
77 #define deg2rad(deg) (((deg)*M_PI)/180.0)
78 #define rad2deg(rad) (((rad)*180.0)/M_PI)
79
80 #define FOV_DIST   2000.0
81 #define MPPX(dist) (4*dist/FOV_DIST)
82
83 void lle2xyz(gdouble lat, gdouble lon, gdouble elev,
84                 gdouble *x, gdouble *y, gdouble *z);
85
86 void xyz2lle(gdouble x, gdouble y, gdouble z,
87                 gdouble *lat, gdouble *lon, gdouble *elev);
88
89 gdouble ll2m(gdouble lon_dist, gdouble lat);
90
91 gdouble distd(gdouble *a, gdouble *b);
92
93 /************
94  * GisWorld *
95  ************/
96 #define GIS_TYPE_WORLD            (gis_world_get_type())
97 #define GIS_WORLD(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),   GIS_TYPE_WORLD, GisWorld))
98 #define GIS_IS_WORLD(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),   GIS_TYPE_WORLD))
99 #define GIS_WORLD_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST   ((klass), GIS_TYPE_WORLD, GisWorldClass))
100 #define GIS_IS_WORLD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE   ((klass), GIS_TYPE_WORLD))
101 #define GIS_WORLD_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),   GIS_TYPE_WORLD, GisWorldClass))
102
103 typedef struct _GisWorld      GisWorld;
104 typedef struct _GisWorldClass GisWorldClass;
105
106 struct _GisWorld {
107         GObject parent_instance;
108
109         /* instance members */
110         gboolean offline;
111 };
112
113 struct _GisWorldClass {
114         GObjectClass parent_class;
115         
116         /* class members */
117 };
118
119 GType gis_world_get_type(void);
120
121 /* Methods */
122 GisWorld *gis_world_new();
123
124 void gis_world_refresh(GisWorld *world);
125
126 void gis_world_set_offline(GisWorld *world, gboolean offline);
127 gboolean gis_world_get_offline(GisWorld *world);
128
129 #endif