]> Pileus Git - grits/commitdiff
Merging GisWorld and GisView into GisViewer
authorAndy Spencer <andy753421@gmail.com>
Sat, 14 Nov 2009 11:04:31 +0000 (11:04 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 14 Nov 2009 11:04:31 +0000 (11:04 +0000)
This commit is broken, but will hopefully be easier for Git to track
changed files

src/gis-util.c [new file with mode: 0644]
src/gis-util.h [moved from src/gis-world.h with 70% similarity]
src/gis-viewer.c [moved from src/gis-view.c with 80% similarity]
src/gis-viewer.h [moved from src/gis-view.h with 93% similarity]
src/gis-world.c [deleted file]

diff --git a/src/gis-util.c b/src/gis-util.c
new file mode 100644 (file)
index 0000000..c2af66d
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <math.h>
+
+#include "gis-util.h"
+
+
+/******************
+ * Global helpers *
+ ******************/
+void lle2xyz(gdouble lat, gdouble lon, gdouble elev,
+               gdouble *x, gdouble *y, gdouble *z)
+{
+       gdouble rad  = elev2rad(elev);
+       gdouble azim = lon2azim(lon);
+       gdouble incl = lat2incl(lat);
+       *z = rad * cos(azim) * sin(incl);
+       *x = rad * sin(azim) * sin(incl);
+       *y = rad * cos(incl);
+}
+
+void xyz2lle(gdouble x, gdouble y, gdouble z,
+               gdouble *lat, gdouble *lon, gdouble *elev)
+{
+       gdouble rad = sqrt(x*x + y*y + z*z);
+       *lat  = incl2lat(acos(y / rad));
+       *lon  = azim2lon(atan2(x,z));
+       *elev = rad2elev(rad);
+}
+
+void xyz2ll(gdouble x, gdouble y, gdouble z,
+               gdouble *lat, gdouble *lon)
+{
+       gdouble rad = sqrt(x*x + y*y + z*z);
+       *lat = incl2lat(acos(y / rad));
+       *lon = azim2lon(atan2(x,z));
+}
+
+gdouble ll2m(gdouble lon_dist, gdouble lat)
+{
+       gdouble azim = (-lat+90)/180*M_PI;
+       gdouble rad  = sin(azim) * EARTH_R;
+       gdouble circ = 2 * M_PI * rad;
+       return lon_dist/360 * circ;
+}
+
+gdouble distd(gdouble *a, gdouble *b)
+{
+       return sqrt((a[0]-b[0])*(a[0]-b[0]) +
+                   (a[1]-b[1])*(a[1]-b[1]) +
+                   (a[2]-b[2])*(a[2]-b[2]));
+}
similarity index 70%
rename from src/gis-world.h
rename to src/gis-util.h
index 3a347808e109c3ba50a9c311f6752382c726c753..a9f288a35b85f2554813355d6abfdeb770d65737 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __GIS_WORLD_H__
-#define __GIS_WORLD_H__
-
-#include <glib-object.h>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
+#ifndef __GIS_UTIL_H__
+#define __GIS_UTIL_H__
 
 #define EARTH_R (6371000)
 #define EARTH_C (2*M_PI*EARTH_R)
 
 #define EARTH_R (6371000)
 #define EARTH_C (2*M_PI*EARTH_R)
@@ -97,40 +91,4 @@ gdouble ll2m(gdouble lon_dist, gdouble lat);
 
 gdouble distd(gdouble *a, gdouble *b);
 
 
 gdouble distd(gdouble *a, gdouble *b);
 
-/************
- * GisWorld *
- ************/
-#define GIS_TYPE_WORLD            (gis_world_get_type())
-#define GIS_WORLD(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),   GIS_TYPE_WORLD, GisWorld))
-#define GIS_IS_WORLD(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),   GIS_TYPE_WORLD))
-#define GIS_WORLD_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST   ((klass), GIS_TYPE_WORLD, GisWorldClass))
-#define GIS_IS_WORLD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE   ((klass), GIS_TYPE_WORLD))
-#define GIS_WORLD_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),   GIS_TYPE_WORLD, GisWorldClass))
-
-typedef struct _GisWorld      GisWorld;
-typedef struct _GisWorldClass GisWorldClass;
-
-struct _GisWorld {
-       GObject parent_instance;
-
-       /* instance members */
-       gboolean offline;
-};
-
-struct _GisWorldClass {
-       GObjectClass parent_class;
-       
-       /* class members */
-};
-
-GType gis_world_get_type(void);
-
-/* Methods */
-GisWorld *gis_world_new();
-
-void gis_world_refresh(GisWorld *world);
-
-void gis_world_set_offline(GisWorld *world, gboolean offline);
-gboolean gis_world_get_offline(GisWorld *world);
-
 #endif
 #endif
similarity index 80%
rename from src/gis-view.c
rename to src/gis-viewer.c
index 0add4f6a6dcacee97f60bc3969f005e7a39eaf16..5041d591ffd03911d5b8d4576fc43b53b8505be1 100644 (file)
 
 #include "gis-marshal.h"
 #include "gis-view.h"
 
 #include "gis-marshal.h"
 #include "gis-view.h"
-#include "gis-world.h"
 
 /* Constants */
 enum {
        PROP_0,
        PROP_TIME,
        PROP_SITE,
 
 /* Constants */
 enum {
        PROP_0,
        PROP_TIME,
        PROP_SITE,
+       PROP_OFFLINE,
 };
 enum {
        SIG_TIME_CHANGED,
        SIG_SITE_CHANGED,
        SIG_LOCATION_CHANGED,
        SIG_ROTATION_CHANGED,
 };
 enum {
        SIG_TIME_CHANGED,
        SIG_SITE_CHANGED,
        SIG_LOCATION_CHANGED,
        SIG_ROTATION_CHANGED,
+       SIG_REFRESH,
+       SIG_OFFLINE,
        NUM_SIGNALS,
 };
 static guint signals[NUM_SIGNALS];
        NUM_SIGNALS,
 };
 static guint signals[NUM_SIGNALS];
@@ -71,6 +73,15 @@ static void _gis_view_emit_site_changed(GisView *self)
        g_signal_emit(self, signals[SIG_SITE_CHANGED], 0,
                        self->site);
 }
        g_signal_emit(self, signals[SIG_SITE_CHANGED], 0,
                        self->site);
 }
+static void _gis_world_emit_refresh(GisWorld *world)
+{
+       g_signal_emit(world, signals[SIG_REFRESH], 0);
+}
+static void _gis_world_emit_offline(GisWorld *world)
+{
+       g_signal_emit(world, signals[SIG_OFFLINE], 0,
+                       world->offline);
+}
 
 
 /***********
 
 
 /***********
@@ -183,6 +194,27 @@ gchar *gis_view_get_site(GisView *self)
        return self->site;
 }
 
        return self->site;
 }
 
+void gis_world_refresh(GisWorld *world)
+{
+       g_debug("GisWorld: refresh");
+       _gis_world_emit_refresh(world);
+}
+
+void gis_world_set_offline(GisWorld *world, gboolean offline)
+{
+       g_assert(GIS_IS_WORLD(world));
+       g_debug("GisWorld: set_offline - %d", offline);
+       world->offline = offline;
+       _gis_world_emit_offline(world);
+}
+
+gboolean gis_world_get_offline(GisWorld *world)
+{
+       g_assert(GIS_IS_WORLD(world));
+       g_debug("GisWorld: get_offline - %d", world->offline);
+       return world->offline;
+}
+
 
 /****************
  * GObject code *
 
 /****************
  * GObject code *
@@ -221,8 +253,9 @@ static void gis_view_set_property(GObject *object, guint property_id,
        g_debug("GisView: set_property");
        GisView *self = GIS_VIEW(object);
        switch (property_id) {
        g_debug("GisView: set_property");
        GisView *self = GIS_VIEW(object);
        switch (property_id) {
-       case PROP_TIME:     gis_view_set_time(self, g_value_get_string(value)); break;
-       case PROP_SITE:     gis_view_set_site(self, g_value_get_string(value)); break;
+       case PROP_TIME:     gis_view_set_time(self, g_value_get_string (value));  break;
+       case PROP_SITE:     gis_view_set_site(self, g_value_get_string (value));  break;
+       case PROP_OFFLINE:  gis_view_set_site(self, g_value_get_boolean(value)); break;
        default:            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
        }
 }
        default:            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
        }
 }
@@ -232,8 +265,9 @@ static void gis_view_get_property(GObject *object, guint property_id,
        g_debug("GisView: get_property");
        GisView *self = GIS_VIEW(object);
        switch (property_id) {
        g_debug("GisView: get_property");
        GisView *self = GIS_VIEW(object);
        switch (property_id) {
-       case PROP_TIME:     g_value_set_string(value, gis_view_get_time(self)); break;
-       case PROP_SITE:     g_value_set_string(value, gis_view_get_site(self)); break;
+       case PROP_TIME:     g_value_set_string (value, gis_view_get_time(self)); break;
+       case PROP_SITE:     g_value_set_string (value, gis_view_get_site(self)); break;
+       case PROP_OFFLINE:  g_value_set_boolean(value, gis_view_get_site(self)); break;
        default:            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
        }
 }
        default:            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
        }
 }
@@ -257,6 +291,12 @@ static void gis_view_class_init(GisViewClass *klass)
                        "site seen by the viewport",
                        "Site of the viewport. Currently this is the name of the radar site.",
                        G_PARAM_READWRITE));
                        "site seen by the viewport",
                        "Site of the viewport. Currently this is the name of the radar site.",
                        G_PARAM_READWRITE));
+       g_object_class_install_property(gobject_class, PROP_OFFLINE,
+               g_param_spec_pointer(
+                       "offline",
+                       "whether the viewer should access the network",
+                       "Offline state of the viewer. If set to true, the viewer will not access the network",
+                       G_PARAM_READWRITE));
        signals[SIG_TIME_CHANGED] = g_signal_new(
                        "time-changed",
                        G_TYPE_FROM_CLASS(gobject_class),
        signals[SIG_TIME_CHANGED] = g_signal_new(
                        "time-changed",
                        G_TYPE_FROM_CLASS(gobject_class),
@@ -305,4 +345,25 @@ static void gis_view_class_init(GisViewClass *klass)
                        G_TYPE_DOUBLE,
                        G_TYPE_DOUBLE,
                        G_TYPE_DOUBLE);
                        G_TYPE_DOUBLE,
                        G_TYPE_DOUBLE,
                        G_TYPE_DOUBLE);
+       signals[SIG_REFRESH] = g_signal_new(
+                       "refresh",
+                       G_TYPE_FROM_CLASS(gobject_class),
+                       G_SIGNAL_RUN_LAST,
+                       0,
+                       NULL,
+                       NULL,
+                       g_cclosure_marshal_VOID__VOID,
+                       G_TYPE_NONE,
+                       0);
+       signals[SIG_OFFLINE] = g_signal_new(
+                       "offline",
+                       G_TYPE_FROM_CLASS(gobject_class),
+                       G_SIGNAL_RUN_LAST,
+                       0,
+                       NULL,
+                       NULL,
+                       g_cclosure_marshal_VOID__BOOLEAN,
+                       G_TYPE_NONE,
+                       1,
+                       G_TYPE_BOOLEAN);
 }
 }
similarity index 93%
rename from src/gis-view.h
rename to src/gis-viewer.h
index ec84b845793e9ba1a7acedec48ba995bd7beec75..6b0d6bdfb2b5f0d40a667c77060c478df022637f 100644 (file)
@@ -39,11 +39,12 @@ struct _GisView {
        gchar   *site;
        gdouble  location[3];
        gdouble  rotation[3];
        gchar   *site;
        gdouble  location[3];
        gdouble  rotation[3];
+       gboolean offline;
 };
 
 struct _GisViewClass {
        GObjectClass parent_class;
 };
 
 struct _GisViewClass {
        GObjectClass parent_class;
-       
+
        /* class members */
 };
 
        /* class members */
 };
 
@@ -68,4 +69,9 @@ void gis_view_rotate      (GisView *view, gdouble  x, gdouble  y, gdouble  z);
 void gis_view_set_site(GisView *view, const gchar *site);
 gchar *gis_view_get_site(GisView *view);
 
 void gis_view_set_site(GisView *view, const gchar *site);
 gchar *gis_view_get_site(GisView *view);
 
+void gis_world_refresh(GisWorld *world);
+
+void gis_world_set_offline(GisWorld *world, gboolean offline);
+gboolean gis_world_get_offline(GisWorld *world);
+
 #endif
 #endif
diff --git a/src/gis-world.c b/src/gis-world.c
deleted file mode 100644 (file)
index c4d74b8..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <glib.h>
-#include <math.h>
-
-#include "gis-marshal.h"
-#include "gis-world.h"
-
-/* Constants */
-double WGS884_SEMI_MAJOR = 6378137.0;      // a
-double WGS884_SEMI_MINOR = 6356752.314245; // b
-double WGS884_INV_FLAT   = 298.257223563;  // 1/f
-
-enum {
-       SIG_REFRESH,
-       SIG_OFFLINE,
-       NUM_SIGNALS,
-};
-static guint signals[NUM_SIGNALS];
-
-
-/* Signal helpers */
-static void _gis_world_emit_refresh(GisWorld *world)
-{
-       g_signal_emit(world, signals[SIG_REFRESH], 0);
-}
-static void _gis_world_emit_offline(GisWorld *world)
-{
-       g_signal_emit(world, signals[SIG_OFFLINE], 0,
-                       world->offline);
-}
-
-/***********
- * Methods *
- ***********/
-GisWorld *gis_world_new()
-{
-       g_debug("GisWorld: new");
-       return g_object_new(GIS_TYPE_WORLD, NULL);
-}
-
-void gis_world_refresh(GisWorld *world)
-{
-       g_debug("GisWorld: refresh");
-       _gis_world_emit_refresh(world);
-}
-
-void gis_world_set_offline(GisWorld *world, gboolean offline)
-{
-       g_assert(GIS_IS_WORLD(world));
-       g_debug("GisWorld: set_offline - %d", offline);
-       world->offline = offline;
-       _gis_world_emit_offline(world);
-}
-
-gboolean gis_world_get_offline(GisWorld *world)
-{
-       g_assert(GIS_IS_WORLD(world));
-       g_debug("GisWorld: get_offline - %d", world->offline);
-       return world->offline;
-}
-
-
-/****************
- * GObject code *
- ****************/
-G_DEFINE_TYPE(GisWorld, gis_world, G_TYPE_OBJECT);
-static void gis_world_init(GisWorld *self)
-{
-       g_debug("GisWorld: init");
-       /* Default values */
-       self->offline = FALSE;
-}
-static void gis_world_dispose(GObject *gobject)
-{
-       g_debug("GisWorld: dispose");
-       /* Drop references to other GObjects */
-       G_OBJECT_CLASS(gis_world_parent_class)->dispose(gobject);
-}
-static void gis_world_finalize(GObject *gobject)
-{
-       g_debug("GisWorld: finalize");
-       GisWorld *self = GIS_WORLD(gobject);
-       G_OBJECT_CLASS(gis_world_parent_class)->finalize(gobject);
-}
-static void gis_world_class_init(GisWorldClass *klass)
-{
-       g_debug("GisWorld: class_init");
-       GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-       gobject_class->dispose      = gis_world_dispose;
-       gobject_class->finalize     = gis_world_finalize;
-       signals[SIG_REFRESH] = g_signal_new(
-                       "refresh",
-                       G_TYPE_FROM_CLASS(gobject_class),
-                       G_SIGNAL_RUN_LAST,
-                       0,
-                       NULL,
-                       NULL,
-                       g_cclosure_marshal_VOID__VOID,
-                       G_TYPE_NONE,
-                       0);
-       signals[SIG_OFFLINE] = g_signal_new(
-                       "offline",
-                       G_TYPE_FROM_CLASS(gobject_class),
-                       G_SIGNAL_RUN_LAST,
-                       0,
-                       NULL,
-                       NULL,
-                       g_cclosure_marshal_VOID__BOOLEAN,
-                       G_TYPE_NONE,
-                       1,
-                       G_TYPE_BOOLEAN);
-}
-
-
-/******************
- * Global helpers *
- ******************/
-void lle2xyz(gdouble lat, gdouble lon, gdouble elev,
-               gdouble *x, gdouble *y, gdouble *z)
-{
-       gdouble rad  = elev2rad(elev);
-       gdouble azim = lon2azim(lon);
-       gdouble incl = lat2incl(lat);
-       *z = rad * cos(azim) * sin(incl);
-       *x = rad * sin(azim) * sin(incl);
-       *y = rad * cos(incl);
-}
-
-void xyz2lle(gdouble x, gdouble y, gdouble z,
-               gdouble *lat, gdouble *lon, gdouble *elev)
-{
-       gdouble rad = sqrt(x*x + y*y + z*z);
-       *lat  = incl2lat(acos(y / rad));
-       *lon  = azim2lon(atan2(x,z));
-       *elev = rad2elev(rad);
-}
-
-void xyz2ll(gdouble x, gdouble y, gdouble z,
-               gdouble *lat, gdouble *lon)
-{
-       gdouble rad = sqrt(x*x + y*y + z*z);
-       *lat = incl2lat(acos(y / rad));
-       *lon = azim2lon(atan2(x,z));
-}
-
-gdouble ll2m(gdouble lon_dist, gdouble lat)
-{
-       gdouble azim = (-lat+90)/180*M_PI;
-       gdouble rad  = sin(azim) * EARTH_R;
-       gdouble circ = 2 * M_PI * rad;
-       return lon_dist/360 * circ;
-}
-
-gdouble distd(gdouble *a, gdouble *b)
-{
-       return sqrt((a[0]-b[0])*(a[0]-b[0]) +
-                   (a[1]-b[1])*(a[1]-b[1]) +
-                   (a[2]-b[2])*(a[2]-b[2]));
-}