]> Pileus Git - aweather/blobdiff - src/plugins/radar.c
Use/update reflectivity colormap
[aweather] / src / plugins / radar.c
index a4ed00479bc19b5713505f7d310ae7a88d058e50..37ed9e3723435aea3e8c5709d83ca062681457cf 100644 (file)
@@ -320,7 +320,8 @@ RadarSite *radar_site_new(city_t *city, GtkWidget *pconfig,
        RadarSite *site = g_new0(RadarSite, 1);
        site->viewer  = g_object_ref(viewer);
        site->prefs   = g_object_ref(prefs);
-       site->http    = http;
+       //site->http    = http;
+       site->http    = gis_http_new(G_DIR_SEPARATOR_S "nexrad" G_DIR_SEPARATOR_S "level2" G_DIR_SEPARATOR_S);
        site->city    = city;
        site->pconfig = pconfig;
 
@@ -340,6 +341,7 @@ void radar_site_free(RadarSite *site)
        gis_viewer_remove(site->viewer, site->marker_ref);
        if (site->location_id)
                g_signal_handler_disconnect(site->viewer, site->location_id);
+       gis_http_free(site->http);
        g_object_unref(site->viewer);
        g_object_unref(site->prefs);
        g_free(site);
@@ -463,12 +465,18 @@ gboolean _conus_update_end(gpointer _conus)
        /* Load and pixbuf */
        GError *error = NULL;
        GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(conus->path, &error);
-       guchar    *pixels = gdk_pixbuf_get_pixels(pixbuf);
-       gint       width  = gdk_pixbuf_get_width(pixbuf);
-       gint       height = gdk_pixbuf_get_height(pixbuf);
-       gint       pxsize = gdk_pixbuf_get_has_alpha(pixbuf) ? 4 : 3;
+       if (!pixbuf || error) {
+               g_warning("GisPluginRadar: _conus_update_end - error loading pixbuf");
+               _gtk_bin_set_child(GTK_BIN(conus->config), gtk_label_new("Error loading pixbuf"));
+               g_remove(conus->path);
+               goto out;
+       }
 
        /* Split pixels into east/west parts */
+       guchar *pixels = gdk_pixbuf_get_pixels(pixbuf);
+       gint    width  = gdk_pixbuf_get_width(pixbuf);
+       gint    height = gdk_pixbuf_get_height(pixbuf);
+       gint    pxsize = gdk_pixbuf_get_has_alpha(pixbuf) ? 4 : 3;
        guchar *pixels_west = g_malloc(4*(width/2)*height);
        guchar *pixels_east = g_malloc(4*(width/2)*height);
        _conus_update_end_split(pixels, pixels_west, pixels_east,
@@ -612,12 +620,10 @@ void radar_conus_free(RadarConus *conus)
 /******************
  * GisPluginRadar *
  ******************/
-static void _draw_hud(GisCallback *callback, gpointer _self)
+static void _draw_hud(GisCallback *callback, GisOpenGL *opengl, gpointer _self)
 {
-       /* TODO */
-       GisPluginRadar *self = GIS_PLUGIN_RADAR(_self);
-       if (!self->colormap)
-               return;
+       /* TODO, pick correct colormaps */
+       AWeatherColormap *colormap = &colormaps[0];
 
        g_debug("GisPluginRadar: _draw_hud");
        /* Print the color table */
@@ -631,7 +637,7 @@ static void _draw_hud(GisCallback *callback, gpointer _self)
        glBegin(GL_QUADS);
        int i;
        for (i = 0; i < 256; i++) {
-               glColor4ubv(self->colormap->data[i]);
+               glColor4ubv(colormap->data[i]);
                glVertex3f(-1.0, (float)((i  ) - 256/2)/(256/2), 0.0); // bot left
                glVertex3f(-1.0, (float)((i+1) - 256/2)/(256/2), 0.0); // top left
                glVertex3f(-0.9, (float)((i+1) - 256/2)/(256/2), 0.0); // top right
@@ -694,7 +700,8 @@ static void gis_plugin_radar_init(GisPluginRadar *self)
        self->sites      = g_hash_table_new_full(g_str_hash, g_str_equal,
                                NULL, (GDestroyNotify)radar_site_free);
        self->config     = gtk_notebook_new();
-       gtk_notebook_set_tab_pos(GTK_NOTEBOOK(self->config), GTK_POS_LEFT);
+       /* Need to position on the top because of Win32 bug */
+       gtk_notebook_set_tab_pos(GTK_NOTEBOOK(self->config), GTK_POS_BOTTOM);
 }
 static void gis_plugin_radar_dispose(GObject *gobject)
 {