2 * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
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/>.
21 #include <glib/gstdio.h>
23 #include <gtk/gtkgl.h>
33 #include "../aweather-location.h"
35 GtkWidget *_gtk_check_label_new(const gchar *text, gboolean state,
36 GCallback on_clicked, gpointer user_data)
38 GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
39 GtkWidget *check = gtk_check_button_new();
40 GtkWidget *label = gtk_label_new(text);
41 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), state);
42 g_signal_connect_swapped(check , "clicked",
43 G_CALLBACK(on_clicked), user_data);
44 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
45 gtk_box_pack_end(GTK_BOX(hbox), check , FALSE, FALSE, 0);
46 gtk_widget_show_all(hbox);
50 void _gtk_bin_set_child(GtkBin *bin, GtkWidget *new)
52 GtkWidget *old = gtk_bin_get_child(bin);
54 gtk_widget_destroy(old);
55 gtk_container_add(GTK_CONTAINER(bin), new);
56 gtk_widget_show_all(new);
59 static gchar *_find_nearest(time_t time, GList *files,
60 gsize offset, gchar *format)
62 g_debug("GisPluginRadar: _find_nearest ...");
63 time_t nearest_time = 0;
64 char *nearest_file = NULL;
67 for (GList *cur = files; cur; cur = cur->next) {
68 gchar *file = cur->data;
69 strptime(file+offset, format, &tm);
70 if (ABS(time - mktime(&tm)) <
71 ABS(time - nearest_time)) {
73 nearest_time = mktime(&tm);
77 g_debug("GisPluginRadar: _find_nearest = %s", nearest_file);
79 return g_strdup(nearest_file);
96 GisMarker *marker; // Map marker for libgis
97 gpointer *marker_ref; // Reference to maker
99 /* Stuff from the parents */
107 RadarSiteStatus status; // Loading status for the site
109 AWeatherLevel2 *level2; // The Level2 structure for the current volume
110 gpointer level2_ref; // GisViewer reference to the added radar
113 time_t time; // Current timestamp of the level2
114 gchar *message; // Error message set while updating
115 guint time_id; // "time-changed" callback ID
116 guint refresh_id; // "refresh" callback ID
117 guint location_id; // "locaiton-changed" callback ID
120 /* format: http://mesonet.agron.iastate.edu/data/nexrd2/raw/KABR/KABR_20090510_0323 */
121 void _site_update_loading(gchar *file, goffset cur,
122 goffset total, gpointer _site)
124 RadarSite *site = _site;
125 GtkWidget *progress_bar = gtk_bin_get_child(GTK_BIN(site->config));
126 double percent = (double)cur/total;
127 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar), MIN(percent, 1.0));
128 gchar *msg = g_strdup_printf("Loading... %5.1f%% (%.2f/%.2f MB)",
129 percent*100, (double)cur/1000000, (double)total/1000000);
130 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress_bar), msg);
133 gboolean _site_update_end(gpointer _site)
135 RadarSite *site = _site;
137 g_warning("GisPluginRadar: _update_end - %s", site->message);
138 _gtk_bin_set_child(GTK_BIN(site->config), gtk_label_new(site->message));
140 _gtk_bin_set_child(GTK_BIN(site->config),
141 aweather_level2_get_config(site->level2));
143 site->status = STATUS_LOADED;
146 gpointer _site_update_thread(gpointer _site)
148 RadarSite *site = _site;
149 g_debug("GisPluginRadar: _site_update_thread - %s", site->city->code);
150 site->message = NULL;
152 gboolean offline = gis_viewer_get_offline(site->viewer);
153 gchar *nexrad_url = gis_prefs_get_string(site->prefs,
154 "aweather/nexrad_url", NULL);
156 /* Find nearest volume (temporally) */
157 g_debug("GisPluginRadar: _site_update_thread - find nearest - %s", site->city->code);
158 gchar *dir_list = g_strconcat(nexrad_url, "/", site->city->code,
159 "/", "dir.list", NULL);
160 GList *files = gis_http_available(site->http,
161 "^K\\w{3}_\\d{8}_\\d{4}$", site->city->code,
162 "\\d+ (.*)", (offline ? NULL : dir_list));
164 gchar *nearest = _find_nearest(site->time, files, 5, "%Y%m%d_%H%M");
165 g_list_foreach(files, (GFunc)g_free, NULL);
168 site->message = "No suitable files found";
172 /* Fetch new volume */
173 g_debug("GisPluginRadar: _site_update_thread - fetch");
174 gchar *local = g_strconcat(site->city->code, "/", nearest, NULL);
175 gchar *uri = g_strconcat(nexrad_url, "/", local, NULL);
176 gchar *file = gis_http_fetch(site->http, uri, local,
177 offline ? GIS_LOCAL : GIS_UPDATE,
178 _site_update_loading, site);
184 site->message = "Fetch failed";
188 /* Load and add new volume */
189 g_debug("GisPluginRadar: _site_update_thread - load - %s", site->city->code);
190 site->level2 = aweather_level2_new_from_file(
191 site->viewer, colormaps, file, site->city->code);
194 site->message = "Load failed";
197 GIS_OBJECT(site->level2)->hidden = site->hidden;
198 site->level2_ref = gis_viewer_add(site->viewer,
199 GIS_OBJECT(site->level2), GIS_LEVEL_WORLD, TRUE);
202 g_idle_add(_site_update_end, site);
205 void _site_update(RadarSite *site)
207 if (site->status == STATUS_LOADING)
209 site->status = STATUS_LOADING;
211 site->time = gis_viewer_get_time(site->viewer);
212 g_debug("GisPluginRadar: _site_update %s - %d",
213 site->city->code, (gint)site->time);
215 /* Add a progress bar */
216 GtkWidget *progress = gtk_progress_bar_new();
217 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), "Loading...");
218 _gtk_bin_set_child(GTK_BIN(site->config), progress);
220 /* Remove old volume */
221 g_debug("GisPluginRadar: _site_update - remove - %s", site->city->code);
222 if (site->level2_ref) {
223 gis_viewer_remove(site->viewer, site->level2_ref);
224 site->level2_ref = NULL;
227 /* Fork loading right away so updating the
228 * list of times doesn't take too long */
229 g_thread_create(_site_update_thread, site, FALSE, NULL);
232 /* RadarSite methods */
233 void radar_site_unload(RadarSite *site)
235 if (site->status != STATUS_LOADED)
236 return; // Abort if it's still loading
238 g_debug("GisPluginRadar: radar_site_unload %s", site->city->code);
241 g_signal_handler_disconnect(site->viewer, site->time_id);
242 if (site->refresh_id)
243 g_signal_handler_disconnect(site->viewer, site->refresh_id);
247 gtk_widget_destroy(site->config);
250 if (site->level2_ref) {
251 gis_viewer_remove(site->viewer, site->level2_ref);
252 site->level2_ref = NULL;
255 site->status = STATUS_UNLOADED;
258 void radar_site_toggle(RadarSite *site)
260 site->hidden = !site->hidden;
262 GIS_OBJECT(site->level2)->hidden = site->hidden;
263 gtk_widget_queue_draw(GTK_WIDGET(site->viewer));
267 void radar_site_load(RadarSite *site)
269 g_debug("GisPluginRadar: radar_site_load %s", site->city->code);
272 site->config = gtk_alignment_new(0, 0, 1, 1);
273 gtk_notebook_append_page(GTK_NOTEBOOK(site->pconfig), site->config,
274 _gtk_check_label_new(site->city->name, !site->hidden,
275 G_CALLBACK(radar_site_toggle), site));
276 gtk_widget_show_all(site->config);
278 /* Set up radar loading */
279 site->time_id = g_signal_connect_swapped(site->viewer, "time-changed",
280 G_CALLBACK(_site_update), site);
281 site->refresh_id = g_signal_connect_swapped(site->viewer, "refresh",
282 G_CALLBACK(_site_update), site);
286 void _site_on_location_changed(GisViewer *viewer,
287 gdouble lat, gdouble lon, gdouble elev,
290 static gdouble min_dist = EARTH_R / 20;
291 RadarSite *site = _site;
293 /* Calculate distance, could cache xyz values */
294 gdouble eye_xyz[3], site_xyz[3];
295 lle2xyz(lat, lon, elev, &eye_xyz[0], &eye_xyz[1], &eye_xyz[2]);
296 lle2xyz(site->city->pos.lat, site->city->pos.lon, site->city->pos.elev,
297 &site_xyz[0], &site_xyz[1], &site_xyz[2]);
298 gdouble dist = distd(site_xyz, eye_xyz);
300 /* Load or unload the site if necessasairy */
301 if (dist <= min_dist && dist < elev*1.25 && site->status == STATUS_UNLOADED)
302 radar_site_load(site);
303 else if (dist > 2*min_dist && site->status != STATUS_UNLOADED)
304 radar_site_unload(site);
307 gboolean _site_add_marker(gpointer _site)
309 RadarSite *site = _site;
310 site->marker = gis_marker_new(site->city->name);
311 GIS_OBJECT(site->marker)->center = site->city->pos;
312 GIS_OBJECT(site->marker)->lod = EARTH_R*site->city->lod;
313 site->marker_ref = gis_viewer_add(site->viewer,
314 GIS_OBJECT(site->marker), GIS_LEVEL_OVERLAY, FALSE);
317 RadarSite *radar_site_new(city_t *city, GtkWidget *pconfig,
318 GisViewer *viewer, GisPrefs *prefs, GisHttp *http)
320 RadarSite *site = g_new0(RadarSite, 1);
321 site->viewer = g_object_ref(viewer);
322 site->prefs = g_object_ref(prefs);
324 site->http = gis_http_new(G_DIR_SEPARATOR_S "nexrad" G_DIR_SEPARATOR_S "level2" G_DIR_SEPARATOR_S);
326 site->pconfig = pconfig;
329 g_idle_add_full(G_PRIORITY_LOW, _site_add_marker, site, NULL);
332 /* Connect signals */
333 site->location_id = g_signal_connect(viewer, "location-changed",
334 G_CALLBACK(_site_on_location_changed), site);
338 void radar_site_free(RadarSite *site)
340 radar_site_unload(site);
341 gis_viewer_remove(site->viewer, site->marker_ref);
342 if (site->location_id)
343 g_signal_handler_disconnect(site->viewer, site->location_id);
344 gis_http_free(site->http);
345 g_object_unref(site->viewer);
346 g_object_unref(site->prefs);
354 #define CONUS_NORTH 50.406626367301044
355 #define CONUS_WEST -127.620375523875420
356 #define CONUS_WIDTH 3400.0
357 #define CONUS_HEIGHT 1600.0
358 #define CONUS_DEG_PER_PX 0.017971305190311
365 const gchar *message;
366 GStaticMutex loading;
370 gpointer *tile_ref[2];
372 guint time_id; // "time-changed" callback ID
373 guint refresh_id; // "refresh" callback ID
376 void _conus_update_loading(gchar *file, goffset cur,
377 goffset total, gpointer _conus)
379 RadarConus *conus = _conus;
380 GtkWidget *progress_bar = gtk_bin_get_child(GTK_BIN(conus->config));
381 double percent = (double)cur/total;
382 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar), MIN(percent, 1.0));
383 gchar *msg = g_strdup_printf("Loading... %5.1f%% (%.2f/%.2f MB)",
384 percent*100, (double)cur/1000000, (double)total/1000000);
385 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress_bar), msg);
389 /* Copy images to graphics memory */
390 static void _conus_update_end_copy(GisTile *tile, guchar *pixels)
393 tile->data = g_new0(guint, 1);
394 glGenTextures(1, tile->data);
397 guint *tex = tile->data;
398 glBindTexture(GL_TEXTURE_2D, *tex);
400 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
401 glPixelStorei(GL_PACK_ALIGNMENT, 1);
402 glTexImage2D(GL_TEXTURE_2D, 0, 4, 2048, 2048, 0,
403 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
404 glTexSubImage2D(GL_TEXTURE_2D, 0, 1,1, CONUS_WIDTH/2,CONUS_HEIGHT,
405 GL_RGBA, GL_UNSIGNED_BYTE, pixels);
406 tile->coords.n = 1.0/(CONUS_WIDTH/2);
407 tile->coords.w = 1.0/ CONUS_HEIGHT;
408 tile->coords.s = tile->coords.n + CONUS_HEIGHT / 2048.0;
409 tile->coords.e = tile->coords.w + (CONUS_WIDTH/2) / 2048.0;
410 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
411 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
412 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
413 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
417 /* Split the pixbuf into east and west halves (with 2K sides)
418 * Also map the pixbuf's alpha values */
419 static void _conus_update_end_split(guchar *pixels, guchar *west, guchar *east,
420 gint width, gint height, gint pxsize)
422 g_debug("GisPluginRadar: _conus_update_end_split");
423 guchar *out[] = {west,east};
424 const guchar alphamap[][4] = {
425 {0x04, 0xe9, 0xe7, 0x30},
426 {0x01, 0x9f, 0xf4, 0x60},
427 {0x03, 0x00, 0xf4, 0x90},
429 for (int y = 0; y < height; y++)
430 for (int x = 0; x < width; x++) {
431 gint subx = x % (width/2);
432 gint idx = x / (width/2);
433 guchar *src = &pixels[(y*width+x)*pxsize];
434 guchar *dst = &out[idx][(y*(width/2)+subx)*4];
444 for (int j = 0; j < G_N_ELEMENTS(alphamap); j++)
445 if (src[0] == alphamap[j][0] &&
446 src[1] == alphamap[j][1] &&
447 src[2] == alphamap[j][2])
448 dst[3] = alphamap[j][3];
453 gboolean _conus_update_end(gpointer _conus)
455 RadarConus *conus = _conus;
456 g_debug("GisPluginRadar: _conus_update_end");
458 /* Check error status */
459 if (conus->message) {
460 g_warning("GisPluginRadar: _conus_update_end - %s", conus->message);
461 _gtk_bin_set_child(GTK_BIN(conus->config), gtk_label_new(conus->message));
465 /* Load and pixbuf */
466 GError *error = NULL;
467 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(conus->path, &error);
468 if (!pixbuf || error) {
469 g_warning("GisPluginRadar: _conus_update_end - error loading pixbuf");
470 _gtk_bin_set_child(GTK_BIN(conus->config), gtk_label_new("Error loading pixbuf"));
471 g_remove(conus->path);
475 /* Split pixels into east/west parts */
476 guchar *pixels = gdk_pixbuf_get_pixels(pixbuf);
477 gint width = gdk_pixbuf_get_width(pixbuf);
478 gint height = gdk_pixbuf_get_height(pixbuf);
479 gint pxsize = gdk_pixbuf_get_has_alpha(pixbuf) ? 4 : 3;
480 guchar *pixels_west = g_malloc(4*(width/2)*height);
481 guchar *pixels_east = g_malloc(4*(width/2)*height);
482 _conus_update_end_split(pixels, pixels_west, pixels_east,
483 width, height, pxsize);
484 g_object_unref(pixbuf);
486 /* Copy pixels to graphics memory */
487 _conus_update_end_copy(conus->tile[0], pixels_west);
488 _conus_update_end_copy(conus->tile[1], pixels_east);
493 gchar *label = g_path_get_basename(conus->path);
494 _gtk_bin_set_child(GTK_BIN(conus->config), gtk_label_new(label));
495 gtk_widget_queue_draw(GTK_WIDGET(conus->viewer));
500 g_static_mutex_unlock(&conus->loading);
504 gpointer _conus_update_thread(gpointer _conus)
506 RadarConus *conus = _conus;
507 conus->message = NULL;
510 g_debug("GisPluginRadar: _conus_update_thread - nearest");
511 gboolean offline = gis_viewer_get_offline(conus->viewer);
512 gchar *conus_url = "http://radar.weather.gov/Conus/RadarImg/";
513 GList *files = gis_http_available(conus->http,
514 "^Conus_[^\"]*_N0Ronly.gif$", "",
515 NULL, (offline ? NULL : conus_url));
516 gchar *nearest = _find_nearest(conus->time, files, 6, "%Y%m%d_%H%M");
517 g_list_foreach(files, (GFunc)g_free, NULL);
520 conus->message = "No suitable files";
524 /* Fetch the image */
525 g_debug("GisPluginRadar: _conus_update_thread - fetch");
526 gchar *uri = g_strconcat(conus_url, nearest, NULL);
527 conus->path = gis_http_fetch(conus->http, uri, nearest, GIS_ONCE,
528 _conus_update_loading, conus);
532 conus->message = "Fetch failed";
537 g_debug("GisPluginRadar: _conus_update_thread - done");
538 g_idle_add(_conus_update_end, conus);
542 void _conus_update(RadarConus *conus)
544 if (!g_static_mutex_trylock(&conus->loading))
546 conus->time = gis_viewer_get_time(conus->viewer);
547 g_debug("GisPluginRadar: _conus_update - %d",
550 /* Add a progress bar */
551 GtkWidget *progress = gtk_progress_bar_new();
552 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), "Loading...");
553 _gtk_bin_set_child(GTK_BIN(conus->config), progress);
555 g_thread_create(_conus_update_thread, conus, FALSE, NULL);
558 void radar_conus_toggle(RadarConus *conus)
560 GIS_OBJECT(conus->tile[0])->hidden =
561 !GIS_OBJECT(conus->tile[0])->hidden;
562 GIS_OBJECT(conus->tile[1])->hidden =
563 !GIS_OBJECT(conus->tile[1])->hidden;
564 gtk_widget_queue_draw(GTK_WIDGET(conus->viewer));
567 RadarConus *radar_conus_new(GtkWidget *pconfig,
568 GisViewer *viewer, GisHttp *http)
570 RadarConus *conus = g_new0(RadarConus, 1);
571 conus->viewer = g_object_ref(viewer);
573 conus->config = gtk_alignment_new(0, 0, 1, 1);
574 g_static_mutex_init(&conus->loading);
576 gdouble south = CONUS_NORTH - CONUS_DEG_PER_PX*CONUS_HEIGHT;
577 gdouble east = CONUS_WEST + CONUS_DEG_PER_PX*CONUS_WIDTH;
578 gdouble mid = CONUS_WEST + CONUS_DEG_PER_PX*CONUS_WIDTH/2;
579 conus->tile[0] = gis_tile_new(NULL, CONUS_NORTH, south, mid, CONUS_WEST);
580 conus->tile[1] = gis_tile_new(NULL, CONUS_NORTH, south, east, mid);
581 conus->tile[0]->zindex = 2;
582 conus->tile[1]->zindex = 1;
583 conus->tile_ref[0] = gis_viewer_add(viewer,
584 GIS_OBJECT(conus->tile[0]), GIS_LEVEL_WORLD, TRUE);
585 conus->tile_ref[1] = gis_viewer_add(viewer,
586 GIS_OBJECT(conus->tile[1]), GIS_LEVEL_WORLD, TRUE);
588 conus->time_id = g_signal_connect_swapped(viewer, "time-changed",
589 G_CALLBACK(_conus_update), conus);
590 conus->refresh_id = g_signal_connect_swapped(viewer, "refresh",
591 G_CALLBACK(_conus_update), conus);
593 gtk_notebook_append_page(GTK_NOTEBOOK(pconfig), conus->config,
594 _gtk_check_label_new("Conus", TRUE,
595 G_CALLBACK(radar_conus_toggle), conus));
596 _conus_update(conus);
600 void radar_conus_free(RadarConus *conus)
602 g_signal_handler_disconnect(conus->viewer, conus->time_id);
603 g_signal_handler_disconnect(conus->viewer, conus->refresh_id);
605 for (int i = 0; i < 2; i++) {
606 GisTile *tile = conus->tile[i];
607 gpointer ref = conus->tile_ref[i];
609 glDeleteTextures(1, tile->data);
612 gis_viewer_remove(conus->viewer, ref);
615 g_object_unref(conus->viewer);
623 static void _draw_hud(GisCallback *callback, gpointer _self)
626 GisPluginRadar *self = GIS_PLUGIN_RADAR(_self);
630 g_debug("GisPluginRadar: _draw_hud");
631 /* Print the color table */
632 glMatrixMode(GL_MODELVIEW ); glLoadIdentity();
633 glMatrixMode(GL_PROJECTION); glLoadIdentity();
634 glDisable(GL_TEXTURE_2D);
635 glDisable(GL_ALPHA_TEST);
636 glDisable(GL_CULL_FACE);
637 glDisable(GL_LIGHTING);
638 glEnable(GL_COLOR_MATERIAL);
641 for (i = 0; i < 256; i++) {
642 glColor4ubv(self->colormap->data[i]);
643 glVertex3f(-1.0, (float)((i ) - 256/2)/(256/2), 0.0); // bot left
644 glVertex3f(-1.0, (float)((i+1) - 256/2)/(256/2), 0.0); // top left
645 glVertex3f(-0.9, (float)((i+1) - 256/2)/(256/2), 0.0); // top right
646 glVertex3f(-0.9, (float)((i ) - 256/2)/(256/2), 0.0); // bot right
652 GisPluginRadar *gis_plugin_radar_new(GisViewer *viewer, GisPrefs *prefs)
654 /* TODO: move to constructor if possible */
655 g_debug("GisPluginRadar: new");
656 GisPluginRadar *self = g_object_new(GIS_TYPE_PLUGIN_RADAR, NULL);
657 self->viewer = viewer;
661 GisCallback *hud_cb = gis_callback_new(_draw_hud, self);
662 self->hud_ref = gis_viewer_add(viewer, GIS_OBJECT(hud_cb), GIS_LEVEL_HUD, FALSE);
665 self->conus = radar_conus_new(self->config, self->viewer, self->conus_http);
667 /* Load radar sites */
668 for (city_t *city = cities; city->type; city++) {
669 if (city->type != LOCATION_CITY)
671 RadarSite *site = radar_site_new(city, self->config,
672 self->viewer, self->prefs, self->sites_http);
673 g_hash_table_insert(self->sites, city->code, site);
679 static GtkWidget *gis_plugin_radar_get_config(GisPlugin *_self)
681 GisPluginRadar *self = GIS_PLUGIN_RADAR(_self);
686 static void gis_plugin_radar_plugin_init(GisPluginInterface *iface);
687 G_DEFINE_TYPE_WITH_CODE(GisPluginRadar, gis_plugin_radar, G_TYPE_OBJECT,
688 G_IMPLEMENT_INTERFACE(GIS_TYPE_PLUGIN,
689 gis_plugin_radar_plugin_init));
690 static void gis_plugin_radar_plugin_init(GisPluginInterface *iface)
692 g_debug("GisPluginRadar: plugin_init");
693 /* Add methods to the interface */
694 iface->get_config = gis_plugin_radar_get_config;
696 static void gis_plugin_radar_init(GisPluginRadar *self)
698 g_debug("GisPluginRadar: class_init");
700 self->sites_http = gis_http_new(G_DIR_SEPARATOR_S "nexrad" G_DIR_SEPARATOR_S "level2" G_DIR_SEPARATOR_S);
701 self->conus_http = gis_http_new(G_DIR_SEPARATOR_S "nexrad" G_DIR_SEPARATOR_S "conus" G_DIR_SEPARATOR_S);
702 self->sites = g_hash_table_new_full(g_str_hash, g_str_equal,
703 NULL, (GDestroyNotify)radar_site_free);
704 self->config = gtk_notebook_new();
705 /* Need to position on the top because of Win32 bug */
706 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(self->config), GTK_POS_BOTTOM);
708 static void gis_plugin_radar_dispose(GObject *gobject)
710 g_debug("GisPluginRadar: dispose");
711 GisPluginRadar *self = GIS_PLUGIN_RADAR(gobject);
712 gis_viewer_remove(self->viewer, self->hud_ref);
713 radar_conus_free(self->conus);
714 /* Drop references */
715 G_OBJECT_CLASS(gis_plugin_radar_parent_class)->dispose(gobject);
717 static void gis_plugin_radar_finalize(GObject *gobject)
719 g_debug("GisPluginRadar: finalize");
720 GisPluginRadar *self = GIS_PLUGIN_RADAR(gobject);
722 gis_http_free(self->conus_http);
723 gis_http_free(self->sites_http);
724 g_hash_table_destroy(self->sites);
725 gtk_widget_destroy(self->config);
726 G_OBJECT_CLASS(gis_plugin_radar_parent_class)->finalize(gobject);
729 static void gis_plugin_radar_class_init(GisPluginRadarClass *klass)
731 g_debug("GisPluginRadar: class_init");
732 GObjectClass *gobject_class = (GObjectClass*)klass;
733 gobject_class->dispose = gis_plugin_radar_dispose;
734 gobject_class->finalize = gis_plugin_radar_finalize;