/*
- * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
+ * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
*
* 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
guint x_flr = (int)x;
guint y_flr = (int)y;
+ //if (lon == 180 || lon == -180)
+ // g_message("lon=%f w=%d min=%f max=%f dist=%f x=%f rem=%f flr=%d",
+ // lon, w, xmin, xmax, xdist, x, x_rem, x_flr);
+
/* TODO: Fix interpolation at edges:
* - Pad these at the edges instead of wrapping/truncating
* - Figure out which pixels to index (is 0,0 edge, center, etc) */
#define LOAD_OPENGL FALSE
struct _LoadTileData {
GisPluginSrtm *self;
+ gchar *path;
GisTile *tile;
GdkPixbuf *pixbuf;
struct _TileData *data;
static gboolean _load_tile_cb(gpointer _load)
{
struct _LoadTileData *load = _load;
+ g_debug("GisPluginSrtm: _load_tile_cb: %s", load->path);
GisPluginSrtm *self = load->self;
GisTile *tile = load->tile;
GdkPixbuf *pixbuf = load->pixbuf;
struct _TileData *data = load->data;
+ g_free(load->path);
g_free(load);
if (LOAD_OPENGL)
data->opengl = _load_opengl(pixbuf);
+ tile->data = data;
+
/* Do necessasairy processing */
/* TODO: Lock this and move to thread, can remove self from _load then */
if (LOAD_BIL)
if (LOAD_OPENGL)
g_object_unref(pixbuf);
- tile->data = data;
return FALSE;
}
static void _load_tile(GisTile *tile, gpointer _self)
{
GisPluginSrtm *self = _self;
- g_debug("GisPluginSrtm: _load_tile");
- gchar *path = gis_wms_make_local(self->wms, tile);
struct _LoadTileData *load = g_new0(struct _LoadTileData, 1);
+ load->path = gis_wms_make_local(self->wms, tile);
+ g_debug("GisPluginSrtm: _load_tile: %s", load->path);
load->self = self;
load->tile = tile;
load->data = g_new0(struct _TileData, 1);
if (LOAD_BIL || LOAD_OPENGL)
- load->data->bil = _load_bil(path);
+ load->data->bil = _load_bil(load->path);
if (LOAD_OPENGL)
load->pixbuf = _load_pixbuf(load->data->bil);
g_idle_add_full(G_PRIORITY_LOW, _load_tile_cb, load, NULL);
- g_free(path);
}
static gboolean _free_tile_cb(gpointer _data)
static void _free_tile(GisTile *tile, gpointer _self)
{
GisPluginSrtm *self = _self;
- g_debug("GisPluginSrtm: _free_tile: %p=%d", tile->data, *(guint*)tile->data);
+ g_debug("GisPluginSrtm: _free_tile: %p", tile->data);
g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL);
}
{
g_debug("GisPluginSrtm: new");
GisPluginSrtm *self = g_object_new(GIS_TYPE_PLUGIN_SRTM, NULL);
- self->viewer = viewer;
+ self->viewer = g_object_ref(viewer);
/* Load initial tiles */
_load_tile(self->tiles, self);
g_debug("GisPluginSrtm: dispose");
GisPluginSrtm *self = GIS_PLUGIN_SRTM(gobject);
/* Drop references */
- g_signal_handler_disconnect(self->viewer, self->sigid);
if (LOAD_BIL)
gis_viewer_clear_height_func(self->viewer);
+ if (self->viewer) {
+ g_signal_handler_disconnect(self->viewer, self->sigid);
+ g_object_unref(self->viewer);
+ self->viewer = NULL;
+ }
G_OBJECT_CLASS(gis_plugin_srtm_parent_class)->dispose(gobject);
}
static void gis_plugin_srtm_finalize(GObject *gobject)