#include <config.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
-#include <gtk/gtkgl.h>
#include <gio/gio.h>
#include <GL/gl.h>
#include <math.h>
site->city = city;
site->pconfig = pconfig;
+ /* Set initial location */
+ gdouble lat, lon, elev;
+ grits_viewer_get_location(viewer, &lat, &lon, &elev);
+ _site_on_location_changed(viewer, lat, lon, elev, site);
+
/* Add marker */
g_idle_add_full(G_PRIORITY_LOW, _site_add_marker, site, NULL);
GError *error = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(conus->path, &error);
if (!pixbuf || error) {
- g_warning("Conus: update_end - error loading pixbuf");
+ g_warning("Conus: update_end - error loading pixbuf: %s", conus->path);
_gtk_bin_set_child(GTK_BIN(conus->config), gtk_label_new("Error loading pixbuf"));
g_remove(conus->path);
goto out;
/* Find nearest */
g_debug("Conus: update_thread - nearest");
+ gboolean offline = grits_viewer_get_offline(conus->viewer);
gchar *conus_url = "http://radar.weather.gov/Conus/RadarImg/";
gchar *nearest;
- if (time(NULL) - conus->time < 60*60*5){
+ if (time(NULL) - conus->time < 60*60*5 && !offline) {
/* radar.weather.gov is full of lies.
* the index pages get cached and out of date */
struct tm tm;
gmtime_r(&conus->time, &tm);
- time_t onthe8 = conus->time - 60*((tm.tm_min+2)%10);
+ time_t onthe8 = conus->time - 60*((tm.tm_min+1)%10+1);
gmtime_r(&onthe8, &tm);
nearest = g_strdup_printf("Conus_%04d%02d%02d_%02d%02d_N0Ronly.gif",
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
/* Fetch the image */
g_debug("Conus: update_thread - fetch");
gchar *uri = g_strconcat(conus_url, nearest, NULL);
- conus->path = grits_http_fetch(conus->http, uri, nearest, GRITS_ONCE,
+ conus->path = grits_http_fetch(conus->http, uri, nearest,
+ offline ? GRITS_LOCAL : GRITS_ONCE,
_conus_update_loading, conus);
g_free(nearest);
g_free(uri);