2 * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
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.
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.
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/>.
18 #ifndef __GIS_WORLD_H__
19 #define __GIS_WORLD_H__
21 #include <glib-object.h>
24 #define M_PI 3.14159265358979323846
27 #define EARTH_R (6371000)
28 #define EARTH_C (2*M_PI*EARTH_R)
34 * rad - Radians, also radius
35 * m - Meters, for earth-based distances
36 * px - Pixels, for screen-based distances
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
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
47 * x - 0° lon is positive
48 * y - 90° lon is positive
49 * z - North pole is positive
51 * llh - lat,lon,height
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
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
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)
77 #define deg2rad(deg) (((deg)*M_PI)/180.0)
78 #define rad2deg(rad) (((rad)*180.0)/M_PI)
80 #define FOV_DIST 2000.0
81 #define MPPX(dist) (4*dist/FOV_DIST)
83 void lle2xyz(gdouble lat, gdouble lon, gdouble elev,
84 gdouble *x, gdouble *y, gdouble *z);
86 void xyz2lle(gdouble x, gdouble y, gdouble z,
87 gdouble *lat, gdouble *lon, gdouble *elev);
89 gdouble ll2m(gdouble lon_dist, gdouble lat);
91 gdouble distd(gdouble *a, gdouble *b);
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))
103 typedef struct _GisWorld GisWorld;
104 typedef struct _GisWorldClass GisWorldClass;
107 GObject parent_instance;
109 /* instance members */
113 struct _GisWorldClass {
114 GObjectClass parent_class;
119 GType gis_world_get_type(void);
122 GisWorld *gis_world_new();
124 void gis_world_refresh(GisWorld *world);
126 void gis_world_set_offline(GisWorld *world, gboolean offline);
127 gboolean gis_world_get_offline(GisWorld *world);