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/>.
20 #include "gis-marshal.h"
21 #include "gis-world.h"
27 double WGS884_SEMI_MAJOR = 6378137.0; // a
28 double WGS884_SEMI_MINOR = 6356752.314245; // b
29 double WGS884_INV_FLAT = 298.257223563; // 1/f
36 static guint signals[NUM_SIGNALS];
38 /* Class/Object init */
39 G_DEFINE_TYPE(GisWorld, gis_world, G_TYPE_OBJECT);
40 static void gis_world_init(GisWorld *self)
42 g_debug("GisWorld: init");
44 self->offline = FALSE;
46 static void gis_world_dispose(GObject *gobject)
48 g_debug("GisWorld: dispose");
49 /* Drop references to other GObjects */
50 G_OBJECT_CLASS(gis_world_parent_class)->dispose(gobject);
52 static void gis_world_finalize(GObject *gobject)
54 g_debug("GisWorld: finalize");
55 GisWorld *self = GIS_WORLD(gobject);
56 G_OBJECT_CLASS(gis_world_parent_class)->finalize(gobject);
58 static void gis_world_class_init(GisWorldClass *klass)
60 g_debug("GisWorld: class_init");
61 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
62 gobject_class->dispose = gis_world_dispose;
63 gobject_class->finalize = gis_world_finalize;
64 signals[SIG_REFRESH] = g_signal_new(
66 G_TYPE_FROM_CLASS(gobject_class),
71 g_cclosure_marshal_VOID__VOID,
74 signals[SIG_OFFLINE] = g_signal_new(
76 G_TYPE_FROM_CLASS(gobject_class),
81 g_cclosure_marshal_VOID__BOOLEAN,
88 static void _gis_world_emit_refresh(GisWorld *world)
90 g_signal_emit(world, signals[SIG_REFRESH], 0);
92 static void _gis_world_emit_offline(GisWorld *world)
94 g_signal_emit(world, signals[SIG_OFFLINE], 0,
102 GisWorld *gis_world_new()
104 g_debug("GisWorld: new");
105 return g_object_new(GIS_TYPE_WORLD, NULL);
108 void gis_world_refresh(GisWorld *world)
110 g_debug("GisWorld: refresh");
111 _gis_world_emit_refresh(world);
114 void gis_world_set_offline(GisWorld *world, gboolean offline)
116 g_assert(GIS_IS_WORLD(world));
117 g_debug("GisWorld: set_offline - %d", offline);
118 world->offline = offline;
119 _gis_world_emit_offline(world);
122 gboolean gis_world_get_offline(GisWorld *world)
124 g_assert(GIS_IS_WORLD(world));
125 g_debug("GisWorld: get_offline - %d", world->offline);
126 return world->offline;