*/
#define _XOPEN_SOURCE
-#include <sys/time.h>
+#include <time.h>
#include <config.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
-#include <GL/gl.h>
#include <math.h>
#include <rsl.h>
}
static gchar *_find_nearest(time_t time, GList *files,
- gsize offset, gchar *format)
+ gsize offset)
{
g_debug("RadarSite: find_nearest ...");
time_t nearest_time = 0;
struct tm tm = {};
for (GList *cur = files; cur; cur = cur->next) {
gchar *file = cur->data;
- strptime(file+offset, format, &tm);
+ sscanf(file+offset, "%4d%2d%2d_%2d%2d",
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
+ &tm.tm_hour, &tm.tm_min);
+ tm.tm_year -= 1900;
+ tm.tm_mon -= 1;
if (ABS(time - mktime(&tm)) <
ABS(time - nearest_time)) {
nearest_file = file;
"^\\w{4}_\\d{8}_\\d{4}$", site->city->code,
"\\d+ (.*)", (offline ? NULL : dir_list));
g_free(dir_list);
- gchar *nearest = _find_nearest(site->time, files, 5, "%Y%m%d_%H%M");
+ gchar *nearest = _find_nearest(site->time, files, 5);
g_list_foreach(files, (GFunc)g_free, NULL);
g_list_free(files);
if (!nearest) {
}
grits_object_hide(GRITS_OBJECT(site->level2), site->hidden);
grits_viewer_add(site->viewer, GRITS_OBJECT(site->level2),
- GRITS_LEVEL_WORLD+1, TRUE);
+ GRITS_LEVEL_WORLD+3, TRUE);
out:
g_idle_add(_site_update_end, site);
gtk_notebook_append_page(GTK_NOTEBOOK(site->pconfig), site->config,
gtk_label_new(site->city->name));
gtk_widget_show_all(site->config);
+ if (gtk_notebook_get_current_page(GTK_NOTEBOOK(site->pconfig)) == 0)
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(site->pconfig), -1);
/* Set up radar loading */
site->time_id = g_signal_connect_swapped(site->viewer, "time-changed",
RadarSite *site = _site;
site->marker = grits_marker_new(site->city->name);
GRITS_OBJECT(site->marker)->center = site->city->pos;
- GRITS_OBJECT(site->marker)->lod = EARTH_R*site->city->lod;
+ GRITS_OBJECT(site->marker)->lod = EARTH_R*0.75*site->city->lod;
grits_viewer_add(site->viewer, GRITS_OBJECT(site->marker),
GRITS_LEVEL_OVERLAY, FALSE);
return FALSE;
"level2" G_DIR_SEPARATOR_S);
site->city = city;
site->pconfig = pconfig;
+ site->hidden = TRUE;
/* Set initial location */
gdouble lat, lon, elev;
glGenTextures(1, tile->data);
}
+ gchar *clear = g_malloc0(2048*2048*4);
guint *tex = tile->data;
glBindTexture(GL_TEXTURE_2D, *tex);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, 4, 2048, 2048, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GL_RGBA, GL_UNSIGNED_BYTE, clear);
glTexSubImage2D(GL_TEXTURE_2D, 0, 1,1, CONUS_WIDTH/2,CONUS_HEIGHT,
GL_RGBA, GL_UNSIGNED_BYTE, pixels);
tile->coords.n = 1.0/(CONUS_WIDTH/2);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glFlush();
+ g_free(clear);
}
/* Split the pixbuf into east and west halves (with 2K sides)
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
- dst[3] = 0xff;
+ dst[3] = 0xff * 0.75;
for (int j = 0; j < G_N_ELEMENTS(alphamap); j++)
if (src[0] == alphamap[j][0] &&
src[1] == alphamap[j][1] &&
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+1)%10+1);
- gmtime_r(&onthe8, &tm);
+ /* gmtime is not thread safe, but it's not used very often so
+ * hopefully it'll be alright for now... :-( */
+ struct tm *tm = gmtime(&conus->time);
+ time_t onthe8 = conus->time - 60*((tm->tm_min+1)%10+1);
+ tm = gmtime(&onthe8);
nearest = g_strdup_printf("Conus_%04d%02d%02d_%02d%02d_N0Ronly.gif",
- tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
- tm.tm_hour, tm.tm_min);
+ tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min);
} else {
GList *files = grits_http_available(conus->http,
"^Conus_[^\"]*_N0Ronly.gif$", "", NULL, NULL);
- nearest = _find_nearest(conus->time, files, 6, "%Y%m%d_%H%M");
+ nearest = _find_nearest(conus->time, files, 6);
g_list_foreach(files, (GFunc)g_free, NULL);
g_list_free(files);
if (!nearest) {
conus->tile[1] = grits_tile_new(NULL, CONUS_NORTH, south, east, mid);
conus->tile[0]->zindex = 2;
conus->tile[1]->zindex = 1;
- grits_viewer_add(viewer, GRITS_OBJECT(conus->tile[0]), GRITS_LEVEL_WORLD, TRUE);
- grits_viewer_add(viewer, GRITS_OBJECT(conus->tile[1]), GRITS_LEVEL_WORLD, TRUE);
+ grits_viewer_add(viewer, GRITS_OBJECT(conus->tile[0]), GRITS_LEVEL_WORLD+2, FALSE);
+ grits_viewer_add(viewer, GRITS_OBJECT(conus->tile[1]), GRITS_LEVEL_WORLD+2, FALSE);
conus->time_id = g_signal_connect_swapped(viewer, "time-changed",
G_CALLBACK(_conus_update), conus);